diff --git a/.github/workflows/celest_cli.yaml b/.github/workflows/celest_cli.yaml new file mode 100644 index 000000000..d565633d0 --- /dev/null +++ b/.github/workflows/celest_cli.yaml @@ -0,0 +1,60 @@ +name: celest_cli +on: + pull_request: + paths: + - ".github/workflows/apps_cli.yaml" + - "apps/cli/**" + - "packages/**" + - "services/**" + +# Prevent duplicate runs due to Graphite +# https://graphite.dev/docs/troubleshooting#why-are-my-actions-running-twice +concurrency: + group: ${{ github.repository }}-${{ github.workflow }}-${{ github.ref }}-${{ github.ref == 'refs/heads/main' && github.sha || ''}} + cancel-in-progress: true + +env: + CELEST_LOCAL_PATH: ${{ github.workspace }} + +jobs: + test: + strategy: + fail-fast: false + matrix: + os: + - ubuntu-latest + - macos-14 + # TODO: Need to fix tests on Windows + # - windows-latest + runs-on: ${{ matrix.os }} + timeout-minutes: 15 + steps: + - name: Git Checkout + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # 4.1.7 + with: + submodules: recursive + # Needed for flutter-version-file: https://github.com/subosito/flutter-action?tab=readme-ov-file#use-version-from-pubspecyaml + - name: Install yq + if: runner.os == 'Windows' + shell: bash + run: | + curl -sL "https://github.com/mikefarah/yq/releases/download/v4.43.1/yq_windows_amd64.exe" -o yq.exe + echo "$PWD" >> "$GITHUB_PATH" + - name: Setup Flutter + uses: subosito/flutter-action@44ac965b96f18d999802d4b807e3256d5a3f9fa1 # 2.16.0 + with: + cache: true + # Locks version to repo constraint (for golden test alignment) + flutter-version-file: pubspec.yaml + - name: Setup Libsecret + if: runner.os == 'Linux' + run: tool/setup-ci.sh + - name: Get Packages + working-directory: apps/cli + run: dart pub upgrade + - name: Test + working-directory: apps/cli + run: dart test -x e2e --fail-fast -j 1 + # - name: Test (Fixtures) + # working-directory: apps/cli + # run: dart test fixtures/legacy/fixtures_test.dart --fail-fast -j 1 diff --git a/apps/cli/.gitignore b/apps/cli/.gitignore new file mode 100644 index 000000000..3dc1cde11 --- /dev/null +++ b/apps/cli/.gitignore @@ -0,0 +1,11 @@ +# https://dart.dev/guides/libraries/private-files +# Created by `dart pub` +.dart_tool/ + +# Build dir +build/ + +tool/debug +**/*.dill +**/*.pkg +vm_service_info.json \ No newline at end of file diff --git a/apps/cli/.vscode/launch.json b/apps/cli/.vscode/launch.json new file mode 100644 index 000000000..445723524 --- /dev/null +++ b/apps/cli/.vscode/launch.json @@ -0,0 +1,23 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "CLI / E2E (--update-goldens)", + "request": "launch", + "type": "dart", + "program": "fixtures/legacy/fixtures_test.dart", + "env": { + "UPDATE_GOLDENS": "true", + "INCLUDE_TESTS": "flutter" + }, + "args": ["--timeout=none"] + }, + { + "name": "CLI (test/analyzer)", + "request": "launch", + "type": "dart", + "program": "test/analyzer/celest_analyzer_test.dart", + "args": ["--timeout=none"] + } + ] +} diff --git a/apps/cli/.vscode/settings.json b/apps/cli/.vscode/settings.json new file mode 100644 index 000000000..b153c4227 --- /dev/null +++ b/apps/cli/.vscode/settings.json @@ -0,0 +1,8 @@ +{ + // -- Dart -- + "dart.analysisExcludedFolders": ["test/openapi/goldens"], + + "files.associations": { + "*.drift": "sql" + } +} diff --git a/apps/cli/CHANGELOG.md b/apps/cli/CHANGELOG.md new file mode 100644 index 000000000..a0712a79e --- /dev/null +++ b/apps/cli/CHANGELOG.md @@ -0,0 +1,3 @@ +## 0.1.0 + +- Initial version. diff --git a/apps/cli/Makefile b/apps/cli/Makefile new file mode 100644 index 000000000..cfb91696f --- /dev/null +++ b/apps/cli/Makefile @@ -0,0 +1,12 @@ +.PHONY: database + +database: + @echo "Generating Dart Drift classes..." + @dart run build_runner build --delete-conflicting-outputs + @for DB in cache cloud project; do \ + echo "Generating schema JSON for $${DB} database..."; \ + mkdir -p lib/database/$${DB}/schema/; \ + dart run drift_dev schema dump lib/database/$${DB}/$${DB}_database.dart lib/database/$${DB}/schema/; \ + echo "Generating migration file for $${DB} database..."; \ + dart run drift_dev schema steps lib/database/$${DB}/schema/ lib/database/$${DB}/$${DB}.migrations.dart; \ + done diff --git a/apps/cli/README.md b/apps/cli/README.md new file mode 100644 index 000000000..11b9410a2 --- /dev/null +++ b/apps/cli/README.md @@ -0,0 +1,3 @@ +## Celest CLI + +The command line interface for Celest. diff --git a/apps/cli/analysis_options.yaml b/apps/cli/analysis_options.yaml new file mode 100644 index 000000000..752a6ffa2 --- /dev/null +++ b/apps/cli/analysis_options.yaml @@ -0,0 +1,12 @@ +include: package:celest_lints/app.yaml + +analyzer: + exclude: + - "**/*.g.dart" + errors: + implementation_imports: ignore + avoid_print: ignore + avoid_catches_without_on_clauses: ignore + camel_case_types: ignore + require_trailing_commas: ignore # TODO: Conflicts with 3.7 formatting + unused_element: info diff --git a/apps/cli/bin/celest.dart b/apps/cli/bin/celest.dart new file mode 100644 index 000000000..e15b0d8e2 --- /dev/null +++ b/apps/cli/bin/celest.dart @@ -0,0 +1,27 @@ +import 'package:celest_cli/commands/analysis_server_command.dart'; +import 'package:celest_cli/commands/build_command.dart'; +import 'package:celest_cli/commands/init_command.dart'; +import 'package:celest_cli/commands/precache_command.dart'; +import 'package:celest_cli/commands/start_command.dart'; +import 'package:celest_cli/commands/uninstall_command.dart'; +import 'package:celest_cli/commands/upgrade_command.dart'; +import 'package:celest_cli/src/cli.dart'; +import 'package:celest_cli/src/version.dart'; + +void main(List args) async { + final cli = + Cli( + 'celest', + 'A command-line interface for Celest, the Flutter cloud platform.', + version: packageVersion, + ) + ..addCommand(InitCommand()) + ..addCommand(StartCommand()) + ..addCommand(BuildCommand()) + ..addCommand(AnalysisServerCommand()) + ..addCommand(UpgradeCommand()) + ..addCommand(UninstallCommand()) + ..addCommand(PrecacheCommand()); + + await cli.run(args); +} diff --git a/apps/cli/build.yaml b/apps/cli/build.yaml new file mode 100644 index 000000000..0809522ba --- /dev/null +++ b/apps/cli/build.yaml @@ -0,0 +1,37 @@ +targets: + json: + sources: + exclude: + - "fixtures/**" + - "lib/database/**" + auto_apply_builders: false + builders: + json_serializable: + enabled: true + options: + explicit_to_json: true + + $default: + sources: + include: + - "lib/database/**" + dependencies: + - ":json" + builders: + drift_dev: + enabled: true + options: + named_parameters: true + store_date_time_values_as_text: false + sql: + dialect: sqlite + options: + version: "3.38" + modules: + - json1 + known_functions: + typeid: text(text) + + # Reduces generated code + skip_verification_code: true + data_class_to_companions: false diff --git a/apps/cli/dart_test.yaml b/apps/cli/dart_test.yaml new file mode 100644 index 000000000..b2276dc40 --- /dev/null +++ b/apps/cli/dart_test.yaml @@ -0,0 +1,11 @@ +tags: + e2e: + timeout: 15m + e2e-installed: + timeout: 5m + e2e-local: + timeout: 15m + openapi: + timeout: 5m + goldens: + timeout: 20m diff --git a/apps/cli/fixtures/.gitattributes b/apps/cli/fixtures/.gitattributes new file mode 100644 index 000000000..80796d5c8 --- /dev/null +++ b/apps/cli/fixtures/.gitattributes @@ -0,0 +1,10 @@ +# Outputs from golden tests +**/goldens/** linguist-generated + +# Platform files generated by Flutter during `flutter create` +**/android/** linguist-generated +**/ios/** linguist-generated +**/linux/** linguist-generated +**/macos/** linguist-generated +**/windows/** linguist-generated +**/web/** linguist-generated diff --git a/apps/cli/fixtures/legacy/_common/lib/_common.dart b/apps/cli/fixtures/legacy/_common/lib/_common.dart new file mode 100644 index 000000000..f2a3fa041 --- /dev/null +++ b/apps/cli/fixtures/legacy/_common/lib/_common.dart @@ -0,0 +1,68 @@ +/// Common types and functions, used for testing APIs which reference other +/// packages. +library; + +final class CustomException implements Exception { + CustomException(this.message); + + final String message; + + @override + String toString() => 'CustomException: $message'; +} + +final class CommonException implements Exception { + CommonException(this.message); + + final String message; + + @override + String toString() => 'CommonException: $message'; +} + +void throwsCustomException() { + throw CustomException('message'); +} + +void throwsCommonException() { + throw CommonException('message'); +} + +final class NestedParent { + const NestedParent(this.child); + + factory NestedParent.fromJson(String value) => + NestedParent(NestedChild(value)); + + final NestedChild child; + + String toJson() => child.value; +} + +final class NestedChild { + const NestedChild(this.value); + + factory NestedChild.fromJson(String value) => NestedChild(value); + + final String value; + + String toJson() => value; +} + +final class OverriddenException implements Exception { + const OverriddenException(this.message); + + factory OverriddenException.fromJson(String value) => + OverriddenException(value); + + final String message; + + String toJson() => message; + + @override + String toString() => 'OverriddenException: $message'; +} + +void throwsOverriddenException() { + throw const OverriddenException('message'); +} diff --git a/apps/cli/fixtures/legacy/_common/lib/marcelo.dart b/apps/cli/fixtures/legacy/_common/lib/marcelo.dart new file mode 100644 index 000000000..e1d3da12f --- /dev/null +++ b/apps/cli/fixtures/legacy/_common/lib/marcelo.dart @@ -0,0 +1,8 @@ +export 'src/models/available_stock.dart'; +export 'src/models/available_stocks.dart'; +export 'src/models/buy_or_sell.dart'; +export 'src/models/cash_balance.dart'; +export 'src/models/errors_and_exceptions.dart'; +export 'src/models/portfolio.dart'; +export 'src/models/stock.dart'; +export 'src/models/ui.dart'; diff --git a/apps/cli/fixtures/legacy/_common/lib/src/models/available_stock.dart b/apps/cli/fixtures/legacy/_common/lib/src/models/available_stock.dart new file mode 100644 index 000000000..4d22b751e --- /dev/null +++ b/apps/cli/fixtures/legacy/_common/lib/src/models/available_stock.dart @@ -0,0 +1,37 @@ +import 'package:_common/src/utils/utils.dart'; +import 'package:meta/meta.dart'; + +@immutable +class AvailableStock { + AvailableStock( + this.ticker, { + required this.name, + required double currentPrice, + }) : currentPrice = round(currentPrice); + + AvailableStock.from(({String ticker, String name, double price}) stock) + : this(stock.ticker, name: stock.name, currentPrice: stock.price); + final String ticker; + final String name; + final double currentPrice; + + String get currentPriceStr => 'US\$ ${currentPrice.toStringAsFixed(2)}'; + + AvailableStock withCurrentPrice(double price) => + AvailableStock(ticker, name: name, currentPrice: round(price)); + + @override + String toString() => '$ticker ($name)'; + + @override + bool operator ==(Object other) => + identical(this, other) || + other is AvailableStock && + runtimeType == other.runtimeType && + ticker == other.ticker && + name == other.name && + currentPrice == other.currentPrice; + + @override + int get hashCode => ticker.hashCode ^ name.hashCode ^ currentPrice.hashCode; +} diff --git a/apps/cli/fixtures/legacy/_common/lib/src/models/available_stocks.dart b/apps/cli/fixtures/legacy/_common/lib/src/models/available_stocks.dart new file mode 100644 index 000000000..9c34fb95b --- /dev/null +++ b/apps/cli/fixtures/legacy/_common/lib/src/models/available_stocks.dart @@ -0,0 +1,71 @@ +import 'package:collection/collection.dart'; +import 'package:fast_immutable_collections/fast_immutable_collections.dart'; + +import 'available_stock.dart'; + +class AvailableStocks { + AvailableStocks(Iterable list) : list = IList(list); + + const AvailableStocks._(this.list); + static const AvailableStocks EMPTY = AvailableStocks._(IListConst([])); + + final IList list; + + AvailableStock? findBySymbolOrNull(String ticker) { + return list.firstWhereOrNull((s) => s.ticker == ticker); + } + + AvailableStock findBySymbol(String ticker) { + final stock = findBySymbolOrNull(ticker); + if (stock == null) throw Exception('Stock not found: $ticker'); + return stock; + } + + void forEach(void Function(AvailableStock availableStock) callback) { + list.forEach(callback); + } + + /// Updates the available stock with the new available stock. + /// If the stock is not found, it is added to the list. + AvailableStocks withAvailableStock(AvailableStock newAvailableStock) { + final isPresent = list.any((s) => s.ticker == newAvailableStock.ticker); + + final newList = isPresent + ? list + .map( + (s) => + s.ticker == newAvailableStock.ticker ? newAvailableStock : s, + ) + .toIList() + : list.add(newAvailableStock); + + return AvailableStocks(newList); + } + + /// Updates the available stock with the new available stock. + /// If the stock is not found, it is NOT added to the list. + AvailableStocks withUpdatedAvailableStock(AvailableStock newAvailableStock) { + final newList = list + .map( + (s) => s.ticker == newAvailableStock.ticker ? newAvailableStock : s, + ) + .toIList(); + + return AvailableStocks(newList); + } + + @override + String toString() { + return 'AvailableStocks: ${list.isEmpty ? 'empty' : list}'; + } + + @override + bool operator ==(Object other) => + identical(this, other) || + other is AvailableStocks && + runtimeType == other.runtimeType && + list == other.list; + + @override + int get hashCode => list.hashCode; +} diff --git a/apps/cli/fixtures/legacy/_common/lib/src/models/buy_or_sell.dart b/apps/cli/fixtures/legacy/_common/lib/src/models/buy_or_sell.dart new file mode 100644 index 000000000..7963bb3d5 --- /dev/null +++ b/apps/cli/fixtures/legacy/_common/lib/src/models/buy_or_sell.dart @@ -0,0 +1,9 @@ +enum BuyOrSell { + buy, + sell; + + @override + String toString() => name; + + bool get isBuy => this == buy; +} diff --git a/apps/cli/fixtures/legacy/_common/lib/src/models/cash_balance.dart b/apps/cli/fixtures/legacy/_common/lib/src/models/cash_balance.dart new file mode 100644 index 000000000..af9caccde --- /dev/null +++ b/apps/cli/fixtures/legacy/_common/lib/src/models/cash_balance.dart @@ -0,0 +1,46 @@ +import 'package:_common/src/utils/map_deserialization_extension.dart'; +import 'package:_common/src/utils/utils.dart'; +import 'package:meta/meta.dart'; + +@immutable +class CashBalance { + CashBalance(double amount) : amount = amount.isNaN ? 0 : round(amount); + + const CashBalance._(this.amount); + + factory CashBalance.fromJson(Json json) => + CashBalance(json.asDouble('amount')!); + static const CashBalance ZERO = CashBalance._(0); + + final double amount; + + CashBalance withAmount(double amount) => CashBalance(round(amount)); + + CashBalance add(double howMuch) { + final newAmount = round(amount + howMuch); + print('Added $howMuch. Cash balance is now: $newAmount.'); + return CashBalance(newAmount); + } + + CashBalance remove(double howMuch) { + var newAmount = round(amount - howMuch); + if (newAmount < 0) newAmount = 0; + print('Removed $howMuch. Cash balance is now: $newAmount.'); + return CashBalance(newAmount); + } + + @override + String toString() => 'US\$ ${amount.toStringAsFixed(2)}'; + + Json toJson() => {'amount': amount}; + + @override + bool operator ==(Object other) => + identical(this, other) || + other is CashBalance && + runtimeType == other.runtimeType && + amount == other.amount; + + @override + int get hashCode => amount.hashCode; +} diff --git a/apps/cli/fixtures/legacy/_common/lib/src/models/errors_and_exceptions.dart b/apps/cli/fixtures/legacy/_common/lib/src/models/errors_and_exceptions.dart new file mode 100644 index 000000000..9973daf86 --- /dev/null +++ b/apps/cli/fixtures/legacy/_common/lib/src/models/errors_and_exceptions.dart @@ -0,0 +1,428 @@ +import 'package:intl/locale.dart'; + +typedef VoidCallback = void Function(); + +/// Represents an error the user could fix, like wrong typed text, or missing +/// internet connection. Methods [dialogTitle] and [dialogContent] return +/// [String]s you can show in an error dialog. +/// +/// An [UserException] may have an optional [cause], which is a more specific +/// root cause of the error. +/// +/// If the error has a "cause" which is another [UserException] or [String], +/// the dialog-title will be the present exception's [msg], and the +/// dialog-content will be the [cause]. Otherwise, the dialog-title will be +/// an empty string, and the dialog-title will be the present +/// exception's [msg]. +/// +/// In other words, If the [cause] is an [UserException] or [String], it may +/// be used in the dialog. But if the [cause] is of a different type it's +/// considered just internal information, and won't be shown to the user. +/// +/// An [UserException] may also have an optional [code], of type +/// [ExceptionCode]. If there is a non-null [code], the String returned by +/// [ExceptionCode.asText] may be used instead of the [msg]. This facilitates +/// translating error messages, since [ExceptionCode.asText] accepts +/// a [Locale]. +/// +/// You can define a special Matcher for your UserException, to use in your +/// tests. Create a test lib with this code: +/// +/// ``` +/// import 'package:matcher/matcher.dart'; +/// const Matcher throwsUserException +/// = Throws(const TypeMatcher()); +/// ``` +/// +/// Then use it in your tests: +/// +/// ``` +/// expect(() => someFunction(), throwsUserException); +/// ``` +/// +/// The [UserException] may be used with the [UserExceptionDialog] to display the +/// exception to the user. In that case, you may also define callbacks [onOk] and +/// [onCancel]. +/// +class UserException implements Exception { + const UserException( + this.msg, { + this.cause, + this.code, + VoidCallback? onOk, + VoidCallback? onCancel, + }) : _onOk = onOk, + _onCancel = onCancel; + + /// Adding `.debug` to the constructor will print the exception to the console. + /// Use this for debugging purposes only. + /// This constructor is marked as deprecated so that you don't forget to remove it. + @deprecated + UserException.debug( + this.msg, { + this.cause, + this.code, + VoidCallback? onOk, + VoidCallback? onCancel, + }) : _onOk = onOk, + _onCancel = onCancel { + print('================================================================\n' + "UserException${code == null ? "" : " (code: $code)"}:\n" + 'Msg = $msg,\n' + "${cause == null ? "" : "Cause = $cause,\n"}" + '================================================================'); + } + + /// Creates a [UserException] from a JSON object. + /// + /// Important: The [cause] and the [code] will be represented as Strings, + /// and [_onOk] and [_onCancel] will be ignored. This means the [fromJson] method + /// may not be able to reconstruct the original exception. + /// + /// --- + /// Use with Celest (https://celest.dev/): + /// + /// Currently you can't import Async Redux in the backend part of Celest, because it uses Flutter. + /// Once I move this [UserException] class into a separate Dart-only package called + /// `async_redux_core`, you will be able to use it with Celest, as long as you export it + /// from `celest/lib/exceptions.dart`: + /// + /// ```dart + /// export 'package:async_redux_core/user_exception.dart; + /// ``` + factory UserException.fromJson(Map json) { + return UserException( + json['msg'] as String?, + cause: json['cause'], + code: switch (json['code']) { + final String code => _StringExceptionCode(code), + _ => null, + }, + ); + } + + /// Some message shown to the user. + final String? msg; + + /// The cause of the user-exception. Usually another error. + final Object? cause; + + /// The error may have some code. This may be used for error message + /// translations, and also to simplify receiving errors from web-services, + /// cloud-functions etc. + final ExceptionCode? code; + + /// Callback to be called after the user views the error and taps OK. + final VoidCallback? _onOk; + + /// Callback to be called after the user views the error and taps CANCEL. + final VoidCallback? _onCancel; + + /// "OK" callback. If the exception has a cause, will return a merged callback. + VoidCallback? get onOk { + final onOkCause = + (cause is UserException) ? (cause as UserException).onOk : null; + + if (onOkCause == null) { + return _onOk; + } else if (_onOk == null) + return onOkCause; + else + return () { + _onOk(); + onOkCause(); + }; + } + + /// "Cancel" callback. If the exception has a cause, will return a merged callback. + VoidCallback? get onCancel { + final onCancelCause = + (cause is UserException) ? (cause as UserException).onCancel : null; + + if (onCancelCause == null) { + return _onCancel; + } else if (_onCancel == null) + return onCancelCause; + else + return () { + _onCancel(); + onCancelCause(); + }; + } + + /// Returns the first cause which, recursively, is NOT a UserException. + /// If not found, returns null. + Object? hardCause() { + if (cause is UserException) { + return (cause as UserException).hardCause(); + } else { + return cause; + } + } + + /// Returns a deep copy of this exception, but stopping at, and not + /// including, the first [cause] which is not a UserException. + UserException withoutHardCause() => UserException( + msg, + cause: (cause is UserException) + ? // + (cause as UserException).withoutHardCause() + : null, + code: code, + onOk: _onOk, + onCancel: _onCancel, + ); + + String dialogTitle([Locale? locale]) => // + (cause is UserException || cause is String) + ? // + _codeAsTextOrMsg(locale) + : ''; + + String dialogContent([Locale? locale]) { + if (cause is UserException) { + return (cause as UserException)._dialogTitleAndContent(locale); + } else if (cause is String) + return cause as String; + else + return _codeAsTextOrMsg(locale); + } + + String _dialogTitleAndContent([Locale? locale]) => (cause is UserException) + ? joinExceptionMainAndCause( + locale, + _codeAsTextOrMsg(locale), + (cause as UserException)._codeAsTextOrMsg(locale), + ) + : _codeAsTextOrMsg(locale); + + /// Return the string that join the main message and the reason message. + /// You can change this variable to inject another way to join them. + static var joinExceptionMainAndCause = ( + Locale? locale, + String? mainMsg, + String? causeMsg, + ) => + "$mainMsg\n\n${_getReasonFromLocale(locale) ?? "Reason"}: $causeMsg"; + + static String? _getReasonFromLocale(Locale? locale) { + if (locale == null) { + return null; + } else { + var reason = _reason[locale.toString()]; + reason ??= _reason[locale.languageCode]; + return reason; + } + } + + static const Map _reason = { + 'en': 'Reason', // English + 'es': 'Razón', // Spanish + 'fr': 'Raison', // French + 'de': 'Grund', // German + 'zh': '原因', // Chinese + 'jp': '理由', // Japanese + 'pt': 'Motivo', // Portuguese + 'it': 'Motivo', // Italian + 'pl': 'Powód', // Polish + 'ko': '이유', // Korean + 'ms': 'Sebab', // Malay + 'ru': 'Причина', // Russian + 'uk': 'Причина', // Ukrainian + 'ar': 'السبب', // Arabic + 'he': 'סיבה', // Hebrew + }; + + /// If there is a [code], and this [code] has a non-empty text returned by + /// [ExceptionCode.asText] in the given [Locale], return this text. + /// Otherwise, if the [msg] is a non-empty text, return this [msg]. + /// Otherwise, if there is a [code], return the [code] itself. + /// Otherwise, return an empty text. + String _codeAsTextOrMsg(Locale? locale) { + final codeAsText = code?.asText(locale); + if (codeAsText != null && codeAsText.isNotEmpty) return codeAsText; + if (msg != null && msg!.isNotEmpty) return msg!; + return code?.toString() ?? ''; + } + + @override + String toString() => _dialogTitleAndContent(); + + /// Creates a JSON object from a [UserException]. + /// + /// Important: The [cause] and the [code] will be represented as Strings, + /// and [_onOk] and [_onCancel] will be ignored. This means the [fromJson] method + /// may not be able to reconstruct the original exception. + /// + /// --- + /// Use with Celest (https://celest.dev/): + /// + /// Currently you can't import Async Redux in the backend part of Celest, because it uses Flutter. + /// Once I move this [UserException] class into a separate Dart-only package called + /// `async_redux_core`, you will be able to use it with Celest, as long as you export it + /// from `celest/lib/exceptions.dart`: + /// + /// ```dart + /// export 'package:async_redux_core/user_exception.dart; + /// ``` + Map toJson() => { + 'msg': msg, + if (cause != null) 'cause': cause.toString(), + if (code != null) 'code': code.toString(), + }; + + @override + bool operator ==(Object other) => + identical(this, other) || + other is UserException && + runtimeType == other.runtimeType && + msg == other.msg && + cause == other.cause && + code == other.code && + _onOk == other._onOk && + _onCancel == other._onCancel; + + @override + int get hashCode => + msg.hashCode ^ + cause.hashCode ^ + code.hashCode ^ + _onOk.hashCode ^ + _onCancel.hashCode; +} + +abstract class ExceptionCode { + const ExceptionCode(); + + String? asText([Locale? locale]); +} + +/// Used for Bugs. +class AppError extends AssertionError { + AppError([ + Object? msg, + this.error, + ]) : super(msg?.toString()); + // + final Object? error; + + @override + String toString() { + var errorStr = ''; + + if (error is Error) { + final errorObj = error as Error; + errorStr = '\n\n\n\n$errorObj\n\n\n\n${errorObj.stackTrace}\n\n\n\n'; + } else if (error != null) errorStr = ' Error: $error'; + + return 'Assertion failed with message:\n>>> ${message.toString() + errorStr} <<<'; + } + + @override + bool operator ==(Object other) => + identical(this, other) || + other is AppError && + runtimeType == other.runtimeType && + message == other.message; + + @override + int get hashCode => message.hashCode; +} + +/// Used when something failed but its is NOT an error, and can be recovered from. +class AppException implements Exception { + AppException([this.msg, this.error]); + // + final Object? error; + final Object? msg; + + @override + String toString() => msg.toString(); +} + +/// Used when something will be implemented in the future. +class NotYetImplementedError extends AssertionError { + NotYetImplementedError([dynamic msg]) + : msg = (msg == null) + ? StackTrace.current.toString() + : '$msg\n\n${StackTrace.current}'; + final String msg; + + @override + String toString() => 'NOT YET IMPLEMENTED!\n $msg'; + + @override + bool operator ==(Object other) => + identical(this, other) || + other is NotYetImplementedError && runtimeType == other.runtimeType; + + @override + int get hashCode => 0; +} + +/// Used to stop the control flow, interrupting a process and breaking out of the current code. +/// This shouldn't be logged nor show any error messages. It also has no stacktrace. +/// Use with care, only if you know what you are doing, because that's generally an anti-pattern. +class InterruptControlFlowException { + const InterruptControlFlowException(); + + @override + bool operator ==(Object other) => + identical(this, other) || + other is InterruptControlFlowException && + runtimeType == other.runtimeType; + + @override + int get hashCode => 0; +} + +/// This should be used when validating input. +class ValidateError extends TypeError { + ValidateError(this.msg); + + ValidateError.semCrashlytics(this.msg); + String msg; + + @override + String toString() => 'ValidateError: $msg'; + + @override + bool operator ==(Object other) => + identical(this, other) || + other is ValidateError && + runtimeType == other.runtimeType && + msg == other.msg; + + @override + int get hashCode => msg.hashCode; +} + +/// UserException that shows in the console. +/// Used for debugging reasons only, for short periods of time. +/// It is marked as [deprecated] so that you don't forget to remove it. +/// Note: To remove it, just remove the "_ShowInConsole" part. +class UserException_ShowInConsole extends UserException { + // + UserException_ShowInConsole( + String msg, { + Object? cause, + ExceptionCode? code, + }) : super(msg, cause: cause, code: code) { + print( + '\nMsg = $msg, ' + '================================================================' + '\nCause = $cause,' + '================================================================' + '\nCode = $code', + ); + } +} + +final class _StringExceptionCode implements ExceptionCode { + _StringExceptionCode(this.code); + + final String code; + + @override + String asText([Locale? locale]) => code; +} diff --git a/apps/cli/fixtures/legacy/_common/lib/src/models/portfolio.dart b/apps/cli/fixtures/legacy/_common/lib/src/models/portfolio.dart new file mode 100644 index 000000000..e37dea97f --- /dev/null +++ b/apps/cli/fixtures/legacy/_common/lib/src/models/portfolio.dart @@ -0,0 +1,175 @@ +import 'package:_common/src/models/errors_and_exceptions.dart'; +import 'package:_common/src/utils/map_deserialization_extension.dart'; +import 'package:_common/src/utils/utils.dart'; +import 'package:collection/collection.dart'; +import 'package:fast_immutable_collections/fast_immutable_collections.dart'; +import 'package:meta/meta.dart'; + +import 'available_stock.dart'; +import 'cash_balance.dart'; +import 'stock.dart'; + +@immutable +class Portfolio { + Portfolio({ + Iterable? stocks, + this.cashBalance = CashBalance.ZERO, + }) : stocks = IList.orNull(stocks) ?? const IListConst([]); + + const Portfolio._() + : stocks = const IListConst([]), + cashBalance = CashBalance.ZERO; + + factory Portfolio.fromJson(Json? json) { + if (json == null) { + return Portfolio.EMPTY; + } else { + final stocks = json.asIListOf('stocks', Stock.fromJson); + final cashBalance = json.asCashBalance('cashBalance') ?? CashBalance.ZERO; + return Portfolio(stocks: stocks, cashBalance: cashBalance); + } + } + static const Portfolio EMPTY = Portfolio._(); + + final IList stocks; + final CashBalance cashBalance; + + Portfolio copyWith({ + Iterable? stocks, + CashBalance? cashBalance, + }) { + return Portfolio( + stocks: (stocks != null) ? stocks.toIList() : this.stocks, + cashBalance: cashBalance ?? this.cashBalance, + ); + } + + bool get isEmpty => stocks.isEmpty; + + Portfolio addCashBalance(double howMuch) { + final newCashBalance = cashBalance.add(howMuch); + return copyWith(cashBalance: newCashBalance); + } + + Portfolio removeCashBalance(double howMuch) { + final newCashBalance = cashBalance.remove(howMuch); + return copyWith(cashBalance: newCashBalance); + } + + Portfolio withoutStock(String ticker) { + return withStock(ticker, 0, 0); + } + + Portfolio withoutStocks() { + return copyWith(stocks: []); + } + + Portfolio withStock(String ticker, int quantity, double averagePrice) { + final newStocks = stocks.where((stock) => stock.ticker != ticker).toList(); + + if (quantity > 0) { + final newStock = + Stock(ticker, howManyShares: quantity, averagePrice: averagePrice); + newStocks.add(newStock); + } + + return copyWith(stocks: newStocks); + } + + int howManyStocks(String ticker) { + final stock = getStockOrNull(ticker); + return stock?.howManyShares ?? 0; + } + + Stock getStock(String ticker) { + final stock = getStockOrNull(ticker); + if (stock == null) { + throw Exception('Stock $ticker not found.'); + } + return stock; + } + + Stock? getStockOrNull(String ticker) { + return stocks.firstWhereOrNull((stock) => stock.ticker == ticker); + } + + bool hasStock(AvailableStock availableStock) { + return _getStockPositionInList(availableStock) != -1; + } + + bool hasMoneyToBuyStock(AvailableStock availableStock) { + return cashBalance.amount >= availableStock.currentPrice; + } + + /// Sells [howMany] shares of [availableStock]. + /// If the user does not own the stock, or does not own enough shares, throws a [UserException]. + /// This exception will be shown to the user in a dialog. + Portfolio sell(AvailableStock availableStock, {required int howMany}) { + final pos = _getStockPositionInList(availableStock); + + if (pos == -1) { + throw const UserException('Cannot sell stock you do not own'); + } else { + final stock = stocks[pos]; + + if (stock.howManyShares < howMany) { + throw UserException( + 'Cannot sell $howMany shares of stock you do not own', + ); + } else { + final newShares = stock.howManyShares - howMany; + final newAveragePrice = round( + ((stock.howManyShares * stock.averagePrice) - + (howMany * availableStock.currentPrice)) / + newShares, + ); + + var newStocks = [...stocks]; + newStocks[pos] = Stock( + stock.ticker, + howManyShares: newShares, + averagePrice: newAveragePrice, + ); + + if (newShares == 0) { + newStocks = newStocks + .where((stock) => stock.ticker != availableStock.ticker) + .toList(); + } + + final newCashBalance = CashBalance( + cashBalance.amount + availableStock.currentPrice * howMany, + ); + return copyWith(stocks: newStocks, cashBalance: newCashBalance); + } + } + } + + int _getStockPositionInList(AvailableStock availableStock) { + return stocks.indexWhere((stock) => stock.ticker == availableStock.ticker); + } + + double get totalCostBasis { + return stocks.fold(0, (sum, stock) => sum + stock.costBasis) + + cashBalance.amount; + } + + @override + String toString() => 'Portfolio{stocks: $stocks, cashBalance: $cashBalance}'; + + Json toJson() => { + 'stocks': stocks.map((stock) => stock.toJson()).toList(), + 'cashBalance': cashBalance.toJson(), + }; + + @override + bool operator ==(Object other) => + identical(this, other) || + other is Portfolio && + runtimeType == other.runtimeType && + stocks == other.stocks && + cashBalance == other.cashBalance; + + @override + int get hashCode => stocks.hashCode ^ cashBalance.hashCode; +} diff --git a/apps/cli/fixtures/legacy/_common/lib/src/models/stock.dart b/apps/cli/fixtures/legacy/_common/lib/src/models/stock.dart new file mode 100644 index 000000000..1b8d13fbf --- /dev/null +++ b/apps/cli/fixtures/legacy/_common/lib/src/models/stock.dart @@ -0,0 +1,49 @@ +import 'package:_common/src/utils/map_deserialization_extension.dart'; +import 'package:meta/meta.dart'; + +/// Stocks the user has. +@immutable +class Stock { + const Stock( + this.ticker, { + required this.howManyShares, + required this.averagePrice, + }); + + factory Stock.fromJson(Json json) { + return Stock( + json.asString('ticker')!, + howManyShares: json.asInt('howManyShares')!, + averagePrice: json.asDouble('averagePrice')!, + ); + } + final String ticker; + final int howManyShares; + final double averagePrice; + + double get costBasis => howManyShares * averagePrice; + + String get averagePriceStr => 'US\$ ${averagePrice.toStringAsFixed(2)}'; + + @override + String toString() => '$howManyShares $ticker @$averagePrice'; + + Json toJson() => { + 'ticker': ticker, + 'howManyShares': howManyShares, + 'averagePrice': averagePrice, + }; + + @override + bool operator ==(Object other) => + identical(this, other) || + other is Stock && + runtimeType == other.runtimeType && + ticker == other.ticker && + howManyShares == other.howManyShares && + averagePrice == other.averagePrice; + + @override + int get hashCode => + ticker.hashCode ^ howManyShares.hashCode ^ averagePrice.hashCode; +} diff --git a/apps/cli/fixtures/legacy/_common/lib/src/models/ui.dart b/apps/cli/fixtures/legacy/_common/lib/src/models/ui.dart new file mode 100644 index 000000000..e56da1b4a --- /dev/null +++ b/apps/cli/fixtures/legacy/_common/lib/src/models/ui.dart @@ -0,0 +1,59 @@ +import 'package:_common/src/utils/map_deserialization_extension.dart'; + +enum ScreenChoice { + signup, + configuration, + portfolioAndCashBalance; +} + +class Ui { + const Ui({ + required this.isDarkMode, + this.screenChoice = ScreenChoice.portfolioAndCashBalance, + }); + final bool isDarkMode; + final ScreenChoice screenChoice; + + static const DEFAULT = Ui(isDarkMode: false); + + Ui toggleLightAndDarkMode() => copy(isDarkMode: !isDarkMode); + + Ui copy({ + bool? isDarkMode, + ScreenChoice? screenChoice, + }) => + Ui( + isDarkMode: isDarkMode ?? this.isDarkMode, + screenChoice: screenChoice ?? this.screenChoice, + ); + + @override + String toString() => + 'Ui{isDarkMode: $isDarkMode, screenChoice: $screenChoice}'; + + /// Don't include [screenChoice]. + Json toJson() => { + 'isDarkMode': isDarkMode, + }; + + /// Don't include [screenChoice]. + static Ui fromJson(Json? json) { + if (json == null) { + return Ui.DEFAULT; + } else { + final isDarkMode = json.asBool('isDarkMode') ?? false; + return Ui(isDarkMode: isDarkMode); + } + } + + @override + bool operator ==(Object other) => + identical(this, other) || + other is Ui && + runtimeType == other.runtimeType && + isDarkMode == other.isDarkMode && + screenChoice == other.screenChoice; + + @override + int get hashCode => isDarkMode.hashCode ^ screenChoice.hashCode; +} diff --git a/apps/cli/fixtures/legacy/_common/lib/src/utils/map_deserialization_extension.dart b/apps/cli/fixtures/legacy/_common/lib/src/utils/map_deserialization_extension.dart new file mode 100644 index 000000000..13c12a6dc --- /dev/null +++ b/apps/cli/fixtures/legacy/_common/lib/src/utils/map_deserialization_extension.dart @@ -0,0 +1,129 @@ +import 'package:_common/src/models/cash_balance.dart'; +import 'package:_common/src/models/errors_and_exceptions.dart'; +import 'package:fast_immutable_collections/fast_immutable_collections.dart'; + +typedef Json = Map; +typedef JsonList = List; + +extension MapDeserializeExtension on Json { + // + + /// If you don't provide [T] you'll get a dynamic List. That's fast, but that almost never + /// what you want. So you should use it if you are going to transform the result anyway. + /// + /// If you write json.asList(key) you will get a List + /// If you write json.asList(key) you will get a List + /// If you write json.asList(key) you will get a List + /// + List asList(String key) { + // + var value = this[key] as List?; + value ??= []; + + // Note: toList is not necessary, but I want to fail right away in case any + // of the values is not as requested. This will also speed up the reads a bit. + if (value is! List) value = value.cast().toList(); + + return value; + } + + /// If you don't provide [T] you'll get a dynamic List. That's fast, but that almost never + /// what you want. So you should use it if you are going to transform the result anyway. + /// + /// If you write json.asList(key) you will get a List + /// If you write json.asList(key) you will get a List + /// If you write json.asList(key) you will get a List + /// + IList asIList(String key) => asList(key).lockUnsafe; + + /// The source in [key] must be a List. It will be converted to IList of [T] by [fromJson]. + IList asIListOf(String key, T Function(Json json) fromJson) => + asListOfJson(key).map(fromJson).toIList(); + + /// The source in [key] must be a List. It will be converted to List of [T] by [fromJson]. + List asListOf(String key, T Function(Json json) fromJson) => + asListOfJson(key).map(fromJson).toList(); + + /// If possible, prefer using [asIListOf] or [asListOf]. + List asListOfJson(String key) => asList(key).cast(); + + String? asString(String key) => this[key] as String?; + + String asStringOrEmpty(String key) => this[key] as String? ?? ''; + + int? asInt(String key) { + final dynamic value = this[key]; + if (value == null) return null; + if (value is int) return value; + if (value is String) return _toIntNullable(value); + throw ValidateError('Cant accept ${value.runtimeType} as int.'); + } + + double? asDouble(String key) { + final dynamic value = this[key]; + if (value == null) return null; + if (value is double) return value; + if (value is String) return _toDoubleNullable(value); + throw ValidateError('Cant accept ${value.runtimeType} as double.'); + } + + bool? asBool(String key) { + // + final dynamic value = this[key]; + + if (value == null) return null; + + if (value is String) { + if (value == 'false') return false; + if (value == 'true') return true; + } + + if (value is! bool) throw ValidateError('Value is not bool: "$value".'); + return value; + } + + Json asMap(String key) { + // + final result = this[key]; + + if (result == null) { + return const {}; + } else if (result is Json) + return result; + else if (result is Map) + return result.cast(); + else + throw ValidateError('Cant accept ${result.runtimeType} as Json.'); + } + + IMap asIMap(String key) { + final map = asMap(key); + return map.cast().lock; + } + + CashBalance? asCashBalance(String key) { + final value = this[key] as Map?; + return (value == null) ? null : CashBalance.fromJson(value); + } +} + +int? _toIntNullable(String? intString) { + if (intString == null) return null; + try { + // if receive a decimal, then remove decimal so int parse doesn't fail + final valueParts = intString.split('.'); + final intNumberPart = valueParts.first; + + return int.parse(intNumberPart); + } catch (error) { + return null; + } +} + +double? _toDoubleNullable(String? doubleString) { + if (doubleString == null) { + return null; + } else { + return double.tryParse(doubleString); + } +} diff --git a/apps/cli/fixtures/legacy/_common/lib/src/utils/utils.dart b/apps/cli/fixtures/legacy/_common/lib/src/utils/utils.dart new file mode 100644 index 000000000..d82949c18 --- /dev/null +++ b/apps/cli/fixtures/legacy/_common/lib/src/utils/utils.dart @@ -0,0 +1,2 @@ +/// Round the value to 2 decimal places. +double round(double value) => double.parse((value).toStringAsFixed(2)); diff --git a/apps/cli/fixtures/legacy/_common/pubspec.yaml b/apps/cli/fixtures/legacy/_common/pubspec.yaml new file mode 100644 index 000000000..5fd586f99 --- /dev/null +++ b/apps/cli/fixtures/legacy/_common/pubspec.yaml @@ -0,0 +1,11 @@ +name: _common +publish_to: none + +environment: + sdk: ^3.7.0 +dependencies: + celest_core: + path: ../../../../../celest/packages/celest_core + fast_immutable_collections: ^10.1.1 + intl: ^0.19.0 + meta: ^1.12.0 diff --git a/apps/cli/fixtures/legacy/api/analysis_options.yaml b/apps/cli/fixtures/legacy/api/analysis_options.yaml new file mode 100644 index 000000000..02bb0ff54 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/analysis_options.yaml @@ -0,0 +1,5 @@ +analyzer: + errors: + deprecated_member_use_from_same_package: ignore + deprecated_member_use: ignore + unused_element: ignore diff --git a/apps/cli/fixtures/legacy/api/client/lib/api_client.dart b/apps/cli/fixtures/legacy/api/client/lib/api_client.dart new file mode 100644 index 000000000..90d659da2 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/client/lib/api_client.dart @@ -0,0 +1,165 @@ +// Generated by Celest. This file should not be modified manually, but +// it can be checked into version control. +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +library; // ignore_for_file: no_leading_underscores_for_library_prefixes + +import 'dart:io'; + +import 'package:api_client/src/functions.dart'; +import 'package:api_client/src/serializers.dart'; +import 'package:celest_core/_internal.dart' as _$celest; +import 'package:celest_core/celest_core.dart' as _$celest; +import 'package:celest_core/src/util/globals.dart' as _$celest; +import 'package:http/http.dart' as _$http_http; +import 'package:native_storage/native_storage.dart' + as _$native_storage_native_storage; + +export 'package:celest_backend/exceptions/demo.dart' show BadNameException; +export 'package:celest_backend/exceptions/exceptions.dart' + show + CustomException, + CustomExceptionToFromJson, + CustomError, + CustomErrorToFromJson, + CustomErrorWithStackTrace; +export 'package:celest_backend/exceptions/overrides.dart' + show OverriddenException; +export 'package:celest_backend/models/classes.dart' + show + Empty, + Fields, + NamedFields, + MixedFields, + DefaultValues, + NestedClass, + OnlyFromJson, + OnlyToJson, + OnlyToJsonWithDefaults, + FromJsonAndToJson, + NonMapToJson, + NonMapToJsonWithDefaults, + NonMapFromAndToJson, + FromJsonStatic; +export 'package:celest_backend/models/cycles.dart' + show Node, Parent, SelfReferencing; +export 'package:celest_backend/models/demo.dart' show Person; +export 'package:celest_backend/models/exceptions.dart' + show SupportedExceptionType, SupportedErrorType; +export 'package:celest_backend/models/extension_types.dart' + show + StringX, + StringXImpl, + StringXToFromJson, + StringXToJson, + StringXToJsonImpl, + StringXFromJson, + StringXFromJsonImpl, + StringXFromJsonStatic, + StringXPrivateField, + StringXPrivateFieldImpl, + StringXPrivateCtor, + StringXPrivateCtorImpl, + Value, + ValueX, + ValueXImpl, + ValueXToFromJson, + ValueXToJson, + ValueXToJsonImpl, + ValueXFromJson, + ValueXFromJsonImpl, + ValueXFromJsonStatic, + Color, + ColorX, + ColorXImpl, + ColorXToFromJson, + ColorXToJson, + ColorXToJsonImpl, + ColorXFromJson, + ColorXFromJsonImpl, + ColorXFromJsonStatic; +export 'package:celest_backend/models/generic_wrappers.dart' + show GenericWrappers; +export 'package:celest_backend/models/metadata.dart' + show Exportable, Serializable, LiteralEnum; +export 'package:celest_backend/models/overrides.dart' + show NestedGrandparent, NestedParent, NestedChild; +export 'package:celest_backend/models/parameter_types.dart' + show MyEnum, SimpleStruct, ComplexStruct, SimpleClass, ComplexClass; +export 'package:celest_backend/models/records.dart' + show NamedFieldsRecord, Nested, NullableNested; +export 'package:celest_backend/models/sealed_classes.dart' + show + Shape, + Rectangle, + Circle, + CircleWithOverriddenCustomJson, + RectangleWithOverriddenCustomJson, + ShapeWithOverriddenCustomJson, + SwappedResult, + Result, + OkResult, + OkShapeResult; +export 'package:celest_backend/models/typedefs.dart' show Portfolio; + +final Celest celest = Celest(); + +enum CelestEnvironment { + local, + production; + + Uri get baseUri => switch (this) { + local => + _$celest.kIsWeb || !Platform.isAndroid + ? Uri.parse('http://localhost:7777') + : Uri.parse('http://10.0.2.2:7777'), + production => Uri.parse('https://example.celest.run'), + }; +} + +class Celest with _$celest.CelestBase { + var _initialized = false; + + late CelestEnvironment _currentEnvironment; + + late final _$native_storage_native_storage.NativeStorage nativeStorage = + _$native_storage_native_storage.NativeStorage(scope: 'celest'); + + @override + late _$http_http.Client httpClient = _$celest.CelestHttpClient( + secureStorage: nativeStorage.secure, + ); + + late Uri _baseUri; + + final _functions = CelestFunctions(); + + T _checkInitialized(T Function() value) { + if (!_initialized) { + throw StateError( + 'Celest has not been initialized. Make sure to call `celest.init()` at the start of your `main` method.', + ); + } + return value(); + } + + CelestEnvironment get currentEnvironment => + _checkInitialized(() => _currentEnvironment); + + @override + Uri get baseUri => _checkInitialized(() => _baseUri); + + CelestFunctions get functions => _checkInitialized(() => _functions); + + void init({ + CelestEnvironment environment = CelestEnvironment.local, + _$celest.Serializers? serializers, + }) { + _currentEnvironment = environment; + _baseUri = environment.baseUri; + if (!_initialized) { + initSerializers(serializers: serializers); + } + _initialized = true; + } +} diff --git a/apps/cli/fixtures/legacy/api/client/lib/src/functions.dart b/apps/cli/fixtures/legacy/api/client/lib/src/functions.dart new file mode 100644 index 000000000..b57a762ae --- /dev/null +++ b/apps/cli/fixtures/legacy/api/client/lib/src/functions.dart @@ -0,0 +1,11035 @@ +// Generated by Celest. This file should not be modified manually, but +// it can be checked into version control. +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +library; // ignore_for_file: no_leading_underscores_for_library_prefixes + +import 'dart:async'; +import 'dart:convert'; +import 'dart:typed_data'; + +import 'package:_common/_common.dart' as _$_common__common; +import 'package:api_client/api_client.dart'; +import 'package:celest/celest.dart' as _$celest; +import 'package:celest_backend/exceptions/demo.dart'; +import 'package:celest_backend/exceptions/exceptions.dart'; +import 'package:celest_backend/exceptions/overrides.dart'; +import 'package:celest_backend/models/classes.dart'; +import 'package:celest_backend/models/cycles.dart'; +import 'package:celest_backend/models/demo.dart'; +import 'package:celest_backend/models/exceptions.dart'; +import 'package:celest_backend/models/extension_types.dart'; +import 'package:celest_backend/models/generic_wrappers.dart'; +import 'package:celest_backend/models/metadata.dart'; +import 'package:celest_backend/models/overrides.dart'; +import 'package:celest_backend/models/parameter_types.dart'; +import 'package:celest_backend/models/records.dart'; +import 'package:celest_backend/models/sealed_classes.dart'; +import 'package:celest_backend/models/typedefs.dart'; +import 'package:celest_backend/src/functions/metadata.dart'; +import 'package:celest_core/celest_core.dart' as _$celest; +import 'package:celest_core/src/exception/cloud_exception.dart' as _$celest; +import 'package:celest_core/src/exception/serialization_exception.dart' + as _$celest; +import 'package:celest_core/src/serialization/json_value.dart' as _$celest; +import 'package:fast_immutable_collections/src/ilist/ilist.dart' + as _$fast_immutable_collections_ilist; +import 'package:fast_immutable_collections/src/imap/imap.dart' + as _$fast_immutable_collections_imap; + +class CelestFunctions { + final asserts = CelestFunctionsAsserts(); + + /// Tests that classes with and without explicit fromJson/toJson methods are + /// serializable and deserializable. + final classes = CelestFunctionsClasses(); + + /// Tests that collections (e.g. Lists/Maps) can be used as parameter and + /// return types. + final collections = CelestFunctionsCollections(); + + /// Tests that some cycles are allowed, e.g. when there is at least one level + /// of indirection. + final cycles = CelestFunctionsCycles(); + + final demo = CelestFunctionsDemo(); + + final exceptions = CelestFunctionsExceptions(); + + /// Tests that extension types are correctly handled by the analyzer. + final extensionTypes = CelestFunctionsExtensionTypes(); + + /// Tests that classes which wrap generic types are generated correctly when + /// those generic types follow the specifications of `json_serializable`, e.g. + /// having a `toJson` method with function parameters for mapping the + /// underlying types to JSON (Object Function(T) toJsonT). + final genericWrappers = CelestFunctionsGenericWrappers(); + + /// Tests that metadata associated with functions and parameters are correctly + /// parsed and transferred to the generated client. + final metadata = CelestFunctionsMetadata(); + + /// Tests that types can be recursively overriden in the serialization protocol + /// using extension types. + final overrides = CelestFunctionsOverrides(); + + final parameterTypes = CelestFunctionsParameterTypes(); + + final parameters = CelestFunctionsParameters(); + + /// Tests that records with and without aliases are serializable and + /// deserializable. + final records = CelestFunctionsRecords(); + + /// Validates all permutations of return types. + final returnTypes = CelestFunctionsReturnTypes(); + + final sealedClasses = CelestFunctionsSealedClasses(); + + /// Checks that typedefs work as expected. + final typedefs = CelestFunctionsTypedefs(); +} + +class CelestFunctionsAsserts { + Never _throwError({int? code, required Map body}) { + final status = body['@status'] as Map?; + final message = status?['message'] as String?; + final details = status?['details'] as _$celest.JsonList?; + final (errorType, errorValue, stackTrace) = switch (details) { + null || [] => const (null, null, StackTrace.empty), + [ + final errorDetails as Map, + { + '@type': 'dart.core.StackTrace', + 'value': final stackTraceValue as String, + }, + ..., + ] => + ( + errorDetails['@type'], + errorDetails['value'], + StackTrace.fromString(stackTraceValue), + ), + [final errorDetails as Map, ...] => ( + errorDetails['@type'], + errorDetails['value'], + StackTrace.empty, + ), + }; + + switch (errorType) { + case 'celest.core.v1.CloudException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.CloudException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.CancelledException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.CancelledException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnknownError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.UnknownError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.BadRequestException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.BadRequestException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnauthorizedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.UnauthorizedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.NotFoundException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.NotFoundException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.AlreadyExistsException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.AlreadyExistsException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.PermissionDeniedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.PermissionDeniedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.ResourceExhaustedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.ResourceExhaustedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.FailedPreconditionException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.FailedPreconditionException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.AbortedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.AbortedException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.OutOfRangeException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.OutOfRangeException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnimplementedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.UnimplementedError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.InternalServerError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.InternalServerError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnavailableError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.UnavailableError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.DataLossError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.DataLossError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.DeadlineExceededError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.DeadlineExceededError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.SerializationException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.SerializationException>(errorValue), + stackTrace, + ); + case 'dart.core.Error': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.AssertionError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.TypeError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.ArgumentError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.RangeError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.IndexError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.UnsupportedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.UnimplementedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.StateError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.ConcurrentModificationError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.core.OutOfMemoryError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.StackOverflowError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.Exception': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.FormatException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.IntegerDivisionByZeroException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.async.AsyncError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.async.TimeoutException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.convert.JsonUnsupportedObjectError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + default: + Error.throwWithStackTrace( + _$celest.CloudException.http( + code: code, + message: message, + details: ((details ?? body) as _$celest.JsonValue), + ), + StackTrace.empty, + ); + } + } + + /// Tests that asserts are enabled when running the local API. + @_$celest.CloudFunction(api: 'asserts', function: 'assertsEnabled') + Future assertsEnabled() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/asserts/asserts-enabled'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return ($body as bool); + } +} + +/// Tests that classes with and without explicit fromJson/toJson methods are +/// serializable and deserializable. +class CelestFunctionsClasses { + Never _throwError({int? code, required Map body}) { + final status = body['@status'] as Map?; + final message = status?['message'] as String?; + final details = status?['details'] as _$celest.JsonList?; + final (errorType, errorValue, stackTrace) = switch (details) { + null || [] => const (null, null, StackTrace.empty), + [ + final errorDetails as Map, + { + '@type': 'dart.core.StackTrace', + 'value': final stackTraceValue as String, + }, + ..., + ] => + ( + errorDetails['@type'], + errorDetails['value'], + StackTrace.fromString(stackTraceValue), + ), + [final errorDetails as Map, ...] => ( + errorDetails['@type'], + errorDetails['value'], + StackTrace.empty, + ), + }; + + switch (errorType) { + case 'celest.core.v1.CloudException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.CloudException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.CancelledException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.CancelledException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnknownError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.UnknownError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.BadRequestException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.BadRequestException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnauthorizedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.UnauthorizedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.NotFoundException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.NotFoundException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.AlreadyExistsException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.AlreadyExistsException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.PermissionDeniedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.PermissionDeniedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.ResourceExhaustedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.ResourceExhaustedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.FailedPreconditionException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.FailedPreconditionException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.AbortedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.AbortedException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.OutOfRangeException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.OutOfRangeException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnimplementedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.UnimplementedError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.InternalServerError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.InternalServerError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnavailableError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.UnavailableError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.DataLossError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.DataLossError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.DeadlineExceededError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.DeadlineExceededError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.SerializationException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.SerializationException>(errorValue), + stackTrace, + ); + case 'dart.core.Error': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.AssertionError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.TypeError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.ArgumentError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.RangeError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.IndexError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.UnsupportedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.UnimplementedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.StateError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.ConcurrentModificationError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.core.OutOfMemoryError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.StackOverflowError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.Exception': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.FormatException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.IntegerDivisionByZeroException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.async.AsyncError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.async.TimeoutException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.convert.JsonUnsupportedObjectError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + default: + Error.throwWithStackTrace( + _$celest.CloudException.http( + code: code, + message: message, + details: ((details ?? body) as _$celest.JsonValue), + ), + StackTrace.empty, + ); + } + } + + @_$celest.CloudFunction(api: 'classes', function: 'empty') + Future empty(Empty value) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/classes/empty'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'value': _$celest.Serializers.instance.serialize(value), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize($body); + } + + @_$celest.CloudFunction(api: 'classes', function: 'asyncEmpty') + Future asyncEmpty(Empty value) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/classes/async-empty'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'value': _$celest.Serializers.instance.serialize(value), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize($body); + } + + @_$celest.CloudFunction(api: 'classes', function: 'fields') + Future fields(Fields value) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/classes/fields'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'value': _$celest.Serializers.instance.serialize(value), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize($body); + } + + @_$celest.CloudFunction(api: 'classes', function: 'asyncFields') + Future asyncFields(Fields value) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/classes/async-fields'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'value': _$celest.Serializers.instance.serialize(value), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize($body); + } + + @_$celest.CloudFunction(api: 'classes', function: 'nullableFields') + Future nullableFields(Fields? value) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/classes/nullable-fields'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'value': _$celest.Serializers.instance.serialize(value), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize($body); + } + + @_$celest.CloudFunction(api: 'classes', function: 'asyncNullableFields') + Future asyncNullableFields(Fields? value) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/classes/async-nullable-fields'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'value': _$celest.Serializers.instance.serialize(value), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize($body); + } + + @_$celest.CloudFunction(api: 'classes', function: 'namedFields') + Future namedFields(NamedFields value) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/classes/named-fields'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'value': _$celest.Serializers.instance.serialize(value), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize($body); + } + + @_$celest.CloudFunction(api: 'classes', function: 'asyncNamedFields') + Future asyncNamedFields(NamedFields value) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/classes/async-named-fields'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'value': _$celest.Serializers.instance.serialize(value), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize($body); + } + + @_$celest.CloudFunction(api: 'classes', function: 'mixedFields') + Future mixedFields(MixedFields value) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/classes/mixed-fields'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'value': _$celest.Serializers.instance.serialize(value), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize($body); + } + + @_$celest.CloudFunction(api: 'classes', function: 'asyncMixedFields') + Future asyncMixedFields(MixedFields value) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/classes/async-mixed-fields'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'value': _$celest.Serializers.instance.serialize(value), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize($body); + } + + @_$celest.CloudFunction(api: 'classes', function: 'defaultValues') + Future defaultValues(DefaultValues value) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/classes/default-values'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'value': _$celest.Serializers.instance.serialize(value), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize($body); + } + + @_$celest.CloudFunction(api: 'classes', function: 'asyncDefaultValues') + Future asyncDefaultValues(DefaultValues value) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/classes/async-default-values'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'value': _$celest.Serializers.instance.serialize(value), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize($body); + } + + @_$celest.CloudFunction(api: 'classes', function: 'nestedClass') + Future nestedClass(NestedClass value) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/classes/nested-class'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'value': _$celest.Serializers.instance.serialize(value), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize($body); + } + + @_$celest.CloudFunction(api: 'classes', function: 'asyncNestedClass') + Future asyncNestedClass(NestedClass value) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/classes/async-nested-class'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'value': _$celest.Serializers.instance.serialize(value), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize($body); + } + + @_$celest.CloudFunction(api: 'classes', function: 'onlyFromJson') + Future onlyFromJson(OnlyFromJson value) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/classes/only-from-json'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'value': _$celest.Serializers.instance.serialize(value), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize($body); + } + + @_$celest.CloudFunction(api: 'classes', function: 'asyncOnlyFromJson') + Future asyncOnlyFromJson(OnlyFromJson value) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/classes/async-only-from-json'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'value': _$celest.Serializers.instance.serialize(value), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize($body); + } + + @_$celest.CloudFunction(api: 'classes', function: 'onlyToJson') + Future onlyToJson(OnlyToJson value) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/classes/only-to-json'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'value': _$celest.Serializers.instance.serialize(value), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize($body); + } + + @_$celest.CloudFunction(api: 'classes', function: 'asyncOnlyToJson') + Future asyncOnlyToJson(OnlyToJson value) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/classes/async-only-to-json'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'value': _$celest.Serializers.instance.serialize(value), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize($body); + } + + @_$celest.CloudFunction(api: 'classes', function: 'onlyToJsonWithDefaults') + Future onlyToJsonWithDefaults( + OnlyToJsonWithDefaults value, + ) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/classes/only-to-json-with-defaults'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'value': _$celest.Serializers.instance + .serialize(value), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize( + $body, + ); + } + + @_$celest.CloudFunction( + api: 'classes', + function: 'asyncOnlyToJsonWithDefaults', + ) + Future asyncOnlyToJsonWithDefaults( + OnlyToJsonWithDefaults value, + ) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/classes/async-only-to-json-with-defaults'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'value': _$celest.Serializers.instance + .serialize(value), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize( + $body, + ); + } + + @_$celest.CloudFunction(api: 'classes', function: 'fromAndToJson') + Future fromAndToJson(FromJsonAndToJson value) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/classes/from-and-to-json'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'value': _$celest.Serializers.instance.serialize( + value, + ), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize($body); + } + + @_$celest.CloudFunction(api: 'classes', function: 'asyncFromAndToJson') + Future asyncFromAndToJson(FromJsonAndToJson value) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/classes/async-from-and-to-json'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'value': _$celest.Serializers.instance.serialize( + value, + ), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize($body); + } + + @_$celest.CloudFunction(api: 'classes', function: 'nonMapToJson') + Future nonMapToJson(NonMapToJson value) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/classes/non-map-to-json'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'value': _$celest.Serializers.instance.serialize(value), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize($body); + } + + @_$celest.CloudFunction(api: 'classes', function: 'asyncNonMapToJson') + Future asyncNonMapToJson(NonMapToJson value) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/classes/async-non-map-to-json'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'value': _$celest.Serializers.instance.serialize(value), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize($body); + } + + @_$celest.CloudFunction(api: 'classes', function: 'nonMapToJsonWithDefaults') + Future nonMapToJsonWithDefaults( + NonMapToJsonWithDefaults value, + ) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/classes/non-map-to-json-with-defaults'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'value': _$celest.Serializers.instance + .serialize(value), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize( + $body, + ); + } + + @_$celest.CloudFunction( + api: 'classes', + function: 'asyncNonMapToJsonWithDefaults', + ) + Future asyncNonMapToJsonWithDefaults( + NonMapToJsonWithDefaults value, + ) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/classes/async-non-map-to-json-with-defaults'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'value': _$celest.Serializers.instance + .serialize(value), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize( + $body, + ); + } + + @_$celest.CloudFunction(api: 'classes', function: 'nonMapFromAndToJson') + Future nonMapFromAndToJson( + NonMapFromAndToJson value, + ) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/classes/non-map-from-and-to-json'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'value': _$celest.Serializers.instance.serialize( + value, + ), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize( + $body, + ); + } + + @_$celest.CloudFunction(api: 'classes', function: 'asyncNonMapFromAndToJson') + Future asyncNonMapFromAndToJson( + NonMapFromAndToJson value, + ) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/classes/async-non-map-from-and-to-json'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'value': _$celest.Serializers.instance.serialize( + value, + ), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize( + $body, + ); + } + + @_$celest.CloudFunction(api: 'classes', function: 'fromJsonStatic') + Future fromJsonStatic(FromJsonStatic value) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/classes/from-json-static'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'value': _$celest.Serializers.instance.serialize( + value, + ), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize($body); + } +} + +/// Tests that collections (e.g. Lists/Maps) can be used as parameter and +/// return types. +class CelestFunctionsCollections { + Never _throwError({int? code, required Map body}) { + final status = body['@status'] as Map?; + final message = status?['message'] as String?; + final details = status?['details'] as _$celest.JsonList?; + final (errorType, errorValue, stackTrace) = switch (details) { + null || [] => const (null, null, StackTrace.empty), + [ + final errorDetails as Map, + { + '@type': 'dart.core.StackTrace', + 'value': final stackTraceValue as String, + }, + ..., + ] => + ( + errorDetails['@type'], + errorDetails['value'], + StackTrace.fromString(stackTraceValue), + ), + [final errorDetails as Map, ...] => ( + errorDetails['@type'], + errorDetails['value'], + StackTrace.empty, + ), + }; + + switch (errorType) { + case 'celest.core.v1.CloudException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.CloudException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.CancelledException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.CancelledException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnknownError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.UnknownError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.BadRequestException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.BadRequestException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnauthorizedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.UnauthorizedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.NotFoundException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.NotFoundException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.AlreadyExistsException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.AlreadyExistsException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.PermissionDeniedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.PermissionDeniedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.ResourceExhaustedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.ResourceExhaustedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.FailedPreconditionException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.FailedPreconditionException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.AbortedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.AbortedException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.OutOfRangeException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.OutOfRangeException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnimplementedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.UnimplementedError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.InternalServerError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.InternalServerError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnavailableError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.UnavailableError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.DataLossError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.DataLossError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.DeadlineExceededError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.DeadlineExceededError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.SerializationException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.SerializationException>(errorValue), + stackTrace, + ); + case 'dart.core.Error': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.AssertionError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.TypeError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.ArgumentError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.RangeError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.IndexError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.UnsupportedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.UnimplementedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.StateError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.ConcurrentModificationError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.core.OutOfMemoryError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.StackOverflowError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.Exception': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.FormatException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.IntegerDivisionByZeroException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.async.AsyncError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.async.TimeoutException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.convert.JsonUnsupportedObjectError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + default: + Error.throwWithStackTrace( + _$celest.CloudException.http( + code: code, + message: message, + details: ((details ?? body) as _$celest.JsonValue), + ), + StackTrace.empty, + ); + } + } + + @_$celest.CloudFunction(api: 'collections', function: 'simpleList') + Future> simpleList(List list) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/collections/simple-list'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({r'list': list}), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return ($body as Iterable).map((el) => (el as String)).toList(); + } + + @_$celest.CloudFunction(api: 'collections', function: 'complexList') + Future> complexList(List list) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/collections/complex-list'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'list': + list + .map( + (el) => + _$celest.Serializers.instance.serialize(el), + ) + .toList(), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return ($body as Iterable) + .map((el) => _$celest.Serializers.instance.deserialize(el)) + .toList(); + } + + @_$celest.CloudFunction(api: 'collections', function: 'simpleMap') + Future> simpleMap(Map map) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/collections/simple-map'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({r'map': map}), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return ($body as Map).map( + (key, value) => MapEntry(key, (value as String)), + ); + } + + @_$celest.CloudFunction(api: 'collections', function: 'dynamicMap') + Future> dynamicMap(Map map) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/collections/dynamic-map'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({r'map': map}), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return ($body as Map); + } + + @_$celest.CloudFunction(api: 'collections', function: 'objectMap') + Future> objectMap(Map map) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/collections/object-map'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({r'map': map}), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return ($body as Map).map( + (key, value) => MapEntry(key, value!), + ); + } + + @_$celest.CloudFunction(api: 'collections', function: 'objectNullableMap') + Future> objectNullableMap( + Map map, + ) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/collections/object-nullable-map'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({r'map': map}), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return ($body as Map); + } + + @_$celest.CloudFunction(api: 'collections', function: 'complexMap') + Future> complexMap( + Map map, + ) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/collections/complex-map'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'map': map.map( + (key, value) => MapEntry( + key, + _$celest.Serializers.instance.serialize(value), + ), + ), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return ($body as Map).map( + (key, value) => MapEntry( + key, + _$celest.Serializers.instance.deserialize(value), + ), + ); + } +} + +/// Tests that some cycles are allowed, e.g. when there is at least one level +/// of indirection. +class CelestFunctionsCycles { + Never _throwError({int? code, required Map body}) { + final status = body['@status'] as Map?; + final message = status?['message'] as String?; + final details = status?['details'] as _$celest.JsonList?; + final (errorType, errorValue, stackTrace) = switch (details) { + null || [] => const (null, null, StackTrace.empty), + [ + final errorDetails as Map, + { + '@type': 'dart.core.StackTrace', + 'value': final stackTraceValue as String, + }, + ..., + ] => + ( + errorDetails['@type'], + errorDetails['value'], + StackTrace.fromString(stackTraceValue), + ), + [final errorDetails as Map, ...] => ( + errorDetails['@type'], + errorDetails['value'], + StackTrace.empty, + ), + }; + + switch (errorType) { + case 'celest.core.v1.CloudException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.CloudException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.CancelledException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.CancelledException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnknownError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.UnknownError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.BadRequestException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.BadRequestException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnauthorizedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.UnauthorizedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.NotFoundException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.NotFoundException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.AlreadyExistsException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.AlreadyExistsException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.PermissionDeniedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.PermissionDeniedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.ResourceExhaustedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.ResourceExhaustedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.FailedPreconditionException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.FailedPreconditionException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.AbortedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.AbortedException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.OutOfRangeException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.OutOfRangeException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnimplementedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.UnimplementedError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.InternalServerError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.InternalServerError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnavailableError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.UnavailableError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.DataLossError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.DataLossError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.DeadlineExceededError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.DeadlineExceededError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.SerializationException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.SerializationException>(errorValue), + stackTrace, + ); + case 'dart.core.Error': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.AssertionError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.TypeError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.ArgumentError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.RangeError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.IndexError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.UnsupportedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.UnimplementedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.StateError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.ConcurrentModificationError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.core.OutOfMemoryError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.StackOverflowError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.Exception': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.FormatException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.IntegerDivisionByZeroException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.async.AsyncError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.async.TimeoutException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.convert.JsonUnsupportedObjectError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + default: + Error.throwWithStackTrace( + _$celest.CloudException.http( + code: code, + message: message, + details: ((details ?? body) as _$celest.JsonValue), + ), + StackTrace.empty, + ); + } + } + + @_$celest.CloudFunction(api: 'cycles', function: 'createTree') + Future createTree() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/cycles/create-tree'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize($body); + } + + @_$celest.CloudFunction(api: 'cycles', function: 'printTree') + Future printTree(Node node) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/cycles/print-tree'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'node': _$celest.Serializers.instance.serialize(node), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return; + } + + @_$celest.CloudFunction(api: 'cycles', function: 'combineTrees') + Future combineTrees( + Node tree1, [ + Parent? tree2, + Node? tree3, + List additionalChildren = const [], + ]) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/cycles/combine-trees'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'tree1': _$celest.Serializers.instance.serialize(tree1), + r'tree2': _$celest.Serializers.instance.serialize(tree2), + r'tree3': _$celest.Serializers.instance.serialize(tree3), + r'additionalChildren': + additionalChildren + .map((el) => _$celest.Serializers.instance.serialize(el)) + .toList(), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize($body); + } + + /// Tests that self-referencing is allowed when there is a level + /// of indirection, e.g. nullability, generics, or a wrapper. + @_$celest.CloudFunction(api: 'cycles', function: 'selfReferencing') + Future selfReferencing( + SelfReferencing selfReferencing, + ) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/cycles/self-referencing'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'selfReferencing': _$celest.Serializers.instance + .serialize(selfReferencing), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize($body); + } +} + +class CelestFunctionsDemo { + Never _throwError({int? code, required Map body}) { + final status = body['@status'] as Map?; + final message = status?['message'] as String?; + final details = status?['details'] as _$celest.JsonList?; + final (errorType, errorValue, stackTrace) = switch (details) { + null || [] => const (null, null, StackTrace.empty), + [ + final errorDetails as Map, + { + '@type': 'dart.core.StackTrace', + 'value': final stackTraceValue as String, + }, + ..., + ] => + ( + errorDetails['@type'], + errorDetails['value'], + StackTrace.fromString(stackTraceValue), + ), + [final errorDetails as Map, ...] => ( + errorDetails['@type'], + errorDetails['value'], + StackTrace.empty, + ), + }; + + switch (errorType) { + case 'celest.core.v1.CloudException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.CloudException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.CancelledException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.CancelledException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnknownError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.UnknownError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.BadRequestException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.BadRequestException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnauthorizedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.UnauthorizedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.NotFoundException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.NotFoundException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.AlreadyExistsException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.AlreadyExistsException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.PermissionDeniedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.PermissionDeniedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.ResourceExhaustedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.ResourceExhaustedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.FailedPreconditionException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.FailedPreconditionException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.AbortedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.AbortedException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.OutOfRangeException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.OutOfRangeException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnimplementedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.UnimplementedError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.InternalServerError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.InternalServerError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnavailableError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.UnavailableError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.DataLossError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.DataLossError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.DeadlineExceededError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.DeadlineExceededError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.SerializationException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.SerializationException>(errorValue), + stackTrace, + ); + case 'dart.core.Error': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.AssertionError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.TypeError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.ArgumentError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.RangeError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.IndexError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.UnsupportedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.UnimplementedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.StateError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.ConcurrentModificationError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.core.OutOfMemoryError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.StackOverflowError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.Exception': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.FormatException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.IntegerDivisionByZeroException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.async.AsyncError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.async.TimeoutException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.convert.JsonUnsupportedObjectError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'api.v1.BadNameException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + default: + Error.throwWithStackTrace( + _$celest.CloudException.http( + code: code, + message: message, + details: ((details ?? body) as _$celest.JsonValue), + ), + StackTrace.empty, + ); + } + } + + /// Says hello to a [person]. + @_$celest.CloudFunction(api: 'demo', function: 'sayHello') + Future sayHello({required Person person}) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/demo/say-hello'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'person': _$celest.Serializers.instance.serialize(person), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return ($body as String); + } +} + +class CelestFunctionsExceptions { + Never _throwError({int? code, required Map body}) { + final status = body['@status'] as Map?; + final message = status?['message'] as String?; + final details = status?['details'] as _$celest.JsonList?; + final (errorType, errorValue, stackTrace) = switch (details) { + null || [] => const (null, null, StackTrace.empty), + [ + final errorDetails as Map, + { + '@type': 'dart.core.StackTrace', + 'value': final stackTraceValue as String, + }, + ..., + ] => + ( + errorDetails['@type'], + errorDetails['value'], + StackTrace.fromString(stackTraceValue), + ), + [final errorDetails as Map, ...] => ( + errorDetails['@type'], + errorDetails['value'], + StackTrace.empty, + ), + }; + + switch (errorType) { + case 'celest.core.v1.CloudException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.CloudException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.CancelledException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.CancelledException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnknownError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.UnknownError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.BadRequestException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.BadRequestException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnauthorizedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.UnauthorizedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.NotFoundException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.NotFoundException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.AlreadyExistsException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.AlreadyExistsException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.PermissionDeniedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.PermissionDeniedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.ResourceExhaustedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.ResourceExhaustedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.FailedPreconditionException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.FailedPreconditionException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.AbortedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.AbortedException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.OutOfRangeException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.OutOfRangeException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnimplementedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.UnimplementedError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.InternalServerError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.InternalServerError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnavailableError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.UnavailableError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.DataLossError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.DataLossError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.DeadlineExceededError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.DeadlineExceededError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.SerializationException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.SerializationException>(errorValue), + stackTrace, + ); + case 'dart.core.Error': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.AssertionError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.TypeError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.ArgumentError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.RangeError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.IndexError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.UnsupportedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.UnimplementedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.StateError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.ConcurrentModificationError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.core.OutOfMemoryError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.StackOverflowError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.Exception': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.FormatException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.IntegerDivisionByZeroException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.async.AsyncError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.async.TimeoutException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.convert.JsonUnsupportedObjectError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'api.v1.CustomException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'api.v1.CustomExceptionToFromJson': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'api.v1.CustomError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'api.v1.CustomErrorToFromJson': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'api.v1.CustomErrorWithStackTrace': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + default: + Error.throwWithStackTrace( + _$celest.CloudException.http( + code: code, + message: message, + details: ((details ?? body) as _$celest.JsonValue), + ), + StackTrace.empty, + ); + } + } + + @_$celest.CloudFunction(api: 'exceptions', function: 'throwsException') + Future throwsException({required SupportedExceptionType type}) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/exceptions/throws-exception'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'type': _$celest.Serializers.instance + .serialize(type), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return; + } + + @_$celest.CloudFunction(api: 'exceptions', function: 'throwsError') + Future throwsError({required SupportedErrorType type}) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/exceptions/throws-error'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'type': _$celest.Serializers.instance.serialize( + type, + ), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return; + } + + @_$celest.CloudFunction(api: 'exceptions', function: 'throwsCustomException') + Future throwsCustomException() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/exceptions/throws-custom-exception'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return; + } + + @_$celest.CloudFunction( + api: 'exceptions', + function: 'throwsCustomExceptionToFromJson', + ) + Future throwsCustomExceptionToFromJson() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve( + '/exceptions/throws-custom-exception-to-from-json', + ), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return; + } + + @_$celest.CloudFunction(api: 'exceptions', function: 'throwsCustomError') + Future throwsCustomError() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/exceptions/throws-custom-error'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return; + } + + @_$celest.CloudFunction( + api: 'exceptions', + function: 'throwsCustomErrorToFromJson', + ) + Future throwsCustomErrorToFromJson() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/exceptions/throws-custom-error-to-from-json'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return; + } + + @_$celest.CloudFunction( + api: 'exceptions', + function: 'throwsCustomErrorWithStackTrace', + ) + Future throwsCustomErrorWithStackTrace() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve( + '/exceptions/throws-custom-error-with-stack-trace', + ), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return; + } +} + +/// Tests that extension types are correctly handled by the analyzer. +class CelestFunctionsExtensionTypes { + Never _throwError({int? code, required Map body}) { + final status = body['@status'] as Map?; + final message = status?['message'] as String?; + final details = status?['details'] as _$celest.JsonList?; + final (errorType, errorValue, stackTrace) = switch (details) { + null || [] => const (null, null, StackTrace.empty), + [ + final errorDetails as Map, + { + '@type': 'dart.core.StackTrace', + 'value': final stackTraceValue as String, + }, + ..., + ] => + ( + errorDetails['@type'], + errorDetails['value'], + StackTrace.fromString(stackTraceValue), + ), + [final errorDetails as Map, ...] => ( + errorDetails['@type'], + errorDetails['value'], + StackTrace.empty, + ), + }; + + switch (errorType) { + case 'dart.async.AsyncError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.async.TimeoutException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.convert.JsonUnsupportedObjectError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.Error': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.AssertionError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.TypeError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.ArgumentError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.RangeError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.IndexError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.UnsupportedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.UnimplementedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.StateError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.ConcurrentModificationError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.core.OutOfMemoryError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.StackOverflowError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.Exception': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.FormatException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.IntegerDivisionByZeroException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'celest.core.v1.CloudException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.CloudException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.CancelledException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.CancelledException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnknownError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.UnknownError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.BadRequestException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.BadRequestException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnauthorizedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.UnauthorizedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.NotFoundException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.NotFoundException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.AlreadyExistsException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.AlreadyExistsException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.PermissionDeniedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.PermissionDeniedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.ResourceExhaustedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.ResourceExhaustedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.FailedPreconditionException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.FailedPreconditionException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.AbortedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.AbortedException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.OutOfRangeException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.OutOfRangeException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnimplementedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.UnimplementedError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.InternalServerError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.InternalServerError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnavailableError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.UnavailableError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.DataLossError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.DataLossError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.DeadlineExceededError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.DeadlineExceededError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.SerializationException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.SerializationException>(errorValue), + stackTrace, + ); + default: + Error.throwWithStackTrace( + _$celest.CloudException.http( + code: code, + message: message, + details: ((details ?? body) as _$celest.JsonValue), + ), + StackTrace.empty, + ); + } + } + + @_$celest.CloudFunction(api: 'extension_types', function: 'string') + Future string(StringX s) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/extension-types/string'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r's': _$celest.Serializers.instance.serialize( + s, + const _$celest.TypeToken('StringX'), + ), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize( + $body, + const _$celest.TypeToken('StringX'), + ); + } + + @_$celest.CloudFunction(api: 'extension_types', function: 'asyncOrString') + Future asyncOrString(StringX s) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/extension-types/async-or-string'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r's': _$celest.Serializers.instance.serialize( + s, + const _$celest.TypeToken('StringX'), + ), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize( + $body, + const _$celest.TypeToken('StringX'), + ); + } + + @_$celest.CloudFunction(api: 'extension_types', function: 'asyncString') + Future asyncString(StringX s) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/extension-types/async-string'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r's': _$celest.Serializers.instance.serialize( + s, + const _$celest.TypeToken('StringX'), + ), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize( + $body, + const _$celest.TypeToken('StringX'), + ); + } + + @_$celest.CloudFunction(api: 'extension_types', function: 'stringImpl') + Future stringImpl(StringXImpl s) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/extension-types/string-impl'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r's': _$celest.Serializers.instance.serialize( + s, + const _$celest.TypeToken('StringXImpl'), + ), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize( + $body, + const _$celest.TypeToken('StringXImpl'), + ); + } + + @_$celest.CloudFunction(api: 'extension_types', function: 'stringToFromJson') + Future stringToFromJson(StringXToFromJson s) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/extension-types/string-to-from-json'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r's': _$celest.Serializers.instance.serialize( + s, + const _$celest.TypeToken('StringXToFromJson'), + ), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize( + $body, + const _$celest.TypeToken('StringXToFromJson'), + ); + } + + @_$celest.CloudFunction(api: 'extension_types', function: 'stringToJson') + Future stringToJson(StringXToJson s) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/extension-types/string-to-json'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r's': _$celest.Serializers.instance.serialize( + s, + const _$celest.TypeToken('StringXToJson'), + ), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize( + $body, + const _$celest.TypeToken('StringXToJson'), + ); + } + + @_$celest.CloudFunction(api: 'extension_types', function: 'stringToJsonImpl') + Future stringToJsonImpl(StringXToJsonImpl s) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/extension-types/string-to-json-impl'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r's': _$celest.Serializers.instance.serialize( + s, + const _$celest.TypeToken('StringXToJsonImpl'), + ), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize( + $body, + const _$celest.TypeToken('StringXToJsonImpl'), + ); + } + + @_$celest.CloudFunction(api: 'extension_types', function: 'stringFromJson') + Future stringFromJson(StringXFromJson s) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/extension-types/string-from-json'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r's': _$celest.Serializers.instance.serialize( + s, + const _$celest.TypeToken('StringXFromJson'), + ), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize( + $body, + const _$celest.TypeToken('StringXFromJson'), + ); + } + + @_$celest.CloudFunction( + api: 'extension_types', + function: 'stringFromJsonImpl', + ) + Future stringFromJsonImpl(StringXFromJsonImpl s) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/extension-types/string-from-json-impl'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r's': _$celest.Serializers.instance.serialize( + s, + const _$celest.TypeToken('StringXFromJsonImpl'), + ), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize( + $body, + const _$celest.TypeToken('StringXFromJsonImpl'), + ); + } + + @_$celest.CloudFunction( + api: 'extension_types', + function: 'stringFromJsonStatic', + ) + Future stringFromJsonStatic( + StringXFromJsonStatic s, + ) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/extension-types/string-from-json-static'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r's': _$celest.Serializers.instance.serialize( + s, + const _$celest.TypeToken( + 'StringXFromJsonStatic', + ), + ), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize( + $body, + const _$celest.TypeToken('StringXFromJsonStatic'), + ); + } + + @_$celest.CloudFunction( + api: 'extension_types', + function: 'stringPrivateField', + ) + Future stringPrivateField(StringXPrivateField s) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/extension-types/string-private-field'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r's': _$celest.Serializers.instance.serialize( + s, + const _$celest.TypeToken('StringXPrivateField'), + ), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize( + $body, + const _$celest.TypeToken('StringXPrivateField'), + ); + } + + @_$celest.CloudFunction( + api: 'extension_types', + function: 'stringPrivateFieldImpl', + ) + Future stringPrivateFieldImpl( + StringXPrivateFieldImpl s, + ) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/extension-types/string-private-field-impl'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r's': _$celest.Serializers.instance.serialize( + s, + const _$celest.TypeToken( + 'StringXPrivateFieldImpl', + ), + ), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize( + $body, + const _$celest.TypeToken( + 'StringXPrivateFieldImpl', + ), + ); + } + + @_$celest.CloudFunction(api: 'extension_types', function: 'stringPrivateCtor') + Future stringPrivateCtor(StringXPrivateCtor s) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/extension-types/string-private-ctor'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r's': _$celest.Serializers.instance.serialize( + s, + const _$celest.TypeToken('StringXPrivateCtor'), + ), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize( + $body, + const _$celest.TypeToken('StringXPrivateCtor'), + ); + } + + @_$celest.CloudFunction( + api: 'extension_types', + function: 'stringPrivateCtorImpl', + ) + Future stringPrivateCtorImpl( + StringXPrivateCtorImpl s, + ) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/extension-types/string-private-ctor-impl'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r's': _$celest.Serializers.instance.serialize( + s, + const _$celest.TypeToken( + 'StringXPrivateCtorImpl', + ), + ), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize( + $body, + const _$celest.TypeToken( + 'StringXPrivateCtorImpl', + ), + ); + } + + @_$celest.CloudFunction(api: 'extension_types', function: 'value') + Future value(Value v) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/extension-types/value'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'v': _$celest.Serializers.instance.serialize(v), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize($body); + } + + @_$celest.CloudFunction(api: 'extension_types', function: 'valueX') + Future valueX(ValueX v) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/extension-types/value-x'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'v': _$celest.Serializers.instance.serialize( + v, + const _$celest.TypeToken('ValueX'), + ), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize( + $body, + const _$celest.TypeToken('ValueX'), + ); + } + + @_$celest.CloudFunction(api: 'extension_types', function: 'valueXImpl') + Future valueXImpl(ValueXImpl v) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/extension-types/value-x-impl'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'v': _$celest.Serializers.instance.serialize( + v, + const _$celest.TypeToken('ValueXImpl'), + ), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize( + $body, + const _$celest.TypeToken('ValueXImpl'), + ); + } + + @_$celest.CloudFunction(api: 'extension_types', function: 'valueXToFromJson') + Future valueXToFromJson(ValueXToFromJson v) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/extension-types/value-x-to-from-json'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'v': _$celest.Serializers.instance.serialize( + v, + const _$celest.TypeToken('ValueXToFromJson'), + ), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize( + $body, + const _$celest.TypeToken('ValueXToFromJson'), + ); + } + + @_$celest.CloudFunction(api: 'extension_types', function: 'valueXToJson') + Future valueXToJson(ValueXToJson v) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/extension-types/value-x-to-json'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'v': _$celest.Serializers.instance.serialize( + v, + const _$celest.TypeToken('ValueXToJson'), + ), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize( + $body, + const _$celest.TypeToken('ValueXToJson'), + ); + } + + @_$celest.CloudFunction(api: 'extension_types', function: 'valueXToJsonImpl') + Future valueXToJsonImpl(ValueXToJsonImpl v) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/extension-types/value-x-to-json-impl'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'v': _$celest.Serializers.instance.serialize( + v, + const _$celest.TypeToken('ValueXToJsonImpl'), + ), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize( + $body, + const _$celest.TypeToken('ValueXToJsonImpl'), + ); + } + + @_$celest.CloudFunction(api: 'extension_types', function: 'valueXFromJson') + Future valueXFromJson(ValueXFromJson v) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/extension-types/value-x-from-json'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'v': _$celest.Serializers.instance.serialize( + v, + const _$celest.TypeToken('ValueXFromJson'), + ), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize( + $body, + const _$celest.TypeToken('ValueXFromJson'), + ); + } + + @_$celest.CloudFunction( + api: 'extension_types', + function: 'valueXFromJsonImpl', + ) + Future valueXFromJsonImpl(ValueXFromJsonImpl v) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/extension-types/value-x-from-json-impl'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'v': _$celest.Serializers.instance.serialize( + v, + const _$celest.TypeToken('ValueXFromJsonImpl'), + ), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize( + $body, + const _$celest.TypeToken('ValueXFromJsonImpl'), + ); + } + + @_$celest.CloudFunction( + api: 'extension_types', + function: 'valueXFromJsonStatic', + ) + Future valueXFromJsonStatic( + ValueXFromJsonStatic v, + ) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/extension-types/value-x-from-json-static'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'v': _$celest.Serializers.instance.serialize( + v, + const _$celest.TypeToken( + 'ValueXFromJsonStatic', + ), + ), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize( + $body, + const _$celest.TypeToken('ValueXFromJsonStatic'), + ); + } + + @_$celest.CloudFunction(api: 'extension_types', function: 'color') + Future color(Color color) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/extension-types/color'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'color': _$celest.Serializers.instance.serialize(color), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize($body); + } + + @_$celest.CloudFunction(api: 'extension_types', function: 'colorX') + Future colorX(ColorX color) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/extension-types/color-x'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'color': _$celest.Serializers.instance.serialize( + color, + const _$celest.TypeToken('ColorX'), + ), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize( + $body, + const _$celest.TypeToken('ColorX'), + ); + } + + @_$celest.CloudFunction(api: 'extension_types', function: 'colorXImpl') + Future colorXImpl(ColorXImpl color) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/extension-types/color-x-impl'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'color': _$celest.Serializers.instance.serialize( + color, + const _$celest.TypeToken('ColorXImpl'), + ), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize( + $body, + const _$celest.TypeToken('ColorXImpl'), + ); + } + + @_$celest.CloudFunction(api: 'extension_types', function: 'colorXToFromJson') + Future colorXToFromJson(ColorXToFromJson color) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/extension-types/color-x-to-from-json'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'color': _$celest.Serializers.instance.serialize( + color, + const _$celest.TypeToken('ColorXToFromJson'), + ), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize( + $body, + const _$celest.TypeToken('ColorXToFromJson'), + ); + } + + @_$celest.CloudFunction(api: 'extension_types', function: 'colorXToJson') + Future colorXToJson(ColorXToJson color) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/extension-types/color-x-to-json'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'color': _$celest.Serializers.instance.serialize( + color, + const _$celest.TypeToken('ColorXToJson'), + ), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize( + $body, + const _$celest.TypeToken('ColorXToJson'), + ); + } + + @_$celest.CloudFunction(api: 'extension_types', function: 'colorXToJsonImpl') + Future colorXToJsonImpl(ColorXToJsonImpl color) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/extension-types/color-x-to-json-impl'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'color': _$celest.Serializers.instance.serialize( + color, + const _$celest.TypeToken('ColorXToJsonImpl'), + ), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize( + $body, + const _$celest.TypeToken('ColorXToJsonImpl'), + ); + } + + @_$celest.CloudFunction(api: 'extension_types', function: 'colorXFromJson') + Future colorXFromJson(ColorXFromJson color) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/extension-types/color-x-from-json'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'color': _$celest.Serializers.instance.serialize( + color, + const _$celest.TypeToken('ColorXFromJson'), + ), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize( + $body, + const _$celest.TypeToken('ColorXFromJson'), + ); + } + + @_$celest.CloudFunction( + api: 'extension_types', + function: 'colorXFromJsonImpl', + ) + Future colorXFromJsonImpl( + ColorXFromJsonImpl color, + ) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/extension-types/color-x-from-json-impl'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'color': _$celest.Serializers.instance.serialize( + color, + const _$celest.TypeToken('ColorXFromJsonImpl'), + ), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize( + $body, + const _$celest.TypeToken('ColorXFromJsonImpl'), + ); + } + + @_$celest.CloudFunction( + api: 'extension_types', + function: 'colorXFromJsonStatic', + ) + Future colorXFromJsonStatic( + ColorXFromJsonStatic color, + ) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/extension-types/color-x-from-json-static'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'color': _$celest.Serializers.instance.serialize( + color, + const _$celest.TypeToken( + 'ColorXFromJsonStatic', + ), + ), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize( + $body, + const _$celest.TypeToken('ColorXFromJsonStatic'), + ); + } + + @_$celest.CloudFunction(api: 'extension_types', function: 'jsonValue') + Future<_$celest.JsonValue> jsonValue(_$celest.JsonValue value) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/extension-types/json-value'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'value': _$celest.Serializers.instance.serialize<_$celest.JsonValue>( + value, + const _$celest.TypeToken<_$celest.JsonValue>('JsonValue'), + ), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize<_$celest.JsonValue>( + $body, + const _$celest.TypeToken<_$celest.JsonValue>('JsonValue'), + ); + } + + @_$celest.CloudFunction(api: 'extension_types', function: 'jsonString') + Future<_$celest.JsonString> jsonString(_$celest.JsonString value) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/extension-types/json-string'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'value': _$celest.Serializers.instance.serialize<_$celest.JsonString>( + value, + const _$celest.TypeToken<_$celest.JsonString>('JsonString'), + ), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize<_$celest.JsonString>( + $body, + const _$celest.TypeToken<_$celest.JsonString>('JsonString'), + ); + } + + @_$celest.CloudFunction(api: 'extension_types', function: 'jsonNum') + Future<_$celest.JsonNum> jsonNum(_$celest.JsonNum value) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/extension-types/json-num'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'value': _$celest.Serializers.instance.serialize<_$celest.JsonNum>( + value, + const _$celest.TypeToken<_$celest.JsonNum>('JsonNum'), + ), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize<_$celest.JsonNum>( + $body, + const _$celest.TypeToken<_$celest.JsonNum>('JsonNum'), + ); + } + + @_$celest.CloudFunction(api: 'extension_types', function: 'jsonInt') + Future<_$celest.JsonInt> jsonInt(_$celest.JsonInt value) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/extension-types/json-int'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'value': _$celest.Serializers.instance.serialize<_$celest.JsonInt>( + value, + const _$celest.TypeToken<_$celest.JsonInt>('JsonInt'), + ), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize<_$celest.JsonInt>( + $body, + const _$celest.TypeToken<_$celest.JsonInt>('JsonInt'), + ); + } + + @_$celest.CloudFunction(api: 'extension_types', function: 'jsonDouble') + Future<_$celest.JsonDouble> jsonDouble(_$celest.JsonDouble value) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/extension-types/json-double'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'value': _$celest.Serializers.instance.serialize<_$celest.JsonDouble>( + value, + const _$celest.TypeToken<_$celest.JsonDouble>('JsonDouble'), + ), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize<_$celest.JsonDouble>( + $body, + const _$celest.TypeToken<_$celest.JsonDouble>('JsonDouble'), + ); + } + + @_$celest.CloudFunction(api: 'extension_types', function: 'jsonBool') + Future<_$celest.JsonBool> jsonBool(_$celest.JsonBool value) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/extension-types/json-bool'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'value': _$celest.Serializers.instance.serialize<_$celest.JsonBool>( + value, + const _$celest.TypeToken<_$celest.JsonBool>('JsonBool'), + ), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize<_$celest.JsonBool>( + $body, + const _$celest.TypeToken<_$celest.JsonBool>('JsonBool'), + ); + } + + @_$celest.CloudFunction(api: 'extension_types', function: 'jsonList') + Future<_$celest.JsonList> jsonList(_$celest.JsonList value) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/extension-types/json-list'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'value': _$celest.Serializers.instance.serialize<_$celest.JsonList>( + value, + const _$celest.TypeToken<_$celest.JsonList>('JsonList'), + ), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize<_$celest.JsonList>( + $body, + const _$celest.TypeToken<_$celest.JsonList>('JsonList'), + ); + } + + @_$celest.CloudFunction(api: 'extension_types', function: 'jsonMap') + Future<_$celest.JsonMap> jsonMap(_$celest.JsonMap value) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/extension-types/json-map'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'value': _$celest.Serializers.instance.serialize<_$celest.JsonMap>( + value, + const _$celest.TypeToken<_$celest.JsonMap>('JsonMap'), + ), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize<_$celest.JsonMap>( + $body, + const _$celest.TypeToken<_$celest.JsonMap>('JsonMap'), + ); + } +} + +/// Tests that classes which wrap generic types are generated correctly when +/// those generic types follow the specifications of `json_serializable`, e.g. +/// having a `toJson` method with function parameters for mapping the +/// underlying types to JSON (Object Function(T) toJsonT). +class CelestFunctionsGenericWrappers { + Never _throwError({int? code, required Map body}) { + final status = body['@status'] as Map?; + final message = status?['message'] as String?; + final details = status?['details'] as _$celest.JsonList?; + final (errorType, errorValue, stackTrace) = switch (details) { + null || [] => const (null, null, StackTrace.empty), + [ + final errorDetails as Map, + { + '@type': 'dart.core.StackTrace', + 'value': final stackTraceValue as String, + }, + ..., + ] => + ( + errorDetails['@type'], + errorDetails['value'], + StackTrace.fromString(stackTraceValue), + ), + [final errorDetails as Map, ...] => ( + errorDetails['@type'], + errorDetails['value'], + StackTrace.empty, + ), + }; + + switch (errorType) { + case 'celest.core.v1.CloudException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.CloudException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.CancelledException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.CancelledException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnknownError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.UnknownError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.BadRequestException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.BadRequestException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnauthorizedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.UnauthorizedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.NotFoundException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.NotFoundException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.AlreadyExistsException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.AlreadyExistsException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.PermissionDeniedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.PermissionDeniedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.ResourceExhaustedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.ResourceExhaustedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.FailedPreconditionException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.FailedPreconditionException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.AbortedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.AbortedException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.OutOfRangeException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.OutOfRangeException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnimplementedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.UnimplementedError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.InternalServerError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.InternalServerError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnavailableError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.UnavailableError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.DataLossError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.DataLossError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.DeadlineExceededError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.DeadlineExceededError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.SerializationException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.SerializationException>(errorValue), + stackTrace, + ); + case 'dart.core.Error': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.AssertionError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.TypeError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.ArgumentError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.RangeError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.IndexError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.UnsupportedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.UnimplementedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.StateError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.ConcurrentModificationError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.core.OutOfMemoryError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.StackOverflowError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.Exception': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.FormatException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.IntegerDivisionByZeroException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.async.AsyncError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.async.TimeoutException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.convert.JsonUnsupportedObjectError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + default: + Error.throwWithStackTrace( + _$celest.CloudException.http( + code: code, + message: message, + details: ((details ?? body) as _$celest.JsonValue), + ), + StackTrace.empty, + ); + } + } + + @_$celest.CloudFunction(api: 'generic_wrappers', function: 'genericWrappers') + Future genericWrappers(GenericWrappers value) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/generic-wrappers/generic-wrappers'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'value': _$celest.Serializers.instance.serialize( + value, + ), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize($body); + } + + @_$celest.CloudFunction( + api: 'generic_wrappers', + function: 'genericWrappersAsync', + ) + Future genericWrappersAsync(GenericWrappers value) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/generic-wrappers/generic-wrappers-async'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'value': _$celest.Serializers.instance.serialize( + value, + ), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize($body); + } + + @_$celest.CloudFunction( + api: 'generic_wrappers', + function: 'genericWrapperParameters', + ) + Future genericWrapperParameters({ + required _$fast_immutable_collections_ilist.IList listOfString, + required _$fast_immutable_collections_ilist.IList listOfUri, + required _$fast_immutable_collections_ilist.IList + listOfSimpleClass, + required _$fast_immutable_collections_ilist.IList< + _$fast_immutable_collections_ilist.IList + > + listOfListOfString, + required _$fast_immutable_collections_ilist.IList< + _$fast_immutable_collections_ilist.IList + > + listOfListOfUri, + required _$fast_immutable_collections_ilist.IList< + _$fast_immutable_collections_ilist.IList + > + listOfListOfSimpleClass, + required _$fast_immutable_collections_imap.IMap mapOfString, + required _$fast_immutable_collections_imap.IMap mapOfUri, + required _$fast_immutable_collections_imap.IMap + mapOfSimpleClass, + required _$fast_immutable_collections_imap.IMap< + String, + _$fast_immutable_collections_ilist.IList + > + mapOfListOfString, + required _$fast_immutable_collections_imap.IMap< + String, + _$fast_immutable_collections_ilist.IList + > + mapOfListOfUri, + required _$fast_immutable_collections_imap.IMap< + String, + _$fast_immutable_collections_ilist.IList + > + mapOfListOfSimpleClass, + required _$fast_immutable_collections_imap.IMap< + String, + _$fast_immutable_collections_imap.IMap + > + mapOfMapOfString, + required _$fast_immutable_collections_imap.IMap< + String, + _$fast_immutable_collections_imap.IMap + > + mapOfMapOfUri, + required _$fast_immutable_collections_imap.IMap< + String, + _$fast_immutable_collections_imap.IMap + > + mapOfMapOfSimpleClass, + }) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/generic-wrappers/generic-wrapper-parameters'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'listOfString': _$celest.Serializers.instance + .serialize<_$fast_immutable_collections_ilist.IList>( + listOfString, + ), + r'listOfUri': _$celest.Serializers.instance + .serialize<_$fast_immutable_collections_ilist.IList>( + listOfUri, + ), + r'listOfSimpleClass': _$celest.Serializers.instance + .serialize<_$fast_immutable_collections_ilist.IList>( + listOfSimpleClass, + ), + r'listOfListOfString': _$celest.Serializers.instance.serialize< + _$fast_immutable_collections_ilist.IList< + _$fast_immutable_collections_ilist.IList + > + >(listOfListOfString), + r'listOfListOfUri': _$celest.Serializers.instance.serialize< + _$fast_immutable_collections_ilist.IList< + _$fast_immutable_collections_ilist.IList + > + >(listOfListOfUri), + r'listOfListOfSimpleClass': _$celest.Serializers.instance.serialize< + _$fast_immutable_collections_ilist.IList< + _$fast_immutable_collections_ilist.IList + > + >(listOfListOfSimpleClass), + r'mapOfString': _$celest.Serializers.instance + .serialize<_$fast_immutable_collections_imap.IMap>( + mapOfString, + ), + r'mapOfUri': _$celest.Serializers.instance + .serialize<_$fast_immutable_collections_imap.IMap>( + mapOfUri, + ), + r'mapOfSimpleClass': _$celest.Serializers.instance.serialize< + _$fast_immutable_collections_imap.IMap + >(mapOfSimpleClass), + r'mapOfListOfString': _$celest.Serializers.instance.serialize< + _$fast_immutable_collections_imap.IMap< + String, + _$fast_immutable_collections_ilist.IList + > + >(mapOfListOfString), + r'mapOfListOfUri': _$celest.Serializers.instance.serialize< + _$fast_immutable_collections_imap.IMap< + String, + _$fast_immutable_collections_ilist.IList + > + >(mapOfListOfUri), + r'mapOfListOfSimpleClass': _$celest.Serializers.instance.serialize< + _$fast_immutable_collections_imap.IMap< + String, + _$fast_immutable_collections_ilist.IList + > + >(mapOfListOfSimpleClass), + r'mapOfMapOfString': _$celest.Serializers.instance.serialize< + _$fast_immutable_collections_imap.IMap< + String, + _$fast_immutable_collections_imap.IMap + > + >(mapOfMapOfString), + r'mapOfMapOfUri': _$celest.Serializers.instance.serialize< + _$fast_immutable_collections_imap.IMap< + String, + _$fast_immutable_collections_imap.IMap + > + >(mapOfMapOfUri), + r'mapOfMapOfSimpleClass': _$celest.Serializers.instance.serialize< + _$fast_immutable_collections_imap.IMap< + String, + _$fast_immutable_collections_imap.IMap + > + >(mapOfMapOfSimpleClass), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize($body); + } +} + +/// Tests that metadata associated with functions and parameters are correctly +/// parsed and transferred to the generated client. +class CelestFunctionsMetadata { + Never _throwError({int? code, required Map body}) { + final status = body['@status'] as Map?; + final message = status?['message'] as String?; + final details = status?['details'] as _$celest.JsonList?; + final (errorType, errorValue, stackTrace) = switch (details) { + null || [] => const (null, null, StackTrace.empty), + [ + final errorDetails as Map, + { + '@type': 'dart.core.StackTrace', + 'value': final stackTraceValue as String, + }, + ..., + ] => + ( + errorDetails['@type'], + errorDetails['value'], + StackTrace.fromString(stackTraceValue), + ), + [final errorDetails as Map, ...] => ( + errorDetails['@type'], + errorDetails['value'], + StackTrace.empty, + ), + }; + + switch (errorType) { + case 'celest.core.v1.CloudException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.CloudException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.CancelledException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.CancelledException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnknownError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.UnknownError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.BadRequestException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.BadRequestException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnauthorizedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.UnauthorizedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.NotFoundException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.NotFoundException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.AlreadyExistsException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.AlreadyExistsException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.PermissionDeniedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.PermissionDeniedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.ResourceExhaustedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.ResourceExhaustedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.FailedPreconditionException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.FailedPreconditionException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.AbortedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.AbortedException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.OutOfRangeException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.OutOfRangeException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnimplementedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.UnimplementedError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.InternalServerError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.InternalServerError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnavailableError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.UnavailableError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.DataLossError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.DataLossError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.DeadlineExceededError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.DeadlineExceededError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.SerializationException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.SerializationException>(errorValue), + stackTrace, + ); + case 'dart.core.Error': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.AssertionError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.TypeError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.ArgumentError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.RangeError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.IndexError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.UnsupportedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.UnimplementedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.StateError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.ConcurrentModificationError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.core.OutOfMemoryError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.StackOverflowError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.Exception': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.FormatException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.IntegerDivisionByZeroException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.async.AsyncError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.async.TimeoutException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.convert.JsonUnsupportedObjectError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + default: + Error.throwWithStackTrace( + _$celest.CloudException.http( + code: code, + message: message, + details: ((details ?? body) as _$celest.JsonValue), + ), + StackTrace.empty, + ); + } + } + + /// A function that has doc comments. + /// + /// This is a doc comment. + /// + /// # This is an H1 + /// ## This is an H2 + /// ### This is an H3 + /// * This is a list item + /// + /// This is an example: + /// + /// ```dart + /// void hasDocComments() {} + /// ``` + @_$celest.CloudFunction(api: 'metadata', function: 'hasDocComments') + Future hasDocComments() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/metadata/has-doc-comments'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return; + } + + @deprecated + @_$celest.CloudFunction(api: 'metadata', function: 'hasDeprecatedAnnotation') + Future hasDeprecatedAnnotation() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/metadata/has-deprecated-annotation'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return; + } + + @Deprecated('Do not use this function.') + @_$celest.CloudFunction( + api: 'metadata', + function: 'hasConstructedDeprecatedAnnotation', + ) + Future hasConstructedDeprecatedAnnotation() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/metadata/has-constructed-deprecated-annotation'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return; + } + + @MyAnnotation.create('positional', named: 'named') + @_$celest.CloudFunction( + api: 'metadata', + function: 'hasNamedConstructedAnnotation', + ) + Future hasNamedConstructedAnnotation() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/metadata/has-named-constructed-annotation'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return; + } + + @Literals( + string: 'string', + intValue: 1, + doubleValue: 1.0, + boolValue: true, + list: const ['list'], + map: const {'map': 'map'}, + enumValue: LiteralEnum.a, + recordValue: const (a: 'a', b: 'b', c: 'c'), + ) + @_$celest.CloudFunction(api: 'metadata', function: 'hasLiteralsAnnotation') + Future hasLiteralsAnnotation( + @Literals( + string: 'string', + intValue: 1, + doubleValue: 1.0, + boolValue: true, + list: const ['list'], + map: const {'map': 'map'}, + enumValue: LiteralEnum.a, + recordValue: const (a: 'a', b: 'b', c: 'c'), + ) + String value, { + @Literals( + string: 'string', + intValue: 1, + doubleValue: 1.0, + boolValue: true, + list: const ['list'], + map: const {'map': 'map'}, + enumValue: LiteralEnum.a, + recordValue: const (a: 'a', b: 'b', c: 'c'), + ) + required String named, + }) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/metadata/has-literals-annotation'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({r'value': value, r'named': named}), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return; + } + + @exportable + @_$celest.CloudFunction(api: 'metadata', function: 'hasExportableAnnotation') + Future hasExportableAnnotation( + @exportable String value, { + @exportable String named = 'named', + }) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/metadata/has-exportable-annotation'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({r'value': value, r'named': named}), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return; + } + + @Exportable() + @_$celest.CloudFunction( + api: 'metadata', + function: 'hasExportableConstructedAnnotation', + ) + Future hasExportableConstructedAnnotation( + @Exportable() String value, { + @Exportable() String named = 'named', + }) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/metadata/has-exportable-constructed-annotation'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({r'value': value, r'named': named}), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return; + } + + @notExportable + @_$celest.CloudFunction( + api: 'metadata', + function: 'hasNotExportableAnnotation', + ) + Future hasNotExportableAnnotation( + @notExportable String value, { + @notExportable String named = 'named', + }) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/metadata/has-not-exportable-annotation'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({r'value': value, r'named': named}), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return; + } + + @_$celest.CloudFunction(api: 'metadata', function: 'positionalDefaultValues') + Future positionalDefaultValues([ + String value = 'value', + int intValue = 1, + double doubleValue = 1.0, + bool boolValue = true, + List list = const ['list'], + Map map = const {'map': 'map'}, + Exportable exportable = const Exportable(), + Serializable serializable = const Serializable.forType('String'), + LiteralEnum enumValue = LiteralEnum.a, + ({String a, String b, String c}) recordValue = const ( + a: 'a', + b: 'b', + c: 'c', + ), + ]) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/metadata/positional-default-values'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'value': value, + r'intValue': intValue, + r'doubleValue': doubleValue, + r'boolValue': boolValue, + r'list': list, + r'map': map, + r'exportable': _$celest.Serializers.instance.serialize( + exportable, + ), + r'serializable': _$celest.Serializers.instance.serialize( + serializable, + ), + r'enumValue': _$celest.Serializers.instance.serialize( + enumValue, + ), + r'recordValue': _$celest.Serializers.instance + .serialize<({String a, String b, String c})>(recordValue), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return; + } + + @_$celest.CloudFunction( + api: 'metadata', + function: 'nullablePositionalDefaultValues', + ) + Future nullablePositionalDefaultValues([ + String? value = 'value', + int? intValue = 1, + double? doubleValue = 1.0, + bool? boolValue = true, + List? list = const ['list'], + Map? map = const {'map': 'map'}, + Exportable? exportable = const Exportable(), + Serializable? serializable = const Serializable.forType('String'), + LiteralEnum? enumValue = LiteralEnum.a, + ({String a, String b, String c})? recordValue = const ( + a: 'a', + b: 'b', + c: 'c', + ), + ]) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/metadata/nullable-positional-default-values'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'value': value, + r'intValue': intValue, + r'doubleValue': doubleValue, + r'boolValue': boolValue, + r'list': list, + r'map': map, + r'exportable': _$celest.Serializers.instance.serialize( + exportable, + ), + r'serializable': _$celest.Serializers.instance.serialize( + serializable, + ), + r'enumValue': _$celest.Serializers.instance.serialize( + enumValue, + ), + r'recordValue': _$celest.Serializers.instance + .serialize<({String a, String b, String c})?>(recordValue), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return; + } + + @_$celest.CloudFunction(api: 'metadata', function: 'namedDefaultValues') + Future namedDefaultValues({ + String value = 'value', + int intValue = 1, + double doubleValue = 1.0, + bool boolValue = true, + List list = const ['list'], + Map map = const {'map': 'map'}, + Exportable exportable = const Exportable(), + Serializable serializable = const Serializable.forType('String'), + LiteralEnum enumValue = LiteralEnum.a, + ({String a, String b, String c}) recordValue = const ( + a: 'a', + b: 'b', + c: 'c', + ), + }) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/metadata/named-default-values'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'value': value, + r'intValue': intValue, + r'doubleValue': doubleValue, + r'boolValue': boolValue, + r'list': list, + r'map': map, + r'exportable': _$celest.Serializers.instance.serialize( + exportable, + ), + r'serializable': _$celest.Serializers.instance.serialize( + serializable, + ), + r'enumValue': _$celest.Serializers.instance.serialize( + enumValue, + ), + r'recordValue': _$celest.Serializers.instance + .serialize<({String a, String b, String c})>(recordValue), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return; + } + + @_$celest.CloudFunction( + api: 'metadata', + function: 'nullableNamedDefaultValues', + ) + Future nullableNamedDefaultValues({ + String? value = 'value', + int? intValue = 1, + double? doubleValue = 1.0, + bool? boolValue = true, + List? list = const ['list'], + Map? map = const {'map': 'map'}, + Exportable? exportable = const Exportable(), + Serializable? serializable = const Serializable.forType('String'), + LiteralEnum? enumValue = LiteralEnum.a, + ({String a, String b, String c})? recordValue = const ( + a: 'a', + b: 'b', + c: 'c', + ), + }) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/metadata/nullable-named-default-values'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'value': value, + r'intValue': intValue, + r'doubleValue': doubleValue, + r'boolValue': boolValue, + r'list': list, + r'map': map, + r'exportable': _$celest.Serializers.instance.serialize( + exportable, + ), + r'serializable': _$celest.Serializers.instance.serialize( + serializable, + ), + r'enumValue': _$celest.Serializers.instance.serialize( + enumValue, + ), + r'recordValue': _$celest.Serializers.instance + .serialize<({String a, String b, String c})?>(recordValue), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return; + } + + @_$celest.CloudFunction( + api: 'metadata', + function: 'positionalDefaultValueVars', + ) + Future positionalDefaultValueVars([ + int value = defaultInt, + double doubleValue = defaultDouble, + bool boolValue = defaultBool, + String stringValue = defaultString, + List listValue = defaultList, + Map mapValue = defaultMap, + LiteralEnum enumValue = defaultEnum, + ({String a, String b, String c}) recordValue = defaultRecord, + Exportable exportable = defaultExportable, + Serializable serializable = defaultSerializable, + ]) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/metadata/positional-default-value-vars'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'value': value, + r'doubleValue': doubleValue, + r'boolValue': boolValue, + r'stringValue': stringValue, + r'listValue': listValue, + r'mapValue': mapValue, + r'enumValue': _$celest.Serializers.instance.serialize( + enumValue, + ), + r'recordValue': _$celest.Serializers.instance + .serialize<({String a, String b, String c})>(recordValue), + r'exportable': _$celest.Serializers.instance.serialize( + exportable, + ), + r'serializable': _$celest.Serializers.instance.serialize( + serializable, + ), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return; + } + + @_$celest.CloudFunction( + api: 'metadata', + function: 'nullablePositionalDefaultValueVars', + ) + Future nullablePositionalDefaultValueVars([ + int? value = defaultInt, + double? doubleValue = defaultDouble, + bool? boolValue = defaultBool, + String? stringValue = defaultString, + List? listValue = defaultList, + Map? mapValue = defaultMap, + LiteralEnum? enumValue = defaultEnum, + ({String a, String b, String c})? recordValue = defaultRecord, + Exportable? exportable = defaultExportable, + Serializable? serializable = defaultSerializable, + ]) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve( + '/metadata/nullable-positional-default-value-vars', + ), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'value': value, + r'doubleValue': doubleValue, + r'boolValue': boolValue, + r'stringValue': stringValue, + r'listValue': listValue, + r'mapValue': mapValue, + r'enumValue': _$celest.Serializers.instance.serialize( + enumValue, + ), + r'recordValue': _$celest.Serializers.instance + .serialize<({String a, String b, String c})?>(recordValue), + r'exportable': _$celest.Serializers.instance.serialize( + exportable, + ), + r'serializable': _$celest.Serializers.instance.serialize( + serializable, + ), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return; + } + + @_$celest.CloudFunction(api: 'metadata', function: 'namedDefaultValueVars') + Future namedDefaultValueVars({ + int value = defaultInt, + double doubleValue = defaultDouble, + bool boolValue = defaultBool, + String stringValue = defaultString, + List listValue = defaultList, + Map mapValue = defaultMap, + LiteralEnum enumValue = defaultEnum, + ({String a, String b, String c}) recordValue = defaultRecord, + Exportable exportable = defaultExportable, + Serializable serializable = defaultSerializable, + }) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/metadata/named-default-value-vars'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'value': value, + r'doubleValue': doubleValue, + r'boolValue': boolValue, + r'stringValue': stringValue, + r'listValue': listValue, + r'mapValue': mapValue, + r'enumValue': _$celest.Serializers.instance.serialize( + enumValue, + ), + r'recordValue': _$celest.Serializers.instance + .serialize<({String a, String b, String c})>(recordValue), + r'exportable': _$celest.Serializers.instance.serialize( + exportable, + ), + r'serializable': _$celest.Serializers.instance.serialize( + serializable, + ), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return; + } + + @_$celest.CloudFunction( + api: 'metadata', + function: 'nullableNamedDefaultValueVars', + ) + Future nullableNamedDefaultValueVars({ + int? value = defaultInt, + double? doubleValue = defaultDouble, + bool? boolValue = defaultBool, + String? stringValue = defaultString, + List? listValue = defaultList, + Map? mapValue = defaultMap, + LiteralEnum? enumValue = defaultEnum, + ({String a, String b, String c})? recordValue = defaultRecord, + Exportable? exportable = defaultExportable, + Serializable? serializable = defaultSerializable, + }) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/metadata/nullable-named-default-value-vars'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'value': value, + r'doubleValue': doubleValue, + r'boolValue': boolValue, + r'stringValue': stringValue, + r'listValue': listValue, + r'mapValue': mapValue, + r'enumValue': _$celest.Serializers.instance.serialize( + enumValue, + ), + r'recordValue': _$celest.Serializers.instance + .serialize<({String a, String b, String c})?>(recordValue), + r'exportable': _$celest.Serializers.instance.serialize( + exportable, + ), + r'serializable': _$celest.Serializers.instance.serialize( + serializable, + ), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return; + } + + @_$celest.CloudFunction( + api: 'metadata', + function: 'positionalDefaultValueVarsPrivate', + ) + Future positionalDefaultValueVarsPrivate([ + int value = 42, + double doubleValue = 42.0, + bool boolValue = true, + String stringValue = 'default', + List listValue = const ['default'], + Map mapValue = const {'default': 'default'}, + LiteralEnum enumValue = LiteralEnum.a, + ({String a, String b, String c}) recordValue = const ( + a: 'a', + b: 'b', + c: 'c', + ), + Exportable exportable = const Exportable(), + Serializable serializable = const Serializable.forType('String'), + ]) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/metadata/positional-default-value-vars-private'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'value': value, + r'doubleValue': doubleValue, + r'boolValue': boolValue, + r'stringValue': stringValue, + r'listValue': listValue, + r'mapValue': mapValue, + r'enumValue': _$celest.Serializers.instance.serialize( + enumValue, + ), + r'recordValue': _$celest.Serializers.instance + .serialize<({String a, String b, String c})>(recordValue), + r'exportable': _$celest.Serializers.instance.serialize( + exportable, + ), + r'serializable': _$celest.Serializers.instance.serialize( + serializable, + ), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return; + } + + @_$celest.CloudFunction( + api: 'metadata', + function: 'nullablePositionalDefaultValueVarsPrivate', + ) + Future nullablePositionalDefaultValueVarsPrivate([ + int? value = 42, + double? doubleValue = 42.0, + bool? boolValue = true, + String? stringValue = 'default', + List? listValue = const ['default'], + Map? mapValue = const {'default': 'default'}, + LiteralEnum? enumValue = LiteralEnum.a, + ({String a, String b, String c})? recordValue = const ( + a: 'a', + b: 'b', + c: 'c', + ), + Exportable? exportable = const Exportable(), + Serializable? serializable = const Serializable.forType('String'), + ]) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve( + '/metadata/nullable-positional-default-value-vars-private', + ), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'value': value, + r'doubleValue': doubleValue, + r'boolValue': boolValue, + r'stringValue': stringValue, + r'listValue': listValue, + r'mapValue': mapValue, + r'enumValue': _$celest.Serializers.instance.serialize( + enumValue, + ), + r'recordValue': _$celest.Serializers.instance + .serialize<({String a, String b, String c})?>(recordValue), + r'exportable': _$celest.Serializers.instance.serialize( + exportable, + ), + r'serializable': _$celest.Serializers.instance.serialize( + serializable, + ), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return; + } + + @_$celest.CloudFunction( + api: 'metadata', + function: 'namedDefaultValueVarsPrivate', + ) + Future namedDefaultValueVarsPrivate({ + int value = 42, + double doubleValue = 42.0, + bool boolValue = true, + String stringValue = 'default', + List listValue = const ['default'], + Map mapValue = const {'default': 'default'}, + LiteralEnum enumValue = LiteralEnum.a, + ({String a, String b, String c}) recordValue = const ( + a: 'a', + b: 'b', + c: 'c', + ), + Exportable exportable = const Exportable(), + Serializable serializable = const Serializable.forType('String'), + }) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/metadata/named-default-value-vars-private'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'value': value, + r'doubleValue': doubleValue, + r'boolValue': boolValue, + r'stringValue': stringValue, + r'listValue': listValue, + r'mapValue': mapValue, + r'enumValue': _$celest.Serializers.instance.serialize( + enumValue, + ), + r'recordValue': _$celest.Serializers.instance + .serialize<({String a, String b, String c})>(recordValue), + r'exportable': _$celest.Serializers.instance.serialize( + exportable, + ), + r'serializable': _$celest.Serializers.instance.serialize( + serializable, + ), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return; + } + + @_$celest.CloudFunction( + api: 'metadata', + function: 'nullableNamedDefaultValueVarsPrivate', + ) + Future nullableNamedDefaultValueVarsPrivate({ + int? value = 42, + double? doubleValue = 42.0, + bool? boolValue = true, + String? stringValue = 'default', + List? listValue = const ['default'], + Map? mapValue = const {'default': 'default'}, + LiteralEnum? enumValue = LiteralEnum.a, + ({String a, String b, String c})? recordValue = const ( + a: 'a', + b: 'b', + c: 'c', + ), + Exportable? exportable = const Exportable(), + Serializable? serializable = const Serializable.forType('String'), + }) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve( + '/metadata/nullable-named-default-value-vars-private', + ), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'value': value, + r'doubleValue': doubleValue, + r'boolValue': boolValue, + r'stringValue': stringValue, + r'listValue': listValue, + r'mapValue': mapValue, + r'enumValue': _$celest.Serializers.instance.serialize( + enumValue, + ), + r'recordValue': _$celest.Serializers.instance + .serialize<({String a, String b, String c})?>(recordValue), + r'exportable': _$celest.Serializers.instance.serialize( + exportable, + ), + r'serializable': _$celest.Serializers.instance.serialize( + serializable, + ), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return; + } +} + +/// Tests that types can be recursively overriden in the serialization protocol +/// using extension types. +class CelestFunctionsOverrides { + Never _throwError({int? code, required Map body}) { + final status = body['@status'] as Map?; + final message = status?['message'] as String?; + final details = status?['details'] as _$celest.JsonList?; + final (errorType, errorValue, stackTrace) = switch (details) { + null || [] => const (null, null, StackTrace.empty), + [ + final errorDetails as Map, + { + '@type': 'dart.core.StackTrace', + 'value': final stackTraceValue as String, + }, + ..., + ] => + ( + errorDetails['@type'], + errorDetails['value'], + StackTrace.fromString(stackTraceValue), + ), + [final errorDetails as Map, ...] => ( + errorDetails['@type'], + errorDetails['value'], + StackTrace.empty, + ), + }; + + switch (errorType) { + case 'celest.core.v1.CloudException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.CloudException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.CancelledException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.CancelledException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnknownError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.UnknownError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.BadRequestException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.BadRequestException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnauthorizedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.UnauthorizedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.NotFoundException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.NotFoundException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.AlreadyExistsException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.AlreadyExistsException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.PermissionDeniedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.PermissionDeniedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.ResourceExhaustedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.ResourceExhaustedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.FailedPreconditionException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.FailedPreconditionException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.AbortedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.AbortedException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.OutOfRangeException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.OutOfRangeException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnimplementedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.UnimplementedError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.InternalServerError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.InternalServerError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnavailableError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.UnavailableError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.DataLossError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.DataLossError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.DeadlineExceededError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.DeadlineExceededError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.SerializationException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.SerializationException>(errorValue), + stackTrace, + ); + case 'dart.core.Error': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.AssertionError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.TypeError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.ArgumentError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.RangeError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.IndexError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.UnsupportedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.UnimplementedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.StateError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.ConcurrentModificationError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.core.OutOfMemoryError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.StackOverflowError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.Exception': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.FormatException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.IntegerDivisionByZeroException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.async.AsyncError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.async.TimeoutException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.convert.JsonUnsupportedObjectError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case '_common.CustomException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$_common__common.CustomException>(errorValue), + stackTrace, + ); + case '_common.CommonException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$_common__common.CommonException>(errorValue), + stackTrace, + ); + case 'api.v1.OverriddenException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + default: + Error.throwWithStackTrace( + _$celest.CloudException.http( + code: code, + message: message, + details: ((details ?? body) as _$celest.JsonValue), + ), + StackTrace.empty, + ); + } + } + + @_$celest.CloudFunction(api: 'overrides', function: 'commonNestedParent') + Future<_$_common__common.NestedParent> commonNestedParent( + _$_common__common.NestedParent parent, + ) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/overrides/common-nested-parent'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'parent': _$celest.Serializers.instance + .serialize<_$_common__common.NestedParent>(parent), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance + .deserialize<_$_common__common.NestedParent>($body); + } + + @_$celest.CloudFunction(api: 'overrides', function: 'commonNestedChild') + Future<_$_common__common.NestedChild> commonNestedChild( + _$_common__common.NestedChild child, + ) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/overrides/common-nested-child'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'child': _$celest.Serializers.instance + .serialize<_$_common__common.NestedChild>(child), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance + .deserialize<_$_common__common.NestedChild>($body); + } + + @_$celest.CloudFunction(api: 'overrides', function: 'nestedGrandparent') + Future nestedGrandparent( + NestedGrandparent grandparent, + ) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/overrides/nested-grandparent'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'grandparent': _$celest.Serializers.instance + .serialize(grandparent), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize($body); + } + + @_$celest.CloudFunction(api: 'overrides', function: 'nestedParent') + Future nestedParent(NestedParent parent) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/overrides/nested-parent'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'parent': _$celest.Serializers.instance.serialize( + parent, + ), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize($body); + } + + @_$celest.CloudFunction(api: 'overrides', function: 'nestedChild') + Future nestedChild(NestedChild child) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/overrides/nested-child'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'child': _$celest.Serializers.instance.serialize(child), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize($body); + } + + @_$celest.CloudFunction( + api: 'overrides', + function: 'callsThrowsCommonOverriddenException', + ) + Future callsThrowsCommonOverriddenException() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve( + '/overrides/calls-throws-common-overridden-exception', + ), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return; + } + + @_$celest.CloudFunction( + api: 'overrides', + function: 'throwsCommonOverriddenException', + ) + Future throwsCommonOverriddenException() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/overrides/throws-common-overridden-exception'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return; + } + + @_$celest.CloudFunction( + api: 'overrides', + function: 'throwsOverriddenException', + ) + Future throwsOverriddenException() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/overrides/throws-overridden-exception'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return; + } + + @_$celest.CloudFunction( + api: 'overrides', + function: 'callsThrowsOverriddenException', + ) + Future callsThrowsOverriddenException() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/overrides/calls-throws-overridden-exception'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return; + } +} + +class CelestFunctionsParameterTypes { + Never _throwError({int? code, required Map body}) { + final status = body['@status'] as Map?; + final message = status?['message'] as String?; + final details = status?['details'] as _$celest.JsonList?; + final (errorType, errorValue, stackTrace) = switch (details) { + null || [] => const (null, null, StackTrace.empty), + [ + final errorDetails as Map, + { + '@type': 'dart.core.StackTrace', + 'value': final stackTraceValue as String, + }, + ..., + ] => + ( + errorDetails['@type'], + errorDetails['value'], + StackTrace.fromString(stackTraceValue), + ), + [final errorDetails as Map, ...] => ( + errorDetails['@type'], + errorDetails['value'], + StackTrace.empty, + ), + }; + + switch (errorType) { + case 'celest.core.v1.CloudException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.CloudException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.CancelledException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.CancelledException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnknownError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.UnknownError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.BadRequestException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.BadRequestException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnauthorizedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.UnauthorizedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.NotFoundException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.NotFoundException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.AlreadyExistsException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.AlreadyExistsException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.PermissionDeniedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.PermissionDeniedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.ResourceExhaustedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.ResourceExhaustedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.FailedPreconditionException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.FailedPreconditionException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.AbortedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.AbortedException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.OutOfRangeException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.OutOfRangeException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnimplementedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.UnimplementedError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.InternalServerError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.InternalServerError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnavailableError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.UnavailableError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.DataLossError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.DataLossError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.DeadlineExceededError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.DeadlineExceededError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.SerializationException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.SerializationException>(errorValue), + stackTrace, + ); + case 'dart.core.Error': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.AssertionError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.TypeError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.ArgumentError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.RangeError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.IndexError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.UnsupportedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.UnimplementedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.StateError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.ConcurrentModificationError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.core.OutOfMemoryError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.StackOverflowError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.Exception': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.FormatException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.IntegerDivisionByZeroException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.async.AsyncError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.async.TimeoutException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.convert.JsonUnsupportedObjectError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + default: + Error.throwWithStackTrace( + _$celest.CloudException.http( + code: code, + message: message, + details: ((details ?? body) as _$celest.JsonValue), + ), + StackTrace.empty, + ); + } + } + + @_$celest.CloudFunction(api: 'parameter_types', function: 'simple') + Future simple( + String aString, + int anInt, + double aDouble, + bool aBool, + MyEnum anEnum, + Null aNull, + BigInt aBigInt, + DateTime aDateTime, + Duration aDuration, + RegExp aRegExp, + StackTrace aStackTrace, + Uri aUri, + UriData aUriData, + Uint8List aUint8List, + Iterable anIterableOfString, + Iterable anIterableOfUint8List, + List aListOfString, + List aListOfInt, + List aListOfDouble, + List aListOfBool, + List aListOfEnum, + List aListOfNull, + List aListOfBigInt, + List aListOfDateTime, + List aListOfDuration, + List aListOfRegExp, + List aListOfStackTrace, + List aListOfUri, + List aListOfUriData, + List aListOfUint8List, + Map aMapOfString, + Map aMapOfInt, + Map aMapOfDouble, + Map aMapOfBool, + Map aMapOfEnum, + Map aMapOfNull, + Map aMapOfBigInt, + Map aMapOfDateTime, + Map aMapOfDuration, + Map aMapOfRegExp, + Map aMapOfStackTrace, + Map aMapOfUri, + Map aMapOfUriData, + Map aMapOfUint8List, + ) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/parameter-types/simple'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'aString': aString, + r'anInt': anInt, + r'aDouble': aDouble, + r'aBool': aBool, + r'anEnum': _$celest.Serializers.instance.serialize(anEnum), + r'aNull': aNull, + r'aBigInt': _$celest.Serializers.instance.serialize(aBigInt), + r'aDateTime': _$celest.Serializers.instance.serialize( + aDateTime, + ), + r'aDuration': _$celest.Serializers.instance.serialize( + aDuration, + ), + r'aRegExp': _$celest.Serializers.instance.serialize(aRegExp), + r'aStackTrace': _$celest.Serializers.instance.serialize( + aStackTrace, + ), + r'aUri': _$celest.Serializers.instance.serialize(aUri), + r'aUriData': _$celest.Serializers.instance.serialize(aUriData), + r'aUint8List': _$celest.Serializers.instance.serialize( + aUint8List, + ), + r'anIterableOfString': anIterableOfString, + r'anIterableOfUint8List': + anIterableOfUint8List + .map( + (el) => + _$celest.Serializers.instance.serialize(el), + ) + .toList(), + r'aListOfString': aListOfString, + r'aListOfInt': aListOfInt, + r'aListOfDouble': aListOfDouble, + r'aListOfBool': aListOfBool, + r'aListOfEnum': + aListOfEnum + .map( + (el) => _$celest.Serializers.instance.serialize(el), + ) + .toList(), + r'aListOfNull': aListOfNull, + r'aListOfBigInt': + aListOfBigInt + .map( + (el) => _$celest.Serializers.instance.serialize(el), + ) + .toList(), + r'aListOfDateTime': + aListOfDateTime + .map( + (el) => _$celest.Serializers.instance.serialize(el), + ) + .toList(), + r'aListOfDuration': + aListOfDuration + .map( + (el) => _$celest.Serializers.instance.serialize(el), + ) + .toList(), + r'aListOfRegExp': + aListOfRegExp + .map( + (el) => _$celest.Serializers.instance.serialize(el), + ) + .toList(), + r'aListOfStackTrace': + aListOfStackTrace + .map( + (el) => + _$celest.Serializers.instance.serialize(el), + ) + .toList(), + r'aListOfUri': + aListOfUri + .map((el) => _$celest.Serializers.instance.serialize(el)) + .toList(), + r'aListOfUriData': + aListOfUriData + .map( + (el) => _$celest.Serializers.instance.serialize(el), + ) + .toList(), + r'aListOfUint8List': + aListOfUint8List + .map( + (el) => + _$celest.Serializers.instance.serialize(el), + ) + .toList(), + r'aMapOfString': aMapOfString, + r'aMapOfInt': aMapOfInt, + r'aMapOfDouble': aMapOfDouble, + r'aMapOfBool': aMapOfBool, + r'aMapOfEnum': aMapOfEnum.map( + (key, value) => MapEntry( + key, + _$celest.Serializers.instance.serialize(value), + ), + ), + r'aMapOfNull': aMapOfNull, + r'aMapOfBigInt': aMapOfBigInt.map( + (key, value) => MapEntry( + key, + _$celest.Serializers.instance.serialize(value), + ), + ), + r'aMapOfDateTime': aMapOfDateTime.map( + (key, value) => MapEntry( + key, + _$celest.Serializers.instance.serialize(value), + ), + ), + r'aMapOfDuration': aMapOfDuration.map( + (key, value) => MapEntry( + key, + _$celest.Serializers.instance.serialize(value), + ), + ), + r'aMapOfRegExp': aMapOfRegExp.map( + (key, value) => MapEntry( + key, + _$celest.Serializers.instance.serialize(value), + ), + ), + r'aMapOfStackTrace': aMapOfStackTrace.map( + (key, value) => MapEntry( + key, + _$celest.Serializers.instance.serialize(value), + ), + ), + r'aMapOfUri': aMapOfUri.map( + (key, value) => MapEntry( + key, + _$celest.Serializers.instance.serialize(value), + ), + ), + r'aMapOfUriData': aMapOfUriData.map( + (key, value) => MapEntry( + key, + _$celest.Serializers.instance.serialize(value), + ), + ), + r'aMapOfUint8List': aMapOfUint8List.map( + (key, value) => MapEntry( + key, + _$celest.Serializers.instance.serialize(value), + ), + ), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return; + } + + @_$celest.CloudFunction(api: 'parameter_types', function: 'simpleOptional') + Future simpleOptional( + String? aString, + int? anInt, + double? aDouble, + bool? aBool, + MyEnum? anEnum, + Null aNull, + BigInt? aBigInt, + DateTime? aDateTime, + Duration? aDuration, + RegExp? aRegExp, + StackTrace? aStackTrace, + Uri? aUri, + UriData? aUriData, + Uint8List? aUint8List, + Iterable? anIterableOfString, + Iterable? anIterableOfUint8List, + List? aListOfString, + List? aListOfInt, + List? aListOfDouble, + List? aListOfBool, + List? aListOfEnum, + List? aListOfNull, + List? aListOfBigInt, + List? aListOfDateTime, + List? aListOfDuration, + List? aListOfRegExp, + List? aListOfStackTrace, + List? aListOfUri, + List? aListOfUriData, + List? aListOfUint8List, + Map? aMapOfString, + Map? aMapOfInt, + Map? aMapOfDouble, + Map? aMapOfBool, + Map? aMapOfEnum, + Map? aMapOfNull, + Map? aMapOfBigInt, + Map? aMapOfDateTime, + Map? aMapOfDuration, + Map? aMapOfRegExp, + Map? aMapOfStackTrace, + Map? aMapOfUri, + Map? aMapOfUriData, + Map? aMapOfUint8List, + ) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/parameter-types/simple-optional'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'aString': aString, + r'anInt': anInt, + r'aDouble': aDouble, + r'aBool': aBool, + r'anEnum': _$celest.Serializers.instance.serialize(anEnum), + r'aNull': aNull, + r'aBigInt': _$celest.Serializers.instance.serialize(aBigInt), + r'aDateTime': _$celest.Serializers.instance.serialize( + aDateTime, + ), + r'aDuration': _$celest.Serializers.instance.serialize( + aDuration, + ), + r'aRegExp': _$celest.Serializers.instance.serialize(aRegExp), + r'aStackTrace': _$celest.Serializers.instance.serialize( + aStackTrace, + ), + r'aUri': _$celest.Serializers.instance.serialize(aUri), + r'aUriData': _$celest.Serializers.instance.serialize( + aUriData, + ), + r'aUint8List': _$celest.Serializers.instance.serialize( + aUint8List, + ), + r'anIterableOfString': anIterableOfString, + r'anIterableOfUint8List': + anIterableOfUint8List + ?.map( + (el) => + _$celest.Serializers.instance.serialize(el), + ) + .toList(), + r'aListOfString': aListOfString, + r'aListOfInt': aListOfInt, + r'aListOfDouble': aListOfDouble, + r'aListOfBool': aListOfBool, + r'aListOfEnum': + aListOfEnum + ?.map( + (el) => _$celest.Serializers.instance.serialize(el), + ) + .toList(), + r'aListOfNull': aListOfNull, + r'aListOfBigInt': + aListOfBigInt + ?.map( + (el) => _$celest.Serializers.instance.serialize(el), + ) + .toList(), + r'aListOfDateTime': + aListOfDateTime + ?.map( + (el) => _$celest.Serializers.instance.serialize(el), + ) + .toList(), + r'aListOfDuration': + aListOfDuration + ?.map( + (el) => _$celest.Serializers.instance.serialize(el), + ) + .toList(), + r'aListOfRegExp': + aListOfRegExp + ?.map( + (el) => _$celest.Serializers.instance.serialize(el), + ) + .toList(), + r'aListOfStackTrace': + aListOfStackTrace + ?.map( + (el) => + _$celest.Serializers.instance.serialize(el), + ) + .toList(), + r'aListOfUri': + aListOfUri + ?.map((el) => _$celest.Serializers.instance.serialize(el)) + .toList(), + r'aListOfUriData': + aListOfUriData + ?.map( + (el) => _$celest.Serializers.instance.serialize(el), + ) + .toList(), + r'aListOfUint8List': + aListOfUint8List + ?.map( + (el) => + _$celest.Serializers.instance.serialize(el), + ) + .toList(), + r'aMapOfString': aMapOfString, + r'aMapOfInt': aMapOfInt, + r'aMapOfDouble': aMapOfDouble, + r'aMapOfBool': aMapOfBool, + r'aMapOfEnum': aMapOfEnum?.map( + (key, value) => MapEntry( + key, + _$celest.Serializers.instance.serialize(value), + ), + ), + r'aMapOfNull': aMapOfNull, + r'aMapOfBigInt': aMapOfBigInt?.map( + (key, value) => MapEntry( + key, + _$celest.Serializers.instance.serialize(value), + ), + ), + r'aMapOfDateTime': aMapOfDateTime?.map( + (key, value) => MapEntry( + key, + _$celest.Serializers.instance.serialize(value), + ), + ), + r'aMapOfDuration': aMapOfDuration?.map( + (key, value) => MapEntry( + key, + _$celest.Serializers.instance.serialize(value), + ), + ), + r'aMapOfRegExp': aMapOfRegExp?.map( + (key, value) => MapEntry( + key, + _$celest.Serializers.instance.serialize(value), + ), + ), + r'aMapOfStackTrace': aMapOfStackTrace?.map( + (key, value) => MapEntry( + key, + _$celest.Serializers.instance.serialize(value), + ), + ), + r'aMapOfUri': aMapOfUri?.map( + (key, value) => MapEntry( + key, + _$celest.Serializers.instance.serialize(value), + ), + ), + r'aMapOfUriData': aMapOfUriData?.map( + (key, value) => MapEntry( + key, + _$celest.Serializers.instance.serialize(value), + ), + ), + r'aMapOfUint8List': aMapOfUint8List?.map( + (key, value) => MapEntry( + key, + _$celest.Serializers.instance.serialize(value), + ), + ), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return; + } + + @_$celest.CloudFunction(api: 'parameter_types', function: 'complex') + Future complex( + SimpleStruct aSimpleStruct, + ComplexStruct aComplexStruct, + SimpleClass aSimpleClass, + ComplexClass aComplexClass, + SimpleStruct? aNullableSimpleStruct, + ComplexStruct? aNullableComplexStruct, + SimpleClass? aNullableSimpleClass, + ComplexClass? aNullableComplexClass, + Iterable anIterableOfSimpleStruct, + Iterable anIterableOfComplexStruct, + Iterable anIterableOfSimpleClass, + Iterable anIterableOfComplexClass, + Iterable? aNullableIterableOfSimpleStruct, + Iterable? aNullableIterableOfComplexStruct, + Iterable? aNullableIterableOfSimpleClass, + Iterable? aNullableIterableOfComplexClass, + Iterable anIterableOfNullableSimpleStruct, + Iterable anIterableOfNullableComplexStruct, + Iterable anIterableOfNullableSimpleClass, + Iterable anIterableOfNullableComplexClass, + List aListOfSimpleStruct, + List aListOfComplexStruct, + List aListOfSimpleClass, + List aListOfComplexClass, + List? aNullableListOfSimpleStruct, + List? aNullableListOfComplexStruct, + List? aNullableListOfSimpleClass, + List? aNullableListOfComplexClass, + List aListOfNullableSimpleStruct, + List aListOfNullableComplexStruct, + List aListOfNullableSimpleClass, + List aListOfNullableComplexClass, + Map aMapOfSimpleStruct, + Map aMapOfComplexStruct, + Map aMapOfSimpleClass, + Map aMapOfComplexClass, + Map? aNullableMapOfSimpleStruct, + Map? aNullableMapOfComplexStruct, + Map? aNullableMapOfSimpleClass, + Map? aNullableMapOfComplexClass, + Map aMapOfNullableSimpleStruct, + Map aMapOfNullableComplexStruct, + Map aMapOfNullableSimpleClass, + Map aMapOfNullableComplexClass, + Map? aNullableMapOfNullableSimpleStruct, + Map? aNullableMapOfNullableComplexStruct, + Map? aNullableMapOfNullableSimpleClass, + Map? aNullableMapOfNullableComplexClass, + ) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/parameter-types/complex'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'aSimpleStruct': _$celest.Serializers.instance.serialize( + aSimpleStruct, + ), + r'aComplexStruct': _$celest.Serializers.instance + .serialize(aComplexStruct), + r'aSimpleClass': _$celest.Serializers.instance.serialize( + aSimpleClass, + ), + r'aComplexClass': _$celest.Serializers.instance.serialize( + aComplexClass, + ), + r'aNullableSimpleStruct': _$celest.Serializers.instance + .serialize(aNullableSimpleStruct), + r'aNullableComplexStruct': _$celest.Serializers.instance + .serialize(aNullableComplexStruct), + r'aNullableSimpleClass': _$celest.Serializers.instance + .serialize(aNullableSimpleClass), + r'aNullableComplexClass': _$celest.Serializers.instance + .serialize(aNullableComplexClass), + r'anIterableOfSimpleStruct': + anIterableOfSimpleStruct + .map( + (el) => + _$celest.Serializers.instance.serialize(el), + ) + .toList(), + r'anIterableOfComplexStruct': + anIterableOfComplexStruct + .map( + (el) => _$celest.Serializers.instance + .serialize(el), + ) + .toList(), + r'anIterableOfSimpleClass': + anIterableOfSimpleClass + .map( + (el) => + _$celest.Serializers.instance.serialize(el), + ) + .toList(), + r'anIterableOfComplexClass': + anIterableOfComplexClass + .map( + (el) => + _$celest.Serializers.instance.serialize(el), + ) + .toList(), + r'aNullableIterableOfSimpleStruct': + aNullableIterableOfSimpleStruct + ?.map( + (el) => + _$celest.Serializers.instance.serialize(el), + ) + .toList(), + r'aNullableIterableOfComplexStruct': + aNullableIterableOfComplexStruct + ?.map( + (el) => _$celest.Serializers.instance + .serialize(el), + ) + .toList(), + r'aNullableIterableOfSimpleClass': + aNullableIterableOfSimpleClass + ?.map( + (el) => + _$celest.Serializers.instance.serialize(el), + ) + .toList(), + r'aNullableIterableOfComplexClass': + aNullableIterableOfComplexClass + ?.map( + (el) => + _$celest.Serializers.instance.serialize(el), + ) + .toList(), + r'anIterableOfNullableSimpleStruct': + anIterableOfNullableSimpleStruct + .map( + (el) => _$celest.Serializers.instance + .serialize(el), + ) + .toList(), + r'anIterableOfNullableComplexStruct': + anIterableOfNullableComplexStruct + .map( + (el) => _$celest.Serializers.instance + .serialize(el), + ) + .toList(), + r'anIterableOfNullableSimpleClass': + anIterableOfNullableSimpleClass + .map( + (el) => + _$celest.Serializers.instance.serialize(el), + ) + .toList(), + r'anIterableOfNullableComplexClass': + anIterableOfNullableComplexClass + .map( + (el) => _$celest.Serializers.instance + .serialize(el), + ) + .toList(), + r'aListOfSimpleStruct': + aListOfSimpleStruct + .map( + (el) => + _$celest.Serializers.instance.serialize(el), + ) + .toList(), + r'aListOfComplexStruct': + aListOfComplexStruct + .map( + (el) => _$celest.Serializers.instance + .serialize(el), + ) + .toList(), + r'aListOfSimpleClass': + aListOfSimpleClass + .map( + (el) => + _$celest.Serializers.instance.serialize(el), + ) + .toList(), + r'aListOfComplexClass': + aListOfComplexClass + .map( + (el) => + _$celest.Serializers.instance.serialize(el), + ) + .toList(), + r'aNullableListOfSimpleStruct': + aNullableListOfSimpleStruct + ?.map( + (el) => + _$celest.Serializers.instance.serialize(el), + ) + .toList(), + r'aNullableListOfComplexStruct': + aNullableListOfComplexStruct + ?.map( + (el) => _$celest.Serializers.instance + .serialize(el), + ) + .toList(), + r'aNullableListOfSimpleClass': + aNullableListOfSimpleClass + ?.map( + (el) => + _$celest.Serializers.instance.serialize(el), + ) + .toList(), + r'aNullableListOfComplexClass': + aNullableListOfComplexClass + ?.map( + (el) => + _$celest.Serializers.instance.serialize(el), + ) + .toList(), + r'aListOfNullableSimpleStruct': + aListOfNullableSimpleStruct + .map( + (el) => _$celest.Serializers.instance + .serialize(el), + ) + .toList(), + r'aListOfNullableComplexStruct': + aListOfNullableComplexStruct + .map( + (el) => _$celest.Serializers.instance + .serialize(el), + ) + .toList(), + r'aListOfNullableSimpleClass': + aListOfNullableSimpleClass + .map( + (el) => + _$celest.Serializers.instance.serialize(el), + ) + .toList(), + r'aListOfNullableComplexClass': + aListOfNullableComplexClass + .map( + (el) => _$celest.Serializers.instance + .serialize(el), + ) + .toList(), + r'aMapOfSimpleStruct': aMapOfSimpleStruct.map( + (key, value) => MapEntry( + key, + _$celest.Serializers.instance.serialize(value), + ), + ), + r'aMapOfComplexStruct': aMapOfComplexStruct.map( + (key, value) => MapEntry( + key, + _$celest.Serializers.instance.serialize(value), + ), + ), + r'aMapOfSimpleClass': aMapOfSimpleClass.map( + (key, value) => MapEntry( + key, + _$celest.Serializers.instance.serialize(value), + ), + ), + r'aMapOfComplexClass': aMapOfComplexClass.map( + (key, value) => MapEntry( + key, + _$celest.Serializers.instance.serialize(value), + ), + ), + r'aNullableMapOfSimpleStruct': aNullableMapOfSimpleStruct?.map( + (key, value) => MapEntry( + key, + _$celest.Serializers.instance.serialize(value), + ), + ), + r'aNullableMapOfComplexStruct': aNullableMapOfComplexStruct?.map( + (key, value) => MapEntry( + key, + _$celest.Serializers.instance.serialize(value), + ), + ), + r'aNullableMapOfSimpleClass': aNullableMapOfSimpleClass?.map( + (key, value) => MapEntry( + key, + _$celest.Serializers.instance.serialize(value), + ), + ), + r'aNullableMapOfComplexClass': aNullableMapOfComplexClass?.map( + (key, value) => MapEntry( + key, + _$celest.Serializers.instance.serialize(value), + ), + ), + r'aMapOfNullableSimpleStruct': aMapOfNullableSimpleStruct.map( + (key, value) => MapEntry( + key, + _$celest.Serializers.instance.serialize(value), + ), + ), + r'aMapOfNullableComplexStruct': aMapOfNullableComplexStruct.map( + (key, value) => MapEntry( + key, + _$celest.Serializers.instance.serialize(value), + ), + ), + r'aMapOfNullableSimpleClass': aMapOfNullableSimpleClass.map( + (key, value) => MapEntry( + key, + _$celest.Serializers.instance.serialize(value), + ), + ), + r'aMapOfNullableComplexClass': aMapOfNullableComplexClass.map( + (key, value) => MapEntry( + key, + _$celest.Serializers.instance.serialize(value), + ), + ), + r'aNullableMapOfNullableSimpleStruct': + aNullableMapOfNullableSimpleStruct?.map( + (key, value) => MapEntry( + key, + _$celest.Serializers.instance.serialize(value), + ), + ), + r'aNullableMapOfNullableComplexStruct': + aNullableMapOfNullableComplexStruct?.map( + (key, value) => MapEntry( + key, + _$celest.Serializers.instance.serialize(value), + ), + ), + r'aNullableMapOfNullableSimpleClass': aNullableMapOfNullableSimpleClass + ?.map( + (key, value) => MapEntry( + key, + _$celest.Serializers.instance.serialize(value), + ), + ), + r'aNullableMapOfNullableComplexClass': + aNullableMapOfNullableComplexClass?.map( + (key, value) => MapEntry( + key, + _$celest.Serializers.instance.serialize(value), + ), + ), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return; + } +} + +class CelestFunctionsParameters { + Never _throwError({int? code, required Map body}) { + final status = body['@status'] as Map?; + final message = status?['message'] as String?; + final details = status?['details'] as _$celest.JsonList?; + final (errorType, errorValue, stackTrace) = switch (details) { + null || [] => const (null, null, StackTrace.empty), + [ + final errorDetails as Map, + { + '@type': 'dart.core.StackTrace', + 'value': final stackTraceValue as String, + }, + ..., + ] => + ( + errorDetails['@type'], + errorDetails['value'], + StackTrace.fromString(stackTraceValue), + ), + [final errorDetails as Map, ...] => ( + errorDetails['@type'], + errorDetails['value'], + StackTrace.empty, + ), + }; + + switch (errorType) { + case 'celest.core.v1.CloudException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.CloudException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.CancelledException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.CancelledException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnknownError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.UnknownError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.BadRequestException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.BadRequestException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnauthorizedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.UnauthorizedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.NotFoundException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.NotFoundException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.AlreadyExistsException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.AlreadyExistsException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.PermissionDeniedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.PermissionDeniedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.ResourceExhaustedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.ResourceExhaustedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.FailedPreconditionException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.FailedPreconditionException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.AbortedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.AbortedException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.OutOfRangeException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.OutOfRangeException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnimplementedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.UnimplementedError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.InternalServerError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.InternalServerError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnavailableError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.UnavailableError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.DataLossError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.DataLossError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.DeadlineExceededError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.DeadlineExceededError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.SerializationException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.SerializationException>(errorValue), + stackTrace, + ); + case 'dart.core.Error': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.AssertionError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.TypeError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.ArgumentError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.RangeError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.IndexError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.UnsupportedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.UnimplementedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.StateError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.ConcurrentModificationError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.core.OutOfMemoryError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.StackOverflowError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.Exception': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.FormatException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.IntegerDivisionByZeroException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.async.AsyncError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.async.TimeoutException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.convert.JsonUnsupportedObjectError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + default: + Error.throwWithStackTrace( + _$celest.CloudException.http( + code: code, + message: message, + details: ((details ?? body) as _$celest.JsonValue), + ), + StackTrace.empty, + ); + } + } + + @_$celest.CloudFunction(api: 'parameters', function: 'optionalPositional') + Future optionalPositional([ + String? optionalString, + int? optionalInt, + ]) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/parameters/optional-positional'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'optionalString': optionalString, + r'optionalInt': optionalInt, + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return; + } + + @_$celest.CloudFunction(api: 'parameters', function: 'optionalNamed') + Future optionalNamed({String? namedString, int? namedInt}) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/parameters/optional-named'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'namedString': namedString, + r'namedInt': namedInt, + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return; + } + + @_$celest.CloudFunction(api: 'parameters', function: 'requiredPositional') + Future requiredPositional( + String requiredString, + int requiredInt, + ) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/parameters/required-positional'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'requiredString': requiredString, + r'requiredInt': requiredInt, + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return; + } + + @_$celest.CloudFunction(api: 'parameters', function: 'requiredNamed') + Future requiredNamed({ + required String requiredString, + required int requiredInt, + }) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/parameters/required-named'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'requiredString': requiredString, + r'requiredInt': requiredInt, + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return; + } +} + +/// Tests that records with and without aliases are serializable and +/// deserializable. +class CelestFunctionsRecords { + Never _throwError({int? code, required Map body}) { + final status = body['@status'] as Map?; + final message = status?['message'] as String?; + final details = status?['details'] as _$celest.JsonList?; + final (errorType, errorValue, stackTrace) = switch (details) { + null || [] => const (null, null, StackTrace.empty), + [ + final errorDetails as Map, + { + '@type': 'dart.core.StackTrace', + 'value': final stackTraceValue as String, + }, + ..., + ] => + ( + errorDetails['@type'], + errorDetails['value'], + StackTrace.fromString(stackTraceValue), + ), + [final errorDetails as Map, ...] => ( + errorDetails['@type'], + errorDetails['value'], + StackTrace.empty, + ), + }; + + switch (errorType) { + case 'celest.core.v1.CloudException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.CloudException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.CancelledException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.CancelledException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnknownError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.UnknownError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.BadRequestException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.BadRequestException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnauthorizedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.UnauthorizedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.NotFoundException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.NotFoundException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.AlreadyExistsException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.AlreadyExistsException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.PermissionDeniedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.PermissionDeniedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.ResourceExhaustedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.ResourceExhaustedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.FailedPreconditionException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.FailedPreconditionException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.AbortedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.AbortedException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.OutOfRangeException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.OutOfRangeException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnimplementedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.UnimplementedError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.InternalServerError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.InternalServerError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnavailableError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.UnavailableError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.DataLossError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.DataLossError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.DeadlineExceededError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.DeadlineExceededError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.SerializationException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.SerializationException>(errorValue), + stackTrace, + ); + case 'dart.core.Error': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.AssertionError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.TypeError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.ArgumentError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.RangeError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.IndexError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.UnsupportedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.UnimplementedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.StateError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.ConcurrentModificationError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.core.OutOfMemoryError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.StackOverflowError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.Exception': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.FormatException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.IntegerDivisionByZeroException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.async.AsyncError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.async.TimeoutException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.convert.JsonUnsupportedObjectError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + default: + Error.throwWithStackTrace( + _$celest.CloudException.http( + code: code, + message: message, + details: ((details ?? body) as _$celest.JsonValue), + ), + StackTrace.empty, + ); + } + } + + @_$celest.CloudFunction(api: 'records', function: 'nonAliasedNamedFields') + Future<({String anotherField, String field})> nonAliasedNamedFields({ + required ({String anotherField, String field}) value, + }) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/records/non-aliased-named-fields'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'value': _$celest.Serializers.instance + .serialize<({String anotherField, String field})>(value), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance + .deserialize<({String anotherField, String field})>($body); + } + + @_$celest.CloudFunction( + api: 'records', + function: 'asyncNonAliasedNamedFields', + ) + Future<({String anotherField, String field})> asyncNonAliasedNamedFields({ + required ({String anotherField, String field}) value, + }) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/records/async-non-aliased-named-fields'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'value': _$celest.Serializers.instance + .serialize<({String anotherField, String field})>(value), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance + .deserialize<({String anotherField, String field})>($body); + } + + @_$celest.CloudFunction(api: 'records', function: 'aliasedNamedFields') + Future aliasedNamedFields({ + required NamedFieldsRecord value, + }) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/records/aliased-named-fields'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'value': _$celest.Serializers.instance.serialize( + value, + ), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize($body); + } + + @_$celest.CloudFunction(api: 'records', function: 'asyncAliasedNamedFields') + Future asyncAliasedNamedFields({ + required NamedFieldsRecord value, + }) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/records/async-aliased-named-fields'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'value': _$celest.Serializers.instance.serialize( + value, + ), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize($body); + } + + @_$celest.CloudFunction(api: 'records', function: 'namedFields') + Future< + ({ + NamedFieldsRecord aliased, + ({String anotherField, String field}) nonAliased, + }) + > + namedFields({ + required ({String anotherField, String field}) nonAliased, + required NamedFieldsRecord aliased, + }) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/records/named-fields'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'nonAliased': _$celest.Serializers.instance + .serialize<({String anotherField, String field})>(nonAliased), + r'aliased': _$celest.Serializers.instance.serialize( + aliased, + ), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize< + ({ + NamedFieldsRecord aliased, + ({String anotherField, String field}) nonAliased, + }) + >($body); + } + + @_$celest.CloudFunction(api: 'records', function: 'asyncNamedFields') + Future< + ({ + NamedFieldsRecord aliased, + ({String anotherField, String field}) nonAliased, + }) + > + asyncNamedFields({ + required ({String anotherField, String field}) nonAliased, + required NamedFieldsRecord aliased, + }) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/records/async-named-fields'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'nonAliased': _$celest.Serializers.instance + .serialize<({String anotherField, String field})>(nonAliased), + r'aliased': _$celest.Serializers.instance.serialize( + aliased, + ), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize< + ({ + NamedFieldsRecord aliased, + ({String anotherField, String field}) nonAliased, + }) + >($body); + } + + @_$celest.CloudFunction(api: 'records', function: 'nested') + Future nested(Nested value) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/records/nested'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'value': _$celest.Serializers.instance.serialize(value), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize($body); + } + + @_$celest.CloudFunction(api: 'records', function: 'asyncNested') + Future asyncNested(Nested value) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/records/async-nested'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'value': _$celest.Serializers.instance.serialize(value), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize($body); + } + + @_$celest.CloudFunction(api: 'records', function: 'nullableNested') + Future nullableNested(NullableNested? value) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/records/nullable-nested'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'value': _$celest.Serializers.instance.serialize( + value, + ), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize($body); + } + + @_$celest.CloudFunction(api: 'records', function: 'asyncNullableNested') + Future asyncNullableNested(NullableNested? value) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/records/async-nullable-nested'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'value': _$celest.Serializers.instance.serialize( + value, + ), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize($body); + } +} + +/// Validates all permutations of return types. +class CelestFunctionsReturnTypes { + Never _throwError({int? code, required Map body}) { + final status = body['@status'] as Map?; + final message = status?['message'] as String?; + final details = status?['details'] as _$celest.JsonList?; + final (errorType, errorValue, stackTrace) = switch (details) { + null || [] => const (null, null, StackTrace.empty), + [ + final errorDetails as Map, + { + '@type': 'dart.core.StackTrace', + 'value': final stackTraceValue as String, + }, + ..., + ] => + ( + errorDetails['@type'], + errorDetails['value'], + StackTrace.fromString(stackTraceValue), + ), + [final errorDetails as Map, ...] => ( + errorDetails['@type'], + errorDetails['value'], + StackTrace.empty, + ), + }; + + switch (errorType) { + case 'celest.core.v1.CloudException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.CloudException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.CancelledException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.CancelledException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnknownError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.UnknownError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.BadRequestException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.BadRequestException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnauthorizedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.UnauthorizedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.NotFoundException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.NotFoundException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.AlreadyExistsException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.AlreadyExistsException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.PermissionDeniedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.PermissionDeniedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.ResourceExhaustedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.ResourceExhaustedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.FailedPreconditionException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.FailedPreconditionException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.AbortedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.AbortedException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.OutOfRangeException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.OutOfRangeException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnimplementedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.UnimplementedError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.InternalServerError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.InternalServerError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnavailableError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.UnavailableError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.DataLossError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.DataLossError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.DeadlineExceededError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.DeadlineExceededError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.SerializationException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.SerializationException>(errorValue), + stackTrace, + ); + case 'dart.core.Error': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.AssertionError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.TypeError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.ArgumentError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.RangeError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.IndexError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.UnsupportedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.UnimplementedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.StateError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.ConcurrentModificationError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.core.OutOfMemoryError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.StackOverflowError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.Exception': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.FormatException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.IntegerDivisionByZeroException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.async.AsyncError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.async.TimeoutException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.convert.JsonUnsupportedObjectError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + default: + Error.throwWithStackTrace( + _$celest.CloudException.http( + code: code, + message: message, + details: ((details ?? body) as _$celest.JsonValue), + ), + StackTrace.empty, + ); + } + } + + @_$celest.CloudFunction(api: 'return_types', function: 'asyncVoidReturn') + Future asyncVoidReturn() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/return-types/async-void-return'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return; + } + + @_$celest.CloudFunction(api: 'return_types', function: 'asyncStringReturn') + Future asyncStringReturn() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/return-types/async-string-return'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return ($body as String); + } + + @_$celest.CloudFunction(api: 'return_types', function: 'asyncIntReturn') + Future asyncIntReturn() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/return-types/async-int-return'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return ($body as num).toInt(); + } + + @_$celest.CloudFunction(api: 'return_types', function: 'asyncDoubleReturn') + Future asyncDoubleReturn() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/return-types/async-double-return'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return ($body as num).toDouble(); + } + + @_$celest.CloudFunction(api: 'return_types', function: 'asyncBoolReturn') + Future asyncBoolReturn() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/return-types/async-bool-return'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return ($body as bool); + } + + @_$celest.CloudFunction(api: 'return_types', function: 'asyncIterableReturn') + Future> asyncIterableReturn() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/return-types/async-iterable-return'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return ($body as Iterable).map((el) => (el as String)).toList(); + } + + @_$celest.CloudFunction(api: 'return_types', function: 'asyncListReturn') + Future> asyncListReturn() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/return-types/async-list-return'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return ($body as Iterable).map((el) => (el as String)).toList(); + } + + @_$celest.CloudFunction(api: 'return_types', function: 'asyncMapReturn') + Future> asyncMapReturn() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/return-types/async-map-return'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return ($body as Map).map( + (key, value) => MapEntry(key, (value as String)), + ); + } + + @_$celest.CloudFunction(api: 'return_types', function: 'asyncStructReturn') + Future asyncStructReturn() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/return-types/async-struct-return'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize($body); + } + + @_$celest.CloudFunction( + api: 'return_types', + function: 'asyncStructReturnNullable', + ) + Future asyncStructReturnNullable() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/return-types/async-struct-return-nullable'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize($body); + } + + @_$celest.CloudFunction( + api: 'return_types', + function: 'asyncComplexStructReturn', + ) + Future asyncComplexStructReturn() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/return-types/async-complex-struct-return'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize($body); + } + + @_$celest.CloudFunction( + api: 'return_types', + function: 'asyncComplexStructReturnNullable', + ) + Future asyncComplexStructReturnNullable() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve( + '/return-types/async-complex-struct-return-nullable', + ), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize($body); + } + + @_$celest.CloudFunction( + api: 'return_types', + function: 'asyncComplexClassReturn', + ) + Future asyncComplexClassReturn() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/return-types/async-complex-class-return'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize($body); + } + + @_$celest.CloudFunction( + api: 'return_types', + function: 'asyncClassReturnNullable', + ) + Future asyncClassReturnNullable() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/return-types/async-class-return-nullable'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize($body); + } + + @_$celest.CloudFunction(api: 'return_types', function: 'asyncOrVoidReturn') + Future asyncOrVoidReturn() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/return-types/async-or-void-return'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return; + } + + @_$celest.CloudFunction(api: 'return_types', function: 'asyncOrStringReturn') + Future asyncOrStringReturn() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/return-types/async-or-string-return'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return ($body as String); + } + + @_$celest.CloudFunction(api: 'return_types', function: 'asyncOrIntReturn') + Future asyncOrIntReturn() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/return-types/async-or-int-return'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return ($body as num).toInt(); + } + + @_$celest.CloudFunction(api: 'return_types', function: 'asyncOrDoubleReturn') + Future asyncOrDoubleReturn() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/return-types/async-or-double-return'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return ($body as num).toDouble(); + } + + @_$celest.CloudFunction(api: 'return_types', function: 'asyncOrBoolReturn') + Future asyncOrBoolReturn() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/return-types/async-or-bool-return'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return ($body as bool); + } + + @_$celest.CloudFunction( + api: 'return_types', + function: 'asyncOrIterableReturn', + ) + Future> asyncOrIterableReturn() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/return-types/async-or-iterable-return'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return ($body as Iterable).map((el) => (el as String)).toList(); + } + + @_$celest.CloudFunction(api: 'return_types', function: 'asyncOrListReturn') + Future> asyncOrListReturn() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/return-types/async-or-list-return'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return ($body as Iterable).map((el) => (el as String)).toList(); + } + + @_$celest.CloudFunction(api: 'return_types', function: 'asyncOrMapReturn') + Future> asyncOrMapReturn() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/return-types/async-or-map-return'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return ($body as Map).map( + (key, value) => MapEntry(key, (value as String)), + ); + } + + @_$celest.CloudFunction(api: 'return_types', function: 'asyncOrStructReturn') + Future asyncOrStructReturn() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/return-types/async-or-struct-return'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize($body); + } + + @_$celest.CloudFunction( + api: 'return_types', + function: 'asyncOrComplexStructReturn', + ) + Future asyncOrComplexStructReturn() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/return-types/async-or-complex-struct-return'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize($body); + } + + @_$celest.CloudFunction( + api: 'return_types', + function: 'asyncOrVoidReturnNullable', + ) + Future asyncOrVoidReturnNullable() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/return-types/async-or-void-return-nullable'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return; + } + + @_$celest.CloudFunction( + api: 'return_types', + function: 'asyncOrStringReturnNullable', + ) + Future asyncOrStringReturnNullable() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/return-types/async-or-string-return-nullable'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return ($body as String?); + } + + @_$celest.CloudFunction( + api: 'return_types', + function: 'asyncOrIntReturnNullable', + ) + Future asyncOrIntReturnNullable() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/return-types/async-or-int-return-nullable'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return ($body as num?)?.toInt(); + } + + @_$celest.CloudFunction( + api: 'return_types', + function: 'asyncOrDoubleReturnNullable', + ) + Future asyncOrDoubleReturnNullable() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/return-types/async-or-double-return-nullable'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return ($body as num?)?.toDouble(); + } + + @_$celest.CloudFunction( + api: 'return_types', + function: 'asyncOrBoolReturnNullable', + ) + Future asyncOrBoolReturnNullable() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/return-types/async-or-bool-return-nullable'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return ($body as bool?); + } + + @_$celest.CloudFunction( + api: 'return_types', + function: 'asyncOrIterableReturnNullable', + ) + Future?> asyncOrIterableReturnNullable() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/return-types/async-or-iterable-return-nullable'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return ($body as Iterable?)?.map((el) => (el as String)).toList(); + } + + @_$celest.CloudFunction( + api: 'return_types', + function: 'asyncOrListReturnNullable', + ) + Future?> asyncOrListReturnNullable() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/return-types/async-or-list-return-nullable'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return ($body as Iterable?)?.map((el) => (el as String)).toList(); + } + + @_$celest.CloudFunction( + api: 'return_types', + function: 'asyncOrMapReturnNullable', + ) + Future?> asyncOrMapReturnNullable() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/return-types/async-or-map-return-nullable'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return ($body as Map?)?.map( + (key, value) => MapEntry(key, (value as String)), + ); + } + + @_$celest.CloudFunction( + api: 'return_types', + function: 'asyncOrStructReturnNullable', + ) + Future asyncOrStructReturnNullable() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/return-types/async-or-struct-return-nullable'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize($body); + } + + @_$celest.CloudFunction( + api: 'return_types', + function: 'asyncOrComplexStructReturnNullable', + ) + Future asyncOrComplexStructReturnNullable() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve( + '/return-types/async-or-complex-struct-return-nullable', + ), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize($body); + } + + @_$celest.CloudFunction( + api: 'return_types', + function: 'asyncOrSimpleClassReturnNullable', + ) + Future asyncOrSimpleClassReturnNullable() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve( + '/return-types/async-or-simple-class-return-nullable', + ), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize($body); + } + + @_$celest.CloudFunction( + api: 'return_types', + function: 'asyncOrComplexClassReturnNullable', + ) + Future asyncOrComplexClassReturnNullable() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve( + '/return-types/async-or-complex-class-return-nullable', + ), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize($body); + } + + @_$celest.CloudFunction(api: 'return_types', function: 'voidReturn') + Future voidReturn() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/return-types/void-return'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return; + } + + @_$celest.CloudFunction(api: 'return_types', function: 'stringReturn') + Future stringReturn() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/return-types/string-return'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return ($body as String); + } + + @_$celest.CloudFunction(api: 'return_types', function: 'intReturn') + Future intReturn() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/return-types/int-return'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return ($body as num).toInt(); + } + + @_$celest.CloudFunction(api: 'return_types', function: 'doubleReturn') + Future doubleReturn() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/return-types/double-return'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return ($body as num).toDouble(); + } + + @_$celest.CloudFunction(api: 'return_types', function: 'boolReturn') + Future boolReturn() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/return-types/bool-return'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return ($body as bool); + } + + @_$celest.CloudFunction(api: 'return_types', function: 'iterableReturn') + Future> iterableReturn() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/return-types/iterable-return'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return ($body as Iterable).map((el) => (el as String)).toList(); + } + + @_$celest.CloudFunction(api: 'return_types', function: 'listReturn') + Future> listReturn() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/return-types/list-return'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return ($body as Iterable).map((el) => (el as String)).toList(); + } + + @_$celest.CloudFunction(api: 'return_types', function: 'mapReturn') + Future> mapReturn() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/return-types/map-return'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return ($body as Map).map( + (key, value) => MapEntry(key, (value as String)), + ); + } + + @_$celest.CloudFunction(api: 'return_types', function: 'structReturn') + Future structReturn() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/return-types/struct-return'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize($body); + } + + @_$celest.CloudFunction(api: 'return_types', function: 'complexReturn') + Future complexReturn() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/return-types/complex-return'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize($body); + } + + @_$celest.CloudFunction(api: 'return_types', function: 'simpleClassReturn') + Future simpleClassReturn() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/return-types/simple-class-return'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize($body); + } + + @_$celest.CloudFunction(api: 'return_types', function: 'complexClassReturn') + Future complexClassReturn() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/return-types/complex-class-return'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize($body); + } + + @_$celest.CloudFunction(api: 'return_types', function: 'stringReturnNullable') + Future stringReturnNullable() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/return-types/string-return-nullable'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return ($body as String?); + } + + @_$celest.CloudFunction(api: 'return_types', function: 'intReturnNullable') + Future intReturnNullable() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/return-types/int-return-nullable'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return ($body as num?)?.toInt(); + } + + @_$celest.CloudFunction(api: 'return_types', function: 'doubleReturnNullable') + Future doubleReturnNullable() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/return-types/double-return-nullable'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return ($body as num?)?.toDouble(); + } + + @_$celest.CloudFunction(api: 'return_types', function: 'boolReturnNullable') + Future boolReturnNullable() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/return-types/bool-return-nullable'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return ($body as bool?); + } + + @_$celest.CloudFunction( + api: 'return_types', + function: 'iterableReturnNullable', + ) + Future?> iterableReturnNullable() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/return-types/iterable-return-nullable'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return ($body as Iterable?)?.map((el) => (el as String)).toList(); + } + + @_$celest.CloudFunction(api: 'return_types', function: 'listReturnNullable') + Future?> listReturnNullable() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/return-types/list-return-nullable'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return ($body as Iterable?)?.map((el) => (el as String)).toList(); + } + + @_$celest.CloudFunction(api: 'return_types', function: 'mapReturnNullable') + Future?> mapReturnNullable() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/return-types/map-return-nullable'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return ($body as Map?)?.map( + (key, value) => MapEntry(key, (value as String)), + ); + } + + @_$celest.CloudFunction(api: 'return_types', function: 'structReturnNullable') + Future structReturnNullable() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/return-types/struct-return-nullable'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize($body); + } + + @_$celest.CloudFunction( + api: 'return_types', + function: 'complexReturnNullable', + ) + Future complexReturnNullable() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/return-types/complex-return-nullable'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize($body); + } + + @_$celest.CloudFunction( + api: 'return_types', + function: 'simpleClassReturnNullable', + ) + Future simpleClassReturnNullable() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/return-types/simple-class-return-nullable'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize($body); + } + + @_$celest.CloudFunction( + api: 'return_types', + function: 'complexClassReturnNullable', + ) + Future complexClassReturnNullable() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/return-types/complex-class-return-nullable'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize($body); + } +} + +class CelestFunctionsSealedClasses { + Never _throwError({int? code, required Map body}) { + final status = body['@status'] as Map?; + final message = status?['message'] as String?; + final details = status?['details'] as _$celest.JsonList?; + final (errorType, errorValue, stackTrace) = switch (details) { + null || [] => const (null, null, StackTrace.empty), + [ + final errorDetails as Map, + { + '@type': 'dart.core.StackTrace', + 'value': final stackTraceValue as String, + }, + ..., + ] => + ( + errorDetails['@type'], + errorDetails['value'], + StackTrace.fromString(stackTraceValue), + ), + [final errorDetails as Map, ...] => ( + errorDetails['@type'], + errorDetails['value'], + StackTrace.empty, + ), + }; + + switch (errorType) { + case 'celest.core.v1.CloudException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.CloudException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.CancelledException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.CancelledException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnknownError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.UnknownError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.BadRequestException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.BadRequestException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnauthorizedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.UnauthorizedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.NotFoundException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.NotFoundException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.AlreadyExistsException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.AlreadyExistsException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.PermissionDeniedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.PermissionDeniedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.ResourceExhaustedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.ResourceExhaustedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.FailedPreconditionException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.FailedPreconditionException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.AbortedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.AbortedException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.OutOfRangeException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.OutOfRangeException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnimplementedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.UnimplementedError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.InternalServerError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.InternalServerError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnavailableError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.UnavailableError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.DataLossError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.DataLossError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.DeadlineExceededError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.DeadlineExceededError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.SerializationException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.SerializationException>(errorValue), + stackTrace, + ); + case 'dart.core.Error': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.AssertionError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.TypeError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.ArgumentError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.RangeError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.IndexError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.UnsupportedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.UnimplementedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.StateError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.ConcurrentModificationError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.core.OutOfMemoryError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.StackOverflowError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.Exception': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.FormatException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.IntegerDivisionByZeroException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.async.AsyncError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.async.TimeoutException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.convert.JsonUnsupportedObjectError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'api.v1.CustomException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'api.v1.CustomExceptionToFromJson': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'api.v1.CustomError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'api.v1.CustomErrorToFromJson': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'api.v1.CustomErrorWithStackTrace': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + default: + Error.throwWithStackTrace( + _$celest.CloudException.http( + code: code, + message: message, + details: ((details ?? body) as _$celest.JsonValue), + ), + StackTrace.empty, + ); + } + } + + @_$celest.CloudFunction(api: 'sealed_classes', function: 'area') + Future area(Shape shape) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/sealed-classes/area'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'shape': _$celest.Serializers.instance.serialize(shape), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return ($body as num).toDouble(); + } + + @_$celest.CloudFunction(api: 'sealed_classes', function: 'sealedClass') + Future> sealedClass({required List shapes}) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/sealed-classes/sealed-class'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'shapes': + shapes + .map((el) => _$celest.Serializers.instance.serialize(el)) + .toList(), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return ($body as Iterable) + .map((el) => _$celest.Serializers.instance.deserialize(el)) + .toList(); + } + + @_$celest.CloudFunction(api: 'sealed_classes', function: 'rectangle') + Future rectangle(Rectangle rectangle) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/sealed-classes/rectangle'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'rectangle': _$celest.Serializers.instance.serialize( + rectangle, + ), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize($body); + } + + @_$celest.CloudFunction(api: 'sealed_classes', function: 'circle') + Future circle(Circle circle) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/sealed-classes/circle'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'circle': _$celest.Serializers.instance.serialize(circle), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize($body); + } + + @_$celest.CloudFunction( + api: 'sealed_classes', + function: 'sealedClassWithInheritedCustomJson', + ) + Future> + sealedClassWithInheritedCustomJson({ + required List shapes, + }) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve( + '/sealed-classes/sealed-class-with-inherited-custom-json', + ), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'shapes': + shapes + .map( + (el) => _$celest.Serializers.instance + .serialize(el), + ) + .toList(), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return ($body as Iterable) + .map( + (el) => _$celest.Serializers.instance + .deserialize(el), + ) + .toList(); + } + + @_$celest.CloudFunction( + api: 'sealed_classes', + function: 'sealedClassWithCustomJson', + ) + Future> sealedClassWithCustomJson({ + required List shapes, + }) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/sealed-classes/sealed-class-with-custom-json'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'shapes': + shapes + .map( + (el) => _$celest.Serializers.instance + .serialize(el), + ) + .toList(), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return ($body as Iterable) + .map( + (el) => _$celest.Serializers.instance + .deserialize(el), + ) + .toList(); + } + + @_$celest.CloudFunction( + api: 'sealed_classes', + function: 'sealedClassWithOverriddenCustomJson', + ) + Future> + sealedClassWithOverriddenCustomJson({ + required CircleWithOverriddenCustomJson circle, + required RectangleWithOverriddenCustomJson rectangle, + required List other, + }) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve( + '/sealed-classes/sealed-class-with-overridden-custom-json', + ), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'circle': _$celest.Serializers.instance + .serialize(circle), + r'rectangle': _$celest.Serializers.instance + .serialize(rectangle), + r'other': + other + .map( + (el) => _$celest.Serializers.instance + .serialize(el), + ) + .toList(), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return ($body as Iterable) + .map( + (el) => _$celest.Serializers.instance + .deserialize(el), + ) + .toList(); + } + + @_$celest.CloudFunction( + api: 'sealed_classes', + function: 'rectangleWithOverriddenCustomJson', + ) + Future rectangleWithOverriddenCustomJson( + RectangleWithOverriddenCustomJson rectangle, + ) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve( + '/sealed-classes/rectangle-with-overridden-custom-json', + ), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'rectangle': _$celest.Serializers.instance + .serialize(rectangle), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance + .deserialize($body); + } + + @_$celest.CloudFunction( + api: 'sealed_classes', + function: 'circleWithOverriddenCustomJson', + ) + Future circleWithOverriddenCustomJson( + ShapeWithOverriddenCustomJson circle, + ) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve( + '/sealed-classes/circle-with-overridden-custom-json', + ), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'circle': _$celest.Serializers.instance + .serialize(circle), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance + .deserialize($body); + } + + @_$celest.CloudFunction(api: 'sealed_classes', function: 'okShapeResults') + Future>> okShapeResults(List shapes) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/sealed-classes/ok-shape-results'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'shapes': + shapes + .map((el) => _$celest.Serializers.instance.serialize(el)) + .toList(), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return ($body as Iterable) + .map( + (el) => + _$celest.Serializers.instance.deserialize>(el), + ) + .toList(); + } + + @_$celest.CloudFunction(api: 'sealed_classes', function: 'errShapeResults') + Future>> errShapeResults(List shapes) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/sealed-classes/err-shape-results'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'shapes': + shapes + .map((el) => _$celest.Serializers.instance.serialize(el)) + .toList(), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return ($body as Iterable) + .map( + (el) => + _$celest.Serializers.instance.deserialize>(el), + ) + .toList(); + } + + @_$celest.CloudFunction(api: 'sealed_classes', function: 'shapeResults') + Future>> shapeResults(List shapes) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/sealed-classes/shape-results'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'shapes': + shapes + .map((el) => _$celest.Serializers.instance.serialize(el)) + .toList(), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return ($body as Iterable) + .map( + (el) => _$celest.Serializers.instance + .deserialize>(el), + ) + .toList(); + } + + @_$celest.CloudFunction( + api: 'sealed_classes', + function: 'aliasedOkShapeResults', + ) + Future>> aliasedOkShapeResults( + List shapes, + ) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/sealed-classes/aliased-ok-shape-results'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'shapes': + shapes + .map((el) => _$celest.Serializers.instance.serialize(el)) + .toList(), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return ($body as Iterable) + .map( + (el) => _$celest.Serializers.instance + .deserialize>(el), + ) + .toList(); + } + + @_$celest.CloudFunction( + api: 'sealed_classes', + function: 'aliasedErrShapeResults', + ) + Future>> aliasedErrShapeResults( + List shapes, + ) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/sealed-classes/aliased-err-shape-results'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'shapes': + shapes + .map((el) => _$celest.Serializers.instance.serialize(el)) + .toList(), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return ($body as Iterable) + .map( + (el) => _$celest.Serializers.instance + .deserialize>(el), + ) + .toList(); + } + + @_$celest.CloudFunction( + api: 'sealed_classes', + function: 'aliasedShapeResults', + ) + Future>> aliasedShapeResults( + List shapes, + ) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/sealed-classes/aliased-shape-results'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'shapes': + shapes + .map((el) => _$celest.Serializers.instance.serialize(el)) + .toList(), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return ($body as Iterable) + .map( + (el) => _$celest.Serializers.instance + .deserialize>(el), + ) + .toList(); + } + + @_$celest.CloudFunction(api: 'sealed_classes', function: 'swappedResult') + Future> swappedResult( + Result result, + ) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/sealed-classes/swapped-result'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'result': _$celest.Serializers.instance + .serialize>(result), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance + .deserialize>($body); + } + + @_$celest.CloudFunction(api: 'sealed_classes', function: 'genericResult') + Future> genericResult(T data) async { + const $T = {Shape: r'Shape', Circle: r'Circle', Rectangle: r'Rectangle'}; + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/sealed-classes/generic-result'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'$T': $T[T]!, + r'data': _$celest.Serializers.instance.serialize(data), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize>($body); + } + + @_$celest.CloudFunction( + api: 'sealed_classes', + function: 'multipleGenericResult', + ) + Future>> multipleGenericResult< + T extends Shape, + E extends ShapeException + >(T data, E error) async { + const $T = {Shape: r'Shape', Circle: r'Circle', Rectangle: r'Rectangle'}; + const $E = { + ShapeException: r'ShapeException', + BadShapeException: r'BadShapeException', + }; + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/sealed-classes/multiple-generic-result'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'$T': $T[T]!, + r'$E': $E[E]!, + r'data': _$celest.Serializers.instance.serialize(data), + r'error': _$celest.Serializers.instance.serialize(error), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return ($body as Iterable) + .map( + (el) => _$celest.Serializers.instance.deserialize>(el), + ) + .toList(); + } + + @_$celest.CloudFunction(api: 'sealed_classes', function: 'okShapeResult') + Future okShapeResult(Shape shape) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/sealed-classes/ok-shape-result'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'shape': _$celest.Serializers.instance.serialize(shape), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize($body); + } +} + +/// Checks that typedefs work as expected. +class CelestFunctionsTypedefs { + Never _throwError({int? code, required Map body}) { + final status = body['@status'] as Map?; + final message = status?['message'] as String?; + final details = status?['details'] as _$celest.JsonList?; + final (errorType, errorValue, stackTrace) = switch (details) { + null || [] => const (null, null, StackTrace.empty), + [ + final errorDetails as Map, + { + '@type': 'dart.core.StackTrace', + 'value': final stackTraceValue as String, + }, + ..., + ] => + ( + errorDetails['@type'], + errorDetails['value'], + StackTrace.fromString(stackTraceValue), + ), + [final errorDetails as Map, ...] => ( + errorDetails['@type'], + errorDetails['value'], + StackTrace.empty, + ), + }; + + switch (errorType) { + case 'celest.core.v1.CloudException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.CloudException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.CancelledException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.CancelledException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnknownError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.UnknownError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.BadRequestException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.BadRequestException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnauthorizedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.UnauthorizedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.NotFoundException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.NotFoundException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.AlreadyExistsException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.AlreadyExistsException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.PermissionDeniedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.PermissionDeniedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.ResourceExhaustedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.ResourceExhaustedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.FailedPreconditionException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.FailedPreconditionException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.AbortedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.AbortedException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.OutOfRangeException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.OutOfRangeException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnimplementedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.UnimplementedError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.InternalServerError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.InternalServerError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnavailableError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.UnavailableError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.DataLossError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.DataLossError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.DeadlineExceededError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.DeadlineExceededError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.SerializationException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.SerializationException>(errorValue), + stackTrace, + ); + case 'dart.core.Error': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.AssertionError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.TypeError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.ArgumentError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.RangeError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.IndexError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.UnsupportedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.UnimplementedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.StateError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.ConcurrentModificationError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.core.OutOfMemoryError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.StackOverflowError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.Exception': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.FormatException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.IntegerDivisionByZeroException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.async.AsyncError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.async.TimeoutException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.convert.JsonUnsupportedObjectError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + default: + Error.throwWithStackTrace( + _$celest.CloudException.http( + code: code, + message: message, + details: ((details ?? body) as _$celest.JsonValue), + ), + StackTrace.empty, + ); + } + } + + @_$celest.CloudFunction(api: 'typedefs', function: 'portfolio') + Future portfolio(Portfolio portfolio) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/typedefs/portfolio'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'portfolio': _$celest.Serializers.instance.serialize( + portfolio, + ), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize($body); + } + + @_$celest.CloudFunction(api: 'typedefs', function: 'json') + Future> json(Map json) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/typedefs/json'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({r'json': json}), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return ($body as Map); + } + + @_$celest.CloudFunction(api: 'typedefs', function: 'nullableJson') + Future?> nullableJson(Map? json) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/typedefs/nullable-json'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({r'json': json}), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return ($body as Map?); + } + + @_$celest.CloudFunction(api: 'typedefs', function: 'mixedJson') + Future?> mixedJson(Map json) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/typedefs/mixed-json'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({r'json': json}), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return ($body as Map?); + } +} diff --git a/apps/cli/fixtures/legacy/api/client/lib/src/serializers.dart b/apps/cli/fixtures/legacy/api/client/lib/src/serializers.dart new file mode 100644 index 000000000..5e0d88334 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/client/lib/src/serializers.dart @@ -0,0 +1,4013 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async'; +import 'dart:convert'; +import 'dart:typed_data'; + +import 'package:_common/_common.dart' as _$_common__common; +import 'package:celest_backend/exceptions/demo.dart'; +import 'package:celest_backend/exceptions/exceptions.dart'; +import 'package:celest_backend/exceptions/overrides.dart'; +import 'package:celest_backend/models/classes.dart'; +import 'package:celest_backend/models/cycles.dart'; +import 'package:celest_backend/models/demo.dart'; +import 'package:celest_backend/models/exceptions.dart'; +import 'package:celest_backend/models/extension_types.dart'; +import 'package:celest_backend/models/generic_wrappers.dart'; +import 'package:celest_backend/models/metadata.dart'; +import 'package:celest_backend/models/overrides.dart'; +import 'package:celest_backend/models/parameter_types.dart'; +import 'package:celest_backend/models/records.dart'; +import 'package:celest_backend/models/sealed_classes.dart'; +import 'package:celest_backend/models/typedefs.dart'; +import 'package:celest_core/celest_core.dart' as _$celest; +import 'package:celest_core/src/exception/cloud_exception.dart' as _$celest; +import 'package:celest_core/src/exception/serialization_exception.dart' + as _$celest; +import 'package:celest_core/src/serialization/json_value.dart' as _$celest; +import 'package:fast_immutable_collections/src/ilist/ilist.dart' + as _$fast_immutable_collections_ilist; +import 'package:fast_immutable_collections/src/imap/imap.dart' + as _$fast_immutable_collections_imap; + +void initSerializers({_$celest.Serializers? serializers}) { + return runZoned(() { + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + r'aliased': _$celest.Serializers.instance + .serialize($value.aliased), + r'nonAliased': _$celest.Serializers.instance + .serialize<({String anotherField, String field})>( + $value.nonAliased, + ), + }, + deserialize: ($serialized) { + return ( + aliased: _$celest.Serializers.instance + .deserialize($serialized[r'aliased']), + nonAliased: _$celest.Serializers.instance + .deserialize<({String anotherField, String field})>( + $serialized[r'nonAliased'], + ), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + r'a': $value.a, + r'b': $value.b, + r'c': $value.c, + }, + deserialize: ($serialized) { + return ( + a: ($serialized[r'a'] as String), + b: ($serialized[r'b'] as String), + c: ($serialized[r'c'] as String), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + r'anotherField': $value.anotherField, + r'field': $value.field, + }, + deserialize: ($serialized) { + return ( + anotherField: ($serialized[r'anotherField'] as String), + field: ($serialized[r'field'] as String), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _$celest.Serializers.instance + .serialize($value.stackTrace), + }, + deserialize: ($serialized) { + return AsyncError( + $serialized[r'error']!, + _$celest.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_$celest.Serializers.instance.serialize( + $value.duration, + ) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return TimeoutException( + ($serialized[r'message'] as String?), + _$celest.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest + .Serializer.define>( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + ConcurrentModificationError, + Map? + >( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: + ($value) => { + if (_$celest.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$_common__common.CommonException, + Map + >( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return _$_common__common.CommonException( + ($serialized[r'message'] as String), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$_common__common.CustomException, + Map + >( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return _$_common__common.CustomException( + ($serialized[r'message'] as String), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return BadNameException(($serialized[r'message'] as String)); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + r'shape': _$celest.Serializers.instance.serialize( + $value.shape, + ), + }, + deserialize: ($serialized) { + return BadShapeException( + _$celest.Serializers.instance.deserialize( + $serialized[r'shape'], + ), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'additionalInfo': _$celest.Serializers.instance + .serialize<_$celest.JsonMap>( + $value.additionalInfo, + const _$celest.TypeToken<_$celest.JsonMap>('JsonMap'), + ), + }, + deserialize: ($serialized) { + return CustomError(); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return CustomErrorToFromJson.fromJson($serialized); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest + .Serializer.define?>( + serialize: + ($value) => { + r'stackTrace': _$celest.Serializers.instance + .serialize($value.stackTrace), + r'message': $value.message, + r'additionalInfo': $value.additionalInfo, + }, + deserialize: ($serialized) { + return CustomErrorWithStackTrace( + stackTrace: _$celest.Serializers.instance.deserialize( + $serialized?[r'stackTrace'], + ), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'additionalInfo': _$celest.Serializers.instance + .serialize<_$celest.JsonMap>( + $value.additionalInfo, + const _$celest.TypeToken<_$celest.JsonMap>('JsonMap'), + ), + }, + deserialize: ($serialized) { + return CustomException(); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest + .Serializer.define>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return CustomExceptionToFromJson.fromJson($serialized); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: ($value) { + if ($value is BadShapeException) { + return { + ...(_$celest.Serializers.instance.serialize( + $value, + ) + as Map), + r'$type': r'BadShapeException', + }; + } + throw _$celest.SerializationException( + (StringBuffer('Unknown subtype of ') + ..write(r'ShapeException') + ..write(': ') + ..write($value.runtimeType)) + .toString(), + ); + }, + deserialize: ($serialized) { + if ($serialized[r'$type'] == r'BadShapeException') { + return _$celest.Serializers.instance.deserialize( + $serialized, + ); + } + throw _$celest.SerializationException( + (StringBuffer('Unknown subtype of ') + ..write(r'ShapeException') + ..write(': ') + ..write($serialized[r'$type'])) + .toString(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return (_$_common__common.OverriddenException( + ($serialized[r'message'] as String), + ) + as OverriddenException); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: + ($value) => { + r'field': $value.field, + if ($value.nullableField case final nullableField?) + r'nullableField': nullableField, + if ($value.nullableFieldWithDefault + case final nullableFieldWithDefault?) + r'nullableFieldWithDefault': nullableFieldWithDefault, + r'fieldWithoutInitializer': $value.fieldWithoutInitializer, + }, + deserialize: ($serialized) { + return DefaultValues( + field: (($serialized?[r'field'] as String?)) ?? 'default', + nullableField: ($serialized?[r'nullableField'] as String?), + nullableFieldWithDefault: + (($serialized?[r'nullableFieldWithDefault'] as String?)) ?? + 'default', + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Empty(); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + r'superField': $value.superField, + r'field': $value.field, + }, + deserialize: ($serialized) { + return Fields( + ($serialized[r'superField'] as String), + ($serialized[r'field'] as String), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return FromJsonAndToJson.fromJson($serialized); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return FromJsonStatic.fromJson($serialized); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + r'superField': $value.superField, + r'field': $value.field, + }, + deserialize: ($serialized) { + return MixedFields( + ($serialized[r'superField'] as String), + field: ($serialized[r'field'] as String), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + r'superField': $value.superField, + r'field': $value.field, + }, + deserialize: ($serialized) { + return NamedFields( + superField: ($serialized[r'superField'] as String), + field: ($serialized[r'field'] as String), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + r'fields': _$celest.Serializers.instance.serialize( + $value.fields, + ), + if (_$celest.Serializers.instance.serialize( + $value.nullableFields, + ) + case final nullableFields?) + r'nullableFields': nullableFields, + }, + deserialize: ($serialized) { + return NestedClass( + _$celest.Serializers.instance.deserialize( + $serialized[r'fields'], + ), + _$celest.Serializers.instance.deserialize( + $serialized[r'nullableFields'], + ), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return NonMapFromAndToJson.fromJson($serialized); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return NonMapToJson(($serialized as String)); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return NonMapToJsonWithDefaults( + (($serialized as String?)) ?? 'default', + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: ($value) => {r'field': $value.field}, + deserialize: ($serialized) { + return OnlyFromJson.fromJson($serialized); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return OnlyToJson(($serialized[r'field'] as String)); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return OnlyToJsonWithDefaults( + (($serialized?[r'field'] as String?)) ?? 'default', + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + r'name': $value.name, + r'children': + $value.children + .map( + (el) => + _$celest.Serializers.instance.serialize(el), + ) + .toList(), + }, + deserialize: ($serialized) { + return Child(($serialized[r'name'] as String)); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: ($value) { + if ($value is Parent) { + return { + ...(_$celest.Serializers.instance.serialize($value) + as Map), + r'$type': r'Parent', + }; + } + if ($value is Child) { + return { + ...(_$celest.Serializers.instance.serialize($value) + as Map), + r'$type': r'Child', + }; + } + throw _$celest.SerializationException( + (StringBuffer('Unknown subtype of ') + ..write(r'Node') + ..write(': ') + ..write($value.runtimeType)) + .toString(), + ); + }, + deserialize: ($serialized) { + if ($serialized[r'$type'] == r'Parent') { + return _$celest.Serializers.instance.deserialize( + $serialized, + ); + } + if ($serialized[r'$type'] == r'Child') { + return _$celest.Serializers.instance.deserialize( + $serialized, + ); + } + throw _$celest.SerializationException( + (StringBuffer('Unknown subtype of ') + ..write(r'Node') + ..write(': ') + ..write($serialized[r'$type'])) + .toString(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + r'name': $value.name, + r'children': + $value.children + .map( + (el) => + _$celest.Serializers.instance.serialize(el), + ) + .toList(), + }, + deserialize: ($serialized) { + return Parent( + ($serialized[r'name'] as String), + ($serialized[r'children'] as Iterable) + .map( + (el) => _$celest.Serializers.instance.deserialize(el), + ) + .toList(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + if (_$celest.Serializers.instance.serialize( + $value.value, + ) + case final value?) + r'value': value, + if (_$celest.Serializers.instance + .serialize($value.wrapper) + case final wrapper?) + r'wrapper': wrapper, + r'list': + $value.list + .map( + (el) => _$celest.Serializers.instance + .serialize(el), + ) + .toList(), + }, + deserialize: ($serialized) { + return SelfReferencing( + value: _$celest.Serializers.instance.deserialize( + $serialized[r'value'], + ), + wrapper: _$celest.Serializers.instance + .deserialize($serialized[r'wrapper']), + list: + ($serialized[r'list'] as Iterable) + .map( + (el) => _$celest.Serializers.instance + .deserialize(el), + ) + .toList(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + r'value': _$celest.Serializers.instance + .serialize($value.value), + }, + deserialize: ($serialized) { + return SelfReferencingWrapper( + value: _$celest.Serializers.instance.deserialize( + $serialized[r'value'], + ), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: ($value) => {r'name': $value.name}, + deserialize: ($serialized) { + return Person(name: ($serialized[r'name'] as String)); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define( + serialize: ($value) => $value.name, + deserialize: ($serialized) { + return SupportedErrorType.values.byName($serialized); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define( + serialize: ($value) => $value.name, + deserialize: ($serialized) { + return SupportedExceptionType.values.byName($serialized); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return Color.fromJson($serialized); + }, + ), + ); + _$celest.Serializers.instance.put( + ColorXSerializer(), + const _$celest.TypeToken('ColorX'), + ); + _$celest.Serializers.instance.put( + ColorXFromJsonSerializer(), + const _$celest.TypeToken('ColorXFromJson'), + ); + _$celest.Serializers.instance.put( + ColorXFromJsonImplSerializer(), + const _$celest.TypeToken('ColorXFromJsonImpl'), + ); + _$celest.Serializers.instance.put( + ColorXFromJsonStaticSerializer(), + const _$celest.TypeToken('ColorXFromJsonStatic'), + ); + _$celest.Serializers.instance.put( + ColorXImplSerializer(), + const _$celest.TypeToken('ColorXImpl'), + ); + _$celest.Serializers.instance.put( + ColorXToFromJsonSerializer(), + const _$celest.TypeToken('ColorXToFromJson'), + ); + _$celest.Serializers.instance.put( + ColorXToJsonSerializer(), + const _$celest.TypeToken('ColorXToJson'), + ); + _$celest.Serializers.instance.put( + ColorXToJsonImplSerializer(), + const _$celest.TypeToken('ColorXToJsonImpl'), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define( + serialize: ($value) => $value.s, + deserialize: ($serialized) { + return StringX(($serialized as String)); + }, + ), + const _$celest.TypeToken('StringX'), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define( + serialize: ($value) => $value.s, + deserialize: ($serialized) { + return StringXFromJson.fromJson($serialized); + }, + ), + const _$celest.TypeToken('StringXFromJson'), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define( + serialize: ($value) => $value, + deserialize: ($serialized) { + return StringXFromJsonImpl.fromJson($serialized); + }, + ), + const _$celest.TypeToken('StringXFromJsonImpl'), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define( + serialize: ($value) => $value.s, + deserialize: ($serialized) { + return StringXFromJsonStatic.fromJson($serialized); + }, + ), + const _$celest.TypeToken('StringXFromJsonStatic'), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define( + serialize: ($value) => $value, + deserialize: ($serialized) { + return StringXImpl(($serialized as String)); + }, + ), + const _$celest.TypeToken('StringXImpl'), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define( + serialize: ($value) => $value.s, + deserialize: ($serialized) { + return (($serialized as String) as StringXPrivateCtor); + }, + ), + const _$celest.TypeToken('StringXPrivateCtor'), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define( + serialize: ($value) => $value, + deserialize: ($serialized) { + return (($serialized as String) as StringXPrivateCtorImpl); + }, + ), + const _$celest.TypeToken( + 'StringXPrivateCtorImpl', + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define( + serialize: ($value) => ($value as String), + deserialize: ($serialized) { + return StringXPrivateField(($serialized as String)); + }, + ), + const _$celest.TypeToken('StringXPrivateField'), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define( + serialize: ($value) => $value, + deserialize: ($serialized) { + return StringXPrivateFieldImpl(($serialized as String)); + }, + ), + const _$celest.TypeToken( + 'StringXPrivateFieldImpl', + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return StringXToFromJson.fromJson($serialized); + }, + ), + const _$celest.TypeToken('StringXToFromJson'), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return StringXToJson(($serialized as String)); + }, + ), + const _$celest.TypeToken('StringXToJson'), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return StringXToJsonImpl(($serialized as String)); + }, + ), + const _$celest.TypeToken('StringXToJsonImpl'), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return Value.fromJson($serialized); + }, + ), + ); + _$celest.Serializers.instance.put( + ValueXSerializer(), + const _$celest.TypeToken('ValueX'), + ); + _$celest.Serializers.instance.put( + ValueXFromJsonSerializer(), + const _$celest.TypeToken('ValueXFromJson'), + ); + _$celest.Serializers.instance.put( + ValueXFromJsonImplSerializer(), + const _$celest.TypeToken('ValueXFromJsonImpl'), + ); + _$celest.Serializers.instance.put( + ValueXFromJsonStaticSerializer(), + const _$celest.TypeToken('ValueXFromJsonStatic'), + ); + _$celest.Serializers.instance.put( + ValueXImplSerializer(), + const _$celest.TypeToken('ValueXImpl'), + ); + _$celest.Serializers.instance.put( + ValueXToFromJsonSerializer(), + const _$celest.TypeToken('ValueXToFromJson'), + ); + _$celest.Serializers.instance.put( + ValueXToJsonSerializer(), + const _$celest.TypeToken('ValueXToJson'), + ); + _$celest.Serializers.instance.put( + ValueXToJsonImplSerializer(), + const _$celest.TypeToken('ValueXToJsonImpl'), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + r'listOfString': _$celest.Serializers.instance + .serialize<_$fast_immutable_collections_ilist.IList>( + $value.listOfString, + ), + r'listOfUri': _$celest.Serializers.instance + .serialize<_$fast_immutable_collections_ilist.IList>( + $value.listOfUri, + ), + r'listOfSimpleClass': _$celest.Serializers.instance.serialize< + _$fast_immutable_collections_ilist.IList + >($value.listOfSimpleClass), + r'listOfListOfString': _$celest.Serializers.instance.serialize< + _$fast_immutable_collections_ilist.IList< + _$fast_immutable_collections_ilist.IList + > + >($value.listOfListOfString), + r'listOfListOfUri': _$celest.Serializers.instance.serialize< + _$fast_immutable_collections_ilist.IList< + _$fast_immutable_collections_ilist.IList + > + >($value.listOfListOfUri), + r'listOfListOfSimpleClass': _$celest.Serializers.instance + .serialize< + _$fast_immutable_collections_ilist.IList< + _$fast_immutable_collections_ilist.IList + > + >($value.listOfListOfSimpleClass), + r'mapOfString': _$celest.Serializers.instance.serialize< + _$fast_immutable_collections_imap.IMap + >($value.mapOfString), + r'mapOfUri': _$celest.Serializers.instance.serialize< + _$fast_immutable_collections_imap.IMap + >($value.mapOfUri), + r'mapOfSimpleClass': _$celest.Serializers.instance.serialize< + _$fast_immutable_collections_imap.IMap + >($value.mapOfSimpleClass), + r'mapOfListOfString': _$celest.Serializers.instance.serialize< + _$fast_immutable_collections_imap.IMap< + String, + _$fast_immutable_collections_ilist.IList + > + >($value.mapOfListOfString), + r'mapOfListOfUri': _$celest.Serializers.instance.serialize< + _$fast_immutable_collections_imap.IMap< + String, + _$fast_immutable_collections_ilist.IList + > + >($value.mapOfListOfUri), + r'mapOfListOfSimpleClass': _$celest.Serializers.instance + .serialize< + _$fast_immutable_collections_imap.IMap< + String, + _$fast_immutable_collections_ilist.IList + > + >($value.mapOfListOfSimpleClass), + r'mapOfMapOfString': _$celest.Serializers.instance.serialize< + _$fast_immutable_collections_imap.IMap< + String, + _$fast_immutable_collections_imap.IMap + > + >($value.mapOfMapOfString), + r'mapOfMapOfUri': _$celest.Serializers.instance.serialize< + _$fast_immutable_collections_imap.IMap< + String, + _$fast_immutable_collections_imap.IMap + > + >($value.mapOfMapOfUri), + r'mapOfMapOfSimpleClass': _$celest.Serializers.instance.serialize< + _$fast_immutable_collections_imap.IMap< + String, + _$fast_immutable_collections_imap.IMap + > + >($value.mapOfMapOfSimpleClass), + }, + deserialize: ($serialized) { + return GenericWrappers( + listOfString: _$celest.Serializers.instance + .deserialize<_$fast_immutable_collections_ilist.IList>( + $serialized[r'listOfString'], + ), + listOfUri: _$celest.Serializers.instance + .deserialize<_$fast_immutable_collections_ilist.IList>( + $serialized[r'listOfUri'], + ), + listOfSimpleClass: _$celest.Serializers.instance.deserialize< + _$fast_immutable_collections_ilist.IList + >($serialized[r'listOfSimpleClass']), + listOfListOfString: _$celest.Serializers.instance.deserialize< + _$fast_immutable_collections_ilist.IList< + _$fast_immutable_collections_ilist.IList + > + >($serialized[r'listOfListOfString']), + listOfListOfUri: _$celest.Serializers.instance.deserialize< + _$fast_immutable_collections_ilist.IList< + _$fast_immutable_collections_ilist.IList + > + >($serialized[r'listOfListOfUri']), + listOfListOfSimpleClass: _$celest.Serializers.instance.deserialize< + _$fast_immutable_collections_ilist.IList< + _$fast_immutable_collections_ilist.IList + > + >($serialized[r'listOfListOfSimpleClass']), + mapOfString: _$celest.Serializers.instance.deserialize< + _$fast_immutable_collections_imap.IMap + >($serialized[r'mapOfString']), + mapOfUri: _$celest.Serializers.instance.deserialize< + _$fast_immutable_collections_imap.IMap + >($serialized[r'mapOfUri']), + mapOfSimpleClass: _$celest.Serializers.instance.deserialize< + _$fast_immutable_collections_imap.IMap + >($serialized[r'mapOfSimpleClass']), + mapOfListOfString: _$celest.Serializers.instance.deserialize< + _$fast_immutable_collections_imap.IMap< + String, + _$fast_immutable_collections_ilist.IList + > + >($serialized[r'mapOfListOfString']), + mapOfListOfUri: _$celest.Serializers.instance.deserialize< + _$fast_immutable_collections_imap.IMap< + String, + _$fast_immutable_collections_ilist.IList + > + >($serialized[r'mapOfListOfUri']), + mapOfListOfSimpleClass: _$celest.Serializers.instance.deserialize< + _$fast_immutable_collections_imap.IMap< + String, + _$fast_immutable_collections_ilist.IList + > + >($serialized[r'mapOfListOfSimpleClass']), + mapOfMapOfString: _$celest.Serializers.instance.deserialize< + _$fast_immutable_collections_imap.IMap< + String, + _$fast_immutable_collections_imap.IMap + > + >($serialized[r'mapOfMapOfString']), + mapOfMapOfUri: _$celest.Serializers.instance.deserialize< + _$fast_immutable_collections_imap.IMap< + String, + _$fast_immutable_collections_imap.IMap + > + >($serialized[r'mapOfMapOfUri']), + mapOfMapOfSimpleClass: _$celest.Serializers.instance.deserialize< + _$fast_immutable_collections_imap.IMap< + String, + _$fast_immutable_collections_imap.IMap + > + >($serialized[r'mapOfMapOfSimpleClass']), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exportable(); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define( + serialize: ($value) => $value.name, + deserialize: ($serialized) { + return LiteralEnum.values.byName($serialized); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: + ($value) => { + if ($value.type case final type?) r'type': type, + }, + deserialize: ($serialized) { + return Serializable(($serialized?[r'type'] as String?)); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return NestedChild.fromJson($serialized); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + r'parent': _$celest.Serializers.instance + .serialize<_$_common__common.NestedParent>($value.parent), + }, + deserialize: ($serialized) { + return NestedGrandparent( + _$celest.Serializers.instance + .deserialize<_$_common__common.NestedParent>( + $serialized[r'parent'], + ), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + r'child': _$celest.Serializers.instance + .serialize<_$_common__common.NestedChild>($value.child), + }, + deserialize: ($serialized) { + return (_$_common__common.NestedParent( + _$celest.Serializers.instance + .deserialize<_$_common__common.NestedChild>( + $serialized[r'child'], + ), + ) + as NestedParent); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return ComplexClass.fromJson($serialized); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + r'aBigInt': _$celest.Serializers.instance.serialize( + $value.aBigInt, + ), + r'aBool': $value.aBool, + r'aDateTime': _$celest.Serializers.instance.serialize( + $value.aDateTime, + ), + r'aDouble': $value.aDouble, + r'aDuration': _$celest.Serializers.instance.serialize( + $value.aDuration, + ), + r'aListOfBigInt': + $value.aListOfBigInt + .map( + (el) => + _$celest.Serializers.instance.serialize(el), + ) + .toList(), + r'aListOfBool': $value.aListOfBool, + r'aListOfDateTime': + $value.aListOfDateTime + .map( + (el) => _$celest.Serializers.instance + .serialize(el), + ) + .toList(), + r'aListOfDouble': $value.aListOfDouble, + r'aListOfDuration': + $value.aListOfDuration + .map( + (el) => _$celest.Serializers.instance + .serialize(el), + ) + .toList(), + r'aListOfEnum': + $value.aListOfEnum + .map( + (el) => + _$celest.Serializers.instance.serialize(el), + ) + .toList(), + r'aListOfInt': $value.aListOfInt, + r'aListOfNull': $value.aListOfNull, + r'aListOfRegExp': + $value.aListOfRegExp + .map( + (el) => + _$celest.Serializers.instance.serialize(el), + ) + .toList(), + r'aListOfSimpleClass': + $value.aListOfSimpleClass + .map( + (el) => _$celest.Serializers.instance + .serialize(el), + ) + .toList(), + r'aListOfSimpleStruct': + $value.aListOfSimpleStruct + .map( + (el) => _$celest.Serializers.instance + .serialize(el), + ) + .toList(), + r'aListOfStackTrace': + $value.aListOfStackTrace + .map( + (el) => _$celest.Serializers.instance + .serialize(el), + ) + .toList(), + r'aListOfString': $value.aListOfString, + r'aListOfUint8List': + $value.aListOfUint8List + .map( + (el) => _$celest.Serializers.instance + .serialize(el), + ) + .toList(), + r'aListOfUri': + $value.aListOfUri + .map( + (el) => + _$celest.Serializers.instance.serialize(el), + ) + .toList(), + r'aListOfUriData': + $value.aListOfUriData + .map( + (el) => _$celest.Serializers.instance + .serialize(el), + ) + .toList(), + r'aMapOfBigInt': $value.aMapOfBigInt.map( + (key, value) => MapEntry( + key, + _$celest.Serializers.instance.serialize(value), + ), + ), + r'aMapOfBool': $value.aMapOfBool, + r'aMapOfDateTime': $value.aMapOfDateTime.map( + (key, value) => MapEntry( + key, + _$celest.Serializers.instance.serialize(value), + ), + ), + r'aMapOfDouble': $value.aMapOfDouble, + r'aMapOfDuration': $value.aMapOfDuration.map( + (key, value) => MapEntry( + key, + _$celest.Serializers.instance.serialize(value), + ), + ), + r'aMapOfEnum': $value.aMapOfEnum.map( + (key, value) => MapEntry( + key, + _$celest.Serializers.instance.serialize(value), + ), + ), + r'aMapOfInt': $value.aMapOfInt, + r'aMapOfNull': $value.aMapOfNull, + r'aMapOfRegExp': $value.aMapOfRegExp.map( + (key, value) => MapEntry( + key, + _$celest.Serializers.instance.serialize(value), + ), + ), + r'aMapOfSimpleClass': $value.aMapOfSimpleClass.map( + (key, value) => MapEntry( + key, + _$celest.Serializers.instance.serialize(value), + ), + ), + r'aMapOfSimpleStruct': $value.aMapOfSimpleStruct.map( + (key, value) => MapEntry( + key, + _$celest.Serializers.instance.serialize(value), + ), + ), + r'aMapOfStackTrace': $value.aMapOfStackTrace.map( + (key, value) => MapEntry( + key, + _$celest.Serializers.instance.serialize(value), + ), + ), + r'aMapOfString': $value.aMapOfString, + r'aMapOfUint8List': $value.aMapOfUint8List.map( + (key, value) => MapEntry( + key, + _$celest.Serializers.instance.serialize(value), + ), + ), + r'aMapOfUri': $value.aMapOfUri.map( + (key, value) => MapEntry( + key, + _$celest.Serializers.instance.serialize(value), + ), + ), + r'aMapOfUriData': $value.aMapOfUriData.map( + (key, value) => MapEntry( + key, + _$celest.Serializers.instance.serialize(value), + ), + ), + r'aNull': $value.aNull, + r'aRegExp': _$celest.Serializers.instance.serialize( + $value.aRegExp, + ), + r'aSimpleClass': _$celest.Serializers.instance + .serialize($value.aSimpleClass), + r'aSimpleStruct': _$celest.Serializers.instance + .serialize($value.aSimpleStruct), + r'aStackTrace': _$celest.Serializers.instance + .serialize($value.aStackTrace), + r'aString': $value.aString, + r'aUint8List': _$celest.Serializers.instance.serialize( + $value.aUint8List, + ), + r'aUri': _$celest.Serializers.instance.serialize( + $value.aUri, + ), + r'aUriData': _$celest.Serializers.instance.serialize( + $value.aUriData, + ), + r'anEnum': _$celest.Serializers.instance.serialize( + $value.anEnum, + ), + r'anInt': $value.anInt, + r'anIterableOfSimpleClass': + $value.anIterableOfSimpleClass + .map( + (el) => _$celest.Serializers.instance + .serialize(el), + ) + .toList(), + }, + deserialize: ($serialized) { + return ( + aBigInt: _$celest.Serializers.instance.deserialize( + $serialized[r'aBigInt'], + ), + aBool: ($serialized[r'aBool'] as bool), + aDateTime: _$celest.Serializers.instance.deserialize( + $serialized[r'aDateTime'], + ), + aDouble: ($serialized[r'aDouble'] as num).toDouble(), + aDuration: _$celest.Serializers.instance.deserialize( + $serialized[r'aDuration'], + ), + aListOfBigInt: + ($serialized[r'aListOfBigInt'] as Iterable) + .map( + (el) => + _$celest.Serializers.instance.deserialize(el), + ) + .toList(), + aListOfBool: + ($serialized[r'aListOfBool'] as Iterable) + .map((el) => (el as bool)) + .toList(), + aListOfDateTime: + ($serialized[r'aListOfDateTime'] as Iterable) + .map( + (el) => _$celest.Serializers.instance + .deserialize(el), + ) + .toList(), + aListOfDouble: + ($serialized[r'aListOfDouble'] as Iterable) + .map((el) => (el as num).toDouble()) + .toList(), + aListOfDuration: + ($serialized[r'aListOfDuration'] as Iterable) + .map( + (el) => _$celest.Serializers.instance + .deserialize(el), + ) + .toList(), + aListOfEnum: + ($serialized[r'aListOfEnum'] as Iterable) + .map( + (el) => + _$celest.Serializers.instance.deserialize(el), + ) + .toList(), + aListOfInt: + ($serialized[r'aListOfInt'] as Iterable) + .map((el) => (el as num).toInt()) + .toList(), + aListOfNull: + ($serialized[r'aListOfNull'] as Iterable) + .map((el) => (el as Null)) + .toList(), + aListOfRegExp: + ($serialized[r'aListOfRegExp'] as Iterable) + .map( + (el) => + _$celest.Serializers.instance.deserialize(el), + ) + .toList(), + aListOfSimpleClass: + ($serialized[r'aListOfSimpleClass'] as Iterable) + .map( + (el) => _$celest.Serializers.instance + .deserialize(el), + ) + .toList(), + aListOfSimpleStruct: + ($serialized[r'aListOfSimpleStruct'] as Iterable) + .map( + (el) => _$celest.Serializers.instance + .deserialize(el), + ) + .toList(), + aListOfStackTrace: + ($serialized[r'aListOfStackTrace'] as Iterable) + .map( + (el) => _$celest.Serializers.instance + .deserialize(el), + ) + .toList(), + aListOfString: + ($serialized[r'aListOfString'] as Iterable) + .map((el) => (el as String)) + .toList(), + aListOfUint8List: + ($serialized[r'aListOfUint8List'] as Iterable) + .map( + (el) => _$celest.Serializers.instance + .deserialize(el), + ) + .toList(), + aListOfUri: + ($serialized[r'aListOfUri'] as Iterable) + .map( + (el) => + _$celest.Serializers.instance.deserialize(el), + ) + .toList(), + aListOfUriData: + ($serialized[r'aListOfUriData'] as Iterable) + .map( + (el) => _$celest.Serializers.instance + .deserialize(el), + ) + .toList(), + aMapOfBigInt: ($serialized[r'aMapOfBigInt'] as Map) + .map( + (key, value) => MapEntry( + key, + _$celest.Serializers.instance.deserialize(value), + ), + ), + aMapOfBool: ($serialized[r'aMapOfBool'] as Map) + .map((key, value) => MapEntry(key, (value as bool))), + aMapOfDateTime: + ($serialized[r'aMapOfDateTime'] as Map).map( + (key, value) => MapEntry( + key, + _$celest.Serializers.instance.deserialize(value), + ), + ), + aMapOfDouble: ($serialized[r'aMapOfDouble'] as Map) + .map((key, value) => MapEntry(key, (value as num).toDouble())), + aMapOfDuration: + ($serialized[r'aMapOfDuration'] as Map).map( + (key, value) => MapEntry( + key, + _$celest.Serializers.instance.deserialize(value), + ), + ), + aMapOfEnum: ($serialized[r'aMapOfEnum'] as Map) + .map( + (key, value) => MapEntry( + key, + _$celest.Serializers.instance.deserialize(value), + ), + ), + aMapOfInt: ($serialized[r'aMapOfInt'] as Map).map( + (key, value) => MapEntry(key, (value as num).toInt()), + ), + aMapOfNull: ($serialized[r'aMapOfNull'] as Map) + .map((key, value) => MapEntry(key, (value as Null))), + aMapOfRegExp: ($serialized[r'aMapOfRegExp'] as Map) + .map( + (key, value) => MapEntry( + key, + _$celest.Serializers.instance.deserialize(value), + ), + ), + aMapOfSimpleClass: + ($serialized[r'aMapOfSimpleClass'] as Map).map( + (key, value) => MapEntry( + key, + _$celest.Serializers.instance.deserialize( + value, + ), + ), + ), + aMapOfSimpleStruct: ($serialized[r'aMapOfSimpleStruct'] + as Map) + .map( + (key, value) => MapEntry( + key, + _$celest.Serializers.instance.deserialize( + value, + ), + ), + ), + aMapOfStackTrace: + ($serialized[r'aMapOfStackTrace'] as Map).map( + (key, value) => MapEntry( + key, + _$celest.Serializers.instance.deserialize( + value, + ), + ), + ), + aMapOfString: ($serialized[r'aMapOfString'] as Map) + .map((key, value) => MapEntry(key, (value as String))), + aMapOfUint8List: + ($serialized[r'aMapOfUint8List'] as Map).map( + (key, value) => MapEntry( + key, + _$celest.Serializers.instance.deserialize(value), + ), + ), + aMapOfUri: ($serialized[r'aMapOfUri'] as Map).map( + (key, value) => MapEntry( + key, + _$celest.Serializers.instance.deserialize(value), + ), + ), + aMapOfUriData: + ($serialized[r'aMapOfUriData'] as Map).map( + (key, value) => MapEntry( + key, + _$celest.Serializers.instance.deserialize(value), + ), + ), + aNull: ($serialized[r'aNull'] as Null), + aRegExp: _$celest.Serializers.instance.deserialize( + $serialized[r'aRegExp'], + ), + aSimpleClass: _$celest.Serializers.instance + .deserialize($serialized[r'aSimpleClass']), + aSimpleStruct: _$celest.Serializers.instance + .deserialize($serialized[r'aSimpleStruct']), + aStackTrace: _$celest.Serializers.instance.deserialize( + $serialized[r'aStackTrace'], + ), + aString: ($serialized[r'aString'] as String), + aUint8List: _$celest.Serializers.instance.deserialize( + $serialized[r'aUint8List'], + ), + aUri: _$celest.Serializers.instance.deserialize( + $serialized[r'aUri'], + ), + aUriData: _$celest.Serializers.instance.deserialize( + $serialized[r'aUriData'], + ), + anEnum: _$celest.Serializers.instance.deserialize( + $serialized[r'anEnum'], + ), + anInt: ($serialized[r'anInt'] as num).toInt(), + anIterableOfSimpleClass: + ($serialized[r'anIterableOfSimpleClass'] as Iterable) + .map( + (el) => _$celest.Serializers.instance + .deserialize(el), + ) + .toList(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define( + serialize: ($value) => $value.name, + deserialize: ($serialized) { + return MyEnum.values.byName($serialized); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return SimpleClass.fromJson($serialized); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return (); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + r'anotherField': $value.anotherField, + r'field': $value.field, + }, + deserialize: ($serialized) { + return ( + anotherField: ($serialized[r'anotherField'] as String), + field: ($serialized[r'field'] as String), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + r'namedFields': _$celest.Serializers.instance + .serialize($value.namedFields), + }, + deserialize: ($serialized) { + return ( + namedFields: _$celest.Serializers.instance + .deserialize($serialized[r'namedFields']), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + if (_$celest.Serializers.instance.serialize( + $value.namedFields, + ) + case final namedFields?) + r'namedFields': namedFields, + }, + deserialize: ($serialized) { + return ( + namedFields: _$celest.Serializers.instance + .deserialize($serialized[r'namedFields']), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + r'radius': $value.radius, + r'area': $value.area, + }, + deserialize: ($serialized) { + return Circle(($serialized[r'radius'] as num).toDouble()); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return CircleWithCustomJson.fromJson($serialized); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + CircleWithInheritedCustomJson, + Map + >( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return (ShapeWithInheritedCustomJson.fromJson({ + r'$type': r'CircleWithInheritedCustomJson', + ...$serialized, + }) + as CircleWithInheritedCustomJson); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + CircleWithOverriddenCustomJson, + Map + >( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return CircleWithOverriddenCustomJson.fromJson($serialized); + }, + ), + ); + _$celest.Serializers.instance.put( + const ErrResult_E_ShapeExceptionSerializer(), + ); + _$celest.Serializers.instance.put( + const ErrResult_E_ShapeExceptionSerializer(), + ); + _$celest.Serializers.instance.put( + const ErrResult_E_ShapeExceptionSerializer(), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define, Map>( + serialize: + ($value) => { + r'error': _$celest.Serializers.instance.serialize( + $value.error, + ), + }, + deserialize: ($serialized) { + return ErrResult( + _$celest.Serializers.instance.deserialize( + $serialized[r'error'], + ), + ); + }, + ), + ); + _$celest.Serializers.instance.put(const ErrResult_T_ShapeSerializer()); + _$celest.Serializers.instance.put( + const ErrResult_T_ShapeSerializer(), + ); + _$celest.Serializers.instance.put( + const ErrResult_T_ShapeSerializer(), + ); + _$celest.Serializers.instance.put( + const ErrResult_T_ShapeSerializer(), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define, Map>( + serialize: ($value) => {r'error': $value.error}, + deserialize: ($serialized) { + return ErrResult(($serialized[r'error'] as String)); + }, + ), + ); + _$celest.Serializers.instance.put( + const OkResult_E_ShapeExceptionSerializer(), + ); + _$celest.Serializers.instance.put( + const OkResult_E_ShapeExceptionSerializer(), + ); + _$celest.Serializers.instance.put( + const OkResult_E_ShapeExceptionSerializer(), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define, Map>( + serialize: ($value) => {r'data': $value.data}, + deserialize: ($serialized) { + return OkResult(($serialized[r'data'] as String)); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define, Map>( + serialize: + ($value) => { + r'data': _$celest.Serializers.instance.serialize( + $value.data, + ), + }, + deserialize: ($serialized) { + return OkResult( + _$celest.Serializers.instance.deserialize( + $serialized[r'data'], + ), + ); + }, + ), + ); + _$celest.Serializers.instance.put(const OkResult_T_ShapeSerializer()); + _$celest.Serializers.instance.put( + const OkResult_T_ShapeSerializer(), + ); + _$celest.Serializers.instance.put( + const OkResult_T_ShapeSerializer(), + ); + _$celest.Serializers.instance.put( + const OkResult_T_ShapeSerializer(), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + r'data': _$celest.Serializers.instance.serialize( + $value.data, + ), + }, + deserialize: ($serialized) { + return OkShapeResult( + _$celest.Serializers.instance.deserialize( + $serialized[r'data'], + ), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + r'width': $value.width, + r'height': $value.height, + r'area': $value.area, + }, + deserialize: ($serialized) { + return Rectangle( + ($serialized[r'width'] as num).toDouble(), + ($serialized[r'height'] as num).toDouble(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return RectangleWithCustomJson.fromJson($serialized); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + RectangleWithInheritedCustomJson, + Map + >( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return (ShapeWithInheritedCustomJson.fromJson({ + r'$type': r'RectangleWithInheritedCustomJson', + ...$serialized, + }) + as RectangleWithInheritedCustomJson); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + RectangleWithOverriddenCustomJson, + Map + >( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return (ShapeWithOverriddenCustomJson.fromJson({ + r'$type': r'RectangleWithOverriddenCustomJson', + ...$serialized, + }) + as RectangleWithOverriddenCustomJson); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define, Map>( + serialize: ($value) { + if ($value is SwappedResult) { + return { + ...(_$celest.Serializers.instance + .serialize>($value) + as Map), + r'$type': r'SwappedResult', + }; + } + if ($value is OkResult) { + return { + ...(_$celest.Serializers.instance.serialize>( + $value, + ) + as Map), + r'$type': r'OkResult', + }; + } + if ($value is ErrResult) { + return { + ...(_$celest.Serializers.instance.serialize>( + $value, + ) + as Map), + r'$type': r'ErrResult', + }; + } + throw _$celest.SerializationException( + (StringBuffer('Unknown subtype of ') + ..write(r'Result') + ..write(': ') + ..write($value.runtimeType)) + .toString(), + ); + }, + deserialize: ($serialized) { + if ($serialized[r'$type'] == r'SwappedResult') { + return _$celest.Serializers.instance + .deserialize>($serialized); + } + if ($serialized[r'$type'] == r'OkResult') { + return _$celest.Serializers.instance.deserialize>( + $serialized, + ); + } + if ($serialized[r'$type'] == r'ErrResult') { + return _$celest.Serializers.instance.deserialize>( + $serialized, + ); + } + throw _$celest.SerializationException( + (StringBuffer('Unknown subtype of ') + ..write(r'Result') + ..write(': ') + ..write($serialized[r'$type'])) + .toString(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define, Map>( + serialize: ($value) { + if ($value is SwappedResult) { + return { + ...(_$celest.Serializers.instance + .serialize>($value) + as Map), + r'$type': r'SwappedResult', + }; + } + if ($value is OkResult) { + return { + ...(_$celest.Serializers.instance.serialize>( + $value, + ) + as Map), + r'$type': r'OkResult', + }; + } + if ($value is ErrResult) { + return { + ...(_$celest.Serializers.instance.serialize>( + $value, + ) + as Map), + r'$type': r'ErrResult', + }; + } + throw _$celest.SerializationException( + (StringBuffer('Unknown subtype of ') + ..write(r'Result') + ..write(': ') + ..write($value.runtimeType)) + .toString(), + ); + }, + deserialize: ($serialized) { + if ($serialized[r'$type'] == r'SwappedResult') { + return _$celest.Serializers.instance + .deserialize>($serialized); + } + if ($serialized[r'$type'] == r'OkResult') { + return _$celest.Serializers.instance.deserialize>( + $serialized, + ); + } + if ($serialized[r'$type'] == r'ErrResult') { + return _$celest.Serializers.instance.deserialize>( + $serialized, + ); + } + throw _$celest.SerializationException( + (StringBuffer('Unknown subtype of ') + ..write(r'Result') + ..write(': ') + ..write($serialized[r'$type'])) + .toString(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + const Result_T_Shape_E_ShapeExceptionSerializer(), + ); + _$celest.Serializers.instance.put( + const Result_T_Shape_E_ShapeExceptionSerializer(), + ); + _$celest.Serializers.instance.put( + const Result_T_Shape_E_ShapeExceptionSerializer< + Shape, + BadShapeException + >(), + ); + _$celest.Serializers.instance.put( + const Result_T_Shape_E_ShapeExceptionSerializer(), + ); + _$celest.Serializers.instance.put( + const Result_T_Shape_E_ShapeExceptionSerializer< + Circle, + BadShapeException + >(), + ); + _$celest.Serializers.instance.put( + const Result_T_Shape_E_ShapeExceptionSerializer< + Rectangle, + ShapeException + >(), + ); + _$celest.Serializers.instance.put( + const Result_T_Shape_E_ShapeExceptionSerializer< + Rectangle, + BadShapeException + >(), + ); + _$celest.Serializers.instance.put( + const Result_E_ShapeException_T_ShapeSerializer(), + ); + _$celest.Serializers.instance.put( + const Result_E_ShapeException_T_ShapeSerializer(), + ); + _$celest.Serializers.instance.put( + const Result_E_ShapeException_T_ShapeSerializer(), + ); + _$celest.Serializers.instance.put( + const Result_E_ShapeException_T_ShapeSerializer< + ShapeException, + Rectangle + >(), + ); + _$celest.Serializers.instance.put( + const Result_E_ShapeException_T_ShapeSerializer< + BadShapeException, + Shape + >(), + ); + _$celest.Serializers.instance.put( + const Result_E_ShapeException_T_ShapeSerializer< + BadShapeException, + Circle + >(), + ); + _$celest.Serializers.instance.put( + const Result_E_ShapeException_T_ShapeSerializer< + BadShapeException, + Rectangle + >(), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: ($value) { + if ($value is Circle) { + return { + ...(_$celest.Serializers.instance.serialize($value) + as Map), + r'$type': r'Circle', + }; + } + if ($value is Rectangle) { + return { + ...(_$celest.Serializers.instance.serialize($value) + as Map), + r'$type': r'Rectangle', + }; + } + throw _$celest.SerializationException( + (StringBuffer('Unknown subtype of ') + ..write(r'Shape') + ..write(': ') + ..write($value.runtimeType)) + .toString(), + ); + }, + deserialize: ($serialized) { + if ($serialized[r'$type'] == r'Circle') { + return _$celest.Serializers.instance.deserialize( + $serialized, + ); + } + if ($serialized[r'$type'] == r'Rectangle') { + return _$celest.Serializers.instance.deserialize( + $serialized, + ); + } + throw _$celest.SerializationException( + (StringBuffer('Unknown subtype of ') + ..write(r'Shape') + ..write(': ') + ..write($serialized[r'$type'])) + .toString(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: ($value) { + if ($value is CircleWithCustomJson) { + return { + ...(_$celest.Serializers.instance.serialize( + $value, + ) + as Map), + r'$type': r'CircleWithCustomJson', + }; + } + if ($value is RectangleWithCustomJson) { + return { + ...(_$celest.Serializers.instance + .serialize($value) + as Map), + r'$type': r'RectangleWithCustomJson', + }; + } + throw _$celest.SerializationException( + (StringBuffer('Unknown subtype of ') + ..write(r'ShapeWithCustomJson') + ..write(': ') + ..write($value.runtimeType)) + .toString(), + ); + }, + deserialize: ($serialized) { + if ($serialized[r'$type'] == r'CircleWithCustomJson') { + return _$celest.Serializers.instance + .deserialize($serialized); + } + if ($serialized[r'$type'] == r'RectangleWithCustomJson') { + return _$celest.Serializers.instance + .deserialize($serialized); + } + throw _$celest.SerializationException( + (StringBuffer('Unknown subtype of ') + ..write(r'ShapeWithCustomJson') + ..write(': ') + ..write($serialized[r'$type'])) + .toString(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + ShapeWithInheritedCustomJson, + Map + >( + serialize: + ($value) => { + ...$value.toJson(), + r'$type': switch ($value) { + CircleWithInheritedCustomJson() => + r'CircleWithInheritedCustomJson', + RectangleWithInheritedCustomJson() => + r'RectangleWithInheritedCustomJson', + }, + }, + deserialize: ($serialized) { + return ShapeWithInheritedCustomJson.fromJson($serialized); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + ShapeWithOverriddenCustomJson, + Map + >( + serialize: + ($value) => { + ...$value.toJson(), + r'$type': switch ($value) { + CircleWithOverriddenCustomJson() => + r'CircleWithOverriddenCustomJson', + RectangleWithOverriddenCustomJson() => + r'RectangleWithOverriddenCustomJson', + }, + }, + deserialize: ($serialized) { + return ShapeWithOverriddenCustomJson.fromJson($serialized); + }, + ), + ); + _$celest.Serializers.instance.put( + const SwappedResult_T_Shape_E_ShapeExceptionSerializer(), + ); + _$celest.Serializers.instance.put( + const SwappedResult_T_Shape_E_ShapeExceptionSerializer< + Shape, + ShapeException + >(), + ); + _$celest.Serializers.instance.put( + const SwappedResult_T_Shape_E_ShapeExceptionSerializer< + Shape, + BadShapeException + >(), + ); + _$celest.Serializers.instance.put( + const SwappedResult_T_Shape_E_ShapeExceptionSerializer< + Circle, + ShapeException + >(), + ); + _$celest.Serializers.instance.put( + const SwappedResult_T_Shape_E_ShapeExceptionSerializer< + Circle, + BadShapeException + >(), + ); + _$celest.Serializers.instance.put( + const SwappedResult_T_Shape_E_ShapeExceptionSerializer< + Rectangle, + ShapeException + >(), + ); + _$celest.Serializers.instance.put( + const SwappedResult_T_Shape_E_ShapeExceptionSerializer< + Rectangle, + BadShapeException + >(), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + SwappedResult, + Map + >( + serialize: + ($value) => { + r'result': _$celest.Serializers.instance + .serialize>($value.result), + }, + deserialize: ($serialized) { + return SwappedResult( + _$celest.Serializers.instance.deserialize>( + $serialized[r'result'], + ), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + const SwappedResult_E_ShapeException_T_ShapeSerializer(), + ); + _$celest.Serializers.instance.put( + const SwappedResult_E_ShapeException_T_ShapeSerializer< + ShapeException, + Shape + >(), + ); + _$celest.Serializers.instance.put( + const SwappedResult_E_ShapeException_T_ShapeSerializer< + ShapeException, + Circle + >(), + ); + _$celest.Serializers.instance.put( + const SwappedResult_E_ShapeException_T_ShapeSerializer< + ShapeException, + Rectangle + >(), + ); + _$celest.Serializers.instance.put( + const SwappedResult_E_ShapeException_T_ShapeSerializer< + BadShapeException, + Shape + >(), + ); + _$celest.Serializers.instance.put( + const SwappedResult_E_ShapeException_T_ShapeSerializer< + BadShapeException, + Circle + >(), + ); + _$celest.Serializers.instance.put( + const SwappedResult_E_ShapeException_T_ShapeSerializer< + BadShapeException, + Rectangle + >(), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + SwappedResult, + Map + >( + serialize: + ($value) => { + r'result': _$celest.Serializers.instance + .serialize>($value.result), + }, + deserialize: ($serialized) { + return SwappedResult( + _$celest.Serializers.instance.deserialize>( + $serialized[r'result'], + ), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return Portfolio.fromJson($serialized); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest + .Serializer.define<_$celest.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.AbortedException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.AlreadyExistsException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.BadRequestException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.BadRequestException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.CancelledException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.CancelledException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define<_$celest.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.CloudException.fromJson($serialized); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define<_$celest.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.DataLossError( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.DeadlineExceededError, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.InternalServerError, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.InternalServerError( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest + .Serializer.define<_$celest.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.NotFoundException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.OutOfRangeException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.OutOfRangeException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.UnauthorizedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.UnauthorizedException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest + .Serializer.define<_$celest.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.UnavailableError( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.UnimplementedError, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.UnimplementedError( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define<_$celest.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.UnknownError( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.SerializationException, + Map + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define<_$celest.JsonBool, bool>( + serialize: ($value) => $value, + deserialize: ($serialized) { + return _$celest.JsonBool(($serialized as bool)); + }, + ), + const _$celest.TypeToken<_$celest.JsonBool>('JsonBool'), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define<_$celest.JsonDouble, double>( + serialize: ($value) => $value, + deserialize: ($serialized) { + return _$celest.JsonDouble(($serialized as num).toDouble()); + }, + ), + const _$celest.TypeToken<_$celest.JsonDouble>('JsonDouble'), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define<_$celest.JsonInt, int>( + serialize: ($value) => $value, + deserialize: ($serialized) { + return _$celest.JsonInt(($serialized as num).toInt()); + }, + ), + const _$celest.TypeToken<_$celest.JsonInt>('JsonInt'), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define<_$celest.JsonList, List>( + serialize: ($value) => $value, + deserialize: ($serialized) { + return _$celest.JsonList(($serialized as Iterable).toList()); + }, + ), + const _$celest.TypeToken<_$celest.JsonList>('JsonList'), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define<_$celest.JsonMap, Map>( + serialize: ($value) => $value, + deserialize: ($serialized) { + return _$celest.JsonMap(($serialized as Map)); + }, + ), + const _$celest.TypeToken<_$celest.JsonMap>('JsonMap'), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define<_$celest.JsonNum, num>( + serialize: ($value) => $value, + deserialize: ($serialized) { + return _$celest.JsonNum(($serialized as num)); + }, + ), + const _$celest.TypeToken<_$celest.JsonNum>('JsonNum'), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define<_$celest.JsonString, String>( + serialize: ($value) => $value, + deserialize: ($serialized) { + return _$celest.JsonString(($serialized as String)); + }, + ), + const _$celest.TypeToken<_$celest.JsonString>('JsonString'), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define<_$celest.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _$celest.JsonValue($serialized); + }, + ), + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$fast_immutable_collections_ilist.IList, + dynamic + >( + serialize: ($value) => $value.toJson((value) => value), + deserialize: ($serialized) { + return _$fast_immutable_collections_ilist.IList.fromJson( + $serialized, + (value) => (value as String), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$fast_immutable_collections_ilist.IList, + dynamic + >( + serialize: + ($value) => $value.toJson( + (value) => _$celest.Serializers.instance.serialize(value), + ), + deserialize: ($serialized) { + return _$fast_immutable_collections_ilist.IList.fromJson( + $serialized, + (value) => _$celest.Serializers.instance.deserialize(value), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$fast_immutable_collections_ilist.IList< + _$fast_immutable_collections_ilist.IList + >, + dynamic + >( + serialize: + ($value) => $value.toJson( + (value) => _$celest.Serializers.instance.serialize< + _$fast_immutable_collections_ilist.IList + >(value), + ), + deserialize: ($serialized) { + return _$fast_immutable_collections_ilist.IList< + _$fast_immutable_collections_ilist.IList + >.fromJson( + $serialized, + (value) => _$celest.Serializers.instance.deserialize< + _$fast_immutable_collections_ilist.IList + >(value), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$fast_immutable_collections_ilist.IList< + _$fast_immutable_collections_ilist.IList + >, + dynamic + >( + serialize: + ($value) => $value.toJson( + (value) => _$celest.Serializers.instance + .serialize<_$fast_immutable_collections_ilist.IList>( + value, + ), + ), + deserialize: ($serialized) { + return _$fast_immutable_collections_ilist.IList< + _$fast_immutable_collections_ilist.IList + >.fromJson( + $serialized, + (value) => _$celest.Serializers.instance + .deserialize<_$fast_immutable_collections_ilist.IList>( + value, + ), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$fast_immutable_collections_ilist.IList< + _$fast_immutable_collections_ilist.IList + >, + dynamic + >( + serialize: + ($value) => $value.toJson( + (value) => _$celest.Serializers.instance + .serialize<_$fast_immutable_collections_ilist.IList>( + value, + ), + ), + deserialize: ($serialized) { + return _$fast_immutable_collections_ilist.IList< + _$fast_immutable_collections_ilist.IList + >.fromJson( + $serialized, + (value) => _$celest.Serializers.instance + .deserialize<_$fast_immutable_collections_ilist.IList>( + value, + ), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$fast_immutable_collections_ilist.IList, + dynamic + >( + serialize: + ($value) => $value.toJson( + (value) => + _$celest.Serializers.instance.serialize(value), + ), + deserialize: ($serialized) { + return _$fast_immutable_collections_ilist.IList.fromJson( + $serialized, + (value) => + _$celest.Serializers.instance.deserialize(value), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$fast_immutable_collections_imap.IMap, + Map + >( + serialize: + ($value) => $value.toJson((value) => value, (value) => value), + deserialize: ($serialized) { + return _$fast_immutable_collections_imap.IMap< + String, + String + >.fromJson( + $serialized, + (value) => (value as String), + (value) => (value as String), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$fast_immutable_collections_imap.IMap< + String, + _$fast_immutable_collections_imap.IMap + >, + Map + >( + serialize: + ($value) => $value.toJson( + (value) => value, + (value) => _$celest.Serializers.instance.serialize< + _$fast_immutable_collections_imap.IMap + >(value), + ), + deserialize: ($serialized) { + return _$fast_immutable_collections_imap.IMap< + String, + _$fast_immutable_collections_imap.IMap + >.fromJson( + $serialized, + (value) => (value as String), + (value) => _$celest.Serializers.instance.deserialize< + _$fast_immutable_collections_imap.IMap + >(value), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$fast_immutable_collections_imap.IMap< + String, + _$fast_immutable_collections_imap.IMap + >, + Map + >( + serialize: + ($value) => $value.toJson( + (value) => value, + (value) => _$celest.Serializers.instance.serialize< + _$fast_immutable_collections_imap.IMap + >(value), + ), + deserialize: ($serialized) { + return _$fast_immutable_collections_imap.IMap< + String, + _$fast_immutable_collections_imap.IMap + >.fromJson( + $serialized, + (value) => (value as String), + (value) => _$celest.Serializers.instance.deserialize< + _$fast_immutable_collections_imap.IMap + >(value), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$fast_immutable_collections_imap.IMap< + String, + _$fast_immutable_collections_imap.IMap + >, + Map + >( + serialize: + ($value) => $value.toJson( + (value) => value, + (value) => _$celest.Serializers.instance.serialize< + _$fast_immutable_collections_imap.IMap + >(value), + ), + deserialize: ($serialized) { + return _$fast_immutable_collections_imap.IMap< + String, + _$fast_immutable_collections_imap.IMap + >.fromJson( + $serialized, + (value) => (value as String), + (value) => _$celest.Serializers.instance.deserialize< + _$fast_immutable_collections_imap.IMap + >(value), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$fast_immutable_collections_imap.IMap< + String, + _$fast_immutable_collections_ilist.IList + >, + Map + >( + serialize: + ($value) => $value.toJson( + (value) => value, + (value) => _$celest.Serializers.instance.serialize< + _$fast_immutable_collections_ilist.IList + >(value), + ), + deserialize: ($serialized) { + return _$fast_immutable_collections_imap.IMap< + String, + _$fast_immutable_collections_ilist.IList + >.fromJson( + $serialized, + (value) => (value as String), + (value) => _$celest.Serializers.instance.deserialize< + _$fast_immutable_collections_ilist.IList + >(value), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$fast_immutable_collections_imap.IMap< + String, + _$fast_immutable_collections_ilist.IList + >, + Map + >( + serialize: + ($value) => $value.toJson( + (value) => value, + (value) => _$celest.Serializers.instance + .serialize<_$fast_immutable_collections_ilist.IList>( + value, + ), + ), + deserialize: ($serialized) { + return _$fast_immutable_collections_imap.IMap< + String, + _$fast_immutable_collections_ilist.IList + >.fromJson( + $serialized, + (value) => (value as String), + (value) => _$celest.Serializers.instance + .deserialize<_$fast_immutable_collections_ilist.IList>( + value, + ), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$fast_immutable_collections_imap.IMap< + String, + _$fast_immutable_collections_ilist.IList + >, + Map + >( + serialize: + ($value) => $value.toJson( + (value) => value, + (value) => _$celest.Serializers.instance + .serialize<_$fast_immutable_collections_ilist.IList>( + value, + ), + ), + deserialize: ($serialized) { + return _$fast_immutable_collections_imap.IMap< + String, + _$fast_immutable_collections_ilist.IList + >.fromJson( + $serialized, + (value) => (value as String), + (value) => _$celest.Serializers.instance + .deserialize<_$fast_immutable_collections_ilist.IList>( + value, + ), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$fast_immutable_collections_imap.IMap, + Map + >( + serialize: + ($value) => $value.toJson( + (value) => value, + (value) => + _$celest.Serializers.instance.serialize(value), + ), + deserialize: ($serialized) { + return _$fast_immutable_collections_imap.IMap< + String, + SimpleClass + >.fromJson( + $serialized, + (value) => (value as String), + (value) => + _$celest.Serializers.instance.deserialize(value), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$fast_immutable_collections_imap.IMap, + Map + >( + serialize: + ($value) => $value.toJson( + (value) => value, + (value) => _$celest.Serializers.instance.serialize(value), + ), + deserialize: ($serialized) { + return _$fast_immutable_collections_imap.IMap.fromJson( + $serialized, + (value) => (value as String), + (value) => _$celest.Serializers.instance.deserialize(value), + ); + }, + ), + ); + }, zoneValues: {_$celest.Serializers: serializers}); +} + +typedef Record$k2phuz = + ({ + NamedFieldsRecord aliased, + ({String anotherField, String field}) nonAliased, + }); +typedef Record$k7x4l9 = ({String a, String b, String c}); +typedef Record$rmm4wt = ({String anotherField, String field}); + +final class ColorXFromJsonImplSerializer + extends _$celest.Serializer { + ColorXFromJsonImplSerializer() { + $serializers..put( + _$celest.Serializer.define( + serialize: ($value) => $value.name, + deserialize: ($serialized) { + return Color.values.byName($serialized); + }, + ), + ); + } + + final _$celest.Serializers $serializers = _$celest.Serializers(); + + @override + ColorXFromJsonImpl deserialize(Object? $value) { + final $serialized = assertWireType($value); + return ColorXFromJsonImpl.fromJson($serialized); + } + + @override + Object? serialize(ColorXFromJsonImpl $value) => $value.toJson(); +} + +final class ColorXFromJsonSerializer + extends _$celest.Serializer { + ColorXFromJsonSerializer() { + $serializers..put( + _$celest.Serializer.define( + serialize: ($value) => $value.name, + deserialize: ($serialized) { + return Color.values.byName($serialized); + }, + ), + ); + } + + final _$celest.Serializers $serializers = _$celest.Serializers(); + + @override + ColorXFromJson deserialize(Object? $value) { + final $serialized = assertWireType($value); + return ColorXFromJson.fromJson($serialized); + } + + @override + Object? serialize(ColorXFromJson $value) => + $serializers.serialize($value.c); +} + +final class ColorXFromJsonStaticSerializer + extends _$celest.Serializer { + ColorXFromJsonStaticSerializer() { + $serializers..put( + _$celest.Serializer.define( + serialize: ($value) => $value.name, + deserialize: ($serialized) { + return Color.values.byName($serialized); + }, + ), + ); + } + + final _$celest.Serializers $serializers = _$celest.Serializers(); + + @override + ColorXFromJsonStatic deserialize(Object? $value) { + final $serialized = assertWireType($value); + return ColorXFromJsonStatic.fromJson($serialized); + } + + @override + Object? serialize(ColorXFromJsonStatic $value) => + $serializers.serialize($value.c); +} + +final class ColorXImplSerializer extends _$celest.Serializer { + ColorXImplSerializer() { + $serializers..put( + _$celest.Serializer.define( + serialize: ($value) => $value.name, + deserialize: ($serialized) { + return Color.values.byName($serialized); + }, + ), + ); + } + + final _$celest.Serializers $serializers = _$celest.Serializers(); + + @override + ColorXImpl deserialize(Object? $value) { + final $serialized = assertWireType($value); + return ColorXImpl($serializers.deserialize($serialized)); + } + + @override + Object? serialize(ColorXImpl $value) => $serializers.serialize($value); +} + +final class ColorXSerializer extends _$celest.Serializer { + ColorXSerializer() { + $serializers..put( + _$celest.Serializer.define( + serialize: ($value) => $value.name, + deserialize: ($serialized) { + return Color.values.byName($serialized); + }, + ), + ); + } + + final _$celest.Serializers $serializers = _$celest.Serializers(); + + @override + ColorX deserialize(Object? $value) { + final $serialized = assertWireType($value); + return ColorX($serializers.deserialize($serialized)); + } + + @override + Object? serialize(ColorX $value) => $serializers.serialize($value.c); +} + +final class ColorXToFromJsonSerializer + extends _$celest.Serializer { + ColorXToFromJsonSerializer() { + $serializers..put( + _$celest.Serializer.define( + serialize: ($value) => $value.name, + deserialize: ($serialized) { + return Color.values.byName($serialized); + }, + ), + ); + } + + final _$celest.Serializers $serializers = _$celest.Serializers(); + + @override + ColorXToFromJson deserialize(Object? $value) { + final $serialized = assertWireType($value); + return ColorXToFromJson.fromJson($serialized); + } + + @override + Object? serialize(ColorXToFromJson $value) => $value.toJson(); +} + +final class ColorXToJsonImplSerializer + extends _$celest.Serializer { + ColorXToJsonImplSerializer() { + $serializers..put( + _$celest.Serializer.define( + serialize: ($value) => $value.name, + deserialize: ($serialized) { + return Color.values.byName($serialized); + }, + ), + ); + } + + final _$celest.Serializers $serializers = _$celest.Serializers(); + + @override + ColorXToJsonImpl deserialize(Object? $value) { + final $serialized = assertWireType($value); + return ColorXToJsonImpl($serializers.deserialize($serialized)); + } + + @override + Object? serialize(ColorXToJsonImpl $value) => $value.toJson(); +} + +final class ColorXToJsonSerializer extends _$celest.Serializer { + ColorXToJsonSerializer() { + $serializers..put( + _$celest.Serializer.define( + serialize: ($value) => $value.name, + deserialize: ($serialized) { + return Color.values.byName($serialized); + }, + ), + ); + } + + final _$celest.Serializers $serializers = _$celest.Serializers(); + + @override + ColorXToJson deserialize(Object? $value) { + final $serialized = assertWireType($value); + return ColorXToJson($serializers.deserialize($serialized)); + } + + @override + Object? serialize(ColorXToJson $value) => $value.toJson(); +} + +final class ErrResult_E_ShapeExceptionSerializer + extends _$celest.Serializer> { + const ErrResult_E_ShapeExceptionSerializer(); + + @override + ErrResult deserialize(Object? $value) { + final $serialized = assertWireType>($value); + return ErrResult( + _$celest.Serializers.instance.deserialize($serialized[r'error']), + ); + } + + @override + Object? serialize(ErrResult $value) => { + r'error': _$celest.Serializers.instance.serialize($value.error), + }; +} + +final class ErrResult_T_ShapeSerializer + extends _$celest.Serializer> { + const ErrResult_T_ShapeSerializer(); + + @override + ErrResult deserialize(Object? $value) { + final $serialized = assertWireType>($value); + return ErrResult( + _$celest.Serializers.instance.deserialize($serialized[r'error']), + ); + } + + @override + Object? serialize(ErrResult $value) => { + r'error': _$celest.Serializers.instance.serialize($value.error), + }; +} + +final class OkResult_E_ShapeExceptionSerializer + extends _$celest.Serializer> { + const OkResult_E_ShapeExceptionSerializer(); + + @override + OkResult deserialize(Object? $value) { + final $serialized = assertWireType>($value); + return OkResult( + _$celest.Serializers.instance.deserialize($serialized[r'data']), + ); + } + + @override + Object? serialize(OkResult $value) => { + r'data': _$celest.Serializers.instance.serialize($value.data), + }; +} + +final class OkResult_T_ShapeSerializer + extends _$celest.Serializer> { + const OkResult_T_ShapeSerializer(); + + @override + OkResult deserialize(Object? $value) { + final $serialized = assertWireType>($value); + return OkResult( + _$celest.Serializers.instance.deserialize($serialized[r'data']), + ); + } + + @override + Object? serialize(OkResult $value) => { + r'data': _$celest.Serializers.instance.serialize($value.data), + }; +} + +final class Result_E_ShapeException_T_ShapeSerializer< + E extends ShapeException, + T extends Shape +> + extends _$celest.Serializer> { + const Result_E_ShapeException_T_ShapeSerializer(); + + @override + Result deserialize(Object? $value) { + final $serialized = assertWireType>($value); + if ($serialized[r'$type'] == r'SwappedResult') { + return _$celest.Serializers.instance.deserialize>( + $serialized, + ); + } + if ($serialized[r'$type'] == r'OkResult') { + return _$celest.Serializers.instance.deserialize>( + $serialized, + ); + } + if ($serialized[r'$type'] == r'ErrResult') { + return _$celest.Serializers.instance.deserialize>( + $serialized, + ); + } + throw _$celest.SerializationException( + (StringBuffer('Unknown subtype of ') + ..write(r'Result') + ..write(': ') + ..write($serialized[r'$type'])) + .toString(), + ); + } + + @override + Object? serialize(Result $value) { + if ($value is SwappedResult) { + return { + ...(_$celest.Serializers.instance.serialize>($value) + as Map), + r'$type': r'SwappedResult', + }; + } + if ($value is OkResult) { + return { + ...(_$celest.Serializers.instance.serialize>($value) + as Map), + r'$type': r'OkResult', + }; + } + if ($value is ErrResult) { + return { + ...(_$celest.Serializers.instance.serialize>($value) + as Map), + r'$type': r'ErrResult', + }; + } + throw _$celest.SerializationException( + (StringBuffer('Unknown subtype of ') + ..write(r'Result') + ..write(': ') + ..write($value.runtimeType)) + .toString(), + ); + } +} + +final class Result_T_Shape_E_ShapeExceptionSerializer< + T extends Shape, + E extends ShapeException +> + extends _$celest.Serializer> { + const Result_T_Shape_E_ShapeExceptionSerializer(); + + @override + Result deserialize(Object? $value) { + final $serialized = assertWireType>($value); + if ($serialized[r'$type'] == r'SwappedResult') { + return _$celest.Serializers.instance.deserialize>( + $serialized, + ); + } + if ($serialized[r'$type'] == r'OkResult') { + return _$celest.Serializers.instance.deserialize>( + $serialized, + ); + } + if ($serialized[r'$type'] == r'ErrResult') { + return _$celest.Serializers.instance.deserialize>( + $serialized, + ); + } + throw _$celest.SerializationException( + (StringBuffer('Unknown subtype of ') + ..write(r'Result') + ..write(': ') + ..write($serialized[r'$type'])) + .toString(), + ); + } + + @override + Object? serialize(Result $value) { + if ($value is SwappedResult) { + return { + ...(_$celest.Serializers.instance.serialize>($value) + as Map), + r'$type': r'SwappedResult', + }; + } + if ($value is OkResult) { + return { + ...(_$celest.Serializers.instance.serialize>($value) + as Map), + r'$type': r'OkResult', + }; + } + if ($value is ErrResult) { + return { + ...(_$celest.Serializers.instance.serialize>($value) + as Map), + r'$type': r'ErrResult', + }; + } + throw _$celest.SerializationException( + (StringBuffer('Unknown subtype of ') + ..write(r'Result') + ..write(': ') + ..write($value.runtimeType)) + .toString(), + ); + } +} + +final class SwappedResult_E_ShapeException_T_ShapeSerializer< + E extends ShapeException, + T extends Shape +> + extends _$celest.Serializer> { + const SwappedResult_E_ShapeException_T_ShapeSerializer(); + + @override + SwappedResult deserialize(Object? $value) { + final $serialized = assertWireType>($value); + return SwappedResult( + _$celest.Serializers.instance.deserialize>( + $serialized[r'result'], + ), + ); + } + + @override + Object? serialize(SwappedResult $value) => { + r'result': _$celest.Serializers.instance.serialize>( + $value.result, + ), + }; +} + +final class SwappedResult_T_Shape_E_ShapeExceptionSerializer< + T extends Shape, + E extends ShapeException +> + extends _$celest.Serializer> { + const SwappedResult_T_Shape_E_ShapeExceptionSerializer(); + + @override + SwappedResult deserialize(Object? $value) { + final $serialized = assertWireType>($value); + return SwappedResult( + _$celest.Serializers.instance.deserialize>( + $serialized[r'result'], + ), + ); + } + + @override + Object? serialize(SwappedResult $value) => { + r'result': _$celest.Serializers.instance.serialize>( + $value.result, + ), + }; +} + +final class ValueXFromJsonImplSerializer + extends _$celest.Serializer { + ValueXFromJsonImplSerializer() { + $serializers..put( + _$celest.Serializer.define( + serialize: ($value) => {r'value': $value.value}, + deserialize: ($serialized) { + return Value(($serialized as String)); + }, + ), + ); + } + + final _$celest.Serializers $serializers = _$celest.Serializers(); + + @override + ValueXFromJsonImpl deserialize(Object? $value) { + final $serialized = assertWireType($value); + return ValueXFromJsonImpl.fromJson($serialized); + } + + @override + Object? serialize(ValueXFromJsonImpl $value) => $value.toJson(); +} + +final class ValueXFromJsonSerializer + extends _$celest.Serializer { + ValueXFromJsonSerializer() { + $serializers..put( + _$celest.Serializer.define>( + serialize: ($value) => {r'value': $value.value}, + deserialize: ($serialized) { + return Value(($serialized[r'value'] as String)); + }, + ), + ); + } + + final _$celest.Serializers $serializers = _$celest.Serializers(); + + @override + ValueXFromJson deserialize(Object? $value) { + final $serialized = assertWireType>($value); + return ValueXFromJson.fromJson($serialized); + } + + @override + Object? serialize(ValueXFromJson $value) => + $serializers.serialize($value.v); +} + +final class ValueXFromJsonStaticSerializer + extends _$celest.Serializer { + ValueXFromJsonStaticSerializer() { + $serializers..put( + _$celest.Serializer.define>( + serialize: ($value) => {r'value': $value.value}, + deserialize: ($serialized) { + return Value(($serialized[r'value'] as String)); + }, + ), + ); + } + + final _$celest.Serializers $serializers = _$celest.Serializers(); + + @override + ValueXFromJsonStatic deserialize(Object? $value) { + final $serialized = assertWireType>($value); + return ValueXFromJsonStatic.fromJson($serialized); + } + + @override + Object? serialize(ValueXFromJsonStatic $value) => + $serializers.serialize($value.v); +} + +final class ValueXImplSerializer extends _$celest.Serializer { + ValueXImplSerializer() { + $serializers..put( + _$celest.Serializer.define>( + serialize: ($value) => {r'value': $value.value}, + deserialize: ($serialized) { + return Value(($serialized[r'value'] as String)); + }, + ), + ); + } + + final _$celest.Serializers $serializers = _$celest.Serializers(); + + @override + ValueXImpl deserialize(Object? $value) { + final $serialized = assertWireType>($value); + return ValueXImpl($serializers.deserialize($serialized)); + } + + @override + Object? serialize(ValueXImpl $value) => $serializers.serialize($value); +} + +final class ValueXSerializer extends _$celest.Serializer { + ValueXSerializer() { + $serializers..put( + _$celest.Serializer.define>( + serialize: ($value) => {r'value': $value.value}, + deserialize: ($serialized) { + return Value(($serialized[r'value'] as String)); + }, + ), + ); + } + + final _$celest.Serializers $serializers = _$celest.Serializers(); + + @override + ValueX deserialize(Object? $value) { + final $serialized = assertWireType>($value); + return ValueX($serializers.deserialize($serialized)); + } + + @override + Object? serialize(ValueX $value) => $serializers.serialize($value.v); +} + +final class ValueXToFromJsonSerializer + extends _$celest.Serializer { + ValueXToFromJsonSerializer() { + $serializers..put( + _$celest.Serializer.define( + serialize: ($value) => {r'value': $value.value}, + deserialize: ($serialized) { + return Value(($serialized as String)); + }, + ), + ); + } + + final _$celest.Serializers $serializers = _$celest.Serializers(); + + @override + ValueXToFromJson deserialize(Object? $value) { + final $serialized = assertWireType($value); + return ValueXToFromJson.fromJson($serialized); + } + + @override + Object? serialize(ValueXToFromJson $value) => $value.toJson(); +} + +final class ValueXToJsonImplSerializer + extends _$celest.Serializer { + ValueXToJsonImplSerializer() { + $serializers..put( + _$celest.Serializer.define( + serialize: ($value) => {r'value': $value.value}, + deserialize: ($serialized) { + return Value(($serialized as String)); + }, + ), + ); + } + + final _$celest.Serializers $serializers = _$celest.Serializers(); + + @override + ValueXToJsonImpl deserialize(Object? $value) { + final $serialized = assertWireType($value); + return ValueXToJsonImpl($serializers.deserialize($serialized)); + } + + @override + Object? serialize(ValueXToJsonImpl $value) => $value.toJson(); +} + +final class ValueXToJsonSerializer extends _$celest.Serializer { + ValueXToJsonSerializer() { + $serializers..put( + _$celest.Serializer.define>( + serialize: ($value) => {r'value': $value.value}, + deserialize: ($serialized) { + return Value(($serialized[r'value'] as String)); + }, + ), + ); + } + + final _$celest.Serializers $serializers = _$celest.Serializers(); + + @override + ValueXToJson deserialize(Object? $value) { + final $serialized = assertWireType>($value); + return ValueXToJson($serializers.deserialize($serialized)); + } + + @override + Object? serialize(ValueXToJson $value) => $value.toJson(); +} diff --git a/apps/cli/fixtures/legacy/api/client/pubspec.yaml b/apps/cli/fixtures/legacy/api/client/pubspec.yaml new file mode 100644 index 000000000..8801b1840 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/client/pubspec.yaml @@ -0,0 +1,29 @@ +name: api_client +description: The Celest client for api. +publish_to: none + +environment: + sdk: ^3.4.0 + +dependencies: + celest: ^1.0.0 + celest_backend: + path: .. + celest_core: ^1.0.0 + http: ^1.0.0 + native_storage: ^0.2.2 + +dependency_overrides: + celest: + path: ../../../../../../celest/packages/celest + celest_ast: + path: ../../../../../../celest/packages/celest_ast + celest_auth: + path: ../../../../../../celest/packages/celest_auth + celest_cloud: + path: ../../../../../../celest/packages/celest_cloud + celest_cloud_auth: + path: ../../../../../../celest/services/celest_cloud_auth + celest_core: + path: ../../../../../../celest/packages/celest_core +dev_dependencies: {} diff --git a/apps/cli/fixtures/legacy/api/goldens/api.local.dart b/apps/cli/fixtures/legacy/api/goldens/api.local.dart new file mode 100644 index 000000000..86e7efd9c --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/api.local.dart @@ -0,0 +1,537 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'package:celest/src/core/context.dart' as _i222; +import 'package:celest/src/runtime/serve.dart' as _i1; + +import 'functions/asserts/assertsEnabled.dart' as _i2; +import 'functions/classes/asyncDefaultValues.dart' as _i3; +import 'functions/classes/asyncEmpty.dart' as _i4; +import 'functions/classes/asyncFields.dart' as _i5; +import 'functions/classes/asyncFromAndToJson.dart' as _i6; +import 'functions/classes/asyncMixedFields.dart' as _i7; +import 'functions/classes/asyncNamedFields.dart' as _i8; +import 'functions/classes/asyncNestedClass.dart' as _i9; +import 'functions/classes/asyncNonMapFromAndToJson.dart' as _i10; +import 'functions/classes/asyncNonMapToJson.dart' as _i11; +import 'functions/classes/asyncNonMapToJsonWithDefaults.dart' as _i12; +import 'functions/classes/asyncNullableFields.dart' as _i13; +import 'functions/classes/asyncOnlyFromJson.dart' as _i14; +import 'functions/classes/asyncOnlyToJson.dart' as _i15; +import 'functions/classes/asyncOnlyToJsonWithDefaults.dart' as _i16; +import 'functions/classes/defaultValues.dart' as _i17; +import 'functions/classes/empty.dart' as _i18; +import 'functions/classes/fields.dart' as _i19; +import 'functions/classes/fromAndToJson.dart' as _i20; +import 'functions/classes/fromJsonStatic.dart' as _i21; +import 'functions/classes/mixedFields.dart' as _i22; +import 'functions/classes/namedFields.dart' as _i23; +import 'functions/classes/nestedClass.dart' as _i24; +import 'functions/classes/nonMapFromAndToJson.dart' as _i25; +import 'functions/classes/nonMapToJson.dart' as _i26; +import 'functions/classes/nonMapToJsonWithDefaults.dart' as _i27; +import 'functions/classes/nullableFields.dart' as _i28; +import 'functions/classes/onlyFromJson.dart' as _i29; +import 'functions/classes/onlyToJson.dart' as _i30; +import 'functions/classes/onlyToJsonWithDefaults.dart' as _i31; +import 'functions/collections/complexList.dart' as _i32; +import 'functions/collections/complexMap.dart' as _i33; +import 'functions/collections/dynamicMap.dart' as _i34; +import 'functions/collections/objectMap.dart' as _i35; +import 'functions/collections/objectNullableMap.dart' as _i36; +import 'functions/collections/simpleList.dart' as _i37; +import 'functions/collections/simpleMap.dart' as _i38; +import 'functions/cycles/combineTrees.dart' as _i39; +import 'functions/cycles/createTree.dart' as _i40; +import 'functions/cycles/printTree.dart' as _i41; +import 'functions/cycles/selfReferencing.dart' as _i42; +import 'functions/demo/sayHello.dart' as _i43; +import 'functions/exceptions/throwsCustomError.dart' as _i44; +import 'functions/exceptions/throwsCustomErrorToFromJson.dart' as _i45; +import 'functions/exceptions/throwsCustomErrorWithStackTrace.dart' as _i46; +import 'functions/exceptions/throwsCustomException.dart' as _i47; +import 'functions/exceptions/throwsCustomExceptionToFromJson.dart' as _i48; +import 'functions/exceptions/throwsError.dart' as _i49; +import 'functions/exceptions/throwsException.dart' as _i50; +import 'functions/extension_types/asyncOrString.dart' as _i51; +import 'functions/extension_types/asyncString.dart' as _i52; +import 'functions/extension_types/color.dart' as _i53; +import 'functions/extension_types/colorX.dart' as _i54; +import 'functions/extension_types/colorXFromJson.dart' as _i55; +import 'functions/extension_types/colorXFromJsonImpl.dart' as _i56; +import 'functions/extension_types/colorXFromJsonStatic.dart' as _i57; +import 'functions/extension_types/colorXImpl.dart' as _i58; +import 'functions/extension_types/colorXToFromJson.dart' as _i59; +import 'functions/extension_types/colorXToJson.dart' as _i60; +import 'functions/extension_types/colorXToJsonImpl.dart' as _i61; +import 'functions/extension_types/jsonBool.dart' as _i62; +import 'functions/extension_types/jsonDouble.dart' as _i63; +import 'functions/extension_types/jsonInt.dart' as _i64; +import 'functions/extension_types/jsonList.dart' as _i65; +import 'functions/extension_types/jsonMap.dart' as _i66; +import 'functions/extension_types/jsonNum.dart' as _i67; +import 'functions/extension_types/jsonString.dart' as _i68; +import 'functions/extension_types/jsonValue.dart' as _i69; +import 'functions/extension_types/string.dart' as _i70; +import 'functions/extension_types/stringFromJson.dart' as _i71; +import 'functions/extension_types/stringFromJsonImpl.dart' as _i72; +import 'functions/extension_types/stringFromJsonStatic.dart' as _i73; +import 'functions/extension_types/stringImpl.dart' as _i74; +import 'functions/extension_types/stringPrivateCtor.dart' as _i75; +import 'functions/extension_types/stringPrivateCtorImpl.dart' as _i76; +import 'functions/extension_types/stringPrivateField.dart' as _i77; +import 'functions/extension_types/stringPrivateFieldImpl.dart' as _i78; +import 'functions/extension_types/stringToFromJson.dart' as _i79; +import 'functions/extension_types/stringToJson.dart' as _i80; +import 'functions/extension_types/stringToJsonImpl.dart' as _i81; +import 'functions/extension_types/value.dart' as _i82; +import 'functions/extension_types/valueX.dart' as _i83; +import 'functions/extension_types/valueXFromJson.dart' as _i84; +import 'functions/extension_types/valueXFromJsonImpl.dart' as _i85; +import 'functions/extension_types/valueXFromJsonStatic.dart' as _i86; +import 'functions/extension_types/valueXImpl.dart' as _i87; +import 'functions/extension_types/valueXToFromJson.dart' as _i88; +import 'functions/extension_types/valueXToJson.dart' as _i89; +import 'functions/extension_types/valueXToJsonImpl.dart' as _i90; +import 'functions/generic_wrappers/genericWrapperParameters.dart' as _i91; +import 'functions/generic_wrappers/genericWrappers.dart' as _i92; +import 'functions/generic_wrappers/genericWrappersAsync.dart' as _i93; +import 'functions/metadata/hasConstructedDeprecatedAnnotation.dart' as _i94; +import 'functions/metadata/hasDeprecatedAnnotation.dart' as _i95; +import 'functions/metadata/hasDocComments.dart' as _i96; +import 'functions/metadata/hasExportableAnnotation.dart' as _i97; +import 'functions/metadata/hasExportableConstructedAnnotation.dart' as _i98; +import 'functions/metadata/hasLiteralsAnnotation.dart' as _i99; +import 'functions/metadata/hasNamedConstructedAnnotation.dart' as _i100; +import 'functions/metadata/hasNotExportableAnnotation.dart' as _i101; +import 'functions/metadata/namedDefaultValues.dart' as _i104; +import 'functions/metadata/namedDefaultValueVars.dart' as _i102; +import 'functions/metadata/namedDefaultValueVarsPrivate.dart' as _i103; +import 'functions/metadata/nullableNamedDefaultValues.dart' as _i107; +import 'functions/metadata/nullableNamedDefaultValueVars.dart' as _i105; +import 'functions/metadata/nullableNamedDefaultValueVarsPrivate.dart' as _i106; +import 'functions/metadata/nullablePositionalDefaultValues.dart' as _i110; +import 'functions/metadata/nullablePositionalDefaultValueVars.dart' as _i108; +import 'functions/metadata/nullablePositionalDefaultValueVarsPrivate.dart' + as _i109; +import 'functions/metadata/positionalDefaultValues.dart' as _i113; +import 'functions/metadata/positionalDefaultValueVars.dart' as _i111; +import 'functions/metadata/positionalDefaultValueVarsPrivate.dart' as _i112; +import 'functions/overrides/callsThrowsCommonOverriddenException.dart' as _i114; +import 'functions/overrides/callsThrowsOverriddenException.dart' as _i115; +import 'functions/overrides/commonNestedChild.dart' as _i116; +import 'functions/overrides/commonNestedParent.dart' as _i117; +import 'functions/overrides/nestedChild.dart' as _i118; +import 'functions/overrides/nestedGrandparent.dart' as _i119; +import 'functions/overrides/nestedParent.dart' as _i120; +import 'functions/overrides/throwsCommonOverriddenException.dart' as _i121; +import 'functions/overrides/throwsOverriddenException.dart' as _i122; +import 'functions/parameter_types/complex.dart' as _i123; +import 'functions/parameter_types/simple.dart' as _i124; +import 'functions/parameter_types/simpleOptional.dart' as _i125; +import 'functions/parameters/optionalNamed.dart' as _i126; +import 'functions/parameters/optionalPositional.dart' as _i127; +import 'functions/parameters/requiredNamed.dart' as _i128; +import 'functions/parameters/requiredPositional.dart' as _i129; +import 'functions/records/aliasedNamedFields.dart' as _i130; +import 'functions/records/asyncAliasedNamedFields.dart' as _i131; +import 'functions/records/asyncNamedFields.dart' as _i132; +import 'functions/records/asyncNested.dart' as _i133; +import 'functions/records/asyncNonAliasedNamedFields.dart' as _i134; +import 'functions/records/asyncNullableNested.dart' as _i135; +import 'functions/records/namedFields.dart' as _i136; +import 'functions/records/nested.dart' as _i137; +import 'functions/records/nonAliasedNamedFields.dart' as _i138; +import 'functions/records/nullableNested.dart' as _i139; +import 'functions/return_types/asyncBoolReturn.dart' as _i140; +import 'functions/return_types/asyncClassReturnNullable.dart' as _i141; +import 'functions/return_types/asyncComplexClassReturn.dart' as _i142; +import 'functions/return_types/asyncComplexStructReturn.dart' as _i143; +import 'functions/return_types/asyncComplexStructReturnNullable.dart' as _i144; +import 'functions/return_types/asyncDoubleReturn.dart' as _i145; +import 'functions/return_types/asyncIntReturn.dart' as _i146; +import 'functions/return_types/asyncIterableReturn.dart' as _i147; +import 'functions/return_types/asyncListReturn.dart' as _i148; +import 'functions/return_types/asyncMapReturn.dart' as _i149; +import 'functions/return_types/asyncOrBoolReturn.dart' as _i150; +import 'functions/return_types/asyncOrBoolReturnNullable.dart' as _i151; +import 'functions/return_types/asyncOrComplexClassReturnNullable.dart' as _i152; +import 'functions/return_types/asyncOrComplexStructReturn.dart' as _i153; +import 'functions/return_types/asyncOrComplexStructReturnNullable.dart' + as _i154; +import 'functions/return_types/asyncOrDoubleReturn.dart' as _i155; +import 'functions/return_types/asyncOrDoubleReturnNullable.dart' as _i156; +import 'functions/return_types/asyncOrIntReturn.dart' as _i157; +import 'functions/return_types/asyncOrIntReturnNullable.dart' as _i158; +import 'functions/return_types/asyncOrIterableReturn.dart' as _i159; +import 'functions/return_types/asyncOrIterableReturnNullable.dart' as _i160; +import 'functions/return_types/asyncOrListReturn.dart' as _i161; +import 'functions/return_types/asyncOrListReturnNullable.dart' as _i162; +import 'functions/return_types/asyncOrMapReturn.dart' as _i163; +import 'functions/return_types/asyncOrMapReturnNullable.dart' as _i164; +import 'functions/return_types/asyncOrSimpleClassReturnNullable.dart' as _i165; +import 'functions/return_types/asyncOrStringReturn.dart' as _i166; +import 'functions/return_types/asyncOrStringReturnNullable.dart' as _i167; +import 'functions/return_types/asyncOrStructReturn.dart' as _i168; +import 'functions/return_types/asyncOrStructReturnNullable.dart' as _i169; +import 'functions/return_types/asyncOrVoidReturn.dart' as _i170; +import 'functions/return_types/asyncOrVoidReturnNullable.dart' as _i171; +import 'functions/return_types/asyncStringReturn.dart' as _i172; +import 'functions/return_types/asyncStructReturn.dart' as _i173; +import 'functions/return_types/asyncStructReturnNullable.dart' as _i174; +import 'functions/return_types/asyncVoidReturn.dart' as _i175; +import 'functions/return_types/boolReturn.dart' as _i176; +import 'functions/return_types/boolReturnNullable.dart' as _i177; +import 'functions/return_types/complexClassReturn.dart' as _i178; +import 'functions/return_types/complexClassReturnNullable.dart' as _i179; +import 'functions/return_types/complexReturn.dart' as _i180; +import 'functions/return_types/complexReturnNullable.dart' as _i181; +import 'functions/return_types/doubleReturn.dart' as _i182; +import 'functions/return_types/doubleReturnNullable.dart' as _i183; +import 'functions/return_types/intReturn.dart' as _i184; +import 'functions/return_types/intReturnNullable.dart' as _i185; +import 'functions/return_types/iterableReturn.dart' as _i186; +import 'functions/return_types/iterableReturnNullable.dart' as _i187; +import 'functions/return_types/listReturn.dart' as _i188; +import 'functions/return_types/listReturnNullable.dart' as _i189; +import 'functions/return_types/mapReturn.dart' as _i190; +import 'functions/return_types/mapReturnNullable.dart' as _i191; +import 'functions/return_types/simpleClassReturn.dart' as _i192; +import 'functions/return_types/simpleClassReturnNullable.dart' as _i193; +import 'functions/return_types/stringReturn.dart' as _i194; +import 'functions/return_types/stringReturnNullable.dart' as _i195; +import 'functions/return_types/structReturn.dart' as _i196; +import 'functions/return_types/structReturnNullable.dart' as _i197; +import 'functions/return_types/voidReturn.dart' as _i198; +import 'functions/sealed_classes/aliasedErrShapeResults.dart' as _i199; +import 'functions/sealed_classes/aliasedOkShapeResults.dart' as _i200; +import 'functions/sealed_classes/aliasedShapeResults.dart' as _i201; +import 'functions/sealed_classes/area.dart' as _i202; +import 'functions/sealed_classes/circle.dart' as _i203; +import 'functions/sealed_classes/circleWithOverriddenCustomJson.dart' as _i204; +import 'functions/sealed_classes/errShapeResults.dart' as _i205; +import 'functions/sealed_classes/genericResult.dart' as _i206; +import 'functions/sealed_classes/multipleGenericResult.dart' as _i207; +import 'functions/sealed_classes/okShapeResult.dart' as _i208; +import 'functions/sealed_classes/okShapeResults.dart' as _i209; +import 'functions/sealed_classes/rectangle.dart' as _i210; +import 'functions/sealed_classes/rectangleWithOverriddenCustomJson.dart' + as _i211; +import 'functions/sealed_classes/sealedClass.dart' as _i212; +import 'functions/sealed_classes/sealedClassWithCustomJson.dart' as _i213; +import 'functions/sealed_classes/sealedClassWithInheritedCustomJson.dart' + as _i214; +import 'functions/sealed_classes/sealedClassWithOverriddenCustomJson.dart' + as _i215; +import 'functions/sealed_classes/shapeResults.dart' as _i216; +import 'functions/sealed_classes/swappedResult.dart' as _i217; +import 'functions/typedefs/json.dart' as _i218; +import 'functions/typedefs/mixedJson.dart' as _i219; +import 'functions/typedefs/nullableJson.dart' as _i220; +import 'functions/typedefs/portfolio.dart' as _i221; + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: { + '/asserts/asserts-enabled': _i2.AssertsEnabledTarget(), + '/classes/async-default-values': _i3.AsyncDefaultValuesTarget(), + '/classes/async-empty': _i4.AsyncEmptyTarget(), + '/classes/async-fields': _i5.AsyncFieldsTarget(), + '/classes/async-from-and-to-json': _i6.AsyncFromAndToJsonTarget(), + '/classes/async-mixed-fields': _i7.AsyncMixedFieldsTarget(), + '/classes/async-named-fields': _i8.AsyncNamedFieldsTarget(), + '/classes/async-nested-class': _i9.AsyncNestedClassTarget(), + '/classes/async-non-map-from-and-to-json': + _i10.AsyncNonMapFromAndToJsonTarget(), + '/classes/async-non-map-to-json': _i11.AsyncNonMapToJsonTarget(), + '/classes/async-non-map-to-json-with-defaults': + _i12.AsyncNonMapToJsonWithDefaultsTarget(), + '/classes/async-nullable-fields': _i13.AsyncNullableFieldsTarget(), + '/classes/async-only-from-json': _i14.AsyncOnlyFromJsonTarget(), + '/classes/async-only-to-json': _i15.AsyncOnlyToJsonTarget(), + '/classes/async-only-to-json-with-defaults': + _i16.AsyncOnlyToJsonWithDefaultsTarget(), + '/classes/default-values': _i17.DefaultValuesTarget(), + '/classes/empty': _i18.EmptyTarget(), + '/classes/fields': _i19.FieldsTarget(), + '/classes/from-and-to-json': _i20.FromAndToJsonTarget(), + '/classes/from-json-static': _i21.FromJsonStaticTarget(), + '/classes/mixed-fields': _i22.MixedFieldsTarget(), + '/classes/named-fields': _i23.NamedFieldsTarget(), + '/classes/nested-class': _i24.NestedClassTarget(), + '/classes/non-map-from-and-to-json': _i25.NonMapFromAndToJsonTarget(), + '/classes/non-map-to-json': _i26.NonMapToJsonTarget(), + '/classes/non-map-to-json-with-defaults': + _i27.NonMapToJsonWithDefaultsTarget(), + '/classes/nullable-fields': _i28.NullableFieldsTarget(), + '/classes/only-from-json': _i29.OnlyFromJsonTarget(), + '/classes/only-to-json': _i30.OnlyToJsonTarget(), + '/classes/only-to-json-with-defaults': + _i31.OnlyToJsonWithDefaultsTarget(), + '/collections/complex-list': _i32.ComplexListTarget(), + '/collections/complex-map': _i33.ComplexMapTarget(), + '/collections/dynamic-map': _i34.DynamicMapTarget(), + '/collections/object-map': _i35.ObjectMapTarget(), + '/collections/object-nullable-map': _i36.ObjectNullableMapTarget(), + '/collections/simple-list': _i37.SimpleListTarget(), + '/collections/simple-map': _i38.SimpleMapTarget(), + '/cycles/combine-trees': _i39.CombineTreesTarget(), + '/cycles/create-tree': _i40.CreateTreeTarget(), + '/cycles/print-tree': _i41.PrintTreeTarget(), + '/cycles/self-referencing': _i42.SelfReferencingTarget(), + '/demo/say-hello': _i43.SayHelloTarget(), + '/exceptions/throws-custom-error': _i44.ThrowsCustomErrorTarget(), + '/exceptions/throws-custom-error-to-from-json': + _i45.ThrowsCustomErrorToFromJsonTarget(), + '/exceptions/throws-custom-error-with-stack-trace': + _i46.ThrowsCustomErrorWithStackTraceTarget(), + '/exceptions/throws-custom-exception': _i47.ThrowsCustomExceptionTarget(), + '/exceptions/throws-custom-exception-to-from-json': + _i48.ThrowsCustomExceptionToFromJsonTarget(), + '/exceptions/throws-error': _i49.ThrowsErrorTarget(), + '/exceptions/throws-exception': _i50.ThrowsExceptionTarget(), + '/extension-types/async-or-string': _i51.AsyncOrStringTarget(), + '/extension-types/async-string': _i52.AsyncStringTarget(), + '/extension-types/color': _i53.ColorTarget(), + '/extension-types/color-x': _i54.ColorXTarget(), + '/extension-types/color-x-from-json': _i55.ColorXFromJsonTarget(), + '/extension-types/color-x-from-json-impl': + _i56.ColorXFromJsonImplTarget(), + '/extension-types/color-x-from-json-static': + _i57.ColorXFromJsonStaticTarget(), + '/extension-types/color-x-impl': _i58.ColorXImplTarget(), + '/extension-types/color-x-to-from-json': _i59.ColorXToFromJsonTarget(), + '/extension-types/color-x-to-json': _i60.ColorXToJsonTarget(), + '/extension-types/color-x-to-json-impl': _i61.ColorXToJsonImplTarget(), + '/extension-types/json-bool': _i62.JsonBoolTarget(), + '/extension-types/json-double': _i63.JsonDoubleTarget(), + '/extension-types/json-int': _i64.JsonIntTarget(), + '/extension-types/json-list': _i65.JsonListTarget(), + '/extension-types/json-map': _i66.JsonMapTarget(), + '/extension-types/json-num': _i67.JsonNumTarget(), + '/extension-types/json-string': _i68.JsonStringTarget(), + '/extension-types/json-value': _i69.JsonValueTarget(), + '/extension-types/string': _i70.StringTarget(), + '/extension-types/string-from-json': _i71.StringFromJsonTarget(), + '/extension-types/string-from-json-impl': _i72.StringFromJsonImplTarget(), + '/extension-types/string-from-json-static': + _i73.StringFromJsonStaticTarget(), + '/extension-types/string-impl': _i74.StringImplTarget(), + '/extension-types/string-private-ctor': _i75.StringPrivateCtorTarget(), + '/extension-types/string-private-ctor-impl': + _i76.StringPrivateCtorImplTarget(), + '/extension-types/string-private-field': _i77.StringPrivateFieldTarget(), + '/extension-types/string-private-field-impl': + _i78.StringPrivateFieldImplTarget(), + '/extension-types/string-to-from-json': _i79.StringToFromJsonTarget(), + '/extension-types/string-to-json': _i80.StringToJsonTarget(), + '/extension-types/string-to-json-impl': _i81.StringToJsonImplTarget(), + '/extension-types/value': _i82.ValueTarget(), + '/extension-types/value-x': _i83.ValueXTarget(), + '/extension-types/value-x-from-json': _i84.ValueXFromJsonTarget(), + '/extension-types/value-x-from-json-impl': + _i85.ValueXFromJsonImplTarget(), + '/extension-types/value-x-from-json-static': + _i86.ValueXFromJsonStaticTarget(), + '/extension-types/value-x-impl': _i87.ValueXImplTarget(), + '/extension-types/value-x-to-from-json': _i88.ValueXToFromJsonTarget(), + '/extension-types/value-x-to-json': _i89.ValueXToJsonTarget(), + '/extension-types/value-x-to-json-impl': _i90.ValueXToJsonImplTarget(), + '/generic-wrappers/generic-wrapper-parameters': + _i91.GenericWrapperParametersTarget(), + '/generic-wrappers/generic-wrappers': _i92.GenericWrappersTarget(), + '/generic-wrappers/generic-wrappers-async': + _i93.GenericWrappersAsyncTarget(), + '/metadata/has-constructed-deprecated-annotation': + _i94.HasConstructedDeprecatedAnnotationTarget(), + '/metadata/has-deprecated-annotation': + _i95.HasDeprecatedAnnotationTarget(), + '/metadata/has-doc-comments': _i96.HasDocCommentsTarget(), + '/metadata/has-exportable-annotation': + _i97.HasExportableAnnotationTarget(), + '/metadata/has-exportable-constructed-annotation': + _i98.HasExportableConstructedAnnotationTarget(), + '/metadata/has-literals-annotation': _i99.HasLiteralsAnnotationTarget(), + '/metadata/has-named-constructed-annotation': + _i100.HasNamedConstructedAnnotationTarget(), + '/metadata/has-not-exportable-annotation': + _i101.HasNotExportableAnnotationTarget(), + '/metadata/named-default-value-vars': _i102.NamedDefaultValueVarsTarget(), + '/metadata/named-default-value-vars-private': + _i103.NamedDefaultValueVarsPrivateTarget(), + '/metadata/named-default-values': _i104.NamedDefaultValuesTarget(), + '/metadata/nullable-named-default-value-vars': + _i105.NullableNamedDefaultValueVarsTarget(), + '/metadata/nullable-named-default-value-vars-private': + _i106.NullableNamedDefaultValueVarsPrivateTarget(), + '/metadata/nullable-named-default-values': + _i107.NullableNamedDefaultValuesTarget(), + '/metadata/nullable-positional-default-value-vars': + _i108.NullablePositionalDefaultValueVarsTarget(), + '/metadata/nullable-positional-default-value-vars-private': + _i109.NullablePositionalDefaultValueVarsPrivateTarget(), + '/metadata/nullable-positional-default-values': + _i110.NullablePositionalDefaultValuesTarget(), + '/metadata/positional-default-value-vars': + _i111.PositionalDefaultValueVarsTarget(), + '/metadata/positional-default-value-vars-private': + _i112.PositionalDefaultValueVarsPrivateTarget(), + '/metadata/positional-default-values': + _i113.PositionalDefaultValuesTarget(), + '/overrides/calls-throws-common-overridden-exception': + _i114.CallsThrowsCommonOverriddenExceptionTarget(), + '/overrides/calls-throws-overridden-exception': + _i115.CallsThrowsOverriddenExceptionTarget(), + '/overrides/common-nested-child': _i116.CommonNestedChildTarget(), + '/overrides/common-nested-parent': _i117.CommonNestedParentTarget(), + '/overrides/nested-child': _i118.NestedChildTarget(), + '/overrides/nested-grandparent': _i119.NestedGrandparentTarget(), + '/overrides/nested-parent': _i120.NestedParentTarget(), + '/overrides/throws-common-overridden-exception': + _i121.ThrowsCommonOverriddenExceptionTarget(), + '/overrides/throws-overridden-exception': + _i122.ThrowsOverriddenExceptionTarget(), + '/parameter-types/complex': _i123.ComplexTarget(), + '/parameter-types/simple': _i124.SimpleTarget(), + '/parameter-types/simple-optional': _i125.SimpleOptionalTarget(), + '/parameters/optional-named': _i126.OptionalNamedTarget(), + '/parameters/optional-positional': _i127.OptionalPositionalTarget(), + '/parameters/required-named': _i128.RequiredNamedTarget(), + '/parameters/required-positional': _i129.RequiredPositionalTarget(), + '/records/aliased-named-fields': _i130.AliasedNamedFieldsTarget(), + '/records/async-aliased-named-fields': + _i131.AsyncAliasedNamedFieldsTarget(), + '/records/async-named-fields': _i132.AsyncNamedFieldsTarget(), + '/records/async-nested': _i133.AsyncNestedTarget(), + '/records/async-non-aliased-named-fields': + _i134.AsyncNonAliasedNamedFieldsTarget(), + '/records/async-nullable-nested': _i135.AsyncNullableNestedTarget(), + '/records/named-fields': _i136.NamedFieldsTarget(), + '/records/nested': _i137.NestedTarget(), + '/records/non-aliased-named-fields': _i138.NonAliasedNamedFieldsTarget(), + '/records/nullable-nested': _i139.NullableNestedTarget(), + '/return-types/async-bool-return': _i140.AsyncBoolReturnTarget(), + '/return-types/async-class-return-nullable': + _i141.AsyncClassReturnNullableTarget(), + '/return-types/async-complex-class-return': + _i142.AsyncComplexClassReturnTarget(), + '/return-types/async-complex-struct-return': + _i143.AsyncComplexStructReturnTarget(), + '/return-types/async-complex-struct-return-nullable': + _i144.AsyncComplexStructReturnNullableTarget(), + '/return-types/async-double-return': _i145.AsyncDoubleReturnTarget(), + '/return-types/async-int-return': _i146.AsyncIntReturnTarget(), + '/return-types/async-iterable-return': _i147.AsyncIterableReturnTarget(), + '/return-types/async-list-return': _i148.AsyncListReturnTarget(), + '/return-types/async-map-return': _i149.AsyncMapReturnTarget(), + '/return-types/async-or-bool-return': _i150.AsyncOrBoolReturnTarget(), + '/return-types/async-or-bool-return-nullable': + _i151.AsyncOrBoolReturnNullableTarget(), + '/return-types/async-or-complex-class-return-nullable': + _i152.AsyncOrComplexClassReturnNullableTarget(), + '/return-types/async-or-complex-struct-return': + _i153.AsyncOrComplexStructReturnTarget(), + '/return-types/async-or-complex-struct-return-nullable': + _i154.AsyncOrComplexStructReturnNullableTarget(), + '/return-types/async-or-double-return': _i155.AsyncOrDoubleReturnTarget(), + '/return-types/async-or-double-return-nullable': + _i156.AsyncOrDoubleReturnNullableTarget(), + '/return-types/async-or-int-return': _i157.AsyncOrIntReturnTarget(), + '/return-types/async-or-int-return-nullable': + _i158.AsyncOrIntReturnNullableTarget(), + '/return-types/async-or-iterable-return': + _i159.AsyncOrIterableReturnTarget(), + '/return-types/async-or-iterable-return-nullable': + _i160.AsyncOrIterableReturnNullableTarget(), + '/return-types/async-or-list-return': _i161.AsyncOrListReturnTarget(), + '/return-types/async-or-list-return-nullable': + _i162.AsyncOrListReturnNullableTarget(), + '/return-types/async-or-map-return': _i163.AsyncOrMapReturnTarget(), + '/return-types/async-or-map-return-nullable': + _i164.AsyncOrMapReturnNullableTarget(), + '/return-types/async-or-simple-class-return-nullable': + _i165.AsyncOrSimpleClassReturnNullableTarget(), + '/return-types/async-or-string-return': _i166.AsyncOrStringReturnTarget(), + '/return-types/async-or-string-return-nullable': + _i167.AsyncOrStringReturnNullableTarget(), + '/return-types/async-or-struct-return': _i168.AsyncOrStructReturnTarget(), + '/return-types/async-or-struct-return-nullable': + _i169.AsyncOrStructReturnNullableTarget(), + '/return-types/async-or-void-return': _i170.AsyncOrVoidReturnTarget(), + '/return-types/async-or-void-return-nullable': + _i171.AsyncOrVoidReturnNullableTarget(), + '/return-types/async-string-return': _i172.AsyncStringReturnTarget(), + '/return-types/async-struct-return': _i173.AsyncStructReturnTarget(), + '/return-types/async-struct-return-nullable': + _i174.AsyncStructReturnNullableTarget(), + '/return-types/async-void-return': _i175.AsyncVoidReturnTarget(), + '/return-types/bool-return': _i176.BoolReturnTarget(), + '/return-types/bool-return-nullable': _i177.BoolReturnNullableTarget(), + '/return-types/complex-class-return': _i178.ComplexClassReturnTarget(), + '/return-types/complex-class-return-nullable': + _i179.ComplexClassReturnNullableTarget(), + '/return-types/complex-return': _i180.ComplexReturnTarget(), + '/return-types/complex-return-nullable': + _i181.ComplexReturnNullableTarget(), + '/return-types/double-return': _i182.DoubleReturnTarget(), + '/return-types/double-return-nullable': + _i183.DoubleReturnNullableTarget(), + '/return-types/int-return': _i184.IntReturnTarget(), + '/return-types/int-return-nullable': _i185.IntReturnNullableTarget(), + '/return-types/iterable-return': _i186.IterableReturnTarget(), + '/return-types/iterable-return-nullable': + _i187.IterableReturnNullableTarget(), + '/return-types/list-return': _i188.ListReturnTarget(), + '/return-types/list-return-nullable': _i189.ListReturnNullableTarget(), + '/return-types/map-return': _i190.MapReturnTarget(), + '/return-types/map-return-nullable': _i191.MapReturnNullableTarget(), + '/return-types/simple-class-return': _i192.SimpleClassReturnTarget(), + '/return-types/simple-class-return-nullable': + _i193.SimpleClassReturnNullableTarget(), + '/return-types/string-return': _i194.StringReturnTarget(), + '/return-types/string-return-nullable': + _i195.StringReturnNullableTarget(), + '/return-types/struct-return': _i196.StructReturnTarget(), + '/return-types/struct-return-nullable': + _i197.StructReturnNullableTarget(), + '/return-types/void-return': _i198.VoidReturnTarget(), + '/sealed-classes/aliased-err-shape-results': + _i199.AliasedErrShapeResultsTarget(), + '/sealed-classes/aliased-ok-shape-results': + _i200.AliasedOkShapeResultsTarget(), + '/sealed-classes/aliased-shape-results': + _i201.AliasedShapeResultsTarget(), + '/sealed-classes/area': _i202.AreaTarget(), + '/sealed-classes/circle': _i203.CircleTarget(), + '/sealed-classes/circle-with-overridden-custom-json': + _i204.CircleWithOverriddenCustomJsonTarget(), + '/sealed-classes/err-shape-results': _i205.ErrShapeResultsTarget(), + '/sealed-classes/generic-result': _i206.GenericResultTarget(), + '/sealed-classes/multiple-generic-result': + _i207.MultipleGenericResultTarget(), + '/sealed-classes/ok-shape-result': _i208.OkShapeResultTarget(), + '/sealed-classes/ok-shape-results': _i209.OkShapeResultsTarget(), + '/sealed-classes/rectangle': _i210.RectangleTarget(), + '/sealed-classes/rectangle-with-overridden-custom-json': + _i211.RectangleWithOverriddenCustomJsonTarget(), + '/sealed-classes/sealed-class': _i212.SealedClassTarget(), + '/sealed-classes/sealed-class-with-custom-json': + _i213.SealedClassWithCustomJsonTarget(), + '/sealed-classes/sealed-class-with-inherited-custom-json': + _i214.SealedClassWithInheritedCustomJsonTarget(), + '/sealed-classes/sealed-class-with-overridden-custom-json': + _i215.SealedClassWithOverriddenCustomJsonTarget(), + '/sealed-classes/shape-results': _i216.ShapeResultsTarget(), + '/sealed-classes/swapped-result': _i217.SwappedResultTarget(), + '/typedefs/json': _i218.JsonTarget(), + '/typedefs/mixed-json': _i219.MixedJsonTarget(), + '/typedefs/nullable-json': _i220.NullableJsonTarget(), + '/typedefs/portfolio': _i221.PortfolioTarget(), + }, + setup: (_i222.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/ast.json b/apps/cli/fixtures/legacy/api/goldens/ast.json new file mode 100644 index 000000000..59660ef57 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/ast.json @@ -0,0 +1,33747 @@ +{ + "name": "api", + "environment": "local", + "reference": { + "$": "Reference", + "symbol": "project", + "url": "package:celest_backend/src/project.dart" + }, + "apis": { + "records": { + "name": "records", + "metadata": [], + "functions": { + "nonAliasedNamedFields": { + "name": "nonAliasedNamedFields", + "apiName": "records", + "typeParameters": [], + "parameters": [ + { + "name": "value", + "type": { + "$": "RecordType", + "namedFieldTypes": { + "anotherField": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + "field": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + }, + "isNullable": false + }, + "required": true, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 328, + "uri": "package:celest_backend/src/functions/records.dart", + "line": 15, + "column": 5 + }, + "end": { + "offset": 333, + "uri": "package:celest_backend/src/functions/records.dart", + "line": 15, + "column": 10 + }, + "text": "value" + } + } + ], + "returnType": { + "$": "RecordType", + "namedFieldTypes": { + "anotherField": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + "field": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + }, + "isNullable": false + }, + "flattenedReturnType": { + "$": "RecordType", + "namedFieldTypes": { + "anotherField": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + "field": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + }, + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 242, + "uri": "package:celest_backend/src/functions/records.dart", + "line": 11, + "column": 3 + }, + "end": { + "offset": 263, + "uri": "package:celest_backend/src/functions/records.dart", + "line": 11, + "column": 24 + }, + "text": "nonAliasedNamedFields" + } + }, + "asyncNonAliasedNamedFields": { + "name": "asyncNonAliasedNamedFields", + "apiName": "records", + "typeParameters": [], + "parameters": [ + { + "name": "value", + "type": { + "$": "RecordType", + "namedFieldTypes": { + "anotherField": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + "field": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + }, + "isNullable": false + }, + "required": true, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 520, + "uri": "package:celest_backend/src/functions/records.dart", + "line": 27, + "column": 5 + }, + "end": { + "offset": 525, + "uri": "package:celest_backend/src/functions/records.dart", + "line": 27, + "column": 10 + }, + "text": "value" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "Future", + "url": "dart:async", + "types": [ + { + "$": "RecordType", + "namedFieldTypes": { + "anotherField": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + "field": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + }, + "isNullable": false + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "RecordType", + "namedFieldTypes": { + "anotherField": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + "field": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + }, + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 429, + "uri": "package:celest_backend/src/functions/records.dart", + "line": 23, + "column": 8 + }, + "end": { + "offset": 455, + "uri": "package:celest_backend/src/functions/records.dart", + "line": 23, + "column": 34 + }, + "text": "asyncNonAliasedNamedFields" + } + }, + "aliasedNamedFields": { + "name": "aliasedNamedFields", + "apiName": "records", + "typeParameters": [], + "parameters": [ + { + "name": "value", + "type": { + "$": "TypeReference", + "symbol": "NamedFieldsRecord", + "url": "package:celest_backend/models/records.dart", + "isNullable": false + }, + "required": true, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 626, + "uri": "package:celest_backend/src/functions/records.dart", + "line": 33, + "column": 29 + }, + "end": { + "offset": 631, + "uri": "package:celest_backend/src/functions/records.dart", + "line": 33, + "column": 34 + }, + "text": "value" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "NamedFieldsRecord", + "url": "package:celest_backend/models/records.dart", + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "NamedFieldsRecord", + "url": "package:celest_backend/models/records.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 576, + "uri": "package:celest_backend/src/functions/records.dart", + "line": 32, + "column": 18 + }, + "end": { + "offset": 594, + "uri": "package:celest_backend/src/functions/records.dart", + "line": 32, + "column": 36 + }, + "text": "aliasedNamedFields" + } + }, + "asyncAliasedNamedFields": { + "name": "asyncAliasedNamedFields", + "apiName": "records", + "typeParameters": [], + "parameters": [ + { + "name": "value", + "type": { + "$": "TypeReference", + "symbol": "NamedFieldsRecord", + "url": "package:celest_backend/models/records.dart", + "isNullable": false + }, + "required": true, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 738, + "uri": "package:celest_backend/src/functions/records.dart", + "line": 38, + "column": 29 + }, + "end": { + "offset": 743, + "uri": "package:celest_backend/src/functions/records.dart", + "line": 38, + "column": 34 + }, + "text": "value" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "Future", + "url": "dart:async", + "types": [ + { + "$": "RecordType", + "namedFieldTypes": { + "anotherField": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + "field": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + }, + "isNullable": false + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "NamedFieldsRecord", + "url": "package:celest_backend/models/records.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 683, + "uri": "package:celest_backend/src/functions/records.dart", + "line": 37, + "column": 26 + }, + "end": { + "offset": 706, + "uri": "package:celest_backend/src/functions/records.dart", + "line": 37, + "column": 49 + }, + "text": "asyncAliasedNamedFields" + } + }, + "namedFields": { + "name": "namedFields", + "apiName": "records", + "typeParameters": [], + "parameters": [ + { + "name": "nonAliased", + "type": { + "$": "RecordType", + "namedFieldTypes": { + "anotherField": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + "field": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + }, + "isNullable": false + }, + "required": true, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 952, + "uri": "package:celest_backend/src/functions/records.dart", + "line": 53, + "column": 5 + }, + "end": { + "offset": 962, + "uri": "package:celest_backend/src/functions/records.dart", + "line": 53, + "column": 15 + }, + "text": "nonAliased" + } + }, + { + "name": "aliased", + "type": { + "$": "TypeReference", + "symbol": "NamedFieldsRecord", + "url": "package:celest_backend/models/records.dart", + "isNullable": false + }, + "required": true, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 993, + "uri": "package:celest_backend/src/functions/records.dart", + "line": 54, + "column": 29 + }, + "end": { + "offset": 1000, + "uri": "package:celest_backend/src/functions/records.dart", + "line": 54, + "column": 36 + }, + "text": "aliased" + } + } + ], + "returnType": { + "$": "RecordType", + "namedFieldTypes": { + "aliased": { + "$": "TypeReference", + "symbol": "NamedFieldsRecord", + "url": "package:celest_backend/models/records.dart", + "isNullable": false + }, + "nonAliased": { + "$": "RecordType", + "namedFieldTypes": { + "anotherField": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + "field": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + }, + "isNullable": false + } + }, + "isNullable": false + }, + "flattenedReturnType": { + "$": "RecordType", + "namedFieldTypes": { + "aliased": { + "$": "TypeReference", + "symbol": "NamedFieldsRecord", + "url": "package:celest_backend/models/records.dart", + "isNullable": false + }, + "nonAliased": { + "$": "RecordType", + "namedFieldTypes": { + "anotherField": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + "field": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + }, + "isNullable": false + } + }, + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 876, + "uri": "package:celest_backend/src/functions/records.dart", + "line": 49, + "column": 3 + }, + "end": { + "offset": 887, + "uri": "package:celest_backend/src/functions/records.dart", + "line": 49, + "column": 14 + }, + "text": "namedFields" + } + }, + "asyncNamedFields": { + "name": "asyncNamedFields", + "apiName": "records", + "typeParameters": [], + "parameters": [ + { + "name": "nonAliased", + "type": { + "$": "RecordType", + "namedFieldTypes": { + "anotherField": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + "field": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + }, + "isNullable": false + }, + "required": true, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 1300, + "uri": "package:celest_backend/src/functions/records.dart", + "line": 72, + "column": 5 + }, + "end": { + "offset": 1310, + "uri": "package:celest_backend/src/functions/records.dart", + "line": 72, + "column": 15 + }, + "text": "nonAliased" + } + }, + { + "name": "aliased", + "type": { + "$": "TypeReference", + "symbol": "NamedFieldsRecord", + "url": "package:celest_backend/models/records.dart", + "isNullable": false + }, + "required": true, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 1341, + "uri": "package:celest_backend/src/functions/records.dart", + "line": 73, + "column": 29 + }, + "end": { + "offset": 1348, + "uri": "package:celest_backend/src/functions/records.dart", + "line": 73, + "column": 36 + }, + "text": "aliased" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "Future", + "url": "dart:async", + "types": [ + { + "$": "RecordType", + "namedFieldTypes": { + "aliased": { + "$": "TypeReference", + "symbol": "NamedFieldsRecord", + "url": "package:celest_backend/models/records.dart", + "isNullable": false + }, + "nonAliased": { + "$": "RecordType", + "namedFieldTypes": { + "anotherField": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + "field": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + }, + "isNullable": false + } + }, + "isNullable": false + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "RecordType", + "namedFieldTypes": { + "aliased": { + "$": "TypeReference", + "symbol": "NamedFieldsRecord", + "url": "package:celest_backend/models/records.dart", + "isNullable": false + }, + "nonAliased": { + "$": "RecordType", + "namedFieldTypes": { + "anotherField": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + "field": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + }, + "isNullable": false + } + }, + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 1219, + "uri": "package:celest_backend/src/functions/records.dart", + "line": 68, + "column": 8 + }, + "end": { + "offset": 1235, + "uri": "package:celest_backend/src/functions/records.dart", + "line": 68, + "column": 24 + }, + "text": "asyncNamedFields" + } + }, + "nested": { + "name": "nested", + "apiName": "records", + "typeParameters": [], + "parameters": [ + { + "name": "value", + "type": { + "$": "TypeReference", + "symbol": "Nested", + "url": "package:celest_backend/models/records.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 1458, + "uri": "package:celest_backend/src/functions/records.dart", + "line": 81, + "column": 21 + }, + "end": { + "offset": 1463, + "uri": "package:celest_backend/src/functions/records.dart", + "line": 81, + "column": 26 + }, + "text": "value" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "Nested", + "url": "package:celest_backend/models/records.dart", + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "Nested", + "url": "package:celest_backend/models/records.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 1444, + "uri": "package:celest_backend/src/functions/records.dart", + "line": 81, + "column": 7 + }, + "end": { + "offset": 1450, + "uri": "package:celest_backend/src/functions/records.dart", + "line": 81, + "column": 13 + }, + "text": "nested" + } + }, + "asyncNested": { + "name": "asyncNested", + "apiName": "records", + "typeParameters": [], + "parameters": [ + { + "name": "value", + "type": { + "$": "TypeReference", + "symbol": "Nested", + "url": "package:celest_backend/models/records.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 1516, + "uri": "package:celest_backend/src/functions/records.dart", + "line": 83, + "column": 34 + }, + "end": { + "offset": 1521, + "uri": "package:celest_backend/src/functions/records.dart", + "line": 83, + "column": 39 + }, + "text": "value" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "Future", + "url": "dart:async", + "types": [ + { + "$": "TypeReference", + "symbol": "Nested", + "url": "package:celest_backend/models/records.dart", + "isNullable": false + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "Nested", + "url": "package:celest_backend/models/records.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 1497, + "uri": "package:celest_backend/src/functions/records.dart", + "line": 83, + "column": 15 + }, + "end": { + "offset": 1508, + "uri": "package:celest_backend/src/functions/records.dart", + "line": 83, + "column": 26 + }, + "text": "asyncNested" + } + }, + "nullableNested": { + "name": "nullableNested", + "apiName": "records", + "typeParameters": [], + "parameters": [ + { + "name": "value", + "type": { + "$": "TypeReference", + "symbol": "NullableNested", + "url": "package:celest_backend/models/records.dart", + "isNullable": true + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 1594, + "uri": "package:celest_backend/src/functions/records.dart", + "line": 86, + "column": 47 + }, + "end": { + "offset": 1599, + "uri": "package:celest_backend/src/functions/records.dart", + "line": 86, + "column": 52 + }, + "text": "value" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "NullableNested", + "url": "package:celest_backend/models/records.dart", + "isNullable": true + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "NullableNested", + "url": "package:celest_backend/models/records.dart", + "isNullable": true + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 1563, + "uri": "package:celest_backend/src/functions/records.dart", + "line": 86, + "column": 16 + }, + "end": { + "offset": 1577, + "uri": "package:celest_backend/src/functions/records.dart", + "line": 86, + "column": 30 + }, + "text": "nullableNested" + } + }, + "asyncNullableNested": { + "name": "asyncNullableNested", + "apiName": "records", + "typeParameters": [], + "parameters": [ + { + "name": "value", + "type": { + "$": "TypeReference", + "symbol": "NullableNested", + "url": "package:celest_backend/models/records.dart", + "isNullable": true + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 1678, + "uri": "package:celest_backend/src/functions/records.dart", + "line": 88, + "column": 60 + }, + "end": { + "offset": 1683, + "uri": "package:celest_backend/src/functions/records.dart", + "line": 88, + "column": 65 + }, + "text": "value" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "Future", + "url": "dart:async", + "types": [ + { + "$": "TypeReference", + "symbol": "NullableNested", + "url": "package:celest_backend/models/records.dart", + "isNullable": true + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "NullableNested", + "url": "package:celest_backend/models/records.dart", + "isNullable": true + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 1642, + "uri": "package:celest_backend/src/functions/records.dart", + "line": 88, + "column": 24 + }, + "end": { + "offset": 1661, + "uri": "package:celest_backend/src/functions/records.dart", + "line": 88, + "column": 43 + }, + "text": "asyncNullableNested" + } + } + }, + "docs": [ + "/// Tests that records with and without aliases are serializable and", + "/// deserializable." + ], + "exceptionTypes": [ + { + "$": "TypeReference", + "symbol": "CloudException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "CancelledException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnknownError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "BadRequestException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnauthorizedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "NotFoundException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AlreadyExistsException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "PermissionDeniedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ResourceExhaustedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "FailedPreconditionException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AbortedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "OutOfRangeException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnimplementedError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "InternalServerError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnavailableError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "DataLossError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "DeadlineExceededError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "SerializationException", + "url": "package:celest_core/src/exception/serialization_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "Error", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AssertionError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "TypeError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ArgumentError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "RangeError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "IndexError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnsupportedError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnimplementedError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "StateError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ConcurrentModificationError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "OutOfMemoryError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "StackOverflowError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "Exception", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "FormatException", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "IntegerDivisionByZeroException", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AsyncError", + "url": "dart:async", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "TimeoutException", + "url": "dart:async", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "JsonUnsupportedObjectError", + "url": "dart:convert", + "isNullable": false + } + ], + "location": { + "start": { + "offset": 0, + "uri": "package:celest_backend/src/functions/records.dart", + "line": 0, + "column": 0 + }, + "end": { + "offset": 0, + "uri": "package:celest_backend/src/functions/records.dart", + "line": 0, + "column": 0 + }, + "text": "" + } + }, + "sealed_classes": { + "name": "sealed_classes", + "metadata": [], + "functions": { + "area": { + "name": "area", + "apiName": "sealed_classes", + "typeParameters": [], + "parameters": [ + { + "name": "shape", + "type": { + "$": "TypeReference", + "symbol": "Shape", + "url": "package:celest_backend/models/sealed_classes.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 223, + "uri": "package:celest_backend/src/functions/sealed_classes.dart", + "line": 6, + "column": 18 + }, + "end": { + "offset": 228, + "uri": "package:celest_backend/src/functions/sealed_classes.dart", + "line": 6, + "column": 23 + }, + "text": "shape" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "double", + "url": "dart:core", + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "double", + "url": "dart:core", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 212, + "uri": "package:celest_backend/src/functions/sealed_classes.dart", + "line": 6, + "column": 7 + }, + "end": { + "offset": 216, + "uri": "package:celest_backend/src/functions/sealed_classes.dart", + "line": 6, + "column": 11 + }, + "text": "area" + } + }, + "sealedClass": { + "name": "sealedClass", + "apiName": "sealed_classes", + "typeParameters": [], + "parameters": [ + { + "name": "shapes", + "type": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "Shape", + "url": "package:celest_backend/models/sealed_classes.dart", + "isNullable": false + } + ], + "isNullable": false + }, + "required": true, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 358, + "uri": "package:celest_backend/src/functions/sealed_classes.dart", + "line": 11, + "column": 23 + }, + "end": { + "offset": 364, + "uri": "package:celest_backend/src/functions/sealed_classes.dart", + "line": 11, + "column": 29 + }, + "text": "shapes" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "Shape", + "url": "package:celest_backend/models/sealed_classes.dart", + "isNullable": false + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "Shape", + "url": "package:celest_backend/models/sealed_classes.dart", + "isNullable": false + } + ], + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 321, + "uri": "package:celest_backend/src/functions/sealed_classes.dart", + "line": 10, + "column": 12 + }, + "end": { + "offset": 332, + "uri": "package:celest_backend/src/functions/sealed_classes.dart", + "line": 10, + "column": 23 + }, + "text": "sealedClass" + } + }, + "rectangle": { + "name": "rectangle", + "apiName": "sealed_classes", + "typeParameters": [], + "parameters": [ + { + "name": "rectangle", + "type": { + "$": "TypeReference", + "symbol": "Rectangle", + "url": "package:celest_backend/models/sealed_classes.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 474, + "uri": "package:celest_backend/src/functions/sealed_classes.dart", + "line": 18, + "column": 30 + }, + "end": { + "offset": 483, + "uri": "package:celest_backend/src/functions/sealed_classes.dart", + "line": 18, + "column": 39 + }, + "text": "rectangle" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "Rectangle", + "url": "package:celest_backend/models/sealed_classes.dart", + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "Rectangle", + "url": "package:celest_backend/models/sealed_classes.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 454, + "uri": "package:celest_backend/src/functions/sealed_classes.dart", + "line": 18, + "column": 10 + }, + "end": { + "offset": 463, + "uri": "package:celest_backend/src/functions/sealed_classes.dart", + "line": 18, + "column": 19 + }, + "text": "rectangle" + } + }, + "circle": { + "name": "circle", + "apiName": "sealed_classes", + "typeParameters": [], + "parameters": [ + { + "name": "circle", + "type": { + "$": "TypeReference", + "symbol": "Circle", + "url": "package:celest_backend/models/sealed_classes.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 527, + "uri": "package:celest_backend/src/functions/sealed_classes.dart", + "line": 20, + "column": 21 + }, + "end": { + "offset": 533, + "uri": "package:celest_backend/src/functions/sealed_classes.dart", + "line": 20, + "column": 27 + }, + "text": "circle" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "Circle", + "url": "package:celest_backend/models/sealed_classes.dart", + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "Circle", + "url": "package:celest_backend/models/sealed_classes.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 513, + "uri": "package:celest_backend/src/functions/sealed_classes.dart", + "line": 20, + "column": 7 + }, + "end": { + "offset": 519, + "uri": "package:celest_backend/src/functions/sealed_classes.dart", + "line": 20, + "column": 13 + }, + "text": "circle" + } + }, + "sealedClassWithInheritedCustomJson": { + "name": "sealedClassWithInheritedCustomJson", + "apiName": "sealed_classes", + "typeParameters": [], + "parameters": [ + { + "name": "shapes", + "type": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "ShapeWithInheritedCustomJson", + "url": "package:celest_backend/models/sealed_classes.dart", + "isNullable": false + } + ], + "isNullable": false + }, + "required": true, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 732, + "uri": "package:celest_backend/src/functions/sealed_classes.dart", + "line": 25, + "column": 46 + }, + "end": { + "offset": 738, + "uri": "package:celest_backend/src/functions/sealed_classes.dart", + "line": 25, + "column": 52 + }, + "text": "shapes" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "ShapeWithInheritedCustomJson", + "url": "package:celest_backend/models/sealed_classes.dart", + "isNullable": false + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "ShapeWithInheritedCustomJson", + "url": "package:celest_backend/models/sealed_classes.dart", + "isNullable": false + } + ], + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 649, + "uri": "package:celest_backend/src/functions/sealed_classes.dart", + "line": 24, + "column": 35 + }, + "end": { + "offset": 683, + "uri": "package:celest_backend/src/functions/sealed_classes.dart", + "line": 24, + "column": 69 + }, + "text": "sealedClassWithInheritedCustomJson" + } + }, + "sealedClassWithCustomJson": { + "name": "sealedClassWithCustomJson", + "apiName": "sealed_classes", + "typeParameters": [], + "parameters": [ + { + "name": "shapes", + "type": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "ShapeWithCustomJson", + "url": "package:celest_backend/models/sealed_classes.dart", + "isNullable": false + } + ], + "isNullable": false + }, + "required": true, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 933, + "uri": "package:celest_backend/src/functions/sealed_classes.dart", + "line": 33, + "column": 37 + }, + "end": { + "offset": 939, + "uri": "package:celest_backend/src/functions/sealed_classes.dart", + "line": 33, + "column": 43 + }, + "text": "shapes" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "ShapeWithCustomJson", + "url": "package:celest_backend/models/sealed_classes.dart", + "isNullable": false + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "ShapeWithCustomJson", + "url": "package:celest_backend/models/sealed_classes.dart", + "isNullable": false + } + ], + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 868, + "uri": "package:celest_backend/src/functions/sealed_classes.dart", + "line": 32, + "column": 26 + }, + "end": { + "offset": 893, + "uri": "package:celest_backend/src/functions/sealed_classes.dart", + "line": 32, + "column": 51 + }, + "text": "sealedClassWithCustomJson" + } + }, + "sealedClassWithOverriddenCustomJson": { + "name": "sealedClassWithOverriddenCustomJson", + "apiName": "sealed_classes", + "typeParameters": [], + "parameters": [ + { + "name": "circle", + "type": { + "$": "TypeReference", + "symbol": "CircleWithOverriddenCustomJson", + "url": "package:celest_backend/models/sealed_classes.dart", + "isNullable": false + }, + "required": true, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 1156, + "uri": "package:celest_backend/src/functions/sealed_classes.dart", + "line": 41, + "column": 42 + }, + "end": { + "offset": 1162, + "uri": "package:celest_backend/src/functions/sealed_classes.dart", + "line": 41, + "column": 48 + }, + "text": "circle" + } + }, + { + "name": "rectangle", + "type": { + "$": "TypeReference", + "symbol": "RectangleWithOverriddenCustomJson", + "url": "package:celest_backend/models/sealed_classes.dart", + "isNullable": false + }, + "required": true, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 1209, + "uri": "package:celest_backend/src/functions/sealed_classes.dart", + "line": 42, + "column": 45 + }, + "end": { + "offset": 1218, + "uri": "package:celest_backend/src/functions/sealed_classes.dart", + "line": 42, + "column": 54 + }, + "text": "rectangle" + } + }, + { + "name": "other", + "type": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "ShapeWithOverriddenCustomJson", + "url": "package:celest_backend/models/sealed_classes.dart", + "isNullable": false + } + ], + "isNullable": false + }, + "required": true, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 1267, + "uri": "package:celest_backend/src/functions/sealed_classes.dart", + "line": 43, + "column": 47 + }, + "end": { + "offset": 1272, + "uri": "package:celest_backend/src/functions/sealed_classes.dart", + "line": 43, + "column": 52 + }, + "text": "other" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "ShapeWithOverriddenCustomJson", + "url": "package:celest_backend/models/sealed_classes.dart", + "isNullable": false + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "ShapeWithOverriddenCustomJson", + "url": "package:celest_backend/models/sealed_classes.dart", + "isNullable": false + } + ], + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 1076, + "uri": "package:celest_backend/src/functions/sealed_classes.dart", + "line": 40, + "column": 36 + }, + "end": { + "offset": 1111, + "uri": "package:celest_backend/src/functions/sealed_classes.dart", + "line": 40, + "column": 71 + }, + "text": "sealedClassWithOverriddenCustomJson" + } + }, + "rectangleWithOverriddenCustomJson": { + "name": "rectangleWithOverriddenCustomJson", + "apiName": "sealed_classes", + "typeParameters": [], + "parameters": [ + { + "name": "rectangle", + "type": { + "$": "TypeReference", + "symbol": "RectangleWithOverriddenCustomJson", + "url": "package:celest_backend/models/sealed_classes.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 1447, + "uri": "package:celest_backend/src/functions/sealed_classes.dart", + "line": 54, + "column": 36 + }, + "end": { + "offset": 1456, + "uri": "package:celest_backend/src/functions/sealed_classes.dart", + "line": 54, + "column": 45 + }, + "text": "rectangle" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "ShapeWithOverriddenCustomJson", + "url": "package:celest_backend/models/sealed_classes.dart", + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "ShapeWithOverriddenCustomJson", + "url": "package:celest_backend/models/sealed_classes.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 1376, + "uri": "package:celest_backend/src/functions/sealed_classes.dart", + "line": 53, + "column": 30 + }, + "end": { + "offset": 1409, + "uri": "package:celest_backend/src/functions/sealed_classes.dart", + "line": 53, + "column": 63 + }, + "text": "rectangleWithOverriddenCustomJson" + } + }, + "circleWithOverriddenCustomJson": { + "name": "circleWithOverriddenCustomJson", + "apiName": "sealed_classes", + "typeParameters": [], + "parameters": [ + { + "name": "circle", + "type": { + "$": "TypeReference", + "symbol": "ShapeWithOverriddenCustomJson", + "url": "package:celest_backend/models/sealed_classes.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 1587, + "uri": "package:celest_backend/src/functions/sealed_classes.dart", + "line": 61, + "column": 32 + }, + "end": { + "offset": 1593, + "uri": "package:celest_backend/src/functions/sealed_classes.dart", + "line": 61, + "column": 38 + }, + "text": "circle" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "CircleWithOverriddenCustomJson", + "url": "package:celest_backend/models/sealed_classes.dart", + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "CircleWithOverriddenCustomJson", + "url": "package:celest_backend/models/sealed_classes.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 1523, + "uri": "package:celest_backend/src/functions/sealed_classes.dart", + "line": 60, + "column": 31 + }, + "end": { + "offset": 1553, + "uri": "package:celest_backend/src/functions/sealed_classes.dart", + "line": 60, + "column": 61 + }, + "text": "circleWithOverriddenCustomJson" + } + }, + "okShapeResults": { + "name": "okShapeResults", + "apiName": "sealed_classes", + "typeParameters": [], + "parameters": [ + { + "name": "shapes", + "type": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "Shape", + "url": "package:celest_backend/models/sealed_classes.dart", + "isNullable": false + } + ], + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 1709, + "uri": "package:celest_backend/src/functions/sealed_classes.dart", + "line": 67, + "column": 49 + }, + "end": { + "offset": 1715, + "uri": "package:celest_backend/src/functions/sealed_classes.dart", + "line": 67, + "column": 55 + }, + "text": "shapes" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "OkResult", + "url": "package:celest_backend/models/sealed_classes.dart", + "types": [ + { + "$": "TypeReference", + "symbol": "Shape", + "url": "package:celest_backend/models/sealed_classes.dart", + "isNullable": false + } + ], + "isNullable": false + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "OkResult", + "url": "package:celest_backend/models/sealed_classes.dart", + "types": [ + { + "$": "TypeReference", + "symbol": "Shape", + "url": "package:celest_backend/models/sealed_classes.dart", + "isNullable": false + } + ], + "isNullable": false + } + ], + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 1682, + "uri": "package:celest_backend/src/functions/sealed_classes.dart", + "line": 67, + "column": 22 + }, + "end": { + "offset": 1696, + "uri": "package:celest_backend/src/functions/sealed_classes.dart", + "line": 67, + "column": 36 + }, + "text": "okShapeResults" + } + }, + "errShapeResults": { + "name": "errShapeResults", + "apiName": "sealed_classes", + "typeParameters": [], + "parameters": [ + { + "name": "shapes", + "type": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "Shape", + "url": "package:celest_backend/models/sealed_classes.dart", + "isNullable": false + } + ], + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 1830, + "uri": "package:celest_backend/src/functions/sealed_classes.dart", + "line": 70, + "column": 52 + }, + "end": { + "offset": 1836, + "uri": "package:celest_backend/src/functions/sealed_classes.dart", + "line": 70, + "column": 58 + }, + "text": "shapes" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "ErrResult", + "url": "package:celest_backend/models/sealed_classes.dart", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "ErrResult", + "url": "package:celest_backend/models/sealed_classes.dart", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + } + ], + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 1802, + "uri": "package:celest_backend/src/functions/sealed_classes.dart", + "line": 70, + "column": 24 + }, + "end": { + "offset": 1817, + "uri": "package:celest_backend/src/functions/sealed_classes.dart", + "line": 70, + "column": 39 + }, + "text": "errShapeResults" + } + }, + "shapeResults": { + "name": "shapeResults", + "apiName": "sealed_classes", + "typeParameters": [], + "parameters": [ + { + "name": "shapes", + "type": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "Shape", + "url": "package:celest_backend/models/sealed_classes.dart", + "isNullable": false + } + ], + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 1969, + "uri": "package:celest_backend/src/functions/sealed_classes.dart", + "line": 73, + "column": 53 + }, + "end": { + "offset": 1975, + "uri": "package:celest_backend/src/functions/sealed_classes.dart", + "line": 73, + "column": 59 + }, + "text": "shapes" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "Result", + "url": "package:celest_backend/models/sealed_classes.dart", + "types": [ + { + "$": "TypeReference", + "symbol": "Shape", + "url": "package:celest_backend/models/sealed_classes.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "Result", + "url": "package:celest_backend/models/sealed_classes.dart", + "types": [ + { + "$": "TypeReference", + "symbol": "Shape", + "url": "package:celest_backend/models/sealed_classes.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + } + ], + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 1944, + "uri": "package:celest_backend/src/functions/sealed_classes.dart", + "line": 73, + "column": 28 + }, + "end": { + "offset": 1956, + "uri": "package:celest_backend/src/functions/sealed_classes.dart", + "line": 73, + "column": 40 + }, + "text": "shapeResults" + } + }, + "aliasedOkShapeResults": { + "name": "aliasedOkShapeResults", + "apiName": "sealed_classes", + "typeParameters": [], + "parameters": [ + { + "name": "shapes", + "type": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "Shape", + "url": "package:celest_backend/models/sealed_classes.dart", + "isNullable": false + } + ], + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 2179, + "uri": "package:celest_backend/src/functions/sealed_classes.dart", + "line": 80, + "column": 60 + }, + "end": { + "offset": 2185, + "uri": "package:celest_backend/src/functions/sealed_classes.dart", + "line": 80, + "column": 66 + }, + "text": "shapes" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "Result", + "url": "package:celest_backend/models/sealed_classes.dart", + "types": [ + { + "$": "TypeReference", + "symbol": "Shape", + "url": "package:celest_backend/models/sealed_classes.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "Result", + "url": "package:celest_backend/models/sealed_classes.dart", + "types": [ + { + "$": "TypeReference", + "symbol": "Shape", + "url": "package:celest_backend/models/sealed_classes.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + } + ], + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 2145, + "uri": "package:celest_backend/src/functions/sealed_classes.dart", + "line": 80, + "column": 26 + }, + "end": { + "offset": 2166, + "uri": "package:celest_backend/src/functions/sealed_classes.dart", + "line": 80, + "column": 47 + }, + "text": "aliasedOkShapeResults" + } + }, + "aliasedErrShapeResults": { + "name": "aliasedErrShapeResults", + "apiName": "sealed_classes", + "typeParameters": [], + "parameters": [ + { + "name": "shapes", + "type": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "Shape", + "url": "package:celest_backend/models/sealed_classes.dart", + "isNullable": false + } + ], + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 2309, + "uri": "package:celest_backend/src/functions/sealed_classes.dart", + "line": 83, + "column": 61 + }, + "end": { + "offset": 2315, + "uri": "package:celest_backend/src/functions/sealed_classes.dart", + "line": 83, + "column": 67 + }, + "text": "shapes" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "Result", + "url": "package:celest_backend/models/sealed_classes.dart", + "types": [ + { + "$": "TypeReference", + "symbol": "Shape", + "url": "package:celest_backend/models/sealed_classes.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "Result", + "url": "package:celest_backend/models/sealed_classes.dart", + "types": [ + { + "$": "TypeReference", + "symbol": "Shape", + "url": "package:celest_backend/models/sealed_classes.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + } + ], + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 2274, + "uri": "package:celest_backend/src/functions/sealed_classes.dart", + "line": 83, + "column": 26 + }, + "end": { + "offset": 2296, + "uri": "package:celest_backend/src/functions/sealed_classes.dart", + "line": 83, + "column": 48 + }, + "text": "aliasedErrShapeResults" + } + }, + "aliasedShapeResults": { + "name": "aliasedShapeResults", + "apiName": "sealed_classes", + "typeParameters": [], + "parameters": [ + { + "name": "shapes", + "type": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "Shape", + "url": "package:celest_backend/models/sealed_classes.dart", + "isNullable": false + } + ], + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 2453, + "uri": "package:celest_backend/src/functions/sealed_classes.dart", + "line": 86, + "column": 58 + }, + "end": { + "offset": 2459, + "uri": "package:celest_backend/src/functions/sealed_classes.dart", + "line": 86, + "column": 64 + }, + "text": "shapes" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "Result", + "url": "package:celest_backend/models/sealed_classes.dart", + "types": [ + { + "$": "TypeReference", + "symbol": "Shape", + "url": "package:celest_backend/models/sealed_classes.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "Result", + "url": "package:celest_backend/models/sealed_classes.dart", + "types": [ + { + "$": "TypeReference", + "symbol": "Shape", + "url": "package:celest_backend/models/sealed_classes.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + } + ], + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 2421, + "uri": "package:celest_backend/src/functions/sealed_classes.dart", + "line": 86, + "column": 26 + }, + "end": { + "offset": 2440, + "uri": "package:celest_backend/src/functions/sealed_classes.dart", + "line": 86, + "column": 45 + }, + "text": "aliasedShapeResults" + } + }, + "swappedResult": { + "name": "swappedResult", + "apiName": "sealed_classes", + "typeParameters": [], + "parameters": [ + { + "name": "result", + "type": { + "$": "TypeReference", + "symbol": "Result", + "url": "package:celest_backend/models/sealed_classes.dart", + "types": [ + { + "$": "TypeReference", + "symbol": "Shape", + "url": "package:celest_backend/models/sealed_classes.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 2613, + "uri": "package:celest_backend/src/functions/sealed_classes.dart", + "line": 92, + "column": 65 + }, + "end": { + "offset": 2619, + "uri": "package:celest_backend/src/functions/sealed_classes.dart", + "line": 92, + "column": 71 + }, + "text": "result" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "SwappedResult", + "url": "package:celest_backend/models/sealed_classes.dart", + "types": [ + { + "$": "TypeReference", + "symbol": "Shape", + "url": "package:celest_backend/models/sealed_classes.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "SwappedResult", + "url": "package:celest_backend/models/sealed_classes.dart", + "types": [ + { + "$": "TypeReference", + "symbol": "Shape", + "url": "package:celest_backend/models/sealed_classes.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 2577, + "uri": "package:celest_backend/src/functions/sealed_classes.dart", + "line": 92, + "column": 29 + }, + "end": { + "offset": 2590, + "uri": "package:celest_backend/src/functions/sealed_classes.dart", + "line": 92, + "column": 42 + }, + "text": "swappedResult" + } + }, + "genericResult": { + "name": "genericResult", + "apiName": "sealed_classes", + "typeParameters": [ + { + "$": "TypeReference", + "symbol": "T", + "bound": { + "$": "TypeReference", + "symbol": "Shape", + "url": "package:celest_backend/models/sealed_classes.dart", + "isNullable": false + } + } + ], + "parameters": [ + { + "name": "data", + "type": { + "$": "TypeReference", + "symbol": "T", + "bound": { + "$": "TypeReference", + "symbol": "Shape", + "url": "package:celest_backend/models/sealed_classes.dart", + "isNullable": false + } + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 2704, + "uri": "package:celest_backend/src/functions/sealed_classes.dart", + "line": 96, + "column": 45 + }, + "end": { + "offset": 2708, + "uri": "package:celest_backend/src/functions/sealed_classes.dart", + "line": 96, + "column": 49 + }, + "text": "data" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "OkResult", + "url": "package:celest_backend/models/sealed_classes.dart", + "types": [ + { + "$": "TypeReference", + "symbol": "T", + "bound": { + "$": "TypeReference", + "symbol": "Shape", + "url": "package:celest_backend/models/sealed_classes.dart", + "isNullable": false + } + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "OkResult", + "url": "package:celest_backend/models/sealed_classes.dart", + "types": [ + { + "$": "TypeReference", + "symbol": "T", + "bound": { + "$": "TypeReference", + "symbol": "Shape", + "url": "package:celest_backend/models/sealed_classes.dart", + "isNullable": false + } + } + ], + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 2671, + "uri": "package:celest_backend/src/functions/sealed_classes.dart", + "line": 96, + "column": 12 + }, + "end": { + "offset": 2684, + "uri": "package:celest_backend/src/functions/sealed_classes.dart", + "line": 96, + "column": 25 + }, + "text": "genericResult" + } + }, + "multipleGenericResult": { + "name": "multipleGenericResult", + "apiName": "sealed_classes", + "typeParameters": [ + { + "$": "TypeReference", + "symbol": "T", + "bound": { + "$": "TypeReference", + "symbol": "Shape", + "url": "package:celest_backend/models/sealed_classes.dart", + "isNullable": false + } + }, + { + "$": "TypeReference", + "symbol": "E", + "bound": { + "$": "TypeReference", + "symbol": "ShapeException", + "url": "package:celest_backend/exceptions/exceptions.dart", + "isNullable": false + } + } + ], + "parameters": [ + { + "name": "data", + "type": { + "$": "TypeReference", + "symbol": "T", + "bound": { + "$": "TypeReference", + "symbol": "Shape", + "url": "package:celest_backend/models/sealed_classes.dart", + "isNullable": false + } + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 2829, + "uri": "package:celest_backend/src/functions/sealed_classes.dart", + "line": 100, + "column": 4 + }, + "end": { + "offset": 2833, + "uri": "package:celest_backend/src/functions/sealed_classes.dart", + "line": 100, + "column": 8 + }, + "text": "data" + } + }, + { + "name": "error", + "type": { + "$": "TypeReference", + "symbol": "E", + "bound": { + "$": "TypeReference", + "symbol": "ShapeException", + "url": "package:celest_backend/exceptions/exceptions.dart", + "isNullable": false + } + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 2839, + "uri": "package:celest_backend/src/functions/sealed_classes.dart", + "line": 101, + "column": 4 + }, + "end": { + "offset": 2844, + "uri": "package:celest_backend/src/functions/sealed_classes.dart", + "line": 101, + "column": 9 + }, + "text": "error" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "Result", + "url": "package:celest_backend/models/sealed_classes.dart", + "types": [ + { + "$": "TypeReference", + "symbol": "T", + "bound": { + "$": "TypeReference", + "symbol": "Shape", + "url": "package:celest_backend/models/sealed_classes.dart", + "isNullable": false + } + }, + { + "$": "TypeReference", + "symbol": "E", + "bound": { + "$": "TypeReference", + "symbol": "ShapeException", + "url": "package:celest_backend/exceptions/exceptions.dart", + "isNullable": false + } + } + ], + "isNullable": false + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "Result", + "url": "package:celest_backend/models/sealed_classes.dart", + "types": [ + { + "$": "TypeReference", + "symbol": "T", + "bound": { + "$": "TypeReference", + "symbol": "Shape", + "url": "package:celest_backend/models/sealed_classes.dart", + "isNullable": false + } + }, + { + "$": "TypeReference", + "symbol": "E", + "bound": { + "$": "TypeReference", + "symbol": "ShapeException", + "url": "package:celest_backend/exceptions/exceptions.dart", + "isNullable": false + } + } + ], + "isNullable": false + } + ], + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 2759, + "uri": "package:celest_backend/src/functions/sealed_classes.dart", + "line": 99, + "column": 4 + }, + "end": { + "offset": 2780, + "uri": "package:celest_backend/src/functions/sealed_classes.dart", + "line": 99, + "column": 25 + }, + "text": "multipleGenericResult" + } + }, + "okShapeResult": { + "name": "okShapeResult", + "apiName": "sealed_classes", + "typeParameters": [], + "parameters": [ + { + "name": "shape", + "type": { + "$": "TypeReference", + "symbol": "Shape", + "url": "package:celest_backend/models/sealed_classes.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 3150, + "uri": "package:celest_backend/src/functions/sealed_classes.dart", + "line": 109, + "column": 34 + }, + "end": { + "offset": 3155, + "uri": "package:celest_backend/src/functions/sealed_classes.dart", + "line": 109, + "column": 39 + }, + "text": "shape" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "OkShapeResult", + "url": "package:celest_backend/models/sealed_classes.dart", + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "OkShapeResult", + "url": "package:celest_backend/models/sealed_classes.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 3130, + "uri": "package:celest_backend/src/functions/sealed_classes.dart", + "line": 109, + "column": 14 + }, + "end": { + "offset": 3143, + "uri": "package:celest_backend/src/functions/sealed_classes.dart", + "line": 109, + "column": 27 + }, + "text": "okShapeResult" + } + } + }, + "docs": [], + "exceptionTypes": [ + { + "$": "TypeReference", + "symbol": "CloudException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "CancelledException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnknownError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "BadRequestException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnauthorizedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "NotFoundException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AlreadyExistsException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "PermissionDeniedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ResourceExhaustedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "FailedPreconditionException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AbortedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "OutOfRangeException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnimplementedError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "InternalServerError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnavailableError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "DataLossError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "DeadlineExceededError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "SerializationException", + "url": "package:celest_core/src/exception/serialization_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "Error", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AssertionError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "TypeError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ArgumentError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "RangeError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "IndexError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnsupportedError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnimplementedError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "StateError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ConcurrentModificationError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "OutOfMemoryError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "StackOverflowError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "Exception", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "FormatException", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "IntegerDivisionByZeroException", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AsyncError", + "url": "dart:async", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "TimeoutException", + "url": "dart:async", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "JsonUnsupportedObjectError", + "url": "dart:convert", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "CustomException", + "url": "package:celest_backend/exceptions/exceptions.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "CustomExceptionToFromJson", + "url": "package:celest_backend/exceptions/exceptions.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "CustomError", + "url": "package:celest_backend/exceptions/exceptions.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "CustomErrorToFromJson", + "url": "package:celest_backend/exceptions/exceptions.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "CustomErrorWithStackTrace", + "url": "package:celest_backend/exceptions/exceptions.dart", + "isNullable": false + } + ], + "location": { + "start": { + "offset": 0, + "uri": "package:celest_backend/src/functions/sealed_classes.dart", + "line": 0, + "column": 0 + }, + "end": { + "offset": 0, + "uri": "package:celest_backend/src/functions/sealed_classes.dart", + "line": 0, + "column": 0 + }, + "text": "" + } + }, + "parameter_types": { + "name": "parameter_types", + "metadata": [], + "functions": { + "simple": { + "name": "simple", + "apiName": "parameter_types", + "typeParameters": [], + "parameters": [ + { + "name": "aString", + "type": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 163, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 7, + "column": 9 + }, + "end": { + "offset": 170, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 7, + "column": 16 + }, + "text": "aString" + } + }, + { + "name": "anInt", + "type": { + "$": "TypeReference", + "symbol": "int", + "url": "dart:core", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 178, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 8, + "column": 6 + }, + "end": { + "offset": 183, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 8, + "column": 11 + }, + "text": "anInt" + } + }, + { + "name": "aDouble", + "type": { + "$": "TypeReference", + "symbol": "double", + "url": "dart:core", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 194, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 9, + "column": 9 + }, + "end": { + "offset": 201, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 9, + "column": 16 + }, + "text": "aDouble" + } + }, + { + "name": "aBool", + "type": { + "$": "TypeReference", + "symbol": "bool", + "url": "dart:core", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 210, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 10, + "column": 7 + }, + "end": { + "offset": 215, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 10, + "column": 12 + }, + "text": "aBool" + } + }, + { + "name": "anEnum", + "type": { + "$": "TypeReference", + "symbol": "MyEnum", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 226, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 11, + "column": 9 + }, + "end": { + "offset": 232, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 11, + "column": 15 + }, + "text": "anEnum" + } + }, + { + "name": "aNull", + "type": { + "$": "TypeReference", + "symbol": "Null", + "url": "dart:core", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 241, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 12, + "column": 7 + }, + "end": { + "offset": 246, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 12, + "column": 12 + }, + "text": "aNull" + } + }, + { + "name": "aBigInt", + "type": { + "$": "Reference", + "symbol": "BigInt", + "url": "dart:core" + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 257, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 13, + "column": 9 + }, + "end": { + "offset": 264, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 13, + "column": 16 + }, + "text": "aBigInt" + } + }, + { + "name": "aDateTime", + "type": { + "$": "Reference", + "symbol": "DateTime", + "url": "dart:core" + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 277, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 14, + "column": 11 + }, + "end": { + "offset": 286, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 14, + "column": 20 + }, + "text": "aDateTime" + } + }, + { + "name": "aDuration", + "type": { + "$": "Reference", + "symbol": "Duration", + "url": "dart:core" + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 299, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 15, + "column": 11 + }, + "end": { + "offset": 308, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 15, + "column": 20 + }, + "text": "aDuration" + } + }, + { + "name": "aRegExp", + "type": { + "$": "Reference", + "symbol": "RegExp", + "url": "dart:core" + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 319, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 16, + "column": 9 + }, + "end": { + "offset": 326, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 16, + "column": 16 + }, + "text": "aRegExp" + } + }, + { + "name": "aStackTrace", + "type": { + "$": "Reference", + "symbol": "StackTrace", + "url": "dart:core" + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 341, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 17, + "column": 13 + }, + "end": { + "offset": 352, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 17, + "column": 24 + }, + "text": "aStackTrace" + } + }, + { + "name": "aUri", + "type": { + "$": "Reference", + "symbol": "Uri", + "url": "dart:core" + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 360, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 18, + "column": 6 + }, + "end": { + "offset": 364, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 18, + "column": 10 + }, + "text": "aUri" + } + }, + { + "name": "aUriData", + "type": { + "$": "Reference", + "symbol": "UriData", + "url": "dart:core" + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 376, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 19, + "column": 10 + }, + "end": { + "offset": 384, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 19, + "column": 18 + }, + "text": "aUriData" + } + }, + { + "name": "aUint8List", + "type": { + "$": "Reference", + "symbol": "Uint8List", + "url": "dart:typed_data" + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 398, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 20, + "column": 12 + }, + "end": { + "offset": 408, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 20, + "column": 22 + }, + "text": "aUint8List" + } + }, + { + "name": "anIterableOfString", + "type": { + "$": "TypeReference", + "symbol": "Iterable", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 429, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 21, + "column": 19 + }, + "end": { + "offset": 447, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 21, + "column": 37 + }, + "text": "anIterableOfString" + } + }, + { + "name": "anIterableOfUint8List", + "type": { + "$": "TypeReference", + "symbol": "Iterable", + "url": "dart:core", + "types": [ + { + "$": "Reference", + "symbol": "Uint8List", + "url": "dart:typed_data" + } + ], + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 471, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 22, + "column": 22 + }, + "end": { + "offset": 492, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 22, + "column": 43 + }, + "text": "anIterableOfUint8List" + } + }, + { + "name": "aListOfString", + "type": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 509, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 23, + "column": 15 + }, + "end": { + "offset": 522, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 23, + "column": 28 + }, + "text": "aListOfString" + } + }, + { + "name": "aListOfInt", + "type": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "int", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 536, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 24, + "column": 12 + }, + "end": { + "offset": 546, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 24, + "column": 22 + }, + "text": "aListOfInt" + } + }, + { + "name": "aListOfDouble", + "type": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "double", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 563, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 25, + "column": 15 + }, + "end": { + "offset": 576, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 25, + "column": 28 + }, + "text": "aListOfDouble" + } + }, + { + "name": "aListOfBool", + "type": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "bool", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 591, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 26, + "column": 13 + }, + "end": { + "offset": 602, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 26, + "column": 24 + }, + "text": "aListOfBool" + } + }, + { + "name": "aListOfEnum", + "type": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "MyEnum", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": false + } + ], + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 619, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 27, + "column": 15 + }, + "end": { + "offset": 630, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 27, + "column": 26 + }, + "text": "aListOfEnum" + } + }, + { + "name": "aListOfNull", + "type": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "Null", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 645, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 28, + "column": 13 + }, + "end": { + "offset": 656, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 28, + "column": 24 + }, + "text": "aListOfNull" + } + }, + { + "name": "aListOfBigInt", + "type": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "Reference", + "symbol": "BigInt", + "url": "dart:core" + } + ], + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 673, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 29, + "column": 15 + }, + "end": { + "offset": 686, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 29, + "column": 28 + }, + "text": "aListOfBigInt" + } + }, + { + "name": "aListOfDateTime", + "type": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "Reference", + "symbol": "DateTime", + "url": "dart:core" + } + ], + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 705, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 30, + "column": 17 + }, + "end": { + "offset": 720, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 30, + "column": 32 + }, + "text": "aListOfDateTime" + } + }, + { + "name": "aListOfDuration", + "type": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "Reference", + "symbol": "Duration", + "url": "dart:core" + } + ], + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 739, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 31, + "column": 17 + }, + "end": { + "offset": 754, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 31, + "column": 32 + }, + "text": "aListOfDuration" + } + }, + { + "name": "aListOfRegExp", + "type": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "Reference", + "symbol": "RegExp", + "url": "dart:core" + } + ], + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 771, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 32, + "column": 15 + }, + "end": { + "offset": 784, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 32, + "column": 28 + }, + "text": "aListOfRegExp" + } + }, + { + "name": "aListOfStackTrace", + "type": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "Reference", + "symbol": "StackTrace", + "url": "dart:core" + } + ], + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 805, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 33, + "column": 19 + }, + "end": { + "offset": 822, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 33, + "column": 36 + }, + "text": "aListOfStackTrace" + } + }, + { + "name": "aListOfUri", + "type": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "Reference", + "symbol": "Uri", + "url": "dart:core" + } + ], + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 836, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 34, + "column": 12 + }, + "end": { + "offset": 846, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 34, + "column": 22 + }, + "text": "aListOfUri" + } + }, + { + "name": "aListOfUriData", + "type": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "Reference", + "symbol": "UriData", + "url": "dart:core" + } + ], + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 864, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 35, + "column": 16 + }, + "end": { + "offset": 878, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 35, + "column": 30 + }, + "text": "aListOfUriData" + } + }, + { + "name": "aListOfUint8List", + "type": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "Reference", + "symbol": "Uint8List", + "url": "dart:typed_data" + } + ], + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 898, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 36, + "column": 18 + }, + "end": { + "offset": 914, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 36, + "column": 34 + }, + "text": "aListOfUint8List" + } + }, + { + "name": "aMapOfString", + "type": { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 938, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 37, + "column": 22 + }, + "end": { + "offset": 950, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 37, + "column": 34 + }, + "text": "aMapOfString" + } + }, + { + "name": "aMapOfInt", + "type": { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "int", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 971, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 38, + "column": 19 + }, + "end": { + "offset": 980, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 38, + "column": 28 + }, + "text": "aMapOfInt" + } + }, + { + "name": "aMapOfDouble", + "type": { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "double", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 1004, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 39, + "column": 22 + }, + "end": { + "offset": 1016, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 39, + "column": 34 + }, + "text": "aMapOfDouble" + } + }, + { + "name": "aMapOfBool", + "type": { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "bool", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 1038, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 40, + "column": 20 + }, + "end": { + "offset": 1048, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 40, + "column": 30 + }, + "text": "aMapOfBool" + } + }, + { + "name": "aMapOfEnum", + "type": { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "MyEnum", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": false + } + ], + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 1072, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 41, + "column": 22 + }, + "end": { + "offset": 1082, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 41, + "column": 32 + }, + "text": "aMapOfEnum" + } + }, + { + "name": "aMapOfNull", + "type": { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "Null", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 1104, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 42, + "column": 20 + }, + "end": { + "offset": 1114, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 42, + "column": 30 + }, + "text": "aMapOfNull" + } + }, + { + "name": "aMapOfBigInt", + "type": { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "Reference", + "symbol": "BigInt", + "url": "dart:core" + } + ], + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 1138, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 43, + "column": 22 + }, + "end": { + "offset": 1150, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 43, + "column": 34 + }, + "text": "aMapOfBigInt" + } + }, + { + "name": "aMapOfDateTime", + "type": { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "Reference", + "symbol": "DateTime", + "url": "dart:core" + } + ], + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 1176, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 44, + "column": 24 + }, + "end": { + "offset": 1190, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 44, + "column": 38 + }, + "text": "aMapOfDateTime" + } + }, + { + "name": "aMapOfDuration", + "type": { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "Reference", + "symbol": "Duration", + "url": "dart:core" + } + ], + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 1216, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 45, + "column": 24 + }, + "end": { + "offset": 1230, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 45, + "column": 38 + }, + "text": "aMapOfDuration" + } + }, + { + "name": "aMapOfRegExp", + "type": { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "Reference", + "symbol": "RegExp", + "url": "dart:core" + } + ], + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 1254, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 46, + "column": 22 + }, + "end": { + "offset": 1266, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 46, + "column": 34 + }, + "text": "aMapOfRegExp" + } + }, + { + "name": "aMapOfStackTrace", + "type": { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "Reference", + "symbol": "StackTrace", + "url": "dart:core" + } + ], + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 1294, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 47, + "column": 26 + }, + "end": { + "offset": 1310, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 47, + "column": 42 + }, + "text": "aMapOfStackTrace" + } + }, + { + "name": "aMapOfUri", + "type": { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "Reference", + "symbol": "Uri", + "url": "dart:core" + } + ], + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 1331, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 48, + "column": 19 + }, + "end": { + "offset": 1340, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 48, + "column": 28 + }, + "text": "aMapOfUri" + } + }, + { + "name": "aMapOfUriData", + "type": { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "Reference", + "symbol": "UriData", + "url": "dart:core" + } + ], + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 1365, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 49, + "column": 23 + }, + "end": { + "offset": 1378, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 49, + "column": 36 + }, + "text": "aMapOfUriData" + } + }, + { + "name": "aMapOfUint8List", + "type": { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "Reference", + "symbol": "Uint8List", + "url": "dart:typed_data" + } + ], + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 1405, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 50, + "column": 25 + }, + "end": { + "offset": 1420, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 50, + "column": 40 + }, + "text": "aMapOfUint8List" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "Future", + "url": "dart:async", + "types": [ + { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 146, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 6, + "column": 13 + }, + "end": { + "offset": 152, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 6, + "column": 19 + }, + "text": "simple" + } + }, + "simpleOptional": { + "name": "simpleOptional", + "apiName": "parameter_types", + "typeParameters": [], + "parameters": [ + { + "name": "aString", + "type": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": true + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 1535, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 56, + "column": 10 + }, + "end": { + "offset": 1542, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 56, + "column": 17 + }, + "text": "aString" + } + }, + { + "name": "anInt", + "type": { + "$": "TypeReference", + "symbol": "int", + "url": "dart:core", + "isNullable": true + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 1551, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 57, + "column": 7 + }, + "end": { + "offset": 1556, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 57, + "column": 12 + }, + "text": "anInt" + } + }, + { + "name": "aDouble", + "type": { + "$": "TypeReference", + "symbol": "double", + "url": "dart:core", + "isNullable": true + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 1568, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 58, + "column": 10 + }, + "end": { + "offset": 1575, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 58, + "column": 17 + }, + "text": "aDouble" + } + }, + { + "name": "aBool", + "type": { + "$": "TypeReference", + "symbol": "bool", + "url": "dart:core", + "isNullable": true + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 1585, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 59, + "column": 8 + }, + "end": { + "offset": 1590, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 59, + "column": 13 + }, + "text": "aBool" + } + }, + { + "name": "anEnum", + "type": { + "$": "TypeReference", + "symbol": "MyEnum", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": true + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 1602, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 60, + "column": 10 + }, + "end": { + "offset": 1608, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 60, + "column": 16 + }, + "text": "anEnum" + } + }, + { + "name": "aNull", + "type": { + "$": "TypeReference", + "symbol": "Null", + "url": "dart:core", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 1617, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 61, + "column": 7 + }, + "end": { + "offset": 1622, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 61, + "column": 12 + }, + "text": "aNull" + } + }, + { + "name": "aBigInt", + "type": { + "$": "TypeReference", + "symbol": "BigInt", + "url": "dart:core", + "isNullable": true + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 1634, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 62, + "column": 10 + }, + "end": { + "offset": 1641, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 62, + "column": 17 + }, + "text": "aBigInt" + } + }, + { + "name": "aDateTime", + "type": { + "$": "TypeReference", + "symbol": "DateTime", + "url": "dart:core", + "isNullable": true + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 1655, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 63, + "column": 12 + }, + "end": { + "offset": 1664, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 63, + "column": 21 + }, + "text": "aDateTime" + } + }, + { + "name": "aDuration", + "type": { + "$": "TypeReference", + "symbol": "Duration", + "url": "dart:core", + "isNullable": true + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 1678, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 64, + "column": 12 + }, + "end": { + "offset": 1687, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 64, + "column": 21 + }, + "text": "aDuration" + } + }, + { + "name": "aRegExp", + "type": { + "$": "TypeReference", + "symbol": "RegExp", + "url": "dart:core", + "isNullable": true + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 1699, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 65, + "column": 10 + }, + "end": { + "offset": 1706, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 65, + "column": 17 + }, + "text": "aRegExp" + } + }, + { + "name": "aStackTrace", + "type": { + "$": "TypeReference", + "symbol": "StackTrace", + "url": "dart:core", + "isNullable": true + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 1722, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 66, + "column": 14 + }, + "end": { + "offset": 1733, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 66, + "column": 25 + }, + "text": "aStackTrace" + } + }, + { + "name": "aUri", + "type": { + "$": "TypeReference", + "symbol": "Uri", + "url": "dart:core", + "isNullable": true + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 1742, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 67, + "column": 7 + }, + "end": { + "offset": 1746, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 67, + "column": 11 + }, + "text": "aUri" + } + }, + { + "name": "aUriData", + "type": { + "$": "TypeReference", + "symbol": "UriData", + "url": "dart:core", + "isNullable": true + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 1759, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 68, + "column": 11 + }, + "end": { + "offset": 1767, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 68, + "column": 19 + }, + "text": "aUriData" + } + }, + { + "name": "aUint8List", + "type": { + "$": "TypeReference", + "symbol": "Uint8List", + "url": "dart:typed_data", + "isNullable": true + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 1782, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 69, + "column": 13 + }, + "end": { + "offset": 1792, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 69, + "column": 23 + }, + "text": "aUint8List" + } + }, + { + "name": "anIterableOfString", + "type": { + "$": "TypeReference", + "symbol": "Iterable", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": true + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 1814, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 70, + "column": 20 + }, + "end": { + "offset": 1832, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 70, + "column": 38 + }, + "text": "anIterableOfString" + } + }, + { + "name": "anIterableOfUint8List", + "type": { + "$": "TypeReference", + "symbol": "Iterable", + "url": "dart:core", + "types": [ + { + "$": "Reference", + "symbol": "Uint8List", + "url": "dart:typed_data" + } + ], + "isNullable": true + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 1857, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 71, + "column": 23 + }, + "end": { + "offset": 1878, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 71, + "column": 44 + }, + "text": "anIterableOfUint8List" + } + }, + { + "name": "aListOfString", + "type": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": true + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 1896, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 72, + "column": 16 + }, + "end": { + "offset": 1909, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 72, + "column": 29 + }, + "text": "aListOfString" + } + }, + { + "name": "aListOfInt", + "type": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "int", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": true + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 1924, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 73, + "column": 13 + }, + "end": { + "offset": 1934, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 73, + "column": 23 + }, + "text": "aListOfInt" + } + }, + { + "name": "aListOfDouble", + "type": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "double", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": true + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 1952, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 74, + "column": 16 + }, + "end": { + "offset": 1965, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 74, + "column": 29 + }, + "text": "aListOfDouble" + } + }, + { + "name": "aListOfBool", + "type": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "bool", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": true + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 1981, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 75, + "column": 14 + }, + "end": { + "offset": 1992, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 75, + "column": 25 + }, + "text": "aListOfBool" + } + }, + { + "name": "aListOfEnum", + "type": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "MyEnum", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": false + } + ], + "isNullable": true + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 2010, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 76, + "column": 16 + }, + "end": { + "offset": 2021, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 76, + "column": 27 + }, + "text": "aListOfEnum" + } + }, + { + "name": "aListOfNull", + "type": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "Null", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": true + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 2037, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 77, + "column": 14 + }, + "end": { + "offset": 2048, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 77, + "column": 25 + }, + "text": "aListOfNull" + } + }, + { + "name": "aListOfBigInt", + "type": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "Reference", + "symbol": "BigInt", + "url": "dart:core" + } + ], + "isNullable": true + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 2066, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 78, + "column": 16 + }, + "end": { + "offset": 2079, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 78, + "column": 29 + }, + "text": "aListOfBigInt" + } + }, + { + "name": "aListOfDateTime", + "type": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "Reference", + "symbol": "DateTime", + "url": "dart:core" + } + ], + "isNullable": true + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 2099, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 79, + "column": 18 + }, + "end": { + "offset": 2114, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 79, + "column": 33 + }, + "text": "aListOfDateTime" + } + }, + { + "name": "aListOfDuration", + "type": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "Reference", + "symbol": "Duration", + "url": "dart:core" + } + ], + "isNullable": true + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 2134, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 80, + "column": 18 + }, + "end": { + "offset": 2149, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 80, + "column": 33 + }, + "text": "aListOfDuration" + } + }, + { + "name": "aListOfRegExp", + "type": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "Reference", + "symbol": "RegExp", + "url": "dart:core" + } + ], + "isNullable": true + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 2167, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 81, + "column": 16 + }, + "end": { + "offset": 2180, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 81, + "column": 29 + }, + "text": "aListOfRegExp" + } + }, + { + "name": "aListOfStackTrace", + "type": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "Reference", + "symbol": "StackTrace", + "url": "dart:core" + } + ], + "isNullable": true + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 2202, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 82, + "column": 20 + }, + "end": { + "offset": 2219, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 82, + "column": 37 + }, + "text": "aListOfStackTrace" + } + }, + { + "name": "aListOfUri", + "type": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "Reference", + "symbol": "Uri", + "url": "dart:core" + } + ], + "isNullable": true + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 2234, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 83, + "column": 13 + }, + "end": { + "offset": 2244, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 83, + "column": 23 + }, + "text": "aListOfUri" + } + }, + { + "name": "aListOfUriData", + "type": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "Reference", + "symbol": "UriData", + "url": "dart:core" + } + ], + "isNullable": true + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 2263, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 84, + "column": 17 + }, + "end": { + "offset": 2277, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 84, + "column": 31 + }, + "text": "aListOfUriData" + } + }, + { + "name": "aListOfUint8List", + "type": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "Reference", + "symbol": "Uint8List", + "url": "dart:typed_data" + } + ], + "isNullable": true + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 2298, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 85, + "column": 19 + }, + "end": { + "offset": 2314, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 85, + "column": 35 + }, + "text": "aListOfUint8List" + } + }, + { + "name": "aMapOfString", + "type": { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": true + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 2339, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 86, + "column": 23 + }, + "end": { + "offset": 2351, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 86, + "column": 35 + }, + "text": "aMapOfString" + } + }, + { + "name": "aMapOfInt", + "type": { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "int", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": true + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 2373, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 87, + "column": 20 + }, + "end": { + "offset": 2382, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 87, + "column": 29 + }, + "text": "aMapOfInt" + } + }, + { + "name": "aMapOfDouble", + "type": { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "double", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": true + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 2407, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 88, + "column": 23 + }, + "end": { + "offset": 2419, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 88, + "column": 35 + }, + "text": "aMapOfDouble" + } + }, + { + "name": "aMapOfBool", + "type": { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "bool", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": true + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 2442, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 89, + "column": 21 + }, + "end": { + "offset": 2452, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 89, + "column": 31 + }, + "text": "aMapOfBool" + } + }, + { + "name": "aMapOfEnum", + "type": { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "MyEnum", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": false + } + ], + "isNullable": true + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 2477, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 90, + "column": 23 + }, + "end": { + "offset": 2487, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 90, + "column": 33 + }, + "text": "aMapOfEnum" + } + }, + { + "name": "aMapOfNull", + "type": { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "Null", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": true + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 2510, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 91, + "column": 21 + }, + "end": { + "offset": 2520, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 91, + "column": 31 + }, + "text": "aMapOfNull" + } + }, + { + "name": "aMapOfBigInt", + "type": { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "Reference", + "symbol": "BigInt", + "url": "dart:core" + } + ], + "isNullable": true + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 2545, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 92, + "column": 23 + }, + "end": { + "offset": 2557, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 92, + "column": 35 + }, + "text": "aMapOfBigInt" + } + }, + { + "name": "aMapOfDateTime", + "type": { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "Reference", + "symbol": "DateTime", + "url": "dart:core" + } + ], + "isNullable": true + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 2584, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 93, + "column": 25 + }, + "end": { + "offset": 2598, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 93, + "column": 39 + }, + "text": "aMapOfDateTime" + } + }, + { + "name": "aMapOfDuration", + "type": { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "Reference", + "symbol": "Duration", + "url": "dart:core" + } + ], + "isNullable": true + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 2625, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 94, + "column": 25 + }, + "end": { + "offset": 2639, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 94, + "column": 39 + }, + "text": "aMapOfDuration" + } + }, + { + "name": "aMapOfRegExp", + "type": { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "Reference", + "symbol": "RegExp", + "url": "dart:core" + } + ], + "isNullable": true + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 2664, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 95, + "column": 23 + }, + "end": { + "offset": 2676, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 95, + "column": 35 + }, + "text": "aMapOfRegExp" + } + }, + { + "name": "aMapOfStackTrace", + "type": { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "Reference", + "symbol": "StackTrace", + "url": "dart:core" + } + ], + "isNullable": true + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 2705, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 96, + "column": 27 + }, + "end": { + "offset": 2721, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 96, + "column": 43 + }, + "text": "aMapOfStackTrace" + } + }, + { + "name": "aMapOfUri", + "type": { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "Reference", + "symbol": "Uri", + "url": "dart:core" + } + ], + "isNullable": true + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 2743, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 97, + "column": 20 + }, + "end": { + "offset": 2752, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 97, + "column": 29 + }, + "text": "aMapOfUri" + } + }, + { + "name": "aMapOfUriData", + "type": { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "Reference", + "symbol": "UriData", + "url": "dart:core" + } + ], + "isNullable": true + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 2778, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 98, + "column": 24 + }, + "end": { + "offset": 2791, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 98, + "column": 37 + }, + "text": "aMapOfUriData" + } + }, + { + "name": "aMapOfUint8List", + "type": { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "Reference", + "symbol": "Uint8List", + "url": "dart:typed_data" + } + ], + "isNullable": true + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 2819, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 99, + "column": 26 + }, + "end": { + "offset": 2834, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 99, + "column": 41 + }, + "text": "aMapOfUint8List" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "Future", + "url": "dart:async", + "types": [ + { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 1509, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 55, + "column": 13 + }, + "end": { + "offset": 1523, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 55, + "column": 27 + }, + "text": "simpleOptional" + } + }, + "complex": { + "name": "complex", + "apiName": "parameter_types", + "typeParameters": [], + "parameters": [ + { + "name": "aSimpleStruct", + "type": { + "$": "TypeReference", + "symbol": "SimpleStruct", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 2892, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 104, + "column": 15 + }, + "end": { + "offset": 2905, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 104, + "column": 28 + }, + "text": "aSimpleStruct" + } + }, + { + "name": "aComplexStruct", + "type": { + "$": "TypeReference", + "symbol": "ComplexStruct", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 2923, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 105, + "column": 16 + }, + "end": { + "offset": 2937, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 105, + "column": 30 + }, + "text": "aComplexStruct" + } + }, + { + "name": "aSimpleClass", + "type": { + "$": "TypeReference", + "symbol": "SimpleClass", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 2953, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 106, + "column": 14 + }, + "end": { + "offset": 2965, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 106, + "column": 26 + }, + "text": "aSimpleClass" + } + }, + { + "name": "aComplexClass", + "type": { + "$": "TypeReference", + "symbol": "ComplexClass", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 2982, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 107, + "column": 15 + }, + "end": { + "offset": 2995, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 107, + "column": 28 + }, + "text": "aComplexClass" + } + }, + { + "name": "aNullableSimpleStruct", + "type": { + "$": "TypeReference", + "symbol": "SimpleStruct", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": true + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 3013, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 108, + "column": 16 + }, + "end": { + "offset": 3034, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 108, + "column": 37 + }, + "text": "aNullableSimpleStruct" + } + }, + { + "name": "aNullableComplexStruct", + "type": { + "$": "TypeReference", + "symbol": "ComplexStruct", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": true + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 3053, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 109, + "column": 17 + }, + "end": { + "offset": 3075, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 109, + "column": 39 + }, + "text": "aNullableComplexStruct" + } + }, + { + "name": "aNullableSimpleClass", + "type": { + "$": "TypeReference", + "symbol": "SimpleClass", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": true + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 3092, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 110, + "column": 15 + }, + "end": { + "offset": 3112, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 110, + "column": 35 + }, + "text": "aNullableSimpleClass" + } + }, + { + "name": "aNullableComplexClass", + "type": { + "$": "TypeReference", + "symbol": "ComplexClass", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": true + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 3130, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 111, + "column": 16 + }, + "end": { + "offset": 3151, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 111, + "column": 37 + }, + "text": "aNullableComplexClass" + } + }, + { + "name": "anIterableOfSimpleStruct", + "type": { + "$": "TypeReference", + "symbol": "Iterable", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "SimpleStruct", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": false + } + ], + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 3178, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 112, + "column": 25 + }, + "end": { + "offset": 3202, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 112, + "column": 49 + }, + "text": "anIterableOfSimpleStruct" + } + }, + { + "name": "anIterableOfComplexStruct", + "type": { + "$": "TypeReference", + "symbol": "Iterable", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "ComplexStruct", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": false + } + ], + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 3230, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 113, + "column": 26 + }, + "end": { + "offset": 3255, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 113, + "column": 51 + }, + "text": "anIterableOfComplexStruct" + } + }, + { + "name": "anIterableOfSimpleClass", + "type": { + "$": "TypeReference", + "symbol": "Iterable", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "SimpleClass", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": false + } + ], + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 3281, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 114, + "column": 24 + }, + "end": { + "offset": 3304, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 114, + "column": 47 + }, + "text": "anIterableOfSimpleClass" + } + }, + { + "name": "anIterableOfComplexClass", + "type": { + "$": "TypeReference", + "symbol": "Iterable", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "ComplexClass", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": false + } + ], + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 3331, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 115, + "column": 25 + }, + "end": { + "offset": 3355, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 115, + "column": 49 + }, + "text": "anIterableOfComplexClass" + } + }, + { + "name": "aNullableIterableOfSimpleStruct", + "type": { + "$": "TypeReference", + "symbol": "Iterable", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "SimpleStruct", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": false + } + ], + "isNullable": true + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 3383, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 116, + "column": 26 + }, + "end": { + "offset": 3414, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 116, + "column": 57 + }, + "text": "aNullableIterableOfSimpleStruct" + } + }, + { + "name": "aNullableIterableOfComplexStruct", + "type": { + "$": "TypeReference", + "symbol": "Iterable", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "ComplexStruct", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": false + } + ], + "isNullable": true + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 3443, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 117, + "column": 27 + }, + "end": { + "offset": 3475, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 117, + "column": 59 + }, + "text": "aNullableIterableOfComplexStruct" + } + }, + { + "name": "aNullableIterableOfSimpleClass", + "type": { + "$": "TypeReference", + "symbol": "Iterable", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "SimpleClass", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": false + } + ], + "isNullable": true + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 3502, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 118, + "column": 25 + }, + "end": { + "offset": 3532, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 118, + "column": 55 + }, + "text": "aNullableIterableOfSimpleClass" + } + }, + { + "name": "aNullableIterableOfComplexClass", + "type": { + "$": "TypeReference", + "symbol": "Iterable", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "ComplexClass", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": false + } + ], + "isNullable": true + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 3560, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 119, + "column": 26 + }, + "end": { + "offset": 3591, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 119, + "column": 57 + }, + "text": "aNullableIterableOfComplexClass" + } + }, + { + "name": "anIterableOfNullableSimpleStruct", + "type": { + "$": "TypeReference", + "symbol": "Iterable", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "SimpleStruct", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": true + } + ], + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 3619, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 120, + "column": 26 + }, + "end": { + "offset": 3651, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 120, + "column": 58 + }, + "text": "anIterableOfNullableSimpleStruct" + } + }, + { + "name": "anIterableOfNullableComplexStruct", + "type": { + "$": "TypeReference", + "symbol": "Iterable", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "ComplexStruct", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": true + } + ], + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 3680, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 121, + "column": 27 + }, + "end": { + "offset": 3713, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 121, + "column": 60 + }, + "text": "anIterableOfNullableComplexStruct" + } + }, + { + "name": "anIterableOfNullableSimpleClass", + "type": { + "$": "TypeReference", + "symbol": "Iterable", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "SimpleClass", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": true + } + ], + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 3740, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 122, + "column": 25 + }, + "end": { + "offset": 3771, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 122, + "column": 56 + }, + "text": "anIterableOfNullableSimpleClass" + } + }, + { + "name": "anIterableOfNullableComplexClass", + "type": { + "$": "TypeReference", + "symbol": "Iterable", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "ComplexClass", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": true + } + ], + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 3799, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 123, + "column": 26 + }, + "end": { + "offset": 3831, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 123, + "column": 58 + }, + "text": "anIterableOfNullableComplexClass" + } + }, + { + "name": "aListOfSimpleStruct", + "type": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "SimpleStruct", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": false + } + ], + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 3854, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 124, + "column": 21 + }, + "end": { + "offset": 3873, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 124, + "column": 40 + }, + "text": "aListOfSimpleStruct" + } + }, + { + "name": "aListOfComplexStruct", + "type": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "ComplexStruct", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": false + } + ], + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 3897, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 125, + "column": 22 + }, + "end": { + "offset": 3917, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 125, + "column": 42 + }, + "text": "aListOfComplexStruct" + } + }, + { + "name": "aListOfSimpleClass", + "type": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "SimpleClass", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": false + } + ], + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 3939, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 126, + "column": 20 + }, + "end": { + "offset": 3957, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 126, + "column": 38 + }, + "text": "aListOfSimpleClass" + } + }, + { + "name": "aListOfComplexClass", + "type": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "ComplexClass", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": false + } + ], + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 3980, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 127, + "column": 21 + }, + "end": { + "offset": 3999, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 127, + "column": 40 + }, + "text": "aListOfComplexClass" + } + }, + { + "name": "aNullableListOfSimpleStruct", + "type": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "SimpleStruct", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": false + } + ], + "isNullable": true + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 4023, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 128, + "column": 22 + }, + "end": { + "offset": 4050, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 128, + "column": 49 + }, + "text": "aNullableListOfSimpleStruct" + } + }, + { + "name": "aNullableListOfComplexStruct", + "type": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "ComplexStruct", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": false + } + ], + "isNullable": true + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 4075, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 129, + "column": 23 + }, + "end": { + "offset": 4103, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 129, + "column": 51 + }, + "text": "aNullableListOfComplexStruct" + } + }, + { + "name": "aNullableListOfSimpleClass", + "type": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "SimpleClass", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": false + } + ], + "isNullable": true + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 4126, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 130, + "column": 21 + }, + "end": { + "offset": 4152, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 130, + "column": 47 + }, + "text": "aNullableListOfSimpleClass" + } + }, + { + "name": "aNullableListOfComplexClass", + "type": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "ComplexClass", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": false + } + ], + "isNullable": true + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 4176, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 131, + "column": 22 + }, + "end": { + "offset": 4203, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 131, + "column": 49 + }, + "text": "aNullableListOfComplexClass" + } + }, + { + "name": "aListOfNullableSimpleStruct", + "type": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "SimpleStruct", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": true + } + ], + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 4227, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 132, + "column": 22 + }, + "end": { + "offset": 4254, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 132, + "column": 49 + }, + "text": "aListOfNullableSimpleStruct" + } + }, + { + "name": "aListOfNullableComplexStruct", + "type": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "ComplexStruct", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": true + } + ], + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 4279, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 133, + "column": 23 + }, + "end": { + "offset": 4307, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 133, + "column": 51 + }, + "text": "aListOfNullableComplexStruct" + } + }, + { + "name": "aListOfNullableSimpleClass", + "type": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "SimpleClass", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": true + } + ], + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 4330, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 134, + "column": 21 + }, + "end": { + "offset": 4356, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 134, + "column": 47 + }, + "text": "aListOfNullableSimpleClass" + } + }, + { + "name": "aListOfNullableComplexClass", + "type": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "ComplexClass", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": true + } + ], + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 4380, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 135, + "column": 22 + }, + "end": { + "offset": 4407, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 135, + "column": 49 + }, + "text": "aListOfNullableComplexClass" + } + }, + { + "name": "aMapOfSimpleStruct", + "type": { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "SimpleStruct", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": false + } + ], + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 4437, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 136, + "column": 28 + }, + "end": { + "offset": 4455, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 136, + "column": 46 + }, + "text": "aMapOfSimpleStruct" + } + }, + { + "name": "aMapOfComplexStruct", + "type": { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ComplexStruct", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": false + } + ], + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 4486, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 137, + "column": 29 + }, + "end": { + "offset": 4505, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 137, + "column": 48 + }, + "text": "aMapOfComplexStruct" + } + }, + { + "name": "aMapOfSimpleClass", + "type": { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "SimpleClass", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": false + } + ], + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 4534, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 138, + "column": 27 + }, + "end": { + "offset": 4551, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 138, + "column": 44 + }, + "text": "aMapOfSimpleClass" + } + }, + { + "name": "aMapOfComplexClass", + "type": { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ComplexClass", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": false + } + ], + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 4581, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 139, + "column": 28 + }, + "end": { + "offset": 4599, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 139, + "column": 46 + }, + "text": "aMapOfComplexClass" + } + }, + { + "name": "aNullableMapOfSimpleStruct", + "type": { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "SimpleStruct", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": false + } + ], + "isNullable": true + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 4630, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 140, + "column": 29 + }, + "end": { + "offset": 4656, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 140, + "column": 55 + }, + "text": "aNullableMapOfSimpleStruct" + } + }, + { + "name": "aNullableMapOfComplexStruct", + "type": { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ComplexStruct", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": false + } + ], + "isNullable": true + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 4688, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 141, + "column": 30 + }, + "end": { + "offset": 4715, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 141, + "column": 57 + }, + "text": "aNullableMapOfComplexStruct" + } + }, + { + "name": "aNullableMapOfSimpleClass", + "type": { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "SimpleClass", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": false + } + ], + "isNullable": true + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 4745, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 142, + "column": 28 + }, + "end": { + "offset": 4770, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 142, + "column": 53 + }, + "text": "aNullableMapOfSimpleClass" + } + }, + { + "name": "aNullableMapOfComplexClass", + "type": { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ComplexClass", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": false + } + ], + "isNullable": true + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 4801, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 143, + "column": 29 + }, + "end": { + "offset": 4827, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 143, + "column": 55 + }, + "text": "aNullableMapOfComplexClass" + } + }, + { + "name": "aMapOfNullableSimpleStruct", + "type": { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "SimpleStruct", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": true + } + ], + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 4858, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 144, + "column": 29 + }, + "end": { + "offset": 4884, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 144, + "column": 55 + }, + "text": "aMapOfNullableSimpleStruct" + } + }, + { + "name": "aMapOfNullableComplexStruct", + "type": { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ComplexStruct", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": true + } + ], + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 4916, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 145, + "column": 30 + }, + "end": { + "offset": 4943, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 145, + "column": 57 + }, + "text": "aMapOfNullableComplexStruct" + } + }, + { + "name": "aMapOfNullableSimpleClass", + "type": { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "SimpleClass", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": true + } + ], + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 4973, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 146, + "column": 28 + }, + "end": { + "offset": 4998, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 146, + "column": 53 + }, + "text": "aMapOfNullableSimpleClass" + } + }, + { + "name": "aMapOfNullableComplexClass", + "type": { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ComplexClass", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": true + } + ], + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 5029, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 147, + "column": 29 + }, + "end": { + "offset": 5055, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 147, + "column": 55 + }, + "text": "aMapOfNullableComplexClass" + } + }, + { + "name": "aNullableMapOfNullableSimpleStruct", + "type": { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "SimpleStruct", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": true + } + ], + "isNullable": true + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 5087, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 148, + "column": 30 + }, + "end": { + "offset": 5121, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 148, + "column": 64 + }, + "text": "aNullableMapOfNullableSimpleStruct" + } + }, + { + "name": "aNullableMapOfNullableComplexStruct", + "type": { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ComplexStruct", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": true + } + ], + "isNullable": true + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 5154, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 149, + "column": 31 + }, + "end": { + "offset": 5189, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 149, + "column": 66 + }, + "text": "aNullableMapOfNullableComplexStruct" + } + }, + { + "name": "aNullableMapOfNullableSimpleClass", + "type": { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "SimpleClass", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": true + } + ], + "isNullable": true + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 5220, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 150, + "column": 29 + }, + "end": { + "offset": 5253, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 150, + "column": 62 + }, + "text": "aNullableMapOfNullableSimpleClass" + } + }, + { + "name": "aNullableMapOfNullableComplexClass", + "type": { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ComplexClass", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": true + } + ], + "isNullable": true + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 5285, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 151, + "column": 30 + }, + "end": { + "offset": 5319, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 151, + "column": 64 + }, + "text": "aNullableMapOfNullableComplexClass" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "Future", + "url": "dart:async", + "types": [ + { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 2868, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 103, + "column": 13 + }, + "end": { + "offset": 2875, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 103, + "column": 20 + }, + "text": "complex" + } + } + }, + "docs": [], + "exceptionTypes": [ + { + "$": "TypeReference", + "symbol": "CloudException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "CancelledException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnknownError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "BadRequestException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnauthorizedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "NotFoundException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AlreadyExistsException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "PermissionDeniedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ResourceExhaustedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "FailedPreconditionException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AbortedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "OutOfRangeException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnimplementedError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "InternalServerError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnavailableError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "DataLossError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "DeadlineExceededError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "SerializationException", + "url": "package:celest_core/src/exception/serialization_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "Error", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AssertionError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "TypeError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ArgumentError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "RangeError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "IndexError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnsupportedError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnimplementedError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "StateError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ConcurrentModificationError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "OutOfMemoryError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "StackOverflowError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "Exception", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "FormatException", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "IntegerDivisionByZeroException", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AsyncError", + "url": "dart:async", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "TimeoutException", + "url": "dart:async", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "JsonUnsupportedObjectError", + "url": "dart:convert", + "isNullable": false + } + ], + "location": { + "start": { + "offset": 0, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 0, + "column": 0 + }, + "end": { + "offset": 0, + "uri": "package:celest_backend/src/functions/parameter_types.dart", + "line": 0, + "column": 0 + }, + "text": "" + } + }, + "cycles": { + "name": "cycles", + "metadata": [], + "functions": { + "createTree": { + "name": "createTree", + "apiName": "cycles", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "TypeReference", + "symbol": "Node", + "url": "package:celest_backend/models/cycles.dart", + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "Node", + "url": "package:celest_backend/models/cycles.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 210, + "uri": "package:celest_backend/src/functions/cycles.dart", + "line": 8, + "column": 5 + }, + "end": { + "offset": 220, + "uri": "package:celest_backend/src/functions/cycles.dart", + "line": 8, + "column": 15 + }, + "text": "createTree" + } + }, + "printTree": { + "name": "printTree", + "apiName": "cycles", + "typeParameters": [], + "parameters": [ + { + "name": "node", + "type": { + "$": "TypeReference", + "symbol": "Node", + "url": "package:celest_backend/models/cycles.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 542, + "uri": "package:celest_backend/src/functions/cycles.dart", + "line": 31, + "column": 20 + }, + "end": { + "offset": 546, + "uri": "package:celest_backend/src/functions/cycles.dart", + "line": 31, + "column": 24 + }, + "text": "node" + } + } + ], + "returnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "flattenedReturnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 527, + "uri": "package:celest_backend/src/functions/cycles.dart", + "line": 31, + "column": 5 + }, + "end": { + "offset": 536, + "uri": "package:celest_backend/src/functions/cycles.dart", + "line": 31, + "column": 14 + }, + "text": "printTree" + } + }, + "combineTrees": { + "name": "combineTrees", + "apiName": "cycles", + "typeParameters": [], + "parameters": [ + { + "name": "tree1", + "type": { + "$": "TypeReference", + "symbol": "Node", + "url": "package:celest_backend/models/cycles.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 841, + "uri": "package:celest_backend/src/functions/cycles.dart", + "line": 45, + "column": 7 + }, + "end": { + "offset": 846, + "uri": "package:celest_backend/src/functions/cycles.dart", + "line": 45, + "column": 12 + }, + "text": "tree1" + } + }, + { + "name": "tree2", + "type": { + "$": "TypeReference", + "symbol": "Parent", + "url": "package:celest_backend/models/cycles.dart", + "isNullable": true + }, + "required": false, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 860, + "uri": "package:celest_backend/src/functions/cycles.dart", + "line": 46, + "column": 10 + }, + "end": { + "offset": 865, + "uri": "package:celest_backend/src/functions/cycles.dart", + "line": 46, + "column": 15 + }, + "text": "tree2" + }, + "defaultTo": { + "$": "DartNull", + "staticType": { + "symbol": "Null", + "url": "dart:core" + } + } + }, + { + "name": "tree3", + "type": { + "$": "TypeReference", + "symbol": "Node", + "url": "package:celest_backend/models/cycles.dart", + "isNullable": true + }, + "required": false, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 875, + "uri": "package:celest_backend/src/functions/cycles.dart", + "line": 47, + "column": 8 + }, + "end": { + "offset": 880, + "uri": "package:celest_backend/src/functions/cycles.dart", + "line": 47, + "column": 13 + }, + "text": "tree3" + }, + "defaultTo": { + "$": "DartNull", + "staticType": { + "symbol": "Null", + "url": "dart:core" + } + } + }, + { + "name": "additionalChildren", + "type": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "Node", + "url": "package:celest_backend/models/cycles.dart", + "isNullable": true + } + ], + "isNullable": false + }, + "required": false, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 896, + "uri": "package:celest_backend/src/functions/cycles.dart", + "line": 48, + "column": 14 + }, + "end": { + "offset": 914, + "uri": "package:celest_backend/src/functions/cycles.dart", + "line": 48, + "column": 32 + }, + "text": "additionalChildren" + }, + "defaultTo": { + "$": "DartList", + "value": [], + "staticType": { + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "Node", + "url": "package:celest_backend/models/cycles.dart", + "isNullable": true + } + ], + "isNullable": false + } + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "Node", + "url": "package:celest_backend/models/cycles.dart", + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "Node", + "url": "package:celest_backend/models/cycles.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 820, + "uri": "package:celest_backend/src/functions/cycles.dart", + "line": 44, + "column": 5 + }, + "end": { + "offset": 832, + "uri": "package:celest_backend/src/functions/cycles.dart", + "line": 44, + "column": 17 + }, + "text": "combineTrees" + } + }, + "selfReferencing": { + "name": "selfReferencing", + "apiName": "cycles", + "typeParameters": [], + "parameters": [ + { + "name": "selfReferencing", + "type": { + "$": "TypeReference", + "symbol": "SelfReferencing", + "url": "package:celest_backend/models/cycles.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 1279, + "uri": "package:celest_backend/src/functions/cycles.dart", + "line": 64, + "column": 48 + }, + "end": { + "offset": 1294, + "uri": "package:celest_backend/src/functions/cycles.dart", + "line": 64, + "column": 63 + }, + "text": "selfReferencing" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "SelfReferencing", + "url": "package:celest_backend/models/cycles.dart", + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "SelfReferencing", + "url": "package:celest_backend/models/cycles.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [ + "/// Tests that self-referencing is allowed when there is a level", + "/// of indirection, e.g. nullability, generics, or a wrapper." + ], + "location": { + "start": { + "offset": 1247, + "uri": "package:celest_backend/src/functions/cycles.dart", + "line": 64, + "column": 16 + }, + "end": { + "offset": 1262, + "uri": "package:celest_backend/src/functions/cycles.dart", + "line": 64, + "column": 31 + }, + "text": "selfReferencing" + } + } + }, + "docs": [ + "/// Tests that some cycles are allowed, e.g. when there is at least one level", + "/// of indirection." + ], + "exceptionTypes": [ + { + "$": "TypeReference", + "symbol": "CloudException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "CancelledException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnknownError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "BadRequestException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnauthorizedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "NotFoundException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AlreadyExistsException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "PermissionDeniedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ResourceExhaustedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "FailedPreconditionException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AbortedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "OutOfRangeException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnimplementedError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "InternalServerError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnavailableError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "DataLossError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "DeadlineExceededError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "SerializationException", + "url": "package:celest_core/src/exception/serialization_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "Error", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AssertionError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "TypeError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ArgumentError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "RangeError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "IndexError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnsupportedError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnimplementedError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "StateError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ConcurrentModificationError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "OutOfMemoryError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "StackOverflowError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "Exception", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "FormatException", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "IntegerDivisionByZeroException", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AsyncError", + "url": "dart:async", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "TimeoutException", + "url": "dart:async", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "JsonUnsupportedObjectError", + "url": "dart:convert", + "isNullable": false + } + ], + "location": { + "start": { + "offset": 0, + "uri": "package:celest_backend/src/functions/cycles.dart", + "line": 0, + "column": 0 + }, + "end": { + "offset": 0, + "uri": "package:celest_backend/src/functions/cycles.dart", + "line": 0, + "column": 0 + }, + "text": "" + } + }, + "extension_types": { + "name": "extension_types", + "metadata": [], + "functions": { + "string": { + "name": "string", + "apiName": "extension_types", + "typeParameters": [], + "parameters": [ + { + "name": "s", + "type": { + "$": "TypeReference", + "symbol": "StringX", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 256, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 10, + "column": 23 + }, + "end": { + "offset": 257, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 10, + "column": 24 + }, + "text": "s" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "StringX", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "StringX", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 241, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 10, + "column": 8 + }, + "end": { + "offset": 247, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 10, + "column": 14 + }, + "text": "string" + } + }, + "asyncOrString": { + "name": "asyncOrString", + "apiName": "extension_types", + "typeParameters": [], + "parameters": [ + { + "name": "s", + "type": { + "$": "TypeReference", + "symbol": "StringX", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 312, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 12, + "column": 40 + }, + "end": { + "offset": 313, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 12, + "column": 41 + }, + "text": "s" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "FutureOr", + "url": "dart:async", + "types": [ + { + "$": "TypeReference", + "symbol": "StringX", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "StringX", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 290, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 12, + "column": 18 + }, + "end": { + "offset": 303, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 12, + "column": 31 + }, + "text": "asyncOrString" + } + }, + "asyncString": { + "name": "asyncString", + "apiName": "extension_types", + "typeParameters": [], + "parameters": [ + { + "name": "s", + "type": { + "$": "TypeReference", + "symbol": "StringX", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 364, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 14, + "column": 36 + }, + "end": { + "offset": 365, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 14, + "column": 37 + }, + "text": "s" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "Future", + "url": "dart:async", + "types": [ + { + "$": "TypeReference", + "symbol": "StringX", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "StringX", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 344, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 14, + "column": 16 + }, + "end": { + "offset": 355, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 14, + "column": 27 + }, + "text": "asyncString" + } + }, + "stringImpl": { + "name": "stringImpl", + "apiName": "extension_types", + "typeParameters": [], + "parameters": [ + { + "name": "s", + "type": { + "$": "TypeReference", + "symbol": "StringXImpl", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 455, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 18, + "column": 35 + }, + "end": { + "offset": 456, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 18, + "column": 36 + }, + "text": "s" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "StringXImpl", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "StringXImpl", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 432, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 18, + "column": 12 + }, + "end": { + "offset": 442, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 18, + "column": 22 + }, + "text": "stringImpl" + } + }, + "stringToFromJson": { + "name": "stringToFromJson", + "apiName": "extension_types", + "typeParameters": [], + "parameters": [ + { + "name": "s", + "type": { + "$": "TypeReference", + "symbol": "StringXToFromJson", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 524, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 20, + "column": 53 + }, + "end": { + "offset": 525, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 20, + "column": 54 + }, + "text": "s" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "StringXToFromJson", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "StringXToFromJson", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 489, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 20, + "column": 18 + }, + "end": { + "offset": 505, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 20, + "column": 34 + }, + "text": "stringToFromJson" + } + }, + "stringToJson": { + "name": "stringToJson", + "apiName": "extension_types", + "typeParameters": [], + "parameters": [ + { + "name": "s", + "type": { + "$": "TypeReference", + "symbol": "StringXToJson", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 581, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 22, + "column": 41 + }, + "end": { + "offset": 582, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 22, + "column": 42 + }, + "text": "s" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "StringXToJson", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "StringXToJson", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 554, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 22, + "column": 14 + }, + "end": { + "offset": 566, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 22, + "column": 26 + }, + "text": "stringToJson" + } + }, + "stringToJsonImpl": { + "name": "stringToJsonImpl", + "apiName": "extension_types", + "typeParameters": [], + "parameters": [ + { + "name": "s", + "type": { + "$": "TypeReference", + "symbol": "StringXToJsonImpl", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 650, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 24, + "column": 53 + }, + "end": { + "offset": 651, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 24, + "column": 54 + }, + "text": "s" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "StringXToJsonImpl", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "StringXToJsonImpl", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 615, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 24, + "column": 18 + }, + "end": { + "offset": 631, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 24, + "column": 34 + }, + "text": "stringToJsonImpl" + } + }, + "stringFromJson": { + "name": "stringFromJson", + "apiName": "extension_types", + "typeParameters": [], + "parameters": [ + { + "name": "s", + "type": { + "$": "TypeReference", + "symbol": "StringXFromJson", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 713, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 26, + "column": 47 + }, + "end": { + "offset": 714, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 26, + "column": 48 + }, + "text": "s" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "StringXFromJson", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "StringXFromJson", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 682, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 26, + "column": 16 + }, + "end": { + "offset": 696, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 26, + "column": 30 + }, + "text": "stringFromJson" + } + }, + "stringFromJsonImpl": { + "name": "stringFromJsonImpl", + "apiName": "extension_types", + "typeParameters": [], + "parameters": [ + { + "name": "s", + "type": { + "$": "TypeReference", + "symbol": "StringXFromJsonImpl", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 788, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 28, + "column": 59 + }, + "end": { + "offset": 789, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 28, + "column": 60 + }, + "text": "s" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "StringXFromJsonImpl", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "StringXFromJsonImpl", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 749, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 28, + "column": 20 + }, + "end": { + "offset": 767, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 28, + "column": 38 + }, + "text": "stringFromJsonImpl" + } + }, + "stringFromJsonStatic": { + "name": "stringFromJsonStatic", + "apiName": "extension_types", + "typeParameters": [], + "parameters": [ + { + "name": "s", + "type": { + "$": "TypeReference", + "symbol": "StringXFromJsonStatic", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 869, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 30, + "column": 65 + }, + "end": { + "offset": 870, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 30, + "column": 66 + }, + "text": "s" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "StringXFromJsonStatic", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "StringXFromJsonStatic", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 826, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 30, + "column": 22 + }, + "end": { + "offset": 846, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 30, + "column": 42 + }, + "text": "stringFromJsonStatic" + } + }, + "stringPrivateField": { + "name": "stringPrivateField", + "apiName": "extension_types", + "typeParameters": [], + "parameters": [ + { + "name": "s", + "type": { + "$": "TypeReference", + "symbol": "StringXPrivateField", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 944, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 32, + "column": 59 + }, + "end": { + "offset": 945, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 32, + "column": 60 + }, + "text": "s" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "StringXPrivateField", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "StringXPrivateField", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 905, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 32, + "column": 20 + }, + "end": { + "offset": 923, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 32, + "column": 38 + }, + "text": "stringPrivateField" + } + }, + "stringPrivateFieldImpl": { + "name": "stringPrivateFieldImpl", + "apiName": "extension_types", + "typeParameters": [], + "parameters": [ + { + "name": "s", + "type": { + "$": "TypeReference", + "symbol": "StringXPrivateFieldImpl", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 1031, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 34, + "column": 71 + }, + "end": { + "offset": 1032, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 34, + "column": 72 + }, + "text": "s" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "StringXPrivateFieldImpl", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "StringXPrivateFieldImpl", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 984, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 34, + "column": 24 + }, + "end": { + "offset": 1006, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 34, + "column": 46 + }, + "text": "stringPrivateFieldImpl" + } + }, + "stringPrivateCtor": { + "name": "stringPrivateCtor", + "apiName": "extension_types", + "typeParameters": [], + "parameters": [ + { + "name": "s", + "type": { + "$": "TypeReference", + "symbol": "StringXPrivateCtor", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 1103, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 36, + "column": 56 + }, + "end": { + "offset": 1104, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 36, + "column": 57 + }, + "text": "s" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "StringXPrivateCtor", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "StringXPrivateCtor", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 1066, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 36, + "column": 19 + }, + "end": { + "offset": 1083, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 36, + "column": 36 + }, + "text": "stringPrivateCtor" + } + }, + "stringPrivateCtorImpl": { + "name": "stringPrivateCtorImpl", + "apiName": "extension_types", + "typeParameters": [], + "parameters": [ + { + "name": "s", + "type": { + "$": "TypeReference", + "symbol": "StringXPrivateCtorImpl", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 1187, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 38, + "column": 68 + }, + "end": { + "offset": 1188, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 38, + "column": 69 + }, + "text": "s" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "StringXPrivateCtorImpl", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "StringXPrivateCtorImpl", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 1142, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 38, + "column": 23 + }, + "end": { + "offset": 1163, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 38, + "column": 44 + }, + "text": "stringPrivateCtorImpl" + } + }, + "value": { + "name": "value", + "apiName": "extension_types", + "typeParameters": [], + "parameters": [ + { + "name": "v", + "type": { + "$": "TypeReference", + "symbol": "Value", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 1258, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 42, + "column": 18 + }, + "end": { + "offset": 1259, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 42, + "column": 19 + }, + "text": "v" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "Value", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "Value", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 1246, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 42, + "column": 6 + }, + "end": { + "offset": 1251, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 42, + "column": 11 + }, + "text": "value" + } + }, + "valueX": { + "name": "valueX", + "apiName": "extension_types", + "typeParameters": [], + "parameters": [ + { + "name": "v", + "type": { + "$": "TypeReference", + "symbol": "ValueX", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 1295, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 44, + "column": 21 + }, + "end": { + "offset": 1296, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 44, + "column": 22 + }, + "text": "v" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "ValueX", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "ValueX", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 1281, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 44, + "column": 7 + }, + "end": { + "offset": 1287, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 44, + "column": 13 + }, + "text": "valueX" + } + }, + "valueXImpl": { + "name": "valueXImpl", + "apiName": "extension_types", + "typeParameters": [], + "parameters": [ + { + "name": "v", + "type": { + "$": "TypeReference", + "symbol": "ValueXImpl", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 1344, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 46, + "column": 33 + }, + "end": { + "offset": 1345, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 46, + "column": 34 + }, + "text": "v" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "ValueXImpl", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "ValueXImpl", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 1322, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 46, + "column": 11 + }, + "end": { + "offset": 1332, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 46, + "column": 21 + }, + "text": "valueXImpl" + } + }, + "valueXToFromJson": { + "name": "valueXToFromJson", + "apiName": "extension_types", + "typeParameters": [], + "parameters": [ + { + "name": "v", + "type": { + "$": "TypeReference", + "symbol": "ValueXToFromJson", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 1411, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 48, + "column": 51 + }, + "end": { + "offset": 1412, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 48, + "column": 52 + }, + "text": "v" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "ValueXToFromJson", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "ValueXToFromJson", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 1377, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 48, + "column": 17 + }, + "end": { + "offset": 1393, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 48, + "column": 33 + }, + "text": "valueXToFromJson" + } + }, + "valueXToJson": { + "name": "valueXToJson", + "apiName": "extension_types", + "typeParameters": [], + "parameters": [ + { + "name": "v", + "type": { + "$": "TypeReference", + "symbol": "ValueXToJson", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 1466, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 50, + "column": 39 + }, + "end": { + "offset": 1467, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 50, + "column": 40 + }, + "text": "v" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "ValueXToJson", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "ValueXToJson", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 1440, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 50, + "column": 13 + }, + "end": { + "offset": 1452, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 50, + "column": 25 + }, + "text": "valueXToJson" + } + }, + "valueXToJsonImpl": { + "name": "valueXToJsonImpl", + "apiName": "extension_types", + "typeParameters": [], + "parameters": [ + { + "name": "v", + "type": { + "$": "TypeReference", + "symbol": "ValueXToJsonImpl", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 1533, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 52, + "column": 51 + }, + "end": { + "offset": 1534, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 52, + "column": 52 + }, + "text": "v" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "ValueXToJsonImpl", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "ValueXToJsonImpl", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 1499, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 52, + "column": 17 + }, + "end": { + "offset": 1515, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 52, + "column": 33 + }, + "text": "valueXToJsonImpl" + } + }, + "valueXFromJson": { + "name": "valueXFromJson", + "apiName": "extension_types", + "typeParameters": [], + "parameters": [ + { + "name": "v", + "type": { + "$": "TypeReference", + "symbol": "ValueXFromJson", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 1594, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 54, + "column": 45 + }, + "end": { + "offset": 1595, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 54, + "column": 46 + }, + "text": "v" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "ValueXFromJson", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "ValueXFromJson", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 1564, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 54, + "column": 15 + }, + "end": { + "offset": 1578, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 54, + "column": 29 + }, + "text": "valueXFromJson" + } + }, + "valueXFromJsonImpl": { + "name": "valueXFromJsonImpl", + "apiName": "extension_types", + "typeParameters": [], + "parameters": [ + { + "name": "v", + "type": { + "$": "TypeReference", + "symbol": "ValueXFromJsonImpl", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 1667, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 56, + "column": 57 + }, + "end": { + "offset": 1668, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 56, + "column": 58 + }, + "text": "v" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "ValueXFromJsonImpl", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "ValueXFromJsonImpl", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 1629, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 56, + "column": 19 + }, + "end": { + "offset": 1647, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 56, + "column": 37 + }, + "text": "valueXFromJsonImpl" + } + }, + "valueXFromJsonStatic": { + "name": "valueXFromJsonStatic", + "apiName": "extension_types", + "typeParameters": [], + "parameters": [ + { + "name": "v", + "type": { + "$": "TypeReference", + "symbol": "ValueXFromJsonStatic", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 1746, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 58, + "column": 63 + }, + "end": { + "offset": 1747, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 58, + "column": 64 + }, + "text": "v" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "ValueXFromJsonStatic", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "ValueXFromJsonStatic", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 1704, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 58, + "column": 21 + }, + "end": { + "offset": 1724, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 58, + "column": 41 + }, + "text": "valueXFromJsonStatic" + } + }, + "color": { + "name": "color", + "apiName": "extension_types", + "typeParameters": [], + "parameters": [ + { + "name": "color", + "type": { + "$": "TypeReference", + "symbol": "Color", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 1795, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 62, + "column": 18 + }, + "end": { + "offset": 1800, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 62, + "column": 23 + }, + "text": "color" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "Color", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "Color", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 1783, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 62, + "column": 6 + }, + "end": { + "offset": 1788, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 62, + "column": 11 + }, + "text": "color" + } + }, + "colorX": { + "name": "colorX", + "apiName": "extension_types", + "typeParameters": [], + "parameters": [ + { + "name": "color", + "type": { + "$": "TypeReference", + "symbol": "ColorX", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 1840, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 64, + "column": 21 + }, + "end": { + "offset": 1845, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 64, + "column": 26 + }, + "text": "color" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "ColorX", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "ColorX", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 1826, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 64, + "column": 7 + }, + "end": { + "offset": 1832, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 64, + "column": 13 + }, + "text": "colorX" + } + }, + "colorXImpl": { + "name": "colorXImpl", + "apiName": "extension_types", + "typeParameters": [], + "parameters": [ + { + "name": "color", + "type": { + "$": "TypeReference", + "symbol": "ColorXImpl", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 1897, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 66, + "column": 33 + }, + "end": { + "offset": 1902, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 66, + "column": 38 + }, + "text": "color" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "ColorXImpl", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "ColorXImpl", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 1875, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 66, + "column": 11 + }, + "end": { + "offset": 1885, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 66, + "column": 21 + }, + "text": "colorXImpl" + } + }, + "colorXToFromJson": { + "name": "colorXToFromJson", + "apiName": "extension_types", + "typeParameters": [], + "parameters": [ + { + "name": "color", + "type": { + "$": "TypeReference", + "symbol": "ColorXToFromJson", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 1972, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 68, + "column": 51 + }, + "end": { + "offset": 1977, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 68, + "column": 56 + }, + "text": "color" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "ColorXToFromJson", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "ColorXToFromJson", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 1938, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 68, + "column": 17 + }, + "end": { + "offset": 1954, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 68, + "column": 33 + }, + "text": "colorXToFromJson" + } + }, + "colorXToJson": { + "name": "colorXToJson", + "apiName": "extension_types", + "typeParameters": [], + "parameters": [ + { + "name": "color", + "type": { + "$": "TypeReference", + "symbol": "ColorXToJson", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 2035, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 70, + "column": 39 + }, + "end": { + "offset": 2040, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 70, + "column": 44 + }, + "text": "color" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "ColorXToJson", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "ColorXToJson", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 2009, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 70, + "column": 13 + }, + "end": { + "offset": 2021, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 70, + "column": 25 + }, + "text": "colorXToJson" + } + }, + "colorXToJsonImpl": { + "name": "colorXToJsonImpl", + "apiName": "extension_types", + "typeParameters": [], + "parameters": [ + { + "name": "color", + "type": { + "$": "TypeReference", + "symbol": "ColorXToJsonImpl", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 2110, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 72, + "column": 51 + }, + "end": { + "offset": 2115, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 72, + "column": 56 + }, + "text": "color" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "ColorXToJsonImpl", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "ColorXToJsonImpl", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 2076, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 72, + "column": 17 + }, + "end": { + "offset": 2092, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 72, + "column": 33 + }, + "text": "colorXToJsonImpl" + } + }, + "colorXFromJson": { + "name": "colorXFromJson", + "apiName": "extension_types", + "typeParameters": [], + "parameters": [ + { + "name": "color", + "type": { + "$": "TypeReference", + "symbol": "ColorXFromJson", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 2179, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 74, + "column": 45 + }, + "end": { + "offset": 2184, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 74, + "column": 50 + }, + "text": "color" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "ColorXFromJson", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "ColorXFromJson", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 2149, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 74, + "column": 15 + }, + "end": { + "offset": 2163, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 74, + "column": 29 + }, + "text": "colorXFromJson" + } + }, + "colorXFromJsonImpl": { + "name": "colorXFromJsonImpl", + "apiName": "extension_types", + "typeParameters": [], + "parameters": [ + { + "name": "color", + "type": { + "$": "TypeReference", + "symbol": "ColorXFromJsonImpl", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 2260, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 76, + "column": 57 + }, + "end": { + "offset": 2265, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 76, + "column": 62 + }, + "text": "color" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "ColorXFromJsonImpl", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "ColorXFromJsonImpl", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 2222, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 76, + "column": 19 + }, + "end": { + "offset": 2240, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 76, + "column": 37 + }, + "text": "colorXFromJsonImpl" + } + }, + "colorXFromJsonStatic": { + "name": "colorXFromJsonStatic", + "apiName": "extension_types", + "typeParameters": [], + "parameters": [ + { + "name": "color", + "type": { + "$": "TypeReference", + "symbol": "ColorXFromJsonStatic", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 2347, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 78, + "column": 63 + }, + "end": { + "offset": 2352, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 78, + "column": 68 + }, + "text": "color" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "ColorXFromJsonStatic", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "ColorXFromJsonStatic", + "url": "package:celest_backend/models/extension_types.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 2305, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 78, + "column": 21 + }, + "end": { + "offset": 2325, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 78, + "column": 41 + }, + "text": "colorXFromJsonStatic" + } + }, + "jsonValue": { + "name": "jsonValue", + "apiName": "extension_types", + "typeParameters": [], + "parameters": [ + { + "name": "value", + "type": { + "$": "TypeReference", + "symbol": "JsonValue", + "url": "package:celest_core/src/serialization/json_value.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 2421, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 82, + "column": 30 + }, + "end": { + "offset": 2426, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 82, + "column": 35 + }, + "text": "value" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "JsonValue", + "url": "package:celest_core/src/serialization/json_value.dart", + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "JsonValue", + "url": "package:celest_core/src/serialization/json_value.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 2401, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 82, + "column": 10 + }, + "end": { + "offset": 2410, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 82, + "column": 19 + }, + "text": "jsonValue" + } + }, + "jsonString": { + "name": "jsonString", + "apiName": "extension_types", + "typeParameters": [], + "parameters": [ + { + "name": "value", + "type": { + "$": "TypeReference", + "symbol": "JsonString", + "url": "package:celest_core/src/serialization/json_value.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 2478, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 84, + "column": 33 + }, + "end": { + "offset": 2483, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 84, + "column": 38 + }, + "text": "value" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "JsonString", + "url": "package:celest_core/src/serialization/json_value.dart", + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "JsonString", + "url": "package:celest_core/src/serialization/json_value.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 2456, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 84, + "column": 11 + }, + "end": { + "offset": 2466, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 84, + "column": 21 + }, + "text": "jsonString" + } + }, + "jsonNum": { + "name": "jsonNum", + "apiName": "extension_types", + "typeParameters": [], + "parameters": [ + { + "name": "value", + "type": { + "$": "TypeReference", + "symbol": "JsonNum", + "url": "package:celest_core/src/serialization/json_value.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 2526, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 86, + "column": 24 + }, + "end": { + "offset": 2531, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 86, + "column": 29 + }, + "text": "value" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "JsonNum", + "url": "package:celest_core/src/serialization/json_value.dart", + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "JsonNum", + "url": "package:celest_core/src/serialization/json_value.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 2510, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 86, + "column": 8 + }, + "end": { + "offset": 2517, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 86, + "column": 15 + }, + "text": "jsonNum" + } + }, + "jsonInt": { + "name": "jsonInt", + "apiName": "extension_types", + "typeParameters": [], + "parameters": [ + { + "name": "value", + "type": { + "$": "TypeReference", + "symbol": "JsonInt", + "url": "package:celest_core/src/serialization/json_value.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 2574, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 88, + "column": 24 + }, + "end": { + "offset": 2579, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 88, + "column": 29 + }, + "text": "value" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "JsonInt", + "url": "package:celest_core/src/serialization/json_value.dart", + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "JsonInt", + "url": "package:celest_core/src/serialization/json_value.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 2558, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 88, + "column": 8 + }, + "end": { + "offset": 2565, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 88, + "column": 15 + }, + "text": "jsonInt" + } + }, + "jsonDouble": { + "name": "jsonDouble", + "apiName": "extension_types", + "typeParameters": [], + "parameters": [ + { + "name": "value", + "type": { + "$": "TypeReference", + "symbol": "JsonDouble", + "url": "package:celest_core/src/serialization/json_value.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 2631, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 90, + "column": 33 + }, + "end": { + "offset": 2636, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 90, + "column": 38 + }, + "text": "value" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "JsonDouble", + "url": "package:celest_core/src/serialization/json_value.dart", + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "JsonDouble", + "url": "package:celest_core/src/serialization/json_value.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 2609, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 90, + "column": 11 + }, + "end": { + "offset": 2619, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 90, + "column": 21 + }, + "text": "jsonDouble" + } + }, + "jsonBool": { + "name": "jsonBool", + "apiName": "extension_types", + "typeParameters": [], + "parameters": [ + { + "name": "value", + "type": { + "$": "TypeReference", + "symbol": "JsonBool", + "url": "package:celest_core/src/serialization/json_value.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 2682, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 92, + "column": 27 + }, + "end": { + "offset": 2687, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 92, + "column": 32 + }, + "text": "value" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "JsonBool", + "url": "package:celest_core/src/serialization/json_value.dart", + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "JsonBool", + "url": "package:celest_core/src/serialization/json_value.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 2664, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 92, + "column": 9 + }, + "end": { + "offset": 2672, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 92, + "column": 17 + }, + "text": "jsonBool" + } + }, + "jsonList": { + "name": "jsonList", + "apiName": "extension_types", + "typeParameters": [], + "parameters": [ + { + "name": "value", + "type": { + "$": "TypeReference", + "symbol": "JsonList", + "url": "package:celest_core/src/serialization/json_value.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 2733, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 94, + "column": 27 + }, + "end": { + "offset": 2738, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 94, + "column": 32 + }, + "text": "value" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "JsonList", + "url": "package:celest_core/src/serialization/json_value.dart", + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "JsonList", + "url": "package:celest_core/src/serialization/json_value.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 2715, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 94, + "column": 9 + }, + "end": { + "offset": 2723, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 94, + "column": 17 + }, + "text": "jsonList" + } + }, + "jsonMap": { + "name": "jsonMap", + "apiName": "extension_types", + "typeParameters": [], + "parameters": [ + { + "name": "value", + "type": { + "$": "TypeReference", + "symbol": "JsonMap", + "url": "package:celest_core/src/serialization/json_value.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 2781, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 96, + "column": 24 + }, + "end": { + "offset": 2786, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 96, + "column": 29 + }, + "text": "value" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "JsonMap", + "url": "package:celest_core/src/serialization/json_value.dart", + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "JsonMap", + "url": "package:celest_core/src/serialization/json_value.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 2765, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 96, + "column": 8 + }, + "end": { + "offset": 2772, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 96, + "column": 15 + }, + "text": "jsonMap" + } + } + }, + "docs": [ + "/// Tests that extension types are correctly handled by the analyzer." + ], + "exceptionTypes": [ + { + "$": "TypeReference", + "symbol": "AsyncError", + "url": "dart:async", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "TimeoutException", + "url": "dart:async", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "JsonUnsupportedObjectError", + "url": "dart:convert", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "Error", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AssertionError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "TypeError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ArgumentError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "RangeError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "IndexError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnsupportedError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnimplementedError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "StateError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ConcurrentModificationError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "OutOfMemoryError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "StackOverflowError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "Exception", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "FormatException", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "IntegerDivisionByZeroException", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "CloudException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "CancelledException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnknownError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "BadRequestException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnauthorizedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "NotFoundException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AlreadyExistsException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "PermissionDeniedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ResourceExhaustedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "FailedPreconditionException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AbortedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "OutOfRangeException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnimplementedError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "InternalServerError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnavailableError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "DataLossError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "DeadlineExceededError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "SerializationException", + "url": "package:celest_core/src/exception/serialization_exception.dart", + "isNullable": false + } + ], + "location": { + "start": { + "offset": 0, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 0, + "column": 0 + }, + "end": { + "offset": 0, + "uri": "package:celest_backend/src/functions/extension_types.dart", + "line": 0, + "column": 0 + }, + "text": "" + } + }, + "typedefs": { + "name": "typedefs", + "metadata": [], + "functions": { + "portfolio": { + "name": "portfolio", + "apiName": "typedefs", + "typeParameters": [], + "parameters": [ + { + "name": "portfolio", + "type": { + "$": "TypeReference", + "symbol": "Portfolio", + "url": "package:celest_backend/models/typedefs.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 249, + "uri": "package:celest_backend/src/functions/typedefs.dart", + "line": 8, + "column": 38 + }, + "end": { + "offset": 258, + "uri": "package:celest_backend/src/functions/typedefs.dart", + "line": 8, + "column": 47 + }, + "text": "portfolio" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "Future", + "url": "dart:async", + "types": [ + { + "$": "TypeReference", + "symbol": "Portfolio", + "url": "package:celest_backend/models/typedefs.dart", + "isNullable": false + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "Portfolio", + "url": "package:celest_backend/models/typedefs.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 229, + "uri": "package:celest_backend/src/functions/typedefs.dart", + "line": 8, + "column": 18 + }, + "end": { + "offset": 238, + "uri": "package:celest_backend/src/functions/typedefs.dart", + "line": 8, + "column": 27 + }, + "text": "portfolio" + } + }, + "json": { + "name": "json", + "apiName": "typedefs", + "typeParameters": [], + "parameters": [ + { + "name": "json", + "type": { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "Reference", + "symbol": "dynamic", + "url": "dart:core" + } + ], + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 310, + "uri": "package:celest_backend/src/functions/typedefs.dart", + "line": 10, + "column": 23 + }, + "end": { + "offset": 314, + "uri": "package:celest_backend/src/functions/typedefs.dart", + "line": 10, + "column": 27 + }, + "text": "json" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "Future", + "url": "dart:async", + "types": [ + { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "Reference", + "symbol": "dynamic", + "url": "dart:core" + } + ], + "isNullable": false + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "Reference", + "symbol": "dynamic", + "url": "dart:core" + } + ], + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 300, + "uri": "package:celest_backend/src/functions/typedefs.dart", + "line": 10, + "column": 13 + }, + "end": { + "offset": 304, + "uri": "package:celest_backend/src/functions/typedefs.dart", + "line": 10, + "column": 17 + }, + "text": "json" + } + }, + "nullableJson": { + "name": "nullableJson", + "apiName": "typedefs", + "typeParameters": [], + "parameters": [ + { + "name": "json", + "type": { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "Reference", + "symbol": "dynamic", + "url": "dart:core" + } + ], + "isNullable": true + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 371, + "uri": "package:celest_backend/src/functions/typedefs.dart", + "line": 12, + "column": 33 + }, + "end": { + "offset": 375, + "uri": "package:celest_backend/src/functions/typedefs.dart", + "line": 12, + "column": 37 + }, + "text": "json" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "Future", + "url": "dart:async", + "types": [ + { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "Reference", + "symbol": "dynamic", + "url": "dart:core" + } + ], + "isNullable": true + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "Reference", + "symbol": "dynamic", + "url": "dart:core" + } + ], + "isNullable": true + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 352, + "uri": "package:celest_backend/src/functions/typedefs.dart", + "line": 12, + "column": 14 + }, + "end": { + "offset": 364, + "uri": "package:celest_backend/src/functions/typedefs.dart", + "line": 12, + "column": 26 + }, + "text": "nullableJson" + } + }, + "mixedJson": { + "name": "mixedJson", + "apiName": "typedefs", + "typeParameters": [], + "parameters": [ + { + "name": "json", + "type": { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "Reference", + "symbol": "dynamic", + "url": "dart:core" + } + ], + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 428, + "uri": "package:celest_backend/src/functions/typedefs.dart", + "line": 14, + "column": 29 + }, + "end": { + "offset": 432, + "uri": "package:celest_backend/src/functions/typedefs.dart", + "line": 14, + "column": 33 + }, + "text": "json" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "Future", + "url": "dart:async", + "types": [ + { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "Reference", + "symbol": "dynamic", + "url": "dart:core" + } + ], + "isNullable": true + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "Reference", + "symbol": "dynamic", + "url": "dart:core" + } + ], + "isNullable": true + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 413, + "uri": "package:celest_backend/src/functions/typedefs.dart", + "line": 14, + "column": 14 + }, + "end": { + "offset": 422, + "uri": "package:celest_backend/src/functions/typedefs.dart", + "line": 14, + "column": 23 + }, + "text": "mixedJson" + } + } + }, + "docs": [ + "/// Checks that typedefs work as expected." + ], + "exceptionTypes": [ + { + "$": "TypeReference", + "symbol": "CloudException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "CancelledException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnknownError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "BadRequestException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnauthorizedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "NotFoundException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AlreadyExistsException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "PermissionDeniedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ResourceExhaustedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "FailedPreconditionException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AbortedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "OutOfRangeException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnimplementedError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "InternalServerError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnavailableError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "DataLossError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "DeadlineExceededError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "SerializationException", + "url": "package:celest_core/src/exception/serialization_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "Error", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AssertionError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "TypeError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ArgumentError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "RangeError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "IndexError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnsupportedError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnimplementedError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "StateError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ConcurrentModificationError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "OutOfMemoryError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "StackOverflowError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "Exception", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "FormatException", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "IntegerDivisionByZeroException", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AsyncError", + "url": "dart:async", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "TimeoutException", + "url": "dart:async", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "JsonUnsupportedObjectError", + "url": "dart:convert", + "isNullable": false + } + ], + "location": { + "start": { + "offset": 0, + "uri": "package:celest_backend/src/functions/typedefs.dart", + "line": 0, + "column": 0 + }, + "end": { + "offset": 0, + "uri": "package:celest_backend/src/functions/typedefs.dart", + "line": 0, + "column": 0 + }, + "text": "" + } + }, + "return_types": { + "name": "return_types", + "metadata": [], + "functions": { + "asyncVoidReturn": { + "name": "asyncVoidReturn", + "apiName": "return_types", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "TypeReference", + "symbol": "Future", + "url": "dart:async", + "types": [ + { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 222, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 10, + "column": 13 + }, + "end": { + "offset": 237, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 10, + "column": 28 + }, + "text": "asyncVoidReturn" + } + }, + "asyncStringReturn": { + "name": "asyncStringReturn", + "apiName": "return_types", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "TypeReference", + "symbol": "Future", + "url": "dart:async", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 272, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 13, + "column": 15 + }, + "end": { + "offset": 289, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 13, + "column": 32 + }, + "text": "asyncStringReturn" + } + }, + "asyncIntReturn": { + "name": "asyncIntReturn", + "apiName": "return_types", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "TypeReference", + "symbol": "Future", + "url": "dart:async", + "types": [ + { + "$": "TypeReference", + "symbol": "int", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "int", + "url": "dart:core", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 348, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 18, + "column": 12 + }, + "end": { + "offset": 362, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 18, + "column": 26 + }, + "text": "asyncIntReturn" + } + }, + "asyncDoubleReturn": { + "name": "asyncDoubleReturn", + "apiName": "return_types", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "TypeReference", + "symbol": "Future", + "url": "dart:async", + "types": [ + { + "$": "TypeReference", + "symbol": "double", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "double", + "url": "dart:core", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 411, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 23, + "column": 15 + }, + "end": { + "offset": 428, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 23, + "column": 32 + }, + "text": "asyncDoubleReturn" + } + }, + "asyncBoolReturn": { + "name": "asyncBoolReturn", + "apiName": "return_types", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "TypeReference", + "symbol": "Future", + "url": "dart:async", + "types": [ + { + "$": "TypeReference", + "symbol": "bool", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "bool", + "url": "dart:core", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 477, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 28, + "column": 13 + }, + "end": { + "offset": 492, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 28, + "column": 28 + }, + "text": "asyncBoolReturn" + } + }, + "asyncIterableReturn": { + "name": "asyncIterableReturn", + "apiName": "return_types", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "TypeReference", + "symbol": "Future", + "url": "dart:async", + "types": [ + { + "$": "TypeReference", + "symbol": "Iterable", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "Iterable", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 553, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 33, + "column": 25 + }, + "end": { + "offset": 572, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 33, + "column": 44 + }, + "text": "asyncIterableReturn" + } + }, + "asyncListReturn": { + "name": "asyncListReturn", + "apiName": "return_types", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "TypeReference", + "symbol": "Future", + "url": "dart:async", + "types": [ + { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 643, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 38, + "column": 21 + }, + "end": { + "offset": 658, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 38, + "column": 36 + }, + "text": "asyncListReturn" + } + }, + "asyncMapReturn": { + "name": "asyncMapReturn", + "apiName": "return_types", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "TypeReference", + "symbol": "Future", + "url": "dart:async", + "types": [ + { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 736, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 43, + "column": 28 + }, + "end": { + "offset": 750, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 43, + "column": 42 + }, + "text": "asyncMapReturn" + } + }, + "asyncStructReturn": { + "name": "asyncStructReturn", + "apiName": "return_types", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "TypeReference", + "symbol": "Future", + "url": "dart:async", + "types": [ + { + "$": "TypeReference", + "symbol": "SimpleStruct", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": false + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "SimpleStruct", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 821, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 48, + "column": 21 + }, + "end": { + "offset": 838, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 48, + "column": 38 + }, + "text": "asyncStructReturn" + } + }, + "asyncStructReturnNullable": { + "name": "asyncStructReturnNullable", + "apiName": "return_types", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "TypeReference", + "symbol": "Future", + "url": "dart:async", + "types": [ + { + "$": "TypeReference", + "symbol": "SimpleStruct", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": true + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "SimpleStruct", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": true + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 894, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 53, + "column": 22 + }, + "end": { + "offset": 919, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 53, + "column": 47 + }, + "text": "asyncStructReturnNullable" + } + }, + "asyncComplexStructReturn": { + "name": "asyncComplexStructReturn", + "apiName": "return_types", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "TypeReference", + "symbol": "Future", + "url": "dart:async", + "types": [ + { + "$": "TypeReference", + "symbol": "ComplexStruct", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": false + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "ComplexStruct", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 977, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 58, + "column": 22 + }, + "end": { + "offset": 1001, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 58, + "column": 46 + }, + "text": "asyncComplexStructReturn" + } + }, + "asyncComplexStructReturnNullable": { + "name": "asyncComplexStructReturnNullable", + "apiName": "return_types", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "TypeReference", + "symbol": "Future", + "url": "dart:async", + "types": [ + { + "$": "TypeReference", + "symbol": "ComplexStruct", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": true + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "ComplexStruct", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": true + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 3307, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 122, + "column": 23 + }, + "end": { + "offset": 3339, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 122, + "column": 55 + }, + "text": "asyncComplexStructReturnNullable" + } + }, + "asyncComplexClassReturn": { + "name": "asyncComplexClassReturn", + "apiName": "return_types", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "TypeReference", + "symbol": "Future", + "url": "dart:async", + "types": [ + { + "$": "TypeReference", + "symbol": "ComplexClass", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": false + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "ComplexClass", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 3396, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 127, + "column": 21 + }, + "end": { + "offset": 3419, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 127, + "column": 44 + }, + "text": "asyncComplexClassReturn" + } + }, + "asyncClassReturnNullable": { + "name": "asyncClassReturnNullable", + "apiName": "return_types", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "TypeReference", + "symbol": "Future", + "url": "dart:async", + "types": [ + { + "$": "TypeReference", + "symbol": "SimpleClass", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": true + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "SimpleClass", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": true + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 5735, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 191, + "column": 21 + }, + "end": { + "offset": 5759, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 191, + "column": 45 + }, + "text": "asyncClassReturnNullable" + } + }, + "asyncOrVoidReturn": { + "name": "asyncOrVoidReturn", + "apiName": "return_types", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "TypeReference", + "symbol": "FutureOr", + "url": "dart:async", + "types": [ + { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 5810, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 196, + "column": 15 + }, + "end": { + "offset": 5827, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 196, + "column": 32 + }, + "text": "asyncOrVoidReturn" + } + }, + "asyncOrStringReturn": { + "name": "asyncOrStringReturn", + "apiName": "return_types", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "TypeReference", + "symbol": "FutureOr", + "url": "dart:async", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 5864, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 199, + "column": 17 + }, + "end": { + "offset": 5883, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 199, + "column": 36 + }, + "text": "asyncOrStringReturn" + } + }, + "asyncOrIntReturn": { + "name": "asyncOrIntReturn", + "apiName": "return_types", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "TypeReference", + "symbol": "FutureOr", + "url": "dart:async", + "types": [ + { + "$": "TypeReference", + "symbol": "int", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "int", + "url": "dart:core", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 5944, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 204, + "column": 14 + }, + "end": { + "offset": 5960, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 204, + "column": 30 + }, + "text": "asyncOrIntReturn" + } + }, + "asyncOrDoubleReturn": { + "name": "asyncOrDoubleReturn", + "apiName": "return_types", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "TypeReference", + "symbol": "FutureOr", + "url": "dart:async", + "types": [ + { + "$": "TypeReference", + "symbol": "double", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "double", + "url": "dart:core", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 6011, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 209, + "column": 17 + }, + "end": { + "offset": 6030, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 209, + "column": 36 + }, + "text": "asyncOrDoubleReturn" + } + }, + "asyncOrBoolReturn": { + "name": "asyncOrBoolReturn", + "apiName": "return_types", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "TypeReference", + "symbol": "FutureOr", + "url": "dart:async", + "types": [ + { + "$": "TypeReference", + "symbol": "bool", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "bool", + "url": "dart:core", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 6081, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 214, + "column": 15 + }, + "end": { + "offset": 6098, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 214, + "column": 32 + }, + "text": "asyncOrBoolReturn" + } + }, + "asyncOrIterableReturn": { + "name": "asyncOrIterableReturn", + "apiName": "return_types", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "TypeReference", + "symbol": "FutureOr", + "url": "dart:async", + "types": [ + { + "$": "TypeReference", + "symbol": "Iterable", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "Iterable", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 6161, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 219, + "column": 27 + }, + "end": { + "offset": 6182, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 219, + "column": 48 + }, + "text": "asyncOrIterableReturn" + } + }, + "asyncOrListReturn": { + "name": "asyncOrListReturn", + "apiName": "return_types", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "TypeReference", + "symbol": "FutureOr", + "url": "dart:async", + "types": [ + { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 6255, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 224, + "column": 23 + }, + "end": { + "offset": 6272, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 224, + "column": 40 + }, + "text": "asyncOrListReturn" + } + }, + "asyncOrMapReturn": { + "name": "asyncOrMapReturn", + "apiName": "return_types", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "TypeReference", + "symbol": "FutureOr", + "url": "dart:async", + "types": [ + { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 6352, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 229, + "column": 30 + }, + "end": { + "offset": 6368, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 229, + "column": 46 + }, + "text": "asyncOrMapReturn" + } + }, + "asyncOrStructReturn": { + "name": "asyncOrStructReturn", + "apiName": "return_types", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "TypeReference", + "symbol": "FutureOr", + "url": "dart:async", + "types": [ + { + "$": "TypeReference", + "symbol": "SimpleStruct", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": false + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "SimpleStruct", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 6441, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 234, + "column": 23 + }, + "end": { + "offset": 6460, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 234, + "column": 42 + }, + "text": "asyncOrStructReturn" + } + }, + "asyncOrComplexStructReturn": { + "name": "asyncOrComplexStructReturn", + "apiName": "return_types", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "TypeReference", + "symbol": "FutureOr", + "url": "dart:async", + "types": [ + { + "$": "TypeReference", + "symbol": "ComplexStruct", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": false + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "ComplexStruct", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 6518, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 239, + "column": 24 + }, + "end": { + "offset": 6544, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 239, + "column": 50 + }, + "text": "asyncOrComplexStructReturn" + } + }, + "asyncOrVoidReturnNullable": { + "name": "asyncOrVoidReturnNullable", + "apiName": "return_types", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "TypeReference", + "symbol": "FutureOr", + "url": "dart:async", + "types": [ + { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + } + ], + "isNullable": true + }, + "flattenedReturnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 8843, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 303, + "column": 16 + }, + "end": { + "offset": 8868, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 303, + "column": 41 + }, + "text": "asyncOrVoidReturnNullable" + } + }, + "asyncOrStringReturnNullable": { + "name": "asyncOrStringReturnNullable", + "apiName": "return_types", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "TypeReference", + "symbol": "FutureOr", + "url": "dart:async", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": true + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": true + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 8916, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 308, + "column": 18 + }, + "end": { + "offset": 8943, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 308, + "column": 45 + }, + "text": "asyncOrStringReturnNullable" + } + }, + "asyncOrIntReturnNullable": { + "name": "asyncOrIntReturnNullable", + "apiName": "return_types", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "TypeReference", + "symbol": "FutureOr", + "url": "dart:async", + "types": [ + { + "$": "TypeReference", + "symbol": "int", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": true + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "int", + "url": "dart:core", + "isNullable": true + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 8988, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 313, + "column": 15 + }, + "end": { + "offset": 9012, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 313, + "column": 39 + }, + "text": "asyncOrIntReturnNullable" + } + }, + "asyncOrDoubleReturnNullable": { + "name": "asyncOrDoubleReturnNullable", + "apiName": "return_types", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "TypeReference", + "symbol": "FutureOr", + "url": "dart:async", + "types": [ + { + "$": "TypeReference", + "symbol": "double", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": true + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "double", + "url": "dart:core", + "isNullable": true + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 9060, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 318, + "column": 18 + }, + "end": { + "offset": 9087, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 318, + "column": 45 + }, + "text": "asyncOrDoubleReturnNullable" + } + }, + "asyncOrBoolReturnNullable": { + "name": "asyncOrBoolReturnNullable", + "apiName": "return_types", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "TypeReference", + "symbol": "FutureOr", + "url": "dart:async", + "types": [ + { + "$": "TypeReference", + "symbol": "bool", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": true + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "bool", + "url": "dart:core", + "isNullable": true + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 9133, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 323, + "column": 16 + }, + "end": { + "offset": 9158, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 323, + "column": 41 + }, + "text": "asyncOrBoolReturnNullable" + } + }, + "asyncOrIterableReturnNullable": { + "name": "asyncOrIterableReturnNullable", + "apiName": "return_types", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "TypeReference", + "symbol": "FutureOr", + "url": "dart:async", + "types": [ + { + "$": "TypeReference", + "symbol": "Iterable", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + } + ], + "isNullable": true + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "Iterable", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": true + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 9216, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 328, + "column": 28 + }, + "end": { + "offset": 9245, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 328, + "column": 57 + }, + "text": "asyncOrIterableReturnNullable" + } + }, + "asyncOrListReturnNullable": { + "name": "asyncOrListReturnNullable", + "apiName": "return_types", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "TypeReference", + "symbol": "FutureOr", + "url": "dart:async", + "types": [ + { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + } + ], + "isNullable": true + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": true + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 9299, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 333, + "column": 24 + }, + "end": { + "offset": 9324, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 333, + "column": 49 + }, + "text": "asyncOrListReturnNullable" + } + }, + "asyncOrMapReturnNullable": { + "name": "asyncOrMapReturnNullable", + "apiName": "return_types", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "TypeReference", + "symbol": "FutureOr", + "url": "dart:async", + "types": [ + { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + } + ], + "isNullable": true + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": true + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 9385, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 338, + "column": 31 + }, + "end": { + "offset": 9409, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 338, + "column": 55 + }, + "text": "asyncOrMapReturnNullable" + } + }, + "asyncOrStructReturnNullable": { + "name": "asyncOrStructReturnNullable", + "apiName": "return_types", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "TypeReference", + "symbol": "FutureOr", + "url": "dart:async", + "types": [ + { + "$": "TypeReference", + "symbol": "SimpleStruct", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": false + } + ], + "isNullable": true + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "SimpleStruct", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": true + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 9463, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 343, + "column": 24 + }, + "end": { + "offset": 9490, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 343, + "column": 51 + }, + "text": "asyncOrStructReturnNullable" + } + }, + "asyncOrComplexStructReturnNullable": { + "name": "asyncOrComplexStructReturnNullable", + "apiName": "return_types", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "TypeReference", + "symbol": "FutureOr", + "url": "dart:async", + "types": [ + { + "$": "TypeReference", + "symbol": "ComplexStruct", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": false + } + ], + "isNullable": true + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "ComplexStruct", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": true + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 9545, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 348, + "column": 25 + }, + "end": { + "offset": 9579, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 348, + "column": 59 + }, + "text": "asyncOrComplexStructReturnNullable" + } + }, + "asyncOrSimpleClassReturnNullable": { + "name": "asyncOrSimpleClassReturnNullable", + "apiName": "return_types", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "TypeReference", + "symbol": "FutureOr", + "url": "dart:async", + "types": [ + { + "$": "TypeReference", + "symbol": "SimpleClass", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": false + } + ], + "isNullable": true + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "SimpleClass", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": true + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 9632, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 353, + "column": 23 + }, + "end": { + "offset": 9664, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 353, + "column": 55 + }, + "text": "asyncOrSimpleClassReturnNullable" + } + }, + "asyncOrComplexClassReturnNullable": { + "name": "asyncOrComplexClassReturnNullable", + "apiName": "return_types", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "TypeReference", + "symbol": "FutureOr", + "url": "dart:async", + "types": [ + { + "$": "TypeReference", + "symbol": "ComplexClass", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": false + } + ], + "isNullable": true + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "ComplexClass", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": true + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 9718, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 358, + "column": 24 + }, + "end": { + "offset": 9751, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 358, + "column": 57 + }, + "text": "asyncOrComplexClassReturnNullable" + } + }, + "voidReturn": { + "name": "voidReturn", + "apiName": "return_types", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "flattenedReturnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 9786, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 363, + "column": 5 + }, + "end": { + "offset": 9796, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 363, + "column": 15 + }, + "text": "voidReturn" + } + }, + "stringReturn": { + "name": "stringReturn", + "apiName": "return_types", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 9817, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 366, + "column": 7 + }, + "end": { + "offset": 9829, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 366, + "column": 19 + }, + "text": "stringReturn" + } + }, + "intReturn": { + "name": "intReturn", + "apiName": "return_types", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "TypeReference", + "symbol": "int", + "url": "dart:core", + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "int", + "url": "dart:core", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 9874, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 371, + "column": 4 + }, + "end": { + "offset": 9883, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 371, + "column": 13 + }, + "text": "intReturn" + } + }, + "doubleReturn": { + "name": "doubleReturn", + "apiName": "return_types", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "TypeReference", + "symbol": "double", + "url": "dart:core", + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "double", + "url": "dart:core", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 9918, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 376, + "column": 7 + }, + "end": { + "offset": 9930, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 376, + "column": 19 + }, + "text": "doubleReturn" + } + }, + "boolReturn": { + "name": "boolReturn", + "apiName": "return_types", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "TypeReference", + "symbol": "bool", + "url": "dart:core", + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "bool", + "url": "dart:core", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 9965, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 381, + "column": 5 + }, + "end": { + "offset": 9975, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 381, + "column": 15 + }, + "text": "boolReturn" + } + }, + "iterableReturn": { + "name": "iterableReturn", + "apiName": "return_types", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "TypeReference", + "symbol": "Iterable", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "Iterable", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 10022, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 386, + "column": 17 + }, + "end": { + "offset": 10036, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 386, + "column": 31 + }, + "text": "iterableReturn" + } + }, + "listReturn": { + "name": "listReturn", + "apiName": "return_types", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 10093, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 391, + "column": 13 + }, + "end": { + "offset": 10103, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 391, + "column": 23 + }, + "text": "listReturn" + } + }, + "mapReturn": { + "name": "mapReturn", + "apiName": "return_types", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 10167, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 396, + "column": 20 + }, + "end": { + "offset": 10176, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 396, + "column": 29 + }, + "text": "mapReturn" + } + }, + "structReturn": { + "name": "structReturn", + "apiName": "return_types", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "TypeReference", + "symbol": "SimpleStruct", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "SimpleStruct", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 10233, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 401, + "column": 13 + }, + "end": { + "offset": 10245, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 401, + "column": 25 + }, + "text": "structReturn" + } + }, + "complexReturn": { + "name": "complexReturn", + "apiName": "return_types", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "TypeReference", + "symbol": "ComplexStruct", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "ComplexStruct", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 10287, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 406, + "column": 14 + }, + "end": { + "offset": 10300, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 406, + "column": 27 + }, + "text": "complexReturn" + } + }, + "simpleClassReturn": { + "name": "simpleClassReturn", + "apiName": "return_types", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "TypeReference", + "symbol": "SimpleClass", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "SimpleClass", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 12589, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 470, + "column": 12 + }, + "end": { + "offset": 12606, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 470, + "column": 29 + }, + "text": "simpleClassReturn" + } + }, + "complexClassReturn": { + "name": "complexClassReturn", + "apiName": "return_types", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "TypeReference", + "symbol": "ComplexClass", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "ComplexClass", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 12658, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 475, + "column": 13 + }, + "end": { + "offset": 12676, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 475, + "column": 31 + }, + "text": "complexClassReturn" + } + }, + "stringReturnNullable": { + "name": "stringReturnNullable", + "apiName": "return_types", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": true + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": true + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 14973, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 539, + "column": 8 + }, + "end": { + "offset": 14993, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 539, + "column": 28 + }, + "text": "stringReturnNullable" + } + }, + "intReturnNullable": { + "name": "intReturnNullable", + "apiName": "return_types", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "TypeReference", + "symbol": "int", + "url": "dart:core", + "isNullable": true + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "int", + "url": "dart:core", + "isNullable": true + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 15028, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 544, + "column": 5 + }, + "end": { + "offset": 15045, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 544, + "column": 22 + }, + "text": "intReturnNullable" + } + }, + "doubleReturnNullable": { + "name": "doubleReturnNullable", + "apiName": "return_types", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "TypeReference", + "symbol": "double", + "url": "dart:core", + "isNullable": true + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "double", + "url": "dart:core", + "isNullable": true + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 15083, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 549, + "column": 8 + }, + "end": { + "offset": 15103, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 549, + "column": 28 + }, + "text": "doubleReturnNullable" + } + }, + "boolReturnNullable": { + "name": "boolReturnNullable", + "apiName": "return_types", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "TypeReference", + "symbol": "bool", + "url": "dart:core", + "isNullable": true + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "bool", + "url": "dart:core", + "isNullable": true + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 15139, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 554, + "column": 6 + }, + "end": { + "offset": 15157, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 554, + "column": 24 + }, + "text": "boolReturnNullable" + } + }, + "iterableReturnNullable": { + "name": "iterableReturnNullable", + "apiName": "return_types", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "TypeReference", + "symbol": "Iterable", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": true + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "Iterable", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": true + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 15205, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 559, + "column": 18 + }, + "end": { + "offset": 15227, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 559, + "column": 40 + }, + "text": "iterableReturnNullable" + } + }, + "listReturnNullable": { + "name": "listReturnNullable", + "apiName": "return_types", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": true + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": true + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 15271, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 564, + "column": 14 + }, + "end": { + "offset": 15289, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 564, + "column": 32 + }, + "text": "listReturnNullable" + } + }, + "mapReturnNullable": { + "name": "mapReturnNullable", + "apiName": "return_types", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": true + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": true + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 15340, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 569, + "column": 21 + }, + "end": { + "offset": 15357, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 569, + "column": 38 + }, + "text": "mapReturnNullable" + } + }, + "structReturnNullable": { + "name": "structReturnNullable", + "apiName": "return_types", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "TypeReference", + "symbol": "SimpleStruct", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": true + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "SimpleStruct", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": true + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 15401, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 574, + "column": 14 + }, + "end": { + "offset": 15421, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 574, + "column": 34 + }, + "text": "structReturnNullable" + } + }, + "complexReturnNullable": { + "name": "complexReturnNullable", + "apiName": "return_types", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "TypeReference", + "symbol": "ComplexStruct", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": true + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "ComplexStruct", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": true + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 15466, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 579, + "column": 15 + }, + "end": { + "offset": 15487, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 579, + "column": 36 + }, + "text": "complexReturnNullable" + } + }, + "simpleClassReturnNullable": { + "name": "simpleClassReturnNullable", + "apiName": "return_types", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "TypeReference", + "symbol": "SimpleClass", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": true + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "SimpleClass", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": true + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 15530, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 584, + "column": 13 + }, + "end": { + "offset": 15555, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 584, + "column": 38 + }, + "text": "simpleClassReturnNullable" + } + }, + "complexClassReturnNullable": { + "name": "complexClassReturnNullable", + "apiName": "return_types", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "TypeReference", + "symbol": "ComplexClass", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": true + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "ComplexClass", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": true + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 15599, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 589, + "column": 14 + }, + "end": { + "offset": 15625, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 589, + "column": 40 + }, + "text": "complexClassReturnNullable" + } + } + }, + "docs": [ + "/// Validates all permutations of return types." + ], + "exceptionTypes": [ + { + "$": "TypeReference", + "symbol": "CloudException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "CancelledException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnknownError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "BadRequestException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnauthorizedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "NotFoundException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AlreadyExistsException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "PermissionDeniedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ResourceExhaustedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "FailedPreconditionException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AbortedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "OutOfRangeException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnimplementedError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "InternalServerError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnavailableError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "DataLossError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "DeadlineExceededError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "SerializationException", + "url": "package:celest_core/src/exception/serialization_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "Error", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AssertionError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "TypeError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ArgumentError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "RangeError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "IndexError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnsupportedError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnimplementedError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "StateError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ConcurrentModificationError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "OutOfMemoryError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "StackOverflowError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "Exception", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "FormatException", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "IntegerDivisionByZeroException", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AsyncError", + "url": "dart:async", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "TimeoutException", + "url": "dart:async", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "JsonUnsupportedObjectError", + "url": "dart:convert", + "isNullable": false + } + ], + "location": { + "start": { + "offset": 0, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 0, + "column": 0 + }, + "end": { + "offset": 0, + "uri": "package:celest_backend/src/functions/return_types.dart", + "line": 0, + "column": 0 + }, + "text": "" + } + }, + "overrides": { + "name": "overrides", + "metadata": [], + "functions": { + "commonNestedParent": { + "name": "commonNestedParent", + "apiName": "overrides", + "typeParameters": [], + "parameters": [ + { + "name": "parent", + "type": { + "$": "TypeReference", + "symbol": "NestedParent", + "url": "package:_common/_common.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 508, + "uri": "package:celest_backend/src/functions/overrides.dart", + "line": 13, + "column": 59 + }, + "end": { + "offset": 514, + "uri": "package:celest_backend/src/functions/overrides.dart", + "line": 13, + "column": 65 + }, + "text": "parent" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "NestedParent", + "url": "package:_common/_common.dart", + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "NestedParent", + "url": "package:_common/_common.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 469, + "uri": "package:celest_backend/src/functions/overrides.dart", + "line": 13, + "column": 20 + }, + "end": { + "offset": 487, + "uri": "package:celest_backend/src/functions/overrides.dart", + "line": 13, + "column": 38 + }, + "text": "commonNestedParent" + } + }, + "commonNestedChild": { + "name": "commonNestedChild", + "apiName": "overrides", + "typeParameters": [], + "parameters": [ + { + "name": "child", + "type": { + "$": "TypeReference", + "symbol": "NestedChild", + "url": "package:_common/_common.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 590, + "uri": "package:celest_backend/src/functions/overrides.dart", + "line": 15, + "column": 56 + }, + "end": { + "offset": 595, + "uri": "package:celest_backend/src/functions/overrides.dart", + "line": 15, + "column": 61 + }, + "text": "child" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "NestedChild", + "url": "package:_common/_common.dart", + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "NestedChild", + "url": "package:_common/_common.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 553, + "uri": "package:celest_backend/src/functions/overrides.dart", + "line": 15, + "column": 19 + }, + "end": { + "offset": 570, + "uri": "package:celest_backend/src/functions/overrides.dart", + "line": 15, + "column": 36 + }, + "text": "commonNestedChild" + } + }, + "nestedGrandparent": { + "name": "nestedGrandparent", + "apiName": "overrides", + "typeParameters": [], + "parameters": [ + { + "name": "grandparent", + "type": { + "$": "TypeReference", + "symbol": "NestedGrandparent", + "url": "package:celest_backend/models/overrides.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 668, + "uri": "package:celest_backend/src/functions/overrides.dart", + "line": 17, + "column": 54 + }, + "end": { + "offset": 679, + "uri": "package:celest_backend/src/functions/overrides.dart", + "line": 17, + "column": 65 + }, + "text": "grandparent" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "NestedGrandparent", + "url": "package:celest_backend/models/overrides.dart", + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "NestedGrandparent", + "url": "package:celest_backend/models/overrides.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 632, + "uri": "package:celest_backend/src/functions/overrides.dart", + "line": 17, + "column": 18 + }, + "end": { + "offset": 649, + "uri": "package:celest_backend/src/functions/overrides.dart", + "line": 17, + "column": 35 + }, + "text": "nestedGrandparent" + } + }, + "nestedParent": { + "name": "nestedParent", + "apiName": "overrides", + "typeParameters": [], + "parameters": [ + { + "name": "parent", + "type": { + "$": "TypeReference", + "symbol": "NestedParent", + "url": "package:celest_backend/models/overrides.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 747, + "uri": "package:celest_backend/src/functions/overrides.dart", + "line": 20, + "column": 39 + }, + "end": { + "offset": 753, + "uri": "package:celest_backend/src/functions/overrides.dart", + "line": 20, + "column": 45 + }, + "text": "parent" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "NestedParent", + "url": "package:celest_backend/models/overrides.dart", + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "NestedParent", + "url": "package:celest_backend/models/overrides.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 721, + "uri": "package:celest_backend/src/functions/overrides.dart", + "line": 20, + "column": 13 + }, + "end": { + "offset": 733, + "uri": "package:celest_backend/src/functions/overrides.dart", + "line": 20, + "column": 25 + }, + "text": "nestedParent" + } + }, + "nestedChild": { + "name": "nestedChild", + "apiName": "overrides", + "typeParameters": [], + "parameters": [ + { + "name": "child", + "type": { + "$": "TypeReference", + "symbol": "NestedChild", + "url": "package:celest_backend/models/overrides.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 809, + "uri": "package:celest_backend/src/functions/overrides.dart", + "line": 22, + "column": 36 + }, + "end": { + "offset": 814, + "uri": "package:celest_backend/src/functions/overrides.dart", + "line": 22, + "column": 41 + }, + "text": "child" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "NestedChild", + "url": "package:celest_backend/models/overrides.dart", + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "NestedChild", + "url": "package:celest_backend/models/overrides.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 785, + "uri": "package:celest_backend/src/functions/overrides.dart", + "line": 22, + "column": 12 + }, + "end": { + "offset": 796, + "uri": "package:celest_backend/src/functions/overrides.dart", + "line": 22, + "column": 23 + }, + "text": "nestedChild" + } + }, + "callsThrowsCommonOverriddenException": { + "name": "callsThrowsCommonOverriddenException", + "apiName": "overrides", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "flattenedReturnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 839, + "uri": "package:celest_backend/src/functions/overrides.dart", + "line": 25, + "column": 5 + }, + "end": { + "offset": 875, + "uri": "package:celest_backend/src/functions/overrides.dart", + "line": 25, + "column": 41 + }, + "text": "callsThrowsCommonOverriddenException" + } + }, + "throwsCommonOverriddenException": { + "name": "throwsCommonOverriddenException", + "apiName": "overrides", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "flattenedReturnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 933, + "uri": "package:celest_backend/src/functions/overrides.dart", + "line": 30, + "column": 5 + }, + "end": { + "offset": 964, + "uri": "package:celest_backend/src/functions/overrides.dart", + "line": 30, + "column": 36 + }, + "text": "throwsCommonOverriddenException" + } + }, + "throwsOverriddenException": { + "name": "throwsOverriddenException", + "apiName": "overrides", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "flattenedReturnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 1031, + "uri": "package:celest_backend/src/functions/overrides.dart", + "line": 35, + "column": 5 + }, + "end": { + "offset": 1056, + "uri": "package:celest_backend/src/functions/overrides.dart", + "line": 35, + "column": 30 + }, + "text": "throwsOverriddenException" + } + }, + "callsThrowsOverriddenException": { + "name": "callsThrowsOverriddenException", + "apiName": "overrides", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "flattenedReturnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 1144, + "uri": "package:celest_backend/src/functions/overrides.dart", + "line": 40, + "column": 5 + }, + "end": { + "offset": 1174, + "uri": "package:celest_backend/src/functions/overrides.dart", + "line": 40, + "column": 35 + }, + "text": "callsThrowsOverriddenException" + } + } + }, + "docs": [ + "/// Tests that types can be recursively overriden in the serialization protocol", + "/// using extension types." + ], + "exceptionTypes": [ + { + "$": "TypeReference", + "symbol": "CloudException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "CancelledException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnknownError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "BadRequestException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnauthorizedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "NotFoundException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AlreadyExistsException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "PermissionDeniedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ResourceExhaustedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "FailedPreconditionException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AbortedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "OutOfRangeException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnimplementedError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "InternalServerError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnavailableError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "DataLossError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "DeadlineExceededError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "SerializationException", + "url": "package:celest_core/src/exception/serialization_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "Error", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AssertionError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "TypeError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ArgumentError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "RangeError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "IndexError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnsupportedError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnimplementedError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "StateError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ConcurrentModificationError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "OutOfMemoryError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "StackOverflowError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "Exception", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "FormatException", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "IntegerDivisionByZeroException", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AsyncError", + "url": "dart:async", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "TimeoutException", + "url": "dart:async", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "JsonUnsupportedObjectError", + "url": "dart:convert", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "CustomException", + "url": "package:_common/_common.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "CommonException", + "url": "package:_common/_common.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "OverriddenException", + "url": "package:celest_backend/exceptions/overrides.dart", + "isNullable": false + } + ], + "location": { + "start": { + "offset": 0, + "uri": "package:celest_backend/src/functions/overrides.dart", + "line": 0, + "column": 0 + }, + "end": { + "offset": 0, + "uri": "package:celest_backend/src/functions/overrides.dart", + "line": 0, + "column": 0 + }, + "text": "" + } + }, + "classes": { + "name": "classes", + "metadata": [], + "functions": { + "empty": { + "name": "empty", + "apiName": "classes", + "typeParameters": [], + "parameters": [ + { + "name": "value", + "type": { + "$": "TypeReference", + "symbol": "Empty", + "url": "package:celest_backend/models/classes.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 240, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 8, + "column": 18 + }, + "end": { + "offset": 245, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 8, + "column": 23 + }, + "text": "value" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "Empty", + "url": "package:celest_backend/models/classes.dart", + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "Empty", + "url": "package:celest_backend/models/classes.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 228, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 8, + "column": 6 + }, + "end": { + "offset": 233, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 8, + "column": 11 + }, + "text": "empty" + } + }, + "asyncEmpty": { + "name": "asyncEmpty", + "apiName": "classes", + "typeParameters": [], + "parameters": [ + { + "name": "value", + "type": { + "$": "TypeReference", + "symbol": "Empty", + "url": "package:celest_backend/models/classes.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 295, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 10, + "column": 31 + }, + "end": { + "offset": 300, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 10, + "column": 36 + }, + "text": "value" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "Future", + "url": "dart:async", + "types": [ + { + "$": "TypeReference", + "symbol": "Empty", + "url": "package:celest_backend/models/classes.dart", + "isNullable": false + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "Empty", + "url": "package:celest_backend/models/classes.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 278, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 10, + "column": 14 + }, + "end": { + "offset": 288, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 10, + "column": 24 + }, + "text": "asyncEmpty" + } + }, + "fields": { + "name": "fields", + "apiName": "classes", + "typeParameters": [], + "parameters": [ + { + "name": "value", + "type": { + "$": "TypeReference", + "symbol": "Fields", + "url": "package:celest_backend/models/classes.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 347, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 13, + "column": 21 + }, + "end": { + "offset": 352, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 13, + "column": 26 + }, + "text": "value" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "Fields", + "url": "package:celest_backend/models/classes.dart", + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "Fields", + "url": "package:celest_backend/models/classes.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 333, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 13, + "column": 7 + }, + "end": { + "offset": 339, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 13, + "column": 13 + }, + "text": "fields" + } + }, + "asyncFields": { + "name": "asyncFields", + "apiName": "classes", + "typeParameters": [], + "parameters": [ + { + "name": "value", + "type": { + "$": "TypeReference", + "symbol": "Fields", + "url": "package:celest_backend/models/classes.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 405, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 15, + "column": 34 + }, + "end": { + "offset": 410, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 15, + "column": 39 + }, + "text": "value" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "Future", + "url": "dart:async", + "types": [ + { + "$": "TypeReference", + "symbol": "Fields", + "url": "package:celest_backend/models/classes.dart", + "isNullable": false + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "Fields", + "url": "package:celest_backend/models/classes.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 386, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 15, + "column": 15 + }, + "end": { + "offset": 397, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 15, + "column": 26 + }, + "text": "asyncFields" + } + }, + "nullableFields": { + "name": "nullableFields", + "apiName": "classes", + "typeParameters": [], + "parameters": [ + { + "name": "value", + "type": { + "$": "TypeReference", + "symbol": "Fields", + "url": "package:celest_backend/models/classes.dart", + "isNullable": true + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 467, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 18, + "column": 31 + }, + "end": { + "offset": 472, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 18, + "column": 36 + }, + "text": "value" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "Fields", + "url": "package:celest_backend/models/classes.dart", + "isNullable": true + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "Fields", + "url": "package:celest_backend/models/classes.dart", + "isNullable": true + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 444, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 18, + "column": 8 + }, + "end": { + "offset": 458, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 18, + "column": 22 + }, + "text": "nullableFields" + } + }, + "asyncNullableFields": { + "name": "asyncNullableFields", + "apiName": "classes", + "typeParameters": [], + "parameters": [ + { + "name": "value", + "type": { + "$": "TypeReference", + "symbol": "Fields", + "url": "package:celest_backend/models/classes.dart", + "isNullable": true + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 535, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 20, + "column": 44 + }, + "end": { + "offset": 540, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 20, + "column": 49 + }, + "text": "value" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "Future", + "url": "dart:async", + "types": [ + { + "$": "TypeReference", + "symbol": "Fields", + "url": "package:celest_backend/models/classes.dart", + "isNullable": true + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "Fields", + "url": "package:celest_backend/models/classes.dart", + "isNullable": true + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 507, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 20, + "column": 16 + }, + "end": { + "offset": 526, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 20, + "column": 35 + }, + "text": "asyncNullableFields" + } + }, + "namedFields": { + "name": "namedFields", + "apiName": "classes", + "typeParameters": [], + "parameters": [ + { + "name": "value", + "type": { + "$": "TypeReference", + "symbol": "NamedFields", + "url": "package:celest_backend/models/classes.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 602, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 23, + "column": 36 + }, + "end": { + "offset": 607, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 23, + "column": 41 + }, + "text": "value" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "NamedFields", + "url": "package:celest_backend/models/classes.dart", + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "NamedFields", + "url": "package:celest_backend/models/classes.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 578, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 23, + "column": 12 + }, + "end": { + "offset": 589, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 23, + "column": 23 + }, + "text": "namedFields" + } + }, + "asyncNamedFields": { + "name": "asyncNamedFields", + "apiName": "classes", + "typeParameters": [], + "parameters": [ + { + "name": "value", + "type": { + "$": "TypeReference", + "symbol": "NamedFields", + "url": "package:celest_backend/models/classes.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 675, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 25, + "column": 49 + }, + "end": { + "offset": 680, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 25, + "column": 54 + }, + "text": "value" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "Future", + "url": "dart:async", + "types": [ + { + "$": "TypeReference", + "symbol": "NamedFields", + "url": "package:celest_backend/models/classes.dart", + "isNullable": false + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "NamedFields", + "url": "package:celest_backend/models/classes.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 646, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 25, + "column": 20 + }, + "end": { + "offset": 662, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 25, + "column": 36 + }, + "text": "asyncNamedFields" + } + }, + "mixedFields": { + "name": "mixedFields", + "apiName": "classes", + "typeParameters": [], + "parameters": [ + { + "name": "value", + "type": { + "$": "TypeReference", + "symbol": "MixedFields", + "url": "package:celest_backend/models/classes.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 742, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 28, + "column": 36 + }, + "end": { + "offset": 747, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 28, + "column": 41 + }, + "text": "value" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "MixedFields", + "url": "package:celest_backend/models/classes.dart", + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "MixedFields", + "url": "package:celest_backend/models/classes.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 718, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 28, + "column": 12 + }, + "end": { + "offset": 729, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 28, + "column": 23 + }, + "text": "mixedFields" + } + }, + "asyncMixedFields": { + "name": "asyncMixedFields", + "apiName": "classes", + "typeParameters": [], + "parameters": [ + { + "name": "value", + "type": { + "$": "TypeReference", + "symbol": "MixedFields", + "url": "package:celest_backend/models/classes.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 815, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 30, + "column": 49 + }, + "end": { + "offset": 820, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 30, + "column": 54 + }, + "text": "value" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "Future", + "url": "dart:async", + "types": [ + { + "$": "TypeReference", + "symbol": "MixedFields", + "url": "package:celest_backend/models/classes.dart", + "isNullable": false + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "MixedFields", + "url": "package:celest_backend/models/classes.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 786, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 30, + "column": 20 + }, + "end": { + "offset": 802, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 30, + "column": 36 + }, + "text": "asyncMixedFields" + } + }, + "defaultValues": { + "name": "defaultValues", + "apiName": "classes", + "typeParameters": [], + "parameters": [ + { + "name": "value", + "type": { + "$": "TypeReference", + "symbol": "DefaultValues", + "url": "package:celest_backend/models/classes.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 888, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 33, + "column": 42 + }, + "end": { + "offset": 893, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 33, + "column": 47 + }, + "text": "value" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "DefaultValues", + "url": "package:celest_backend/models/classes.dart", + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "DefaultValues", + "url": "package:celest_backend/models/classes.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 860, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 33, + "column": 14 + }, + "end": { + "offset": 873, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 33, + "column": 27 + }, + "text": "defaultValues" + } + }, + "asyncDefaultValues": { + "name": "asyncDefaultValues", + "apiName": "classes", + "typeParameters": [], + "parameters": [ + { + "name": "value", + "type": { + "$": "TypeReference", + "symbol": "DefaultValues", + "url": "package:celest_backend/models/classes.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 967, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 35, + "column": 55 + }, + "end": { + "offset": 972, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 35, + "column": 60 + }, + "text": "value" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "Future", + "url": "dart:async", + "types": [ + { + "$": "TypeReference", + "symbol": "DefaultValues", + "url": "package:celest_backend/models/classes.dart", + "isNullable": false + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "DefaultValues", + "url": "package:celest_backend/models/classes.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 934, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 35, + "column": 22 + }, + "end": { + "offset": 952, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 35, + "column": 40 + }, + "text": "asyncDefaultValues" + } + }, + "nestedClass": { + "name": "nestedClass", + "apiName": "classes", + "typeParameters": [], + "parameters": [ + { + "name": "value", + "type": { + "$": "TypeReference", + "symbol": "NestedClass", + "url": "package:celest_backend/models/classes.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 1034, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 38, + "column": 36 + }, + "end": { + "offset": 1039, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 38, + "column": 41 + }, + "text": "value" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "NestedClass", + "url": "package:celest_backend/models/classes.dart", + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "NestedClass", + "url": "package:celest_backend/models/classes.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 1010, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 38, + "column": 12 + }, + "end": { + "offset": 1021, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 38, + "column": 23 + }, + "text": "nestedClass" + } + }, + "asyncNestedClass": { + "name": "asyncNestedClass", + "apiName": "classes", + "typeParameters": [], + "parameters": [ + { + "name": "value", + "type": { + "$": "TypeReference", + "symbol": "NestedClass", + "url": "package:celest_backend/models/classes.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 1107, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 40, + "column": 49 + }, + "end": { + "offset": 1112, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 40, + "column": 54 + }, + "text": "value" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "Future", + "url": "dart:async", + "types": [ + { + "$": "TypeReference", + "symbol": "NestedClass", + "url": "package:celest_backend/models/classes.dart", + "isNullable": false + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "NestedClass", + "url": "package:celest_backend/models/classes.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 1078, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 40, + "column": 20 + }, + "end": { + "offset": 1094, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 40, + "column": 36 + }, + "text": "asyncNestedClass" + } + }, + "onlyFromJson": { + "name": "onlyFromJson", + "apiName": "classes", + "typeParameters": [], + "parameters": [ + { + "name": "value", + "type": { + "$": "TypeReference", + "symbol": "OnlyFromJson", + "url": "package:celest_backend/models/classes.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 1177, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 43, + "column": 39 + }, + "end": { + "offset": 1182, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 43, + "column": 44 + }, + "text": "value" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "OnlyFromJson", + "url": "package:celest_backend/models/classes.dart", + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "OnlyFromJson", + "url": "package:celest_backend/models/classes.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 1151, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 43, + "column": 13 + }, + "end": { + "offset": 1163, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 43, + "column": 25 + }, + "text": "onlyFromJson" + } + }, + "asyncOnlyFromJson": { + "name": "asyncOnlyFromJson", + "apiName": "classes", + "typeParameters": [], + "parameters": [ + { + "name": "value", + "type": { + "$": "TypeReference", + "symbol": "OnlyFromJson", + "url": "package:celest_backend/models/classes.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 1253, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 45, + "column": 52 + }, + "end": { + "offset": 1258, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 45, + "column": 57 + }, + "text": "value" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "Future", + "url": "dart:async", + "types": [ + { + "$": "TypeReference", + "symbol": "OnlyFromJson", + "url": "package:celest_backend/models/classes.dart", + "isNullable": false + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "OnlyFromJson", + "url": "package:celest_backend/models/classes.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 1222, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 45, + "column": 21 + }, + "end": { + "offset": 1239, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 45, + "column": 38 + }, + "text": "asyncOnlyFromJson" + } + }, + "onlyToJson": { + "name": "onlyToJson", + "apiName": "classes", + "typeParameters": [], + "parameters": [ + { + "name": "value", + "type": { + "$": "TypeReference", + "symbol": "OnlyToJson", + "url": "package:celest_backend/models/classes.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 1317, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 48, + "column": 33 + }, + "end": { + "offset": 1322, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 48, + "column": 38 + }, + "text": "value" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "OnlyToJson", + "url": "package:celest_backend/models/classes.dart", + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "OnlyToJson", + "url": "package:celest_backend/models/classes.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 1295, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 48, + "column": 11 + }, + "end": { + "offset": 1305, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 48, + "column": 21 + }, + "text": "onlyToJson" + } + }, + "asyncOnlyToJson": { + "name": "asyncOnlyToJson", + "apiName": "classes", + "typeParameters": [], + "parameters": [ + { + "name": "value", + "type": { + "$": "TypeReference", + "symbol": "OnlyToJson", + "url": "package:celest_backend/models/classes.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 1387, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 50, + "column": 46 + }, + "end": { + "offset": 1392, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 50, + "column": 51 + }, + "text": "value" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "Future", + "url": "dart:async", + "types": [ + { + "$": "TypeReference", + "symbol": "OnlyToJson", + "url": "package:celest_backend/models/classes.dart", + "isNullable": false + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "OnlyToJson", + "url": "package:celest_backend/models/classes.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 1360, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 50, + "column": 19 + }, + "end": { + "offset": 1375, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 50, + "column": 34 + }, + "text": "asyncOnlyToJson" + } + }, + "onlyToJsonWithDefaults": { + "name": "onlyToJsonWithDefaults", + "apiName": "classes", + "typeParameters": [], + "parameters": [ + { + "name": "value", + "type": { + "$": "TypeReference", + "symbol": "OnlyToJsonWithDefaults", + "url": "package:celest_backend/models/classes.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 1490, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 54, + "column": 25 + }, + "end": { + "offset": 1495, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 54, + "column": 30 + }, + "text": "value" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "OnlyToJsonWithDefaults", + "url": "package:celest_backend/models/classes.dart", + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "OnlyToJsonWithDefaults", + "url": "package:celest_backend/models/classes.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 1441, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 53, + "column": 23 + }, + "end": { + "offset": 1463, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 53, + "column": 45 + }, + "text": "onlyToJsonWithDefaults" + } + }, + "asyncOnlyToJsonWithDefaults": { + "name": "asyncOnlyToJsonWithDefaults", + "apiName": "classes", + "typeParameters": [], + "parameters": [ + { + "name": "value", + "type": { + "$": "TypeReference", + "symbol": "OnlyToJsonWithDefaults", + "url": "package:celest_backend/models/classes.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 1605, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 59, + "column": 25 + }, + "end": { + "offset": 1610, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 59, + "column": 30 + }, + "text": "value" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "Future", + "url": "dart:async", + "types": [ + { + "$": "TypeReference", + "symbol": "OnlyToJsonWithDefaults", + "url": "package:celest_backend/models/classes.dart", + "isNullable": false + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "OnlyToJsonWithDefaults", + "url": "package:celest_backend/models/classes.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 1551, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 58, + "column": 31 + }, + "end": { + "offset": 1578, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 58, + "column": 58 + }, + "text": "asyncOnlyToJsonWithDefaults" + } + }, + "fromAndToJson": { + "name": "fromAndToJson", + "apiName": "classes", + "typeParameters": [], + "parameters": [ + { + "name": "value", + "type": { + "$": "TypeReference", + "symbol": "FromJsonAndToJson", + "url": "package:celest_backend/models/classes.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 1692, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 64, + "column": 50 + }, + "end": { + "offset": 1697, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 64, + "column": 55 + }, + "text": "value" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "FromJsonAndToJson", + "url": "package:celest_backend/models/classes.dart", + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "FromJsonAndToJson", + "url": "package:celest_backend/models/classes.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 1660, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 64, + "column": 18 + }, + "end": { + "offset": 1673, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 64, + "column": 31 + }, + "text": "fromAndToJson" + } + }, + "asyncFromAndToJson": { + "name": "asyncFromAndToJson", + "apiName": "classes", + "typeParameters": [], + "parameters": [ + { + "name": "value", + "type": { + "$": "TypeReference", + "symbol": "FromJsonAndToJson", + "url": "package:celest_backend/models/classes.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 1782, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 67, + "column": 20 + }, + "end": { + "offset": 1787, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 67, + "column": 25 + }, + "text": "value" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "Future", + "url": "dart:async", + "types": [ + { + "$": "TypeReference", + "symbol": "FromJsonAndToJson", + "url": "package:celest_backend/models/classes.dart", + "isNullable": false + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "FromJsonAndToJson", + "url": "package:celest_backend/models/classes.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 1742, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 66, + "column": 26 + }, + "end": { + "offset": 1760, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 66, + "column": 44 + }, + "text": "asyncFromAndToJson" + } + }, + "nonMapToJson": { + "name": "nonMapToJson", + "apiName": "classes", + "typeParameters": [], + "parameters": [ + { + "name": "value", + "type": { + "$": "TypeReference", + "symbol": "NonMapToJson", + "url": "package:celest_backend/models/classes.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 1858, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 72, + "column": 39 + }, + "end": { + "offset": 1863, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 72, + "column": 44 + }, + "text": "value" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "NonMapToJson", + "url": "package:celest_backend/models/classes.dart", + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "NonMapToJson", + "url": "package:celest_backend/models/classes.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 1832, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 72, + "column": 13 + }, + "end": { + "offset": 1844, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 72, + "column": 25 + }, + "text": "nonMapToJson" + } + }, + "asyncNonMapToJson": { + "name": "asyncNonMapToJson", + "apiName": "classes", + "typeParameters": [], + "parameters": [ + { + "name": "value", + "type": { + "$": "TypeReference", + "symbol": "NonMapToJson", + "url": "package:celest_backend/models/classes.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 1934, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 74, + "column": 52 + }, + "end": { + "offset": 1939, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 74, + "column": 57 + }, + "text": "value" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "Future", + "url": "dart:async", + "types": [ + { + "$": "TypeReference", + "symbol": "NonMapToJson", + "url": "package:celest_backend/models/classes.dart", + "isNullable": false + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "NonMapToJson", + "url": "package:celest_backend/models/classes.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 1903, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 74, + "column": 21 + }, + "end": { + "offset": 1920, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 74, + "column": 38 + }, + "text": "asyncNonMapToJson" + } + }, + "nonMapToJsonWithDefaults": { + "name": "nonMapToJsonWithDefaults", + "apiName": "classes", + "typeParameters": [], + "parameters": [ + { + "name": "value", + "type": { + "$": "TypeReference", + "symbol": "NonMapToJsonWithDefaults", + "url": "package:celest_backend/models/classes.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 2043, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 78, + "column": 27 + }, + "end": { + "offset": 2048, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 78, + "column": 32 + }, + "text": "value" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "NonMapToJsonWithDefaults", + "url": "package:celest_backend/models/classes.dart", + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "NonMapToJsonWithDefaults", + "url": "package:celest_backend/models/classes.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 1990, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 77, + "column": 25 + }, + "end": { + "offset": 2014, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 77, + "column": 49 + }, + "text": "nonMapToJsonWithDefaults" + } + }, + "asyncNonMapToJsonWithDefaults": { + "name": "asyncNonMapToJsonWithDefaults", + "apiName": "classes", + "typeParameters": [], + "parameters": [ + { + "name": "value", + "type": { + "$": "TypeReference", + "symbol": "NonMapToJsonWithDefaults", + "url": "package:celest_backend/models/classes.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 2164, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 83, + "column": 27 + }, + "end": { + "offset": 2169, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 83, + "column": 32 + }, + "text": "value" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "Future", + "url": "dart:async", + "types": [ + { + "$": "TypeReference", + "symbol": "NonMapToJsonWithDefaults", + "url": "package:celest_backend/models/classes.dart", + "isNullable": false + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "NonMapToJsonWithDefaults", + "url": "package:celest_backend/models/classes.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 2106, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 82, + "column": 33 + }, + "end": { + "offset": 2135, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 82, + "column": 62 + }, + "text": "asyncNonMapToJsonWithDefaults" + } + }, + "nonMapFromAndToJson": { + "name": "nonMapFromAndToJson", + "apiName": "classes", + "typeParameters": [], + "parameters": [ + { + "name": "value", + "type": { + "$": "TypeReference", + "symbol": "NonMapFromAndToJson", + "url": "package:celest_backend/models/classes.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 2264, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 89, + "column": 22 + }, + "end": { + "offset": 2269, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 89, + "column": 27 + }, + "text": "value" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "NonMapFromAndToJson", + "url": "package:celest_backend/models/classes.dart", + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "NonMapFromAndToJson", + "url": "package:celest_backend/models/classes.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 2221, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 88, + "column": 20 + }, + "end": { + "offset": 2240, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 88, + "column": 39 + }, + "text": "nonMapFromAndToJson" + } + }, + "asyncNonMapFromAndToJson": { + "name": "asyncNonMapFromAndToJson", + "apiName": "classes", + "typeParameters": [], + "parameters": [ + { + "name": "value", + "type": { + "$": "TypeReference", + "symbol": "NonMapFromAndToJson", + "url": "package:celest_backend/models/classes.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 2370, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 94, + "column": 22 + }, + "end": { + "offset": 2375, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 94, + "column": 27 + }, + "text": "value" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "Future", + "url": "dart:async", + "types": [ + { + "$": "TypeReference", + "symbol": "NonMapFromAndToJson", + "url": "package:celest_backend/models/classes.dart", + "isNullable": false + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "NonMapFromAndToJson", + "url": "package:celest_backend/models/classes.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 2322, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 93, + "column": 28 + }, + "end": { + "offset": 2346, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 93, + "column": 52 + }, + "text": "asyncNonMapFromAndToJson" + } + }, + "fromJsonStatic": { + "name": "fromJsonStatic", + "apiName": "classes", + "typeParameters": [], + "parameters": [ + { + "name": "value", + "type": { + "$": "TypeReference", + "symbol": "FromJsonStatic", + "url": "package:celest_backend/models/classes.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 2452, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 99, + "column": 45 + }, + "end": { + "offset": 2457, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 99, + "column": 50 + }, + "text": "value" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "FromJsonStatic", + "url": "package:celest_backend/models/classes.dart", + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "FromJsonStatic", + "url": "package:celest_backend/models/classes.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 2422, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 99, + "column": 15 + }, + "end": { + "offset": 2436, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 99, + "column": 29 + }, + "text": "fromJsonStatic" + } + } + }, + "docs": [ + "/// Tests that classes with and without explicit fromJson/toJson methods are", + "/// serializable and deserializable." + ], + "exceptionTypes": [ + { + "$": "TypeReference", + "symbol": "CloudException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "CancelledException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnknownError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "BadRequestException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnauthorizedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "NotFoundException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AlreadyExistsException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "PermissionDeniedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ResourceExhaustedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "FailedPreconditionException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AbortedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "OutOfRangeException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnimplementedError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "InternalServerError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnavailableError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "DataLossError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "DeadlineExceededError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "SerializationException", + "url": "package:celest_core/src/exception/serialization_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "Error", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AssertionError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "TypeError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ArgumentError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "RangeError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "IndexError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnsupportedError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnimplementedError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "StateError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ConcurrentModificationError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "OutOfMemoryError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "StackOverflowError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "Exception", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "FormatException", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "IntegerDivisionByZeroException", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AsyncError", + "url": "dart:async", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "TimeoutException", + "url": "dart:async", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "JsonUnsupportedObjectError", + "url": "dart:convert", + "isNullable": false + } + ], + "location": { + "start": { + "offset": 0, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 0, + "column": 0 + }, + "end": { + "offset": 0, + "uri": "package:celest_backend/src/functions/classes.dart", + "line": 0, + "column": 0 + }, + "text": "" + } + }, + "exceptions": { + "name": "exceptions", + "metadata": [], + "functions": { + "throwsException": { + "name": "throwsException", + "apiName": "exceptions", + "typeParameters": [], + "parameters": [ + { + "name": "type", + "type": { + "$": "TypeReference", + "symbol": "SupportedExceptionType", + "url": "package:celest_backend/models/exceptions.dart", + "isNullable": false + }, + "required": true, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 218, + "uri": "package:celest_backend/src/functions/exceptions.dart", + "line": 6, + "column": 34 + }, + "end": { + "offset": 222, + "uri": "package:celest_backend/src/functions/exceptions.dart", + "line": 6, + "column": 38 + }, + "text": "type" + } + } + ], + "returnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "flattenedReturnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 166, + "uri": "package:celest_backend/src/functions/exceptions.dart", + "line": 5, + "column": 5 + }, + "end": { + "offset": 181, + "uri": "package:celest_backend/src/functions/exceptions.dart", + "line": 5, + "column": 20 + }, + "text": "throwsException" + } + }, + "throwsError": { + "name": "throwsError", + "apiName": "exceptions", + "typeParameters": [], + "parameters": [ + { + "name": "type", + "type": { + "$": "TypeReference", + "symbol": "SupportedErrorType", + "url": "package:celest_backend/models/exceptions.dart", + "isNullable": false + }, + "required": true, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 494, + "uri": "package:celest_backend/src/functions/exceptions.dart", + "line": 18, + "column": 30 + }, + "end": { + "offset": 498, + "uri": "package:celest_backend/src/functions/exceptions.dart", + "line": 18, + "column": 34 + }, + "text": "type" + } + } + ], + "returnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "flattenedReturnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 450, + "uri": "package:celest_backend/src/functions/exceptions.dart", + "line": 17, + "column": 5 + }, + "end": { + "offset": 461, + "uri": "package:celest_backend/src/functions/exceptions.dart", + "line": 17, + "column": 16 + }, + "text": "throwsError" + } + }, + "throwsCustomException": { + "name": "throwsCustomException", + "apiName": "exceptions", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "flattenedReturnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 695, + "uri": "package:celest_backend/src/functions/exceptions.dart", + "line": 29, + "column": 5 + }, + "end": { + "offset": 716, + "uri": "package:celest_backend/src/functions/exceptions.dart", + "line": 29, + "column": 26 + }, + "text": "throwsCustomException" + } + }, + "throwsCustomExceptionToFromJson": { + "name": "throwsCustomExceptionToFromJson", + "apiName": "exceptions", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "flattenedReturnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 763, + "uri": "package:celest_backend/src/functions/exceptions.dart", + "line": 34, + "column": 5 + }, + "end": { + "offset": 794, + "uri": "package:celest_backend/src/functions/exceptions.dart", + "line": 34, + "column": 36 + }, + "text": "throwsCustomExceptionToFromJson" + } + }, + "throwsCustomError": { + "name": "throwsCustomError", + "apiName": "exceptions", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "flattenedReturnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 851, + "uri": "package:celest_backend/src/functions/exceptions.dart", + "line": 39, + "column": 5 + }, + "end": { + "offset": 868, + "uri": "package:celest_backend/src/functions/exceptions.dart", + "line": 39, + "column": 22 + }, + "text": "throwsCustomError" + } + }, + "throwsCustomErrorToFromJson": { + "name": "throwsCustomErrorToFromJson", + "apiName": "exceptions", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "flattenedReturnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 911, + "uri": "package:celest_backend/src/functions/exceptions.dart", + "line": 44, + "column": 5 + }, + "end": { + "offset": 938, + "uri": "package:celest_backend/src/functions/exceptions.dart", + "line": 44, + "column": 32 + }, + "text": "throwsCustomErrorToFromJson" + } + }, + "throwsCustomErrorWithStackTrace": { + "name": "throwsCustomErrorWithStackTrace", + "apiName": "exceptions", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "flattenedReturnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 991, + "uri": "package:celest_backend/src/functions/exceptions.dart", + "line": 49, + "column": 5 + }, + "end": { + "offset": 1022, + "uri": "package:celest_backend/src/functions/exceptions.dart", + "line": 49, + "column": 36 + }, + "text": "throwsCustomErrorWithStackTrace" + } + } + }, + "docs": [], + "exceptionTypes": [ + { + "$": "TypeReference", + "symbol": "CloudException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "CancelledException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnknownError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "BadRequestException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnauthorizedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "NotFoundException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AlreadyExistsException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "PermissionDeniedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ResourceExhaustedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "FailedPreconditionException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AbortedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "OutOfRangeException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnimplementedError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "InternalServerError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnavailableError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "DataLossError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "DeadlineExceededError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "SerializationException", + "url": "package:celest_core/src/exception/serialization_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "Error", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AssertionError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "TypeError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ArgumentError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "RangeError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "IndexError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnsupportedError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnimplementedError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "StateError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ConcurrentModificationError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "OutOfMemoryError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "StackOverflowError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "Exception", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "FormatException", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "IntegerDivisionByZeroException", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AsyncError", + "url": "dart:async", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "TimeoutException", + "url": "dart:async", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "JsonUnsupportedObjectError", + "url": "dart:convert", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "CustomException", + "url": "package:celest_backend/exceptions/exceptions.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "CustomExceptionToFromJson", + "url": "package:celest_backend/exceptions/exceptions.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "CustomError", + "url": "package:celest_backend/exceptions/exceptions.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "CustomErrorToFromJson", + "url": "package:celest_backend/exceptions/exceptions.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "CustomErrorWithStackTrace", + "url": "package:celest_backend/exceptions/exceptions.dart", + "isNullable": false + } + ], + "location": { + "start": { + "offset": 0, + "uri": "package:celest_backend/src/functions/exceptions.dart", + "line": 0, + "column": 0 + }, + "end": { + "offset": 0, + "uri": "package:celest_backend/src/functions/exceptions.dart", + "line": 0, + "column": 0 + }, + "text": "" + } + }, + "metadata": { + "name": "metadata", + "metadata": [], + "functions": { + "hasDocComments": { + "name": "hasDocComments", + "apiName": "metadata", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "flattenedReturnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [ + "/// A function that has doc comments.", + "///", + "/// This is a doc comment.", + "///", + "/// # This is an H1", + "/// ## This is an H2", + "/// ### This is an H3", + "/// * This is a list item", + "///", + "/// This is an example:", + "///", + "/// ```dart", + "/// void hasDocComments() {}", + "/// ```" + ], + "location": { + "start": { + "offset": 523, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 23, + "column": 5 + }, + "end": { + "offset": 537, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 23, + "column": 19 + }, + "text": "hasDocComments" + } + }, + "hasDeprecatedAnnotation": { + "name": "hasDeprecatedAnnotation", + "apiName": "metadata", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "flattenedReturnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + }, + { + "$": "DartInstance", + "classRef": { + "symbol": "Deprecated", + "url": "dart:core", + "isNullable": false + }, + "constructor": "", + "positionalArguments": { + "message": { + "$": "DartString", + "value": "next release", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "namedArguments": {}, + "staticType": { + "symbol": "Deprecated", + "url": "dart:core", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 568, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 27, + "column": 5 + }, + "end": { + "offset": 591, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 27, + "column": 28 + }, + "text": "hasDeprecatedAnnotation" + } + }, + "hasConstructedDeprecatedAnnotation": { + "name": "hasConstructedDeprecatedAnnotation", + "apiName": "metadata", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "flattenedReturnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + }, + { + "$": "DartInstance", + "classRef": { + "symbol": "Deprecated", + "url": "dart:core", + "isNullable": false + }, + "constructor": "", + "positionalArguments": { + "message": { + "$": "DartString", + "value": "Do not use this function.", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "namedArguments": {}, + "staticType": { + "symbol": "Deprecated", + "url": "dart:core", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 651, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 31, + "column": 5 + }, + "end": { + "offset": 685, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 31, + "column": 39 + }, + "text": "hasConstructedDeprecatedAnnotation" + } + }, + "hasNamedConstructedAnnotation": { + "name": "hasNamedConstructedAnnotation", + "apiName": "metadata", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "flattenedReturnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + }, + { + "$": "DartInstance", + "classRef": { + "symbol": "MyAnnotation", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + }, + "constructor": "create", + "positionalArguments": { + "positional": { + "$": "DartString", + "value": "positional", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "namedArguments": { + "named": { + "$": "DartString", + "value": "named", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "staticType": { + "symbol": "MyAnnotation", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 755, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 35, + "column": 5 + }, + "end": { + "offset": 784, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 35, + "column": 34 + }, + "text": "hasNamedConstructedAnnotation" + } + }, + "hasLiteralsAnnotation": { + "name": "hasLiteralsAnnotation", + "apiName": "metadata", + "typeParameters": [], + "parameters": [ + { + "name": "value", + "type": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "Literals", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": { + "string": { + "$": "DartString", + "value": "string", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + }, + "intValue": { + "$": "DartInt", + "value": 1, + "staticType": { + "symbol": "int", + "url": "dart:core" + } + }, + "doubleValue": { + "$": "DartDouble", + "value": 1.0, + "staticType": { + "symbol": "double", + "url": "dart:core" + } + }, + "boolValue": { + "$": "DartBool", + "value": true, + "staticType": { + "symbol": "bool", + "url": "dart:core" + } + }, + "list": { + "$": "DartList", + "value": [ + { + "$": "DartString", + "value": "list", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + ], + "staticType": { + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + } + }, + "map": { + "$": "DartMap", + "value": { + "{\"$\":\"DartString\",\"value\":\"map\",\"staticType\":{\"symbol\":\"String\",\"url\":\"dart:core\"}}": { + "$": "DartString", + "value": "map", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "staticType": { + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + } + }, + "enumValue": { + "$": "DartEnum", + "enumRef": { + "symbol": "LiteralEnum", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + }, + "value": "a", + "staticType": { + "symbol": "LiteralEnum", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + } + }, + "recordValue": { + "$": "DartRecord", + "positionalFields": [], + "namedFields": { + "a": { + "$": "DartString", + "value": "a", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + }, + "b": { + "$": "DartString", + "value": "b", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + }, + "c": { + "$": "DartString", + "value": "c", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "staticType": { + "symbol": "Record$k7x4l9", + "isNullable": false + } + } + }, + "staticType": { + "symbol": "Literals", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + } + } + ], + "location": { + "start": { + "offset": 1249, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 59, + "column": 9 + }, + "end": { + "offset": 1254, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 59, + "column": 14 + }, + "text": "value" + } + }, + { + "name": "named", + "type": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + "required": true, + "named": true, + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "Literals", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": { + "string": { + "$": "DartString", + "value": "string", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + }, + "intValue": { + "$": "DartInt", + "value": 1, + "staticType": { + "symbol": "int", + "url": "dart:core" + } + }, + "doubleValue": { + "$": "DartDouble", + "value": 1.0, + "staticType": { + "symbol": "double", + "url": "dart:core" + } + }, + "boolValue": { + "$": "DartBool", + "value": true, + "staticType": { + "symbol": "bool", + "url": "dart:core" + } + }, + "list": { + "$": "DartList", + "value": [ + { + "$": "DartString", + "value": "list", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + ], + "staticType": { + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + } + }, + "map": { + "$": "DartMap", + "value": { + "{\"$\":\"DartString\",\"value\":\"map\",\"staticType\":{\"symbol\":\"String\",\"url\":\"dart:core\"}}": { + "$": "DartString", + "value": "map", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "staticType": { + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + } + }, + "enumValue": { + "$": "DartEnum", + "enumRef": { + "symbol": "LiteralEnum", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + }, + "value": "a", + "staticType": { + "symbol": "LiteralEnum", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + } + }, + "recordValue": { + "$": "DartRecord", + "positionalFields": [], + "namedFields": { + "a": { + "$": "DartString", + "value": "a", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + }, + "b": { + "$": "DartString", + "value": "b", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + }, + "c": { + "$": "DartString", + "value": "c", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "staticType": { + "symbol": "Record$k7x4l9", + "isNullable": false + } + } + }, + "staticType": { + "symbol": "Literals", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + } + } + ], + "location": { + "start": { + "offset": 1493, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 70, + "column": 18 + }, + "end": { + "offset": 1498, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 70, + "column": 23 + }, + "text": "named" + } + } + ], + "returnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "flattenedReturnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + }, + { + "$": "DartInstance", + "classRef": { + "symbol": "Literals", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": { + "string": { + "$": "DartString", + "value": "string", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + }, + "intValue": { + "$": "DartInt", + "value": 1, + "staticType": { + "symbol": "int", + "url": "dart:core" + } + }, + "doubleValue": { + "$": "DartDouble", + "value": 1.0, + "staticType": { + "symbol": "double", + "url": "dart:core" + } + }, + "boolValue": { + "$": "DartBool", + "value": true, + "staticType": { + "symbol": "bool", + "url": "dart:core" + } + }, + "list": { + "$": "DartList", + "value": [ + { + "$": "DartString", + "value": "list", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + ], + "staticType": { + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + } + }, + "map": { + "$": "DartMap", + "value": { + "{\"$\":\"DartString\",\"value\":\"map\",\"staticType\":{\"symbol\":\"String\",\"url\":\"dart:core\"}}": { + "$": "DartString", + "value": "map", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "staticType": { + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + } + }, + "enumValue": { + "$": "DartEnum", + "enumRef": { + "symbol": "LiteralEnum", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + }, + "value": "a", + "staticType": { + "symbol": "LiteralEnum", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + } + }, + "recordValue": { + "$": "DartRecord", + "positionalFields": [], + "namedFields": { + "a": { + "$": "DartString", + "value": "a", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + }, + "b": { + "$": "DartString", + "value": "b", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + }, + "c": { + "$": "DartString", + "value": "c", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "staticType": { + "symbol": "Record$k7x4l9", + "isNullable": false + } + } + }, + "staticType": { + "symbol": "Literals", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 1000, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 48, + "column": 5 + }, + "end": { + "offset": 1021, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 48, + "column": 26 + }, + "text": "hasLiteralsAnnotation" + } + }, + "hasExportableAnnotation": { + "name": "hasExportableAnnotation", + "apiName": "metadata", + "typeParameters": [], + "parameters": [ + { + "name": "value", + "type": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "Exportable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "Exportable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + } + } + ], + "location": { + "start": { + "offset": 1577, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 76, + "column": 21 + }, + "end": { + "offset": 1582, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 76, + "column": 26 + }, + "text": "value" + } + }, + { + "name": "named", + "type": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + "required": false, + "named": true, + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "Exportable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "Exportable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + } + } + ], + "location": { + "start": { + "offset": 1607, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 77, + "column": 21 + }, + "end": { + "offset": 1612, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 77, + "column": 26 + }, + "text": "named" + }, + "defaultTo": { + "$": "DartString", + "value": "named", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + } + ], + "returnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "flattenedReturnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + }, + { + "$": "DartInstance", + "classRef": { + "symbol": "Exportable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "Exportable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 1531, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 75, + "column": 5 + }, + "end": { + "offset": 1554, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 75, + "column": 28 + }, + "text": "hasExportableAnnotation" + } + }, + "hasExportableConstructedAnnotation": { + "name": "hasExportableConstructedAnnotation", + "apiName": "metadata", + "typeParameters": [], + "parameters": [ + { + "name": "value", + "type": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "Exportable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "Exportable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + } + } + ], + "location": { + "start": { + "offset": 1716, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 83, + "column": 23 + }, + "end": { + "offset": 1721, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 83, + "column": 28 + }, + "text": "value" + } + }, + { + "name": "named", + "type": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + "required": false, + "named": true, + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "Exportable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "Exportable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + } + } + ], + "location": { + "start": { + "offset": 1748, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 84, + "column": 23 + }, + "end": { + "offset": 1753, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 84, + "column": 28 + }, + "text": "named" + }, + "defaultTo": { + "$": "DartString", + "value": "named", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + } + ], + "returnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "flattenedReturnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + }, + { + "$": "DartInstance", + "classRef": { + "symbol": "Exportable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "Exportable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 1657, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 82, + "column": 5 + }, + "end": { + "offset": 1691, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 82, + "column": 39 + }, + "text": "hasExportableConstructedAnnotation" + } + }, + "hasNotExportableAnnotation": { + "name": "hasNotExportableAnnotation", + "apiName": "metadata", + "typeParameters": [], + "parameters": [ + { + "name": "value", + "type": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_NotExportable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_NotExportable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + } + } + ], + "location": { + "start": { + "offset": 1851, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 90, + "column": 24 + }, + "end": { + "offset": 1856, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 90, + "column": 29 + }, + "text": "value" + } + }, + { + "name": "named", + "type": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + "required": false, + "named": true, + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_NotExportable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_NotExportable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + } + } + ], + "location": { + "start": { + "offset": 1884, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 91, + "column": 24 + }, + "end": { + "offset": 1889, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 91, + "column": 29 + }, + "text": "named" + }, + "defaultTo": { + "$": "DartString", + "value": "named", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + } + ], + "returnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "flattenedReturnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + }, + { + "$": "DartInstance", + "classRef": { + "symbol": "_NotExportable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_NotExportable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 1799, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 89, + "column": 5 + }, + "end": { + "offset": 1825, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 89, + "column": 31 + }, + "text": "hasNotExportableAnnotation" + } + }, + "positionalDefaultValues": { + "name": "positionalDefaultValues", + "apiName": "metadata", + "typeParameters": [], + "parameters": [ + { + "name": "value", + "type": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + "required": false, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 1980, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 98, + "column": 9 + }, + "end": { + "offset": 1985, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 98, + "column": 14 + }, + "text": "value" + }, + "defaultTo": { + "$": "DartString", + "value": "value", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + { + "name": "intValue", + "type": { + "$": "TypeReference", + "symbol": "int", + "url": "dart:core", + "isNullable": false + }, + "required": false, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 2003, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 99, + "column": 6 + }, + "end": { + "offset": 2011, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 99, + "column": 14 + }, + "text": "intValue" + }, + "defaultTo": { + "$": "DartInt", + "value": 1, + "staticType": { + "symbol": "int", + "url": "dart:core" + } + } + }, + { + "name": "doubleValue", + "type": { + "$": "TypeReference", + "symbol": "double", + "url": "dart:core", + "isNullable": false + }, + "required": false, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 2026, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 100, + "column": 9 + }, + "end": { + "offset": 2037, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 100, + "column": 20 + }, + "text": "doubleValue" + }, + "defaultTo": { + "$": "DartDouble", + "value": 1.0, + "staticType": { + "symbol": "double", + "url": "dart:core" + } + } + }, + { + "name": "boolValue", + "type": { + "$": "TypeReference", + "symbol": "bool", + "url": "dart:core", + "isNullable": false + }, + "required": false, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 2052, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 101, + "column": 7 + }, + "end": { + "offset": 2061, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 101, + "column": 16 + }, + "text": "boolValue" + }, + "defaultTo": { + "$": "DartBool", + "value": true, + "staticType": { + "symbol": "bool", + "url": "dart:core" + } + } + }, + { + "name": "list", + "type": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + }, + "required": false, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 2085, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 102, + "column": 15 + }, + "end": { + "offset": 2089, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 102, + "column": 19 + }, + "text": "list" + }, + "defaultTo": { + "$": "DartList", + "value": [ + { + "$": "DartString", + "value": "list", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + ], + "staticType": { + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + } + } + }, + { + "name": "map", + "type": { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + }, + "required": false, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 2130, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 103, + "column": 22 + }, + "end": { + "offset": 2133, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 103, + "column": 25 + }, + "text": "map" + }, + "defaultTo": { + "$": "DartMap", + "value": { + "{\"$\":\"DartString\",\"value\":\"map\",\"staticType\":{\"symbol\":\"String\",\"url\":\"dart:core\"}}": { + "$": "DartString", + "value": "map", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "staticType": { + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + } + } + }, + { + "name": "exportable", + "type": { + "$": "TypeReference", + "symbol": "Exportable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + }, + "required": false, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 2171, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 104, + "column": 13 + }, + "end": { + "offset": 2181, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 104, + "column": 23 + }, + "text": "exportable" + }, + "defaultTo": { + "$": "DartInstance", + "classRef": { + "symbol": "Exportable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "Exportable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + } + } + }, + { + "name": "serializable", + "type": { + "$": "TypeReference", + "symbol": "Serializable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + }, + "required": false, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 2219, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 105, + "column": 15 + }, + "end": { + "offset": 2231, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 105, + "column": 27 + }, + "text": "serializable" + }, + "defaultTo": { + "$": "DartInstance", + "classRef": { + "symbol": "Serializable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + }, + "constructor": "forType", + "positionalArguments": { + "type": { + "$": "DartString", + "value": "String", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "namedArguments": {}, + "staticType": { + "symbol": "Serializable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + } + } + }, + { + "name": "enumValue", + "type": { + "$": "TypeReference", + "symbol": "LiteralEnum", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + }, + "required": false, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 2286, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 106, + "column": 14 + }, + "end": { + "offset": 2295, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 106, + "column": 23 + }, + "text": "enumValue" + }, + "defaultTo": { + "$": "DartEnum", + "enumRef": { + "symbol": "LiteralEnum", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + }, + "value": "a", + "staticType": { + "symbol": "LiteralEnum", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + } + } + }, + { + "name": "recordValue", + "type": { + "$": "RecordType", + "namedFieldTypes": { + "a": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + "b": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + "c": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + }, + "isNullable": false + }, + "required": false, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 2348, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 107, + "column": 35 + }, + "end": { + "offset": 2359, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 107, + "column": 46 + }, + "text": "recordValue" + }, + "defaultTo": { + "$": "DartRecord", + "positionalFields": [], + "namedFields": { + "a": { + "$": "DartString", + "value": "a", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + }, + "b": { + "$": "DartString", + "value": "b", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + }, + "c": { + "$": "DartString", + "value": "c", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "staticType": { + "symbol": "Record$k7x4l9", + "isNullable": false + } + } + } + ], + "returnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "flattenedReturnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 1945, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 97, + "column": 5 + }, + "end": { + "offset": 1968, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 97, + "column": 28 + }, + "text": "positionalDefaultValues" + } + }, + "nullablePositionalDefaultValues": { + "name": "nullablePositionalDefaultValues", + "apiName": "metadata", + "typeParameters": [], + "parameters": [ + { + "name": "value", + "type": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": true + }, + "required": false, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 2451, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 112, + "column": 10 + }, + "end": { + "offset": 2456, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 112, + "column": 15 + }, + "text": "value" + }, + "defaultTo": { + "$": "DartString", + "value": "value", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + { + "name": "intValue", + "type": { + "$": "TypeReference", + "symbol": "int", + "url": "dart:core", + "isNullable": true + }, + "required": false, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 2475, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 113, + "column": 7 + }, + "end": { + "offset": 2483, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 113, + "column": 15 + }, + "text": "intValue" + }, + "defaultTo": { + "$": "DartInt", + "value": 1, + "staticType": { + "symbol": "int", + "url": "dart:core" + } + } + }, + { + "name": "doubleValue", + "type": { + "$": "TypeReference", + "symbol": "double", + "url": "dart:core", + "isNullable": true + }, + "required": false, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 2499, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 114, + "column": 10 + }, + "end": { + "offset": 2510, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 114, + "column": 21 + }, + "text": "doubleValue" + }, + "defaultTo": { + "$": "DartDouble", + "value": 1.0, + "staticType": { + "symbol": "double", + "url": "dart:core" + } + } + }, + { + "name": "boolValue", + "type": { + "$": "TypeReference", + "symbol": "bool", + "url": "dart:core", + "isNullable": true + }, + "required": false, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 2526, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 115, + "column": 8 + }, + "end": { + "offset": 2535, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 115, + "column": 17 + }, + "text": "boolValue" + }, + "defaultTo": { + "$": "DartBool", + "value": true, + "staticType": { + "symbol": "bool", + "url": "dart:core" + } + } + }, + { + "name": "list", + "type": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": true + }, + "required": false, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 2560, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 116, + "column": 16 + }, + "end": { + "offset": 2564, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 116, + "column": 20 + }, + "text": "list" + }, + "defaultTo": { + "$": "DartList", + "value": [ + { + "$": "DartString", + "value": "list", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + ], + "staticType": { + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + } + } + }, + { + "name": "map", + "type": { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": true + }, + "required": false, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 2606, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 117, + "column": 23 + }, + "end": { + "offset": 2609, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 117, + "column": 26 + }, + "text": "map" + }, + "defaultTo": { + "$": "DartMap", + "value": { + "{\"$\":\"DartString\",\"value\":\"map\",\"staticType\":{\"symbol\":\"String\",\"url\":\"dart:core\"}}": { + "$": "DartString", + "value": "map", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "staticType": { + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + } + } + }, + { + "name": "exportable", + "type": { + "$": "TypeReference", + "symbol": "Exportable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": true + }, + "required": false, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 2648, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 118, + "column": 14 + }, + "end": { + "offset": 2658, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 118, + "column": 24 + }, + "text": "exportable" + }, + "defaultTo": { + "$": "DartInstance", + "classRef": { + "symbol": "Exportable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "Exportable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + } + } + }, + { + "name": "serializable", + "type": { + "$": "TypeReference", + "symbol": "Serializable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": true + }, + "required": false, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 2697, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 119, + "column": 16 + }, + "end": { + "offset": 2709, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 119, + "column": 28 + }, + "text": "serializable" + }, + "defaultTo": { + "$": "DartInstance", + "classRef": { + "symbol": "Serializable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + }, + "constructor": "forType", + "positionalArguments": { + "type": { + "$": "DartString", + "value": "String", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "namedArguments": {}, + "staticType": { + "symbol": "Serializable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + } + } + }, + { + "name": "enumValue", + "type": { + "$": "TypeReference", + "symbol": "LiteralEnum", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": true + }, + "required": false, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 2765, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 120, + "column": 15 + }, + "end": { + "offset": 2774, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 120, + "column": 24 + }, + "text": "enumValue" + }, + "defaultTo": { + "$": "DartEnum", + "enumRef": { + "symbol": "LiteralEnum", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + }, + "value": "a", + "staticType": { + "symbol": "LiteralEnum", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + } + } + }, + { + "name": "recordValue", + "type": { + "$": "RecordType", + "namedFieldTypes": { + "a": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + "b": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + "c": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + }, + "isNullable": true + }, + "required": false, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 2828, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 121, + "column": 36 + }, + "end": { + "offset": 2839, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 121, + "column": 47 + }, + "text": "recordValue" + }, + "defaultTo": { + "$": "DartRecord", + "positionalFields": [], + "namedFields": { + "a": { + "$": "DartString", + "value": "a", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + }, + "b": { + "$": "DartString", + "value": "b", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + }, + "c": { + "$": "DartString", + "value": "c", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "staticType": { + "symbol": "Record$k7x4l9", + "isNullable": false + } + } + } + ], + "returnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "flattenedReturnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 2407, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 111, + "column": 5 + }, + "end": { + "offset": 2438, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 111, + "column": 36 + }, + "text": "nullablePositionalDefaultValues" + } + }, + "namedDefaultValues": { + "name": "namedDefaultValues", + "apiName": "metadata", + "typeParameters": [], + "parameters": [ + { + "name": "value", + "type": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + "required": false, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 2917, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 126, + "column": 9 + }, + "end": { + "offset": 2922, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 126, + "column": 14 + }, + "text": "value" + }, + "defaultTo": { + "$": "DartString", + "value": "value", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + { + "name": "intValue", + "type": { + "$": "TypeReference", + "symbol": "int", + "url": "dart:core", + "isNullable": false + }, + "required": false, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 2940, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 127, + "column": 6 + }, + "end": { + "offset": 2948, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 127, + "column": 14 + }, + "text": "intValue" + }, + "defaultTo": { + "$": "DartInt", + "value": 1, + "staticType": { + "symbol": "int", + "url": "dart:core" + } + } + }, + { + "name": "doubleValue", + "type": { + "$": "TypeReference", + "symbol": "double", + "url": "dart:core", + "isNullable": false + }, + "required": false, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 2963, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 128, + "column": 9 + }, + "end": { + "offset": 2974, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 128, + "column": 20 + }, + "text": "doubleValue" + }, + "defaultTo": { + "$": "DartDouble", + "value": 1.0, + "staticType": { + "symbol": "double", + "url": "dart:core" + } + } + }, + { + "name": "boolValue", + "type": { + "$": "TypeReference", + "symbol": "bool", + "url": "dart:core", + "isNullable": false + }, + "required": false, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 2989, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 129, + "column": 7 + }, + "end": { + "offset": 2998, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 129, + "column": 16 + }, + "text": "boolValue" + }, + "defaultTo": { + "$": "DartBool", + "value": true, + "staticType": { + "symbol": "bool", + "url": "dart:core" + } + } + }, + { + "name": "list", + "type": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + }, + "required": false, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 3022, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 130, + "column": 15 + }, + "end": { + "offset": 3026, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 130, + "column": 19 + }, + "text": "list" + }, + "defaultTo": { + "$": "DartList", + "value": [ + { + "$": "DartString", + "value": "list", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + ], + "staticType": { + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + } + } + }, + { + "name": "map", + "type": { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + }, + "required": false, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 3067, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 131, + "column": 22 + }, + "end": { + "offset": 3070, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 131, + "column": 25 + }, + "text": "map" + }, + "defaultTo": { + "$": "DartMap", + "value": { + "{\"$\":\"DartString\",\"value\":\"map\",\"staticType\":{\"symbol\":\"String\",\"url\":\"dart:core\"}}": { + "$": "DartString", + "value": "map", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "staticType": { + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + } + } + }, + { + "name": "exportable", + "type": { + "$": "TypeReference", + "symbol": "Exportable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + }, + "required": false, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 3108, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 132, + "column": 13 + }, + "end": { + "offset": 3118, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 132, + "column": 23 + }, + "text": "exportable" + }, + "defaultTo": { + "$": "DartInstance", + "classRef": { + "symbol": "Exportable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "Exportable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + } + } + }, + { + "name": "serializable", + "type": { + "$": "TypeReference", + "symbol": "Serializable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + }, + "required": false, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 3156, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 133, + "column": 15 + }, + "end": { + "offset": 3168, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 133, + "column": 27 + }, + "text": "serializable" + }, + "defaultTo": { + "$": "DartInstance", + "classRef": { + "symbol": "Serializable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + }, + "constructor": "forType", + "positionalArguments": { + "type": { + "$": "DartString", + "value": "String", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "namedArguments": {}, + "staticType": { + "symbol": "Serializable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + } + } + }, + { + "name": "enumValue", + "type": { + "$": "TypeReference", + "symbol": "LiteralEnum", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + }, + "required": false, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 3223, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 134, + "column": 14 + }, + "end": { + "offset": 3232, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 134, + "column": 23 + }, + "text": "enumValue" + }, + "defaultTo": { + "$": "DartEnum", + "enumRef": { + "symbol": "LiteralEnum", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + }, + "value": "a", + "staticType": { + "symbol": "LiteralEnum", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + } + } + }, + { + "name": "recordValue", + "type": { + "$": "RecordType", + "namedFieldTypes": { + "a": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + "b": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + "c": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + }, + "isNullable": false + }, + "required": false, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 3285, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 135, + "column": 35 + }, + "end": { + "offset": 3296, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 135, + "column": 46 + }, + "text": "recordValue" + }, + "defaultTo": { + "$": "DartRecord", + "positionalFields": [], + "namedFields": { + "a": { + "$": "DartString", + "value": "a", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + }, + "b": { + "$": "DartString", + "value": "b", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + }, + "c": { + "$": "DartString", + "value": "c", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "staticType": { + "symbol": "Record$k7x4l9", + "isNullable": false + } + } + } + ], + "returnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "flattenedReturnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 2887, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 125, + "column": 5 + }, + "end": { + "offset": 2905, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 125, + "column": 23 + }, + "text": "namedDefaultValues" + } + }, + "nullableNamedDefaultValues": { + "name": "nullableNamedDefaultValues", + "apiName": "metadata", + "typeParameters": [], + "parameters": [ + { + "name": "value", + "type": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": true + }, + "required": false, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 3383, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 140, + "column": 10 + }, + "end": { + "offset": 3388, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 140, + "column": 15 + }, + "text": "value" + }, + "defaultTo": { + "$": "DartString", + "value": "value", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + { + "name": "intValue", + "type": { + "$": "TypeReference", + "symbol": "int", + "url": "dart:core", + "isNullable": true + }, + "required": false, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 3407, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 141, + "column": 7 + }, + "end": { + "offset": 3415, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 141, + "column": 15 + }, + "text": "intValue" + }, + "defaultTo": { + "$": "DartInt", + "value": 1, + "staticType": { + "symbol": "int", + "url": "dart:core" + } + } + }, + { + "name": "doubleValue", + "type": { + "$": "TypeReference", + "symbol": "double", + "url": "dart:core", + "isNullable": true + }, + "required": false, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 3431, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 142, + "column": 10 + }, + "end": { + "offset": 3442, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 142, + "column": 21 + }, + "text": "doubleValue" + }, + "defaultTo": { + "$": "DartDouble", + "value": 1.0, + "staticType": { + "symbol": "double", + "url": "dart:core" + } + } + }, + { + "name": "boolValue", + "type": { + "$": "TypeReference", + "symbol": "bool", + "url": "dart:core", + "isNullable": true + }, + "required": false, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 3458, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 143, + "column": 8 + }, + "end": { + "offset": 3467, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 143, + "column": 17 + }, + "text": "boolValue" + }, + "defaultTo": { + "$": "DartBool", + "value": true, + "staticType": { + "symbol": "bool", + "url": "dart:core" + } + } + }, + { + "name": "list", + "type": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": true + }, + "required": false, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 3492, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 144, + "column": 16 + }, + "end": { + "offset": 3496, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 144, + "column": 20 + }, + "text": "list" + }, + "defaultTo": { + "$": "DartList", + "value": [ + { + "$": "DartString", + "value": "list", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + ], + "staticType": { + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + } + } + }, + { + "name": "map", + "type": { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": true + }, + "required": false, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 3538, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 145, + "column": 23 + }, + "end": { + "offset": 3541, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 145, + "column": 26 + }, + "text": "map" + }, + "defaultTo": { + "$": "DartMap", + "value": { + "{\"$\":\"DartString\",\"value\":\"map\",\"staticType\":{\"symbol\":\"String\",\"url\":\"dart:core\"}}": { + "$": "DartString", + "value": "map", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "staticType": { + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + } + } + }, + { + "name": "exportable", + "type": { + "$": "TypeReference", + "symbol": "Exportable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": true + }, + "required": false, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 3580, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 146, + "column": 14 + }, + "end": { + "offset": 3590, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 146, + "column": 24 + }, + "text": "exportable" + }, + "defaultTo": { + "$": "DartInstance", + "classRef": { + "symbol": "Exportable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "Exportable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + } + } + }, + { + "name": "serializable", + "type": { + "$": "TypeReference", + "symbol": "Serializable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": true + }, + "required": false, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 3629, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 147, + "column": 16 + }, + "end": { + "offset": 3641, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 147, + "column": 28 + }, + "text": "serializable" + }, + "defaultTo": { + "$": "DartInstance", + "classRef": { + "symbol": "Serializable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + }, + "constructor": "forType", + "positionalArguments": { + "type": { + "$": "DartString", + "value": "String", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "namedArguments": {}, + "staticType": { + "symbol": "Serializable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + } + } + }, + { + "name": "enumValue", + "type": { + "$": "TypeReference", + "symbol": "LiteralEnum", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": true + }, + "required": false, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 3697, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 148, + "column": 15 + }, + "end": { + "offset": 3706, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 148, + "column": 24 + }, + "text": "enumValue" + }, + "defaultTo": { + "$": "DartEnum", + "enumRef": { + "symbol": "LiteralEnum", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + }, + "value": "a", + "staticType": { + "symbol": "LiteralEnum", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + } + } + }, + { + "name": "recordValue", + "type": { + "$": "RecordType", + "namedFieldTypes": { + "a": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + "b": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + "c": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + }, + "isNullable": true + }, + "required": false, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 3760, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 149, + "column": 36 + }, + "end": { + "offset": 3771, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 149, + "column": 47 + }, + "text": "recordValue" + }, + "defaultTo": { + "$": "DartRecord", + "positionalFields": [], + "namedFields": { + "a": { + "$": "DartString", + "value": "a", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + }, + "b": { + "$": "DartString", + "value": "b", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + }, + "c": { + "$": "DartString", + "value": "c", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "staticType": { + "symbol": "Record$k7x4l9", + "isNullable": false + } + } + } + ], + "returnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "flattenedReturnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 3344, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 139, + "column": 5 + }, + "end": { + "offset": 3370, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 139, + "column": 31 + }, + "text": "nullableNamedDefaultValues" + } + }, + "positionalDefaultValueVars": { + "name": "positionalDefaultValueVars", + "apiName": "metadata", + "typeParameters": [], + "parameters": [ + { + "name": "value", + "type": { + "$": "TypeReference", + "symbol": "int", + "url": "dart:core", + "isNullable": false + }, + "required": false, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 4337, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 168, + "column": 6 + }, + "end": { + "offset": 4342, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 168, + "column": 11 + }, + "text": "value" + }, + "defaultTo": { + "$": "DartInt", + "value": 42, + "staticType": { + "symbol": "int", + "url": "dart:core" + } + } + }, + { + "name": "doubleValue", + "type": { + "$": "TypeReference", + "symbol": "double", + "url": "dart:core", + "isNullable": false + }, + "required": false, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 4366, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 169, + "column": 9 + }, + "end": { + "offset": 4377, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 169, + "column": 20 + }, + "text": "doubleValue" + }, + "defaultTo": { + "$": "DartDouble", + "value": 42.0, + "staticType": { + "symbol": "double", + "url": "dart:core" + } + } + }, + { + "name": "boolValue", + "type": { + "$": "TypeReference", + "symbol": "bool", + "url": "dart:core", + "isNullable": false + }, + "required": false, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 4402, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 170, + "column": 7 + }, + "end": { + "offset": 4411, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 170, + "column": 16 + }, + "text": "boolValue" + }, + "defaultTo": { + "$": "DartBool", + "value": true, + "staticType": { + "symbol": "bool", + "url": "dart:core" + } + } + }, + { + "name": "stringValue", + "type": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + "required": false, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 4436, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 171, + "column": 9 + }, + "end": { + "offset": 4447, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 171, + "column": 20 + }, + "text": "stringValue" + }, + "defaultTo": { + "$": "DartString", + "value": "default", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + { + "name": "listValue", + "type": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + }, + "required": false, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 4480, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 172, + "column": 15 + }, + "end": { + "offset": 4489, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 172, + "column": 24 + }, + "text": "listValue" + }, + "defaultTo": { + "$": "DartList", + "value": [ + { + "$": "DartString", + "value": "default", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + ], + "staticType": { + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + } + } + }, + { + "name": "mapValue", + "type": { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + }, + "required": false, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 4527, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 173, + "column": 22 + }, + "end": { + "offset": 4535, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 173, + "column": 30 + }, + "text": "mapValue" + }, + "defaultTo": { + "$": "DartMap", + "value": { + "{\"$\":\"DartString\",\"value\":\"default\",\"staticType\":{\"symbol\":\"String\",\"url\":\"dart:core\"}}": { + "$": "DartString", + "value": "default", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "staticType": { + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + } + } + }, + { + "name": "enumValue", + "type": { + "$": "TypeReference", + "symbol": "LiteralEnum", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + }, + "required": false, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 4564, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 174, + "column": 14 + }, + "end": { + "offset": 4573, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 174, + "column": 23 + }, + "text": "enumValue" + }, + "defaultTo": { + "$": "DartEnum", + "enumRef": { + "symbol": "LiteralEnum", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + }, + "value": "a", + "staticType": { + "symbol": "LiteralEnum", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + } + } + }, + { + "name": "recordValue", + "type": { + "$": "RecordType", + "namedFieldTypes": { + "a": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + "b": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + "c": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + }, + "isNullable": false + }, + "required": false, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 4624, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 175, + "column": 35 + }, + "end": { + "offset": 4635, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 175, + "column": 46 + }, + "text": "recordValue" + }, + "defaultTo": { + "$": "DartRecord", + "positionalFields": [], + "namedFields": { + "a": { + "$": "DartString", + "value": "a", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + }, + "b": { + "$": "DartString", + "value": "b", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + }, + "c": { + "$": "DartString", + "value": "c", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "staticType": { + "symbol": "Record$k7x4l9", + "isNullable": false + } + } + }, + { + "name": "exportable", + "type": { + "$": "TypeReference", + "symbol": "Exportable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + }, + "required": false, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 4666, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 176, + "column": 13 + }, + "end": { + "offset": 4676, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 176, + "column": 23 + }, + "text": "exportable" + }, + "defaultTo": { + "$": "DartInstance", + "classRef": { + "symbol": "Exportable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "Exportable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + } + } + }, + { + "name": "serializable", + "type": { + "$": "TypeReference", + "symbol": "Serializable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + }, + "required": false, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 4713, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 177, + "column": 15 + }, + "end": { + "offset": 4725, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 177, + "column": 27 + }, + "text": "serializable" + }, + "defaultTo": { + "$": "DartInstance", + "classRef": { + "symbol": "Serializable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + }, + "constructor": "forType", + "positionalArguments": { + "type": { + "$": "DartString", + "value": "String", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "namedArguments": {}, + "staticType": { + "symbol": "Serializable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + } + } + } + ], + "returnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "flattenedReturnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 4302, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 167, + "column": 5 + }, + "end": { + "offset": 4328, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 167, + "column": 31 + }, + "text": "positionalDefaultValueVars" + } + }, + "nullablePositionalDefaultValueVars": { + "name": "nullablePositionalDefaultValueVars", + "apiName": "metadata", + "typeParameters": [], + "parameters": [ + { + "name": "value", + "type": { + "$": "TypeReference", + "symbol": "int", + "url": "dart:core", + "isNullable": true + }, + "required": false, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 4812, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 182, + "column": 7 + }, + "end": { + "offset": 4817, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 182, + "column": 12 + }, + "text": "value" + }, + "defaultTo": { + "$": "DartInt", + "value": 42, + "staticType": { + "symbol": "int", + "url": "dart:core" + } + } + }, + { + "name": "doubleValue", + "type": { + "$": "TypeReference", + "symbol": "double", + "url": "dart:core", + "isNullable": true + }, + "required": false, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 4842, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 183, + "column": 10 + }, + "end": { + "offset": 4853, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 183, + "column": 21 + }, + "text": "doubleValue" + }, + "defaultTo": { + "$": "DartDouble", + "value": 42.0, + "staticType": { + "symbol": "double", + "url": "dart:core" + } + } + }, + { + "name": "boolValue", + "type": { + "$": "TypeReference", + "symbol": "bool", + "url": "dart:core", + "isNullable": true + }, + "required": false, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 4879, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 184, + "column": 8 + }, + "end": { + "offset": 4888, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 184, + "column": 17 + }, + "text": "boolValue" + }, + "defaultTo": { + "$": "DartBool", + "value": true, + "staticType": { + "symbol": "bool", + "url": "dart:core" + } + } + }, + { + "name": "stringValue", + "type": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": true + }, + "required": false, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 4914, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 185, + "column": 10 + }, + "end": { + "offset": 4925, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 185, + "column": 21 + }, + "text": "stringValue" + }, + "defaultTo": { + "$": "DartString", + "value": "default", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + { + "name": "listValue", + "type": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": true + }, + "required": false, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 4959, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 186, + "column": 16 + }, + "end": { + "offset": 4968, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 186, + "column": 25 + }, + "text": "listValue" + }, + "defaultTo": { + "$": "DartList", + "value": [ + { + "$": "DartString", + "value": "default", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + ], + "staticType": { + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + } + } + }, + { + "name": "mapValue", + "type": { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": true + }, + "required": false, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 5007, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 187, + "column": 23 + }, + "end": { + "offset": 5015, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 187, + "column": 31 + }, + "text": "mapValue" + }, + "defaultTo": { + "$": "DartMap", + "value": { + "{\"$\":\"DartString\",\"value\":\"default\",\"staticType\":{\"symbol\":\"String\",\"url\":\"dart:core\"}}": { + "$": "DartString", + "value": "default", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "staticType": { + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + } + } + }, + { + "name": "enumValue", + "type": { + "$": "TypeReference", + "symbol": "LiteralEnum", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": true + }, + "required": false, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 5045, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 188, + "column": 15 + }, + "end": { + "offset": 5054, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 188, + "column": 24 + }, + "text": "enumValue" + }, + "defaultTo": { + "$": "DartEnum", + "enumRef": { + "symbol": "LiteralEnum", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + }, + "value": "a", + "staticType": { + "symbol": "LiteralEnum", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + } + } + }, + { + "name": "recordValue", + "type": { + "$": "RecordType", + "namedFieldTypes": { + "a": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + "b": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + "c": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + }, + "isNullable": true + }, + "required": false, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 5106, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 189, + "column": 36 + }, + "end": { + "offset": 5117, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 189, + "column": 47 + }, + "text": "recordValue" + }, + "defaultTo": { + "$": "DartRecord", + "positionalFields": [], + "namedFields": { + "a": { + "$": "DartString", + "value": "a", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + }, + "b": { + "$": "DartString", + "value": "b", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + }, + "c": { + "$": "DartString", + "value": "c", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "staticType": { + "symbol": "Record$k7x4l9", + "isNullable": false + } + } + }, + { + "name": "exportable", + "type": { + "$": "TypeReference", + "symbol": "Exportable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": true + }, + "required": false, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 5149, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 190, + "column": 14 + }, + "end": { + "offset": 5159, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 190, + "column": 24 + }, + "text": "exportable" + }, + "defaultTo": { + "$": "DartInstance", + "classRef": { + "symbol": "Exportable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "Exportable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + } + } + }, + { + "name": "serializable", + "type": { + "$": "TypeReference", + "symbol": "Serializable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": true + }, + "required": false, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 5197, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 191, + "column": 16 + }, + "end": { + "offset": 5209, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 191, + "column": 28 + }, + "text": "serializable" + }, + "defaultTo": { + "$": "DartInstance", + "classRef": { + "symbol": "Serializable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + }, + "constructor": "forType", + "positionalArguments": { + "type": { + "$": "DartString", + "value": "String", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "namedArguments": {}, + "staticType": { + "symbol": "Serializable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + } + } + } + ], + "returnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "flattenedReturnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 4768, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 181, + "column": 5 + }, + "end": { + "offset": 4802, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 181, + "column": 39 + }, + "text": "nullablePositionalDefaultValueVars" + } + }, + "namedDefaultValueVars": { + "name": "namedDefaultValueVars", + "apiName": "metadata", + "typeParameters": [], + "parameters": [ + { + "name": "value", + "type": { + "$": "TypeReference", + "symbol": "int", + "url": "dart:core", + "isNullable": false + }, + "required": false, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 5282, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 196, + "column": 6 + }, + "end": { + "offset": 5287, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 196, + "column": 11 + }, + "text": "value" + }, + "defaultTo": { + "$": "DartInt", + "value": 42, + "staticType": { + "symbol": "int", + "url": "dart:core" + } + } + }, + { + "name": "doubleValue", + "type": { + "$": "TypeReference", + "symbol": "double", + "url": "dart:core", + "isNullable": false + }, + "required": false, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 5311, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 197, + "column": 9 + }, + "end": { + "offset": 5322, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 197, + "column": 20 + }, + "text": "doubleValue" + }, + "defaultTo": { + "$": "DartDouble", + "value": 42.0, + "staticType": { + "symbol": "double", + "url": "dart:core" + } + } + }, + { + "name": "boolValue", + "type": { + "$": "TypeReference", + "symbol": "bool", + "url": "dart:core", + "isNullable": false + }, + "required": false, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 5347, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 198, + "column": 7 + }, + "end": { + "offset": 5356, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 198, + "column": 16 + }, + "text": "boolValue" + }, + "defaultTo": { + "$": "DartBool", + "value": true, + "staticType": { + "symbol": "bool", + "url": "dart:core" + } + } + }, + { + "name": "stringValue", + "type": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + "required": false, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 5381, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 199, + "column": 9 + }, + "end": { + "offset": 5392, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 199, + "column": 20 + }, + "text": "stringValue" + }, + "defaultTo": { + "$": "DartString", + "value": "default", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + { + "name": "listValue", + "type": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + }, + "required": false, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 5425, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 200, + "column": 15 + }, + "end": { + "offset": 5434, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 200, + "column": 24 + }, + "text": "listValue" + }, + "defaultTo": { + "$": "DartList", + "value": [ + { + "$": "DartString", + "value": "default", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + ], + "staticType": { + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + } + } + }, + { + "name": "mapValue", + "type": { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + }, + "required": false, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 5472, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 201, + "column": 22 + }, + "end": { + "offset": 5480, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 201, + "column": 30 + }, + "text": "mapValue" + }, + "defaultTo": { + "$": "DartMap", + "value": { + "{\"$\":\"DartString\",\"value\":\"default\",\"staticType\":{\"symbol\":\"String\",\"url\":\"dart:core\"}}": { + "$": "DartString", + "value": "default", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "staticType": { + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + } + } + }, + { + "name": "enumValue", + "type": { + "$": "TypeReference", + "symbol": "LiteralEnum", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + }, + "required": false, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 5509, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 202, + "column": 14 + }, + "end": { + "offset": 5518, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 202, + "column": 23 + }, + "text": "enumValue" + }, + "defaultTo": { + "$": "DartEnum", + "enumRef": { + "symbol": "LiteralEnum", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + }, + "value": "a", + "staticType": { + "symbol": "LiteralEnum", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + } + } + }, + { + "name": "recordValue", + "type": { + "$": "RecordType", + "namedFieldTypes": { + "a": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + "b": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + "c": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + }, + "isNullable": false + }, + "required": false, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 5569, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 203, + "column": 35 + }, + "end": { + "offset": 5580, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 203, + "column": 46 + }, + "text": "recordValue" + }, + "defaultTo": { + "$": "DartRecord", + "positionalFields": [], + "namedFields": { + "a": { + "$": "DartString", + "value": "a", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + }, + "b": { + "$": "DartString", + "value": "b", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + }, + "c": { + "$": "DartString", + "value": "c", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "staticType": { + "symbol": "Record$k7x4l9", + "isNullable": false + } + } + }, + { + "name": "exportable", + "type": { + "$": "TypeReference", + "symbol": "Exportable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + }, + "required": false, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 5611, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 204, + "column": 13 + }, + "end": { + "offset": 5621, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 204, + "column": 23 + }, + "text": "exportable" + }, + "defaultTo": { + "$": "DartInstance", + "classRef": { + "symbol": "Exportable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "Exportable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + } + } + }, + { + "name": "serializable", + "type": { + "$": "TypeReference", + "symbol": "Serializable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + }, + "required": false, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 5658, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 205, + "column": 15 + }, + "end": { + "offset": 5670, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 205, + "column": 27 + }, + "text": "serializable" + }, + "defaultTo": { + "$": "DartInstance", + "classRef": { + "symbol": "Serializable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + }, + "constructor": "forType", + "positionalArguments": { + "type": { + "$": "DartString", + "value": "String", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "namedArguments": {}, + "staticType": { + "symbol": "Serializable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + } + } + } + ], + "returnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "flattenedReturnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 5252, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 195, + "column": 5 + }, + "end": { + "offset": 5273, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 195, + "column": 26 + }, + "text": "namedDefaultValueVars" + } + }, + "nullableNamedDefaultValueVars": { + "name": "nullableNamedDefaultValueVars", + "apiName": "metadata", + "typeParameters": [], + "parameters": [ + { + "name": "value", + "type": { + "$": "TypeReference", + "symbol": "int", + "url": "dart:core", + "isNullable": true + }, + "required": false, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 5752, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 210, + "column": 7 + }, + "end": { + "offset": 5757, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 210, + "column": 12 + }, + "text": "value" + }, + "defaultTo": { + "$": "DartInt", + "value": 42, + "staticType": { + "symbol": "int", + "url": "dart:core" + } + } + }, + { + "name": "doubleValue", + "type": { + "$": "TypeReference", + "symbol": "double", + "url": "dart:core", + "isNullable": true + }, + "required": false, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 5782, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 211, + "column": 10 + }, + "end": { + "offset": 5793, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 211, + "column": 21 + }, + "text": "doubleValue" + }, + "defaultTo": { + "$": "DartDouble", + "value": 42.0, + "staticType": { + "symbol": "double", + "url": "dart:core" + } + } + }, + { + "name": "boolValue", + "type": { + "$": "TypeReference", + "symbol": "bool", + "url": "dart:core", + "isNullable": true + }, + "required": false, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 5819, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 212, + "column": 8 + }, + "end": { + "offset": 5828, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 212, + "column": 17 + }, + "text": "boolValue" + }, + "defaultTo": { + "$": "DartBool", + "value": true, + "staticType": { + "symbol": "bool", + "url": "dart:core" + } + } + }, + { + "name": "stringValue", + "type": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": true + }, + "required": false, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 5854, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 213, + "column": 10 + }, + "end": { + "offset": 5865, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 213, + "column": 21 + }, + "text": "stringValue" + }, + "defaultTo": { + "$": "DartString", + "value": "default", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + { + "name": "listValue", + "type": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": true + }, + "required": false, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 5899, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 214, + "column": 16 + }, + "end": { + "offset": 5908, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 214, + "column": 25 + }, + "text": "listValue" + }, + "defaultTo": { + "$": "DartList", + "value": [ + { + "$": "DartString", + "value": "default", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + ], + "staticType": { + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + } + } + }, + { + "name": "mapValue", + "type": { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": true + }, + "required": false, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 5947, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 215, + "column": 23 + }, + "end": { + "offset": 5955, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 215, + "column": 31 + }, + "text": "mapValue" + }, + "defaultTo": { + "$": "DartMap", + "value": { + "{\"$\":\"DartString\",\"value\":\"default\",\"staticType\":{\"symbol\":\"String\",\"url\":\"dart:core\"}}": { + "$": "DartString", + "value": "default", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "staticType": { + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + } + } + }, + { + "name": "enumValue", + "type": { + "$": "TypeReference", + "symbol": "LiteralEnum", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": true + }, + "required": false, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 5985, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 216, + "column": 15 + }, + "end": { + "offset": 5994, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 216, + "column": 24 + }, + "text": "enumValue" + }, + "defaultTo": { + "$": "DartEnum", + "enumRef": { + "symbol": "LiteralEnum", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + }, + "value": "a", + "staticType": { + "symbol": "LiteralEnum", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + } + } + }, + { + "name": "recordValue", + "type": { + "$": "RecordType", + "namedFieldTypes": { + "a": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + "b": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + "c": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + }, + "isNullable": true + }, + "required": false, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 6046, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 217, + "column": 36 + }, + "end": { + "offset": 6057, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 217, + "column": 47 + }, + "text": "recordValue" + }, + "defaultTo": { + "$": "DartRecord", + "positionalFields": [], + "namedFields": { + "a": { + "$": "DartString", + "value": "a", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + }, + "b": { + "$": "DartString", + "value": "b", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + }, + "c": { + "$": "DartString", + "value": "c", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "staticType": { + "symbol": "Record$k7x4l9", + "isNullable": false + } + } + }, + { + "name": "exportable", + "type": { + "$": "TypeReference", + "symbol": "Exportable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": true + }, + "required": false, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 6089, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 218, + "column": 14 + }, + "end": { + "offset": 6099, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 218, + "column": 24 + }, + "text": "exportable" + }, + "defaultTo": { + "$": "DartInstance", + "classRef": { + "symbol": "Exportable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "Exportable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + } + } + }, + { + "name": "serializable", + "type": { + "$": "TypeReference", + "symbol": "Serializable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": true + }, + "required": false, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 6137, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 219, + "column": 16 + }, + "end": { + "offset": 6149, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 219, + "column": 28 + }, + "text": "serializable" + }, + "defaultTo": { + "$": "DartInstance", + "classRef": { + "symbol": "Serializable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + }, + "constructor": "forType", + "positionalArguments": { + "type": { + "$": "DartString", + "value": "String", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "namedArguments": {}, + "staticType": { + "symbol": "Serializable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + } + } + } + ], + "returnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "flattenedReturnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 5713, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 209, + "column": 5 + }, + "end": { + "offset": 5742, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 209, + "column": 34 + }, + "text": "nullableNamedDefaultValueVars" + } + }, + "positionalDefaultValueVarsPrivate": { + "name": "positionalDefaultValueVarsPrivate", + "apiName": "metadata", + "typeParameters": [], + "parameters": [ + { + "name": "value", + "type": { + "$": "TypeReference", + "symbol": "int", + "url": "dart:core", + "isNullable": false + }, + "required": false, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 7035, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 245, + "column": 6 + }, + "end": { + "offset": 7040, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 245, + "column": 11 + }, + "text": "value" + }, + "defaultTo": { + "$": "DartInt", + "value": 42, + "staticType": { + "symbol": "int", + "url": "dart:core" + } + } + }, + { + "name": "doubleValue", + "type": { + "$": "TypeReference", + "symbol": "double", + "url": "dart:core", + "isNullable": false + }, + "required": false, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 7065, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 246, + "column": 9 + }, + "end": { + "offset": 7076, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 246, + "column": 20 + }, + "text": "doubleValue" + }, + "defaultTo": { + "$": "DartDouble", + "value": 42.0, + "staticType": { + "symbol": "double", + "url": "dart:core" + } + } + }, + { + "name": "boolValue", + "type": { + "$": "TypeReference", + "symbol": "bool", + "url": "dart:core", + "isNullable": false + }, + "required": false, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 7102, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 247, + "column": 7 + }, + "end": { + "offset": 7111, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 247, + "column": 16 + }, + "text": "boolValue" + }, + "defaultTo": { + "$": "DartBool", + "value": true, + "staticType": { + "symbol": "bool", + "url": "dart:core" + } + } + }, + { + "name": "stringValue", + "type": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + "required": false, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 7137, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 248, + "column": 9 + }, + "end": { + "offset": 7148, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 248, + "column": 20 + }, + "text": "stringValue" + }, + "defaultTo": { + "$": "DartString", + "value": "default", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + { + "name": "listValue", + "type": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + }, + "required": false, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 7182, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 249, + "column": 15 + }, + "end": { + "offset": 7191, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 249, + "column": 24 + }, + "text": "listValue" + }, + "defaultTo": { + "$": "DartList", + "value": [ + { + "$": "DartString", + "value": "default", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + ], + "staticType": { + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + } + } + }, + { + "name": "mapValue", + "type": { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + }, + "required": false, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 7230, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 250, + "column": 22 + }, + "end": { + "offset": 7238, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 250, + "column": 30 + }, + "text": "mapValue" + }, + "defaultTo": { + "$": "DartMap", + "value": { + "{\"$\":\"DartString\",\"value\":\"default\",\"staticType\":{\"symbol\":\"String\",\"url\":\"dart:core\"}}": { + "$": "DartString", + "value": "default", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "staticType": { + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + } + } + }, + { + "name": "enumValue", + "type": { + "$": "TypeReference", + "symbol": "LiteralEnum", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + }, + "required": false, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 7268, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 251, + "column": 14 + }, + "end": { + "offset": 7277, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 251, + "column": 23 + }, + "text": "enumValue" + }, + "defaultTo": { + "$": "DartEnum", + "enumRef": { + "symbol": "LiteralEnum", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + }, + "value": "a", + "staticType": { + "symbol": "LiteralEnum", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + } + } + }, + { + "name": "recordValue", + "type": { + "$": "RecordType", + "namedFieldTypes": { + "a": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + "b": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + "c": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + }, + "isNullable": false + }, + "required": false, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 7329, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 252, + "column": 35 + }, + "end": { + "offset": 7340, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 252, + "column": 46 + }, + "text": "recordValue" + }, + "defaultTo": { + "$": "DartRecord", + "positionalFields": [], + "namedFields": { + "a": { + "$": "DartString", + "value": "a", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + }, + "b": { + "$": "DartString", + "value": "b", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + }, + "c": { + "$": "DartString", + "value": "c", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "staticType": { + "symbol": "Record$k7x4l9", + "isNullable": false + } + } + }, + { + "name": "exportable", + "type": { + "$": "TypeReference", + "symbol": "Exportable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + }, + "required": false, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 7372, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 253, + "column": 13 + }, + "end": { + "offset": 7382, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 253, + "column": 23 + }, + "text": "exportable" + }, + "defaultTo": { + "$": "DartInstance", + "classRef": { + "symbol": "Exportable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "Exportable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + } + } + }, + { + "name": "serializable", + "type": { + "$": "TypeReference", + "symbol": "Serializable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + }, + "required": false, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 7420, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 254, + "column": 15 + }, + "end": { + "offset": 7432, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 254, + "column": 27 + }, + "text": "serializable" + }, + "defaultTo": { + "$": "DartInstance", + "classRef": { + "symbol": "Serializable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + }, + "constructor": "forType", + "positionalArguments": { + "type": { + "$": "DartString", + "value": "String", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "namedArguments": {}, + "staticType": { + "symbol": "Serializable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + } + } + } + ], + "returnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "flattenedReturnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 6993, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 244, + "column": 5 + }, + "end": { + "offset": 7026, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 244, + "column": 38 + }, + "text": "positionalDefaultValueVarsPrivate" + } + }, + "nullablePositionalDefaultValueVarsPrivate": { + "name": "nullablePositionalDefaultValueVarsPrivate", + "apiName": "metadata", + "typeParameters": [], + "parameters": [ + { + "name": "value", + "type": { + "$": "TypeReference", + "symbol": "int", + "url": "dart:core", + "isNullable": true + }, + "required": false, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 7527, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 259, + "column": 7 + }, + "end": { + "offset": 7532, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 259, + "column": 12 + }, + "text": "value" + }, + "defaultTo": { + "$": "DartInt", + "value": 42, + "staticType": { + "symbol": "int", + "url": "dart:core" + } + } + }, + { + "name": "doubleValue", + "type": { + "$": "TypeReference", + "symbol": "double", + "url": "dart:core", + "isNullable": true + }, + "required": false, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 7558, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 260, + "column": 10 + }, + "end": { + "offset": 7569, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 260, + "column": 21 + }, + "text": "doubleValue" + }, + "defaultTo": { + "$": "DartDouble", + "value": 42.0, + "staticType": { + "symbol": "double", + "url": "dart:core" + } + } + }, + { + "name": "boolValue", + "type": { + "$": "TypeReference", + "symbol": "bool", + "url": "dart:core", + "isNullable": true + }, + "required": false, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 7596, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 261, + "column": 8 + }, + "end": { + "offset": 7605, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 261, + "column": 17 + }, + "text": "boolValue" + }, + "defaultTo": { + "$": "DartBool", + "value": true, + "staticType": { + "symbol": "bool", + "url": "dart:core" + } + } + }, + { + "name": "stringValue", + "type": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": true + }, + "required": false, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 7632, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 262, + "column": 10 + }, + "end": { + "offset": 7643, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 262, + "column": 21 + }, + "text": "stringValue" + }, + "defaultTo": { + "$": "DartString", + "value": "default", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + { + "name": "listValue", + "type": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": true + }, + "required": false, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 7678, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 263, + "column": 16 + }, + "end": { + "offset": 7687, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 263, + "column": 25 + }, + "text": "listValue" + }, + "defaultTo": { + "$": "DartList", + "value": [ + { + "$": "DartString", + "value": "default", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + ], + "staticType": { + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + } + } + }, + { + "name": "mapValue", + "type": { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": true + }, + "required": false, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 7727, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 264, + "column": 23 + }, + "end": { + "offset": 7735, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 264, + "column": 31 + }, + "text": "mapValue" + }, + "defaultTo": { + "$": "DartMap", + "value": { + "{\"$\":\"DartString\",\"value\":\"default\",\"staticType\":{\"symbol\":\"String\",\"url\":\"dart:core\"}}": { + "$": "DartString", + "value": "default", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "staticType": { + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + } + } + }, + { + "name": "enumValue", + "type": { + "$": "TypeReference", + "symbol": "LiteralEnum", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": true + }, + "required": false, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 7766, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 265, + "column": 15 + }, + "end": { + "offset": 7775, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 265, + "column": 24 + }, + "text": "enumValue" + }, + "defaultTo": { + "$": "DartEnum", + "enumRef": { + "symbol": "LiteralEnum", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + }, + "value": "a", + "staticType": { + "symbol": "LiteralEnum", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + } + } + }, + { + "name": "recordValue", + "type": { + "$": "RecordType", + "namedFieldTypes": { + "a": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + "b": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + "c": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + }, + "isNullable": true + }, + "required": false, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 7828, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 266, + "column": 36 + }, + "end": { + "offset": 7839, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 266, + "column": 47 + }, + "text": "recordValue" + }, + "defaultTo": { + "$": "DartRecord", + "positionalFields": [], + "namedFields": { + "a": { + "$": "DartString", + "value": "a", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + }, + "b": { + "$": "DartString", + "value": "b", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + }, + "c": { + "$": "DartString", + "value": "c", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "staticType": { + "symbol": "Record$k7x4l9", + "isNullable": false + } + } + }, + { + "name": "exportable", + "type": { + "$": "TypeReference", + "symbol": "Exportable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": true + }, + "required": false, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 7872, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 267, + "column": 14 + }, + "end": { + "offset": 7882, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 267, + "column": 24 + }, + "text": "exportable" + }, + "defaultTo": { + "$": "DartInstance", + "classRef": { + "symbol": "Exportable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "Exportable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + } + } + }, + { + "name": "serializable", + "type": { + "$": "TypeReference", + "symbol": "Serializable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": true + }, + "required": false, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 7921, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 268, + "column": 16 + }, + "end": { + "offset": 7933, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 268, + "column": 28 + }, + "text": "serializable" + }, + "defaultTo": { + "$": "DartInstance", + "classRef": { + "symbol": "Serializable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + }, + "constructor": "forType", + "positionalArguments": { + "type": { + "$": "DartString", + "value": "String", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "namedArguments": {}, + "staticType": { + "symbol": "Serializable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + } + } + } + ], + "returnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "flattenedReturnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 7476, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 258, + "column": 5 + }, + "end": { + "offset": 7517, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 258, + "column": 46 + }, + "text": "nullablePositionalDefaultValueVarsPrivate" + } + }, + "namedDefaultValueVarsPrivate": { + "name": "namedDefaultValueVarsPrivate", + "apiName": "metadata", + "typeParameters": [], + "parameters": [ + { + "name": "value", + "type": { + "$": "TypeReference", + "symbol": "int", + "url": "dart:core", + "isNullable": false + }, + "required": false, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 8014, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 273, + "column": 6 + }, + "end": { + "offset": 8019, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 273, + "column": 11 + }, + "text": "value" + }, + "defaultTo": { + "$": "DartInt", + "value": 42, + "staticType": { + "symbol": "int", + "url": "dart:core" + } + } + }, + { + "name": "doubleValue", + "type": { + "$": "TypeReference", + "symbol": "double", + "url": "dart:core", + "isNullable": false + }, + "required": false, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 8044, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 274, + "column": 9 + }, + "end": { + "offset": 8055, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 274, + "column": 20 + }, + "text": "doubleValue" + }, + "defaultTo": { + "$": "DartDouble", + "value": 42.0, + "staticType": { + "symbol": "double", + "url": "dart:core" + } + } + }, + { + "name": "boolValue", + "type": { + "$": "TypeReference", + "symbol": "bool", + "url": "dart:core", + "isNullable": false + }, + "required": false, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 8081, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 275, + "column": 7 + }, + "end": { + "offset": 8090, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 275, + "column": 16 + }, + "text": "boolValue" + }, + "defaultTo": { + "$": "DartBool", + "value": true, + "staticType": { + "symbol": "bool", + "url": "dart:core" + } + } + }, + { + "name": "stringValue", + "type": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + "required": false, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 8116, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 276, + "column": 9 + }, + "end": { + "offset": 8127, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 276, + "column": 20 + }, + "text": "stringValue" + }, + "defaultTo": { + "$": "DartString", + "value": "default", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + { + "name": "listValue", + "type": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + }, + "required": false, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 8161, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 277, + "column": 15 + }, + "end": { + "offset": 8170, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 277, + "column": 24 + }, + "text": "listValue" + }, + "defaultTo": { + "$": "DartList", + "value": [ + { + "$": "DartString", + "value": "default", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + ], + "staticType": { + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + } + } + }, + { + "name": "mapValue", + "type": { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + }, + "required": false, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 8209, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 278, + "column": 22 + }, + "end": { + "offset": 8217, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 278, + "column": 30 + }, + "text": "mapValue" + }, + "defaultTo": { + "$": "DartMap", + "value": { + "{\"$\":\"DartString\",\"value\":\"default\",\"staticType\":{\"symbol\":\"String\",\"url\":\"dart:core\"}}": { + "$": "DartString", + "value": "default", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "staticType": { + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + } + } + }, + { + "name": "enumValue", + "type": { + "$": "TypeReference", + "symbol": "LiteralEnum", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + }, + "required": false, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 8247, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 279, + "column": 14 + }, + "end": { + "offset": 8256, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 279, + "column": 23 + }, + "text": "enumValue" + }, + "defaultTo": { + "$": "DartEnum", + "enumRef": { + "symbol": "LiteralEnum", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + }, + "value": "a", + "staticType": { + "symbol": "LiteralEnum", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + } + } + }, + { + "name": "recordValue", + "type": { + "$": "RecordType", + "namedFieldTypes": { + "a": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + "b": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + "c": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + }, + "isNullable": false + }, + "required": false, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 8308, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 280, + "column": 35 + }, + "end": { + "offset": 8319, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 280, + "column": 46 + }, + "text": "recordValue" + }, + "defaultTo": { + "$": "DartRecord", + "positionalFields": [], + "namedFields": { + "a": { + "$": "DartString", + "value": "a", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + }, + "b": { + "$": "DartString", + "value": "b", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + }, + "c": { + "$": "DartString", + "value": "c", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "staticType": { + "symbol": "Record$k7x4l9", + "isNullable": false + } + } + }, + { + "name": "exportable", + "type": { + "$": "TypeReference", + "symbol": "Exportable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + }, + "required": false, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 8351, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 281, + "column": 13 + }, + "end": { + "offset": 8361, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 281, + "column": 23 + }, + "text": "exportable" + }, + "defaultTo": { + "$": "DartInstance", + "classRef": { + "symbol": "Exportable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "Exportable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + } + } + }, + { + "name": "serializable", + "type": { + "$": "TypeReference", + "symbol": "Serializable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + }, + "required": false, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 8399, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 282, + "column": 15 + }, + "end": { + "offset": 8411, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 282, + "column": 27 + }, + "text": "serializable" + }, + "defaultTo": { + "$": "DartInstance", + "classRef": { + "symbol": "Serializable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + }, + "constructor": "forType", + "positionalArguments": { + "type": { + "$": "DartString", + "value": "String", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "namedArguments": {}, + "staticType": { + "symbol": "Serializable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + } + } + } + ], + "returnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "flattenedReturnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 7977, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 272, + "column": 5 + }, + "end": { + "offset": 8005, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 272, + "column": 33 + }, + "text": "namedDefaultValueVarsPrivate" + } + }, + "nullableNamedDefaultValueVarsPrivate": { + "name": "nullableNamedDefaultValueVarsPrivate", + "apiName": "metadata", + "typeParameters": [], + "parameters": [ + { + "name": "value", + "type": { + "$": "TypeReference", + "symbol": "int", + "url": "dart:core", + "isNullable": true + }, + "required": false, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 8501, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 287, + "column": 7 + }, + "end": { + "offset": 8506, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 287, + "column": 12 + }, + "text": "value" + }, + "defaultTo": { + "$": "DartInt", + "value": 42, + "staticType": { + "symbol": "int", + "url": "dart:core" + } + } + }, + { + "name": "doubleValue", + "type": { + "$": "TypeReference", + "symbol": "double", + "url": "dart:core", + "isNullable": true + }, + "required": false, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 8532, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 288, + "column": 10 + }, + "end": { + "offset": 8543, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 288, + "column": 21 + }, + "text": "doubleValue" + }, + "defaultTo": { + "$": "DartDouble", + "value": 42.0, + "staticType": { + "symbol": "double", + "url": "dart:core" + } + } + }, + { + "name": "boolValue", + "type": { + "$": "TypeReference", + "symbol": "bool", + "url": "dart:core", + "isNullable": true + }, + "required": false, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 8570, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 289, + "column": 8 + }, + "end": { + "offset": 8579, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 289, + "column": 17 + }, + "text": "boolValue" + }, + "defaultTo": { + "$": "DartBool", + "value": true, + "staticType": { + "symbol": "bool", + "url": "dart:core" + } + } + }, + { + "name": "stringValue", + "type": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": true + }, + "required": false, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 8606, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 290, + "column": 10 + }, + "end": { + "offset": 8617, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 290, + "column": 21 + }, + "text": "stringValue" + }, + "defaultTo": { + "$": "DartString", + "value": "default", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + { + "name": "listValue", + "type": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": true + }, + "required": false, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 8652, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 291, + "column": 16 + }, + "end": { + "offset": 8661, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 291, + "column": 25 + }, + "text": "listValue" + }, + "defaultTo": { + "$": "DartList", + "value": [ + { + "$": "DartString", + "value": "default", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + ], + "staticType": { + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + } + } + }, + { + "name": "mapValue", + "type": { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": true + }, + "required": false, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 8701, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 292, + "column": 23 + }, + "end": { + "offset": 8709, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 292, + "column": 31 + }, + "text": "mapValue" + }, + "defaultTo": { + "$": "DartMap", + "value": { + "{\"$\":\"DartString\",\"value\":\"default\",\"staticType\":{\"symbol\":\"String\",\"url\":\"dart:core\"}}": { + "$": "DartString", + "value": "default", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "staticType": { + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + } + } + }, + { + "name": "enumValue", + "type": { + "$": "TypeReference", + "symbol": "LiteralEnum", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": true + }, + "required": false, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 8740, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 293, + "column": 15 + }, + "end": { + "offset": 8749, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 293, + "column": 24 + }, + "text": "enumValue" + }, + "defaultTo": { + "$": "DartEnum", + "enumRef": { + "symbol": "LiteralEnum", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + }, + "value": "a", + "staticType": { + "symbol": "LiteralEnum", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + } + } + }, + { + "name": "recordValue", + "type": { + "$": "RecordType", + "namedFieldTypes": { + "a": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + "b": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + "c": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + }, + "isNullable": true + }, + "required": false, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 8802, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 294, + "column": 36 + }, + "end": { + "offset": 8813, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 294, + "column": 47 + }, + "text": "recordValue" + }, + "defaultTo": { + "$": "DartRecord", + "positionalFields": [], + "namedFields": { + "a": { + "$": "DartString", + "value": "a", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + }, + "b": { + "$": "DartString", + "value": "b", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + }, + "c": { + "$": "DartString", + "value": "c", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "staticType": { + "symbol": "Record$k7x4l9", + "isNullable": false + } + } + }, + { + "name": "exportable", + "type": { + "$": "TypeReference", + "symbol": "Exportable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": true + }, + "required": false, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 8846, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 295, + "column": 14 + }, + "end": { + "offset": 8856, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 295, + "column": 24 + }, + "text": "exportable" + }, + "defaultTo": { + "$": "DartInstance", + "classRef": { + "symbol": "Exportable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "Exportable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + } + } + }, + { + "name": "serializable", + "type": { + "$": "TypeReference", + "symbol": "Serializable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": true + }, + "required": false, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 8895, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 296, + "column": 16 + }, + "end": { + "offset": 8907, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 296, + "column": 28 + }, + "text": "serializable" + }, + "defaultTo": { + "$": "DartInstance", + "classRef": { + "symbol": "Serializable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + }, + "constructor": "forType", + "positionalArguments": { + "type": { + "$": "DartString", + "value": "String", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "namedArguments": {}, + "staticType": { + "symbol": "Serializable", + "url": "package:celest_backend/models/metadata.dart", + "isNullable": false + } + } + } + ], + "returnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "flattenedReturnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 8455, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 286, + "column": 5 + }, + "end": { + "offset": 8491, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 286, + "column": 41 + }, + "text": "nullableNamedDefaultValueVarsPrivate" + } + } + }, + "docs": [ + "/// Tests that metadata associated with functions and parameters are correctly", + "/// parsed and transferred to the generated client." + ], + "exceptionTypes": [ + { + "$": "TypeReference", + "symbol": "CloudException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "CancelledException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnknownError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "BadRequestException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnauthorizedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "NotFoundException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AlreadyExistsException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "PermissionDeniedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ResourceExhaustedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "FailedPreconditionException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AbortedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "OutOfRangeException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnimplementedError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "InternalServerError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnavailableError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "DataLossError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "DeadlineExceededError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "SerializationException", + "url": "package:celest_core/src/exception/serialization_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "Error", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AssertionError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "TypeError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ArgumentError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "RangeError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "IndexError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnsupportedError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnimplementedError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "StateError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ConcurrentModificationError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "OutOfMemoryError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "StackOverflowError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "Exception", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "FormatException", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "IntegerDivisionByZeroException", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AsyncError", + "url": "dart:async", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "TimeoutException", + "url": "dart:async", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "JsonUnsupportedObjectError", + "url": "dart:convert", + "isNullable": false + } + ], + "location": { + "start": { + "offset": 0, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 0, + "column": 0 + }, + "end": { + "offset": 0, + "uri": "package:celest_backend/src/functions/metadata.dart", + "line": 0, + "column": 0 + }, + "text": "" + } + }, + "parameters": { + "name": "parameters", + "metadata": [], + "functions": { + "optionalPositional": { + "name": "optionalPositional", + "apiName": "parameters", + "typeParameters": [], + "parameters": [ + { + "name": "optionalString", + "type": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": true + }, + "required": false, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 89, + "uri": "package:celest_backend/src/functions/parameters.dart", + "line": 4, + "column": 10 + }, + "end": { + "offset": 103, + "uri": "package:celest_backend/src/functions/parameters.dart", + "line": 4, + "column": 24 + }, + "text": "optionalString" + }, + "defaultTo": { + "$": "DartNull", + "staticType": { + "symbol": "Null", + "url": "dart:core" + } + } + }, + { + "name": "optionalInt", + "type": { + "$": "TypeReference", + "symbol": "int", + "url": "dart:core", + "isNullable": true + }, + "required": false, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 112, + "uri": "package:celest_backend/src/functions/parameters.dart", + "line": 5, + "column": 7 + }, + "end": { + "offset": 123, + "uri": "package:celest_backend/src/functions/parameters.dart", + "line": 5, + "column": 18 + }, + "text": "optionalInt" + }, + "defaultTo": { + "$": "DartNull", + "staticType": { + "symbol": "Null", + "url": "dart:core" + } + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "Future", + "url": "dart:async", + "types": [ + { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 58, + "uri": "package:celest_backend/src/functions/parameters.dart", + "line": 3, + "column": 13 + }, + "end": { + "offset": 76, + "uri": "package:celest_backend/src/functions/parameters.dart", + "line": 3, + "column": 31 + }, + "text": "optionalPositional" + } + }, + "optionalNamed": { + "name": "optionalNamed", + "apiName": "parameters", + "typeParameters": [], + "parameters": [ + { + "name": "namedString", + "type": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": true + }, + "required": false, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 184, + "uri": "package:celest_backend/src/functions/parameters.dart", + "line": 10, + "column": 10 + }, + "end": { + "offset": 195, + "uri": "package:celest_backend/src/functions/parameters.dart", + "line": 10, + "column": 21 + }, + "text": "namedString" + }, + "defaultTo": { + "$": "DartNull", + "staticType": { + "symbol": "Null", + "url": "dart:core" + } + } + }, + { + "name": "namedInt", + "type": { + "$": "TypeReference", + "symbol": "int", + "url": "dart:core", + "isNullable": true + }, + "required": false, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 204, + "uri": "package:celest_backend/src/functions/parameters.dart", + "line": 11, + "column": 7 + }, + "end": { + "offset": 212, + "uri": "package:celest_backend/src/functions/parameters.dart", + "line": 11, + "column": 15 + }, + "text": "namedInt" + }, + "defaultTo": { + "$": "DartNull", + "staticType": { + "symbol": "Null", + "url": "dart:core" + } + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "Future", + "url": "dart:async", + "types": [ + { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 158, + "uri": "package:celest_backend/src/functions/parameters.dart", + "line": 9, + "column": 13 + }, + "end": { + "offset": 171, + "uri": "package:celest_backend/src/functions/parameters.dart", + "line": 9, + "column": 26 + }, + "text": "optionalNamed" + } + }, + "requiredPositional": { + "name": "requiredPositional", + "apiName": "parameters", + "typeParameters": [], + "parameters": [ + { + "name": "requiredString", + "type": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 276, + "uri": "package:celest_backend/src/functions/parameters.dart", + "line": 16, + "column": 9 + }, + "end": { + "offset": 290, + "uri": "package:celest_backend/src/functions/parameters.dart", + "line": 16, + "column": 23 + }, + "text": "requiredString" + } + }, + { + "name": "requiredInt", + "type": { + "$": "TypeReference", + "symbol": "int", + "url": "dart:core", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 298, + "uri": "package:celest_backend/src/functions/parameters.dart", + "line": 17, + "column": 6 + }, + "end": { + "offset": 309, + "uri": "package:celest_backend/src/functions/parameters.dart", + "line": 17, + "column": 17 + }, + "text": "requiredInt" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "Future", + "url": "dart:async", + "types": [ + { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 247, + "uri": "package:celest_backend/src/functions/parameters.dart", + "line": 15, + "column": 13 + }, + "end": { + "offset": 265, + "uri": "package:celest_backend/src/functions/parameters.dart", + "line": 15, + "column": 31 + }, + "text": "requiredPositional" + } + }, + "requiredNamed": { + "name": "requiredNamed", + "apiName": "parameters", + "typeParameters": [], + "parameters": [ + { + "name": "requiredString", + "type": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + "required": true, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 377, + "uri": "package:celest_backend/src/functions/parameters.dart", + "line": 22, + "column": 18 + }, + "end": { + "offset": 391, + "uri": "package:celest_backend/src/functions/parameters.dart", + "line": 22, + "column": 32 + }, + "text": "requiredString" + } + }, + { + "name": "requiredInt", + "type": { + "$": "TypeReference", + "symbol": "int", + "url": "dart:core", + "isNullable": false + }, + "required": true, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 408, + "uri": "package:celest_backend/src/functions/parameters.dart", + "line": 23, + "column": 15 + }, + "end": { + "offset": 419, + "uri": "package:celest_backend/src/functions/parameters.dart", + "line": 23, + "column": 26 + }, + "text": "requiredInt" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "Future", + "url": "dart:async", + "types": [ + { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 343, + "uri": "package:celest_backend/src/functions/parameters.dart", + "line": 21, + "column": 13 + }, + "end": { + "offset": 356, + "uri": "package:celest_backend/src/functions/parameters.dart", + "line": 21, + "column": 26 + }, + "text": "requiredNamed" + } + } + }, + "docs": [], + "exceptionTypes": [ + { + "$": "TypeReference", + "symbol": "CloudException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "CancelledException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnknownError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "BadRequestException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnauthorizedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "NotFoundException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AlreadyExistsException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "PermissionDeniedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ResourceExhaustedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "FailedPreconditionException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AbortedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "OutOfRangeException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnimplementedError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "InternalServerError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnavailableError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "DataLossError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "DeadlineExceededError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "SerializationException", + "url": "package:celest_core/src/exception/serialization_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "Error", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AssertionError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "TypeError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ArgumentError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "RangeError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "IndexError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnsupportedError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnimplementedError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "StateError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ConcurrentModificationError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "OutOfMemoryError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "StackOverflowError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "Exception", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "FormatException", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "IntegerDivisionByZeroException", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AsyncError", + "url": "dart:async", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "TimeoutException", + "url": "dart:async", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "JsonUnsupportedObjectError", + "url": "dart:convert", + "isNullable": false + } + ], + "location": { + "start": { + "offset": 0, + "uri": "package:celest_backend/src/functions/parameters.dart", + "line": 0, + "column": 0 + }, + "end": { + "offset": 0, + "uri": "package:celest_backend/src/functions/parameters.dart", + "line": 0, + "column": 0 + }, + "text": "" + } + }, + "collections": { + "name": "collections", + "metadata": [], + "functions": { + "simpleList": { + "name": "simpleList", + "apiName": "collections", + "typeParameters": [], + "parameters": [ + { + "name": "list", + "type": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 253, + "uri": "package:celest_backend/src/functions/collections.dart", + "line": 8, + "column": 45 + }, + "end": { + "offset": 257, + "uri": "package:celest_backend/src/functions/collections.dart", + "line": 8, + "column": 49 + }, + "text": "list" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "Future", + "url": "dart:async", + "types": [ + { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 229, + "uri": "package:celest_backend/src/functions/collections.dart", + "line": 8, + "column": 21 + }, + "end": { + "offset": 239, + "uri": "package:celest_backend/src/functions/collections.dart", + "line": 8, + "column": 31 + }, + "text": "simpleList" + } + }, + "complexList": { + "name": "complexList", + "apiName": "collections", + "typeParameters": [], + "parameters": [ + { + "name": "list", + "type": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "SimpleClass", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": false + } + ], + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 337, + "uri": "package:celest_backend/src/functions/collections.dart", + "line": 10, + "column": 56 + }, + "end": { + "offset": 341, + "uri": "package:celest_backend/src/functions/collections.dart", + "line": 10, + "column": 60 + }, + "text": "list" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "Future", + "url": "dart:async", + "types": [ + { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "SimpleClass", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": false + } + ], + "isNullable": false + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "SimpleClass", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": false + } + ], + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 307, + "uri": "package:celest_backend/src/functions/collections.dart", + "line": 10, + "column": 26 + }, + "end": { + "offset": 318, + "uri": "package:celest_backend/src/functions/collections.dart", + "line": 10, + "column": 37 + }, + "text": "complexList" + } + }, + "simpleMap": { + "name": "simpleMap", + "apiName": "collections", + "typeParameters": [], + "parameters": [ + { + "name": "map", + "type": { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 424, + "uri": "package:celest_backend/src/functions/collections.dart", + "line": 13, + "column": 58 + }, + "end": { + "offset": 427, + "uri": "package:celest_backend/src/functions/collections.dart", + "line": 13, + "column": 61 + }, + "text": "map" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "Future", + "url": "dart:async", + "types": [ + { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 394, + "uri": "package:celest_backend/src/functions/collections.dart", + "line": 13, + "column": 28 + }, + "end": { + "offset": 403, + "uri": "package:celest_backend/src/functions/collections.dart", + "line": 13, + "column": 37 + }, + "text": "simpleMap" + } + }, + "dynamicMap": { + "name": "dynamicMap", + "apiName": "collections", + "typeParameters": [], + "parameters": [ + { + "name": "map", + "type": { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "Reference", + "symbol": "dynamic", + "url": "dart:core" + } + ], + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 511, + "uri": "package:celest_backend/src/functions/collections.dart", + "line": 15, + "column": 61 + }, + "end": { + "offset": 514, + "uri": "package:celest_backend/src/functions/collections.dart", + "line": 15, + "column": 64 + }, + "text": "map" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "Future", + "url": "dart:async", + "types": [ + { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "Reference", + "symbol": "dynamic", + "url": "dart:core" + } + ], + "isNullable": false + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "Reference", + "symbol": "dynamic", + "url": "dart:core" + } + ], + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 479, + "uri": "package:celest_backend/src/functions/collections.dart", + "line": 15, + "column": 29 + }, + "end": { + "offset": 489, + "uri": "package:celest_backend/src/functions/collections.dart", + "line": 15, + "column": 39 + }, + "text": "dynamicMap" + } + }, + "objectMap": { + "name": "objectMap", + "apiName": "collections", + "typeParameters": [], + "parameters": [ + { + "name": "map", + "type": { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "Object", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 595, + "uri": "package:celest_backend/src/functions/collections.dart", + "line": 17, + "column": 58 + }, + "end": { + "offset": 598, + "uri": "package:celest_backend/src/functions/collections.dart", + "line": 17, + "column": 61 + }, + "text": "map" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "Future", + "url": "dart:async", + "types": [ + { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "Object", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "Object", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 565, + "uri": "package:celest_backend/src/functions/collections.dart", + "line": 17, + "column": 28 + }, + "end": { + "offset": 574, + "uri": "package:celest_backend/src/functions/collections.dart", + "line": 17, + "column": 37 + }, + "text": "objectMap" + } + }, + "objectNullableMap": { + "name": "objectNullableMap", + "apiName": "collections", + "typeParameters": [], + "parameters": [ + { + "name": "map", + "type": { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "Object", + "url": "dart:core", + "isNullable": true + } + ], + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 692, + "uri": "package:celest_backend/src/functions/collections.dart", + "line": 20, + "column": 23 + }, + "end": { + "offset": 695, + "uri": "package:celest_backend/src/functions/collections.dart", + "line": 20, + "column": 26 + }, + "text": "map" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "Future", + "url": "dart:async", + "types": [ + { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "Object", + "url": "dart:core", + "isNullable": true + } + ], + "isNullable": false + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "Object", + "url": "dart:core", + "isNullable": true + } + ], + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 650, + "uri": "package:celest_backend/src/functions/collections.dart", + "line": 19, + "column": 29 + }, + "end": { + "offset": 667, + "uri": "package:celest_backend/src/functions/collections.dart", + "line": 19, + "column": 46 + }, + "text": "objectNullableMap" + } + }, + "complexMap": { + "name": "complexMap", + "apiName": "collections", + "typeParameters": [], + "parameters": [ + { + "name": "map", + "type": { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "SimpleClass", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": false + } + ], + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 796, + "uri": "package:celest_backend/src/functions/collections.dart", + "line": 25, + "column": 27 + }, + "end": { + "offset": 799, + "uri": "package:celest_backend/src/functions/collections.dart", + "line": 25, + "column": 30 + }, + "text": "map" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "Future", + "url": "dart:async", + "types": [ + { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "SimpleClass", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": false + } + ], + "isNullable": false + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "Map", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "SimpleClass", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": false + } + ], + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 757, + "uri": "package:celest_backend/src/functions/collections.dart", + "line": 24, + "column": 33 + }, + "end": { + "offset": 767, + "uri": "package:celest_backend/src/functions/collections.dart", + "line": 24, + "column": 43 + }, + "text": "complexMap" + } + } + }, + "docs": [ + "/// Tests that collections (e.g. Lists/Maps) can be used as parameter and", + "/// return types." + ], + "exceptionTypes": [ + { + "$": "TypeReference", + "symbol": "CloudException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "CancelledException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnknownError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "BadRequestException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnauthorizedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "NotFoundException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AlreadyExistsException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "PermissionDeniedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ResourceExhaustedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "FailedPreconditionException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AbortedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "OutOfRangeException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnimplementedError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "InternalServerError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnavailableError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "DataLossError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "DeadlineExceededError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "SerializationException", + "url": "package:celest_core/src/exception/serialization_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "Error", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AssertionError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "TypeError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ArgumentError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "RangeError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "IndexError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnsupportedError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnimplementedError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "StateError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ConcurrentModificationError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "OutOfMemoryError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "StackOverflowError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "Exception", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "FormatException", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "IntegerDivisionByZeroException", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AsyncError", + "url": "dart:async", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "TimeoutException", + "url": "dart:async", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "JsonUnsupportedObjectError", + "url": "dart:convert", + "isNullable": false + } + ], + "location": { + "start": { + "offset": 0, + "uri": "package:celest_backend/src/functions/collections.dart", + "line": 0, + "column": 0 + }, + "end": { + "offset": 0, + "uri": "package:celest_backend/src/functions/collections.dart", + "line": 0, + "column": 0 + }, + "text": "" + } + }, + "generic_wrappers": { + "name": "generic_wrappers", + "metadata": [], + "functions": { + "genericWrappers": { + "name": "genericWrappers", + "apiName": "generic_wrappers", + "typeParameters": [], + "parameters": [ + { + "name": "value", + "type": { + "$": "TypeReference", + "symbol": "GenericWrappers", + "url": "package:celest_backend/models/generic_wrappers.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 588, + "uri": "package:celest_backend/src/functions/generic_wrappers.dart", + "line": 12, + "column": 48 + }, + "end": { + "offset": 593, + "uri": "package:celest_backend/src/functions/generic_wrappers.dart", + "line": 12, + "column": 53 + }, + "text": "value" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "GenericWrappers", + "url": "package:celest_backend/models/generic_wrappers.dart", + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "GenericWrappers", + "url": "package:celest_backend/models/generic_wrappers.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 556, + "uri": "package:celest_backend/src/functions/generic_wrappers.dart", + "line": 12, + "column": 16 + }, + "end": { + "offset": 571, + "uri": "package:celest_backend/src/functions/generic_wrappers.dart", + "line": 12, + "column": 31 + }, + "text": "genericWrappers" + } + }, + "genericWrappersAsync": { + "name": "genericWrappersAsync", + "apiName": "generic_wrappers", + "typeParameters": [], + "parameters": [ + { + "name": "value", + "type": { + "$": "TypeReference", + "symbol": "GenericWrappers", + "url": "package:celest_backend/models/generic_wrappers.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 673, + "uri": "package:celest_backend/src/functions/generic_wrappers.dart", + "line": 14, + "column": 61 + }, + "end": { + "offset": 678, + "uri": "package:celest_backend/src/functions/generic_wrappers.dart", + "line": 14, + "column": 66 + }, + "text": "value" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "Future", + "url": "dart:async", + "types": [ + { + "$": "TypeReference", + "symbol": "GenericWrappers", + "url": "package:celest_backend/models/generic_wrappers.dart", + "isNullable": false + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "GenericWrappers", + "url": "package:celest_backend/models/generic_wrappers.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 636, + "uri": "package:celest_backend/src/functions/generic_wrappers.dart", + "line": 14, + "column": 24 + }, + "end": { + "offset": 656, + "uri": "package:celest_backend/src/functions/generic_wrappers.dart", + "line": 14, + "column": 44 + }, + "text": "genericWrappersAsync" + } + }, + "genericWrapperParameters": { + "name": "genericWrapperParameters", + "apiName": "generic_wrappers", + "typeParameters": [], + "parameters": [ + { + "name": "listOfString", + "type": { + "$": "TypeReference", + "symbol": "IList", + "url": "package:fast_immutable_collections/src/ilist/ilist.dart", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + }, + "required": true, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 775, + "uri": "package:celest_backend/src/functions/generic_wrappers.dart", + "line": 18, + "column": 25 + }, + "end": { + "offset": 787, + "uri": "package:celest_backend/src/functions/generic_wrappers.dart", + "line": 18, + "column": 37 + }, + "text": "listOfString" + } + }, + { + "name": "listOfUri", + "type": { + "$": "TypeReference", + "symbol": "IList", + "url": "package:fast_immutable_collections/src/ilist/ilist.dart", + "types": [ + { + "$": "Reference", + "symbol": "Uri", + "url": "dart:core" + } + ], + "isNullable": false + }, + "required": true, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 811, + "uri": "package:celest_backend/src/functions/generic_wrappers.dart", + "line": 19, + "column": 22 + }, + "end": { + "offset": 820, + "uri": "package:celest_backend/src/functions/generic_wrappers.dart", + "line": 19, + "column": 31 + }, + "text": "listOfUri" + } + }, + { + "name": "listOfSimpleClass", + "type": { + "$": "TypeReference", + "symbol": "IList", + "url": "package:fast_immutable_collections/src/ilist/ilist.dart", + "types": [ + { + "$": "TypeReference", + "symbol": "SimpleClass", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": false + } + ], + "isNullable": false + }, + "required": true, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 852, + "uri": "package:celest_backend/src/functions/generic_wrappers.dart", + "line": 20, + "column": 30 + }, + "end": { + "offset": 869, + "uri": "package:celest_backend/src/functions/generic_wrappers.dart", + "line": 20, + "column": 47 + }, + "text": "listOfSimpleClass" + } + }, + { + "name": "listOfListOfString", + "type": { + "$": "TypeReference", + "symbol": "IList", + "url": "package:fast_immutable_collections/src/ilist/ilist.dart", + "types": [ + { + "$": "TypeReference", + "symbol": "IList", + "url": "package:fast_immutable_collections/src/ilist/ilist.dart", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + } + ], + "isNullable": false + }, + "required": true, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 903, + "uri": "package:celest_backend/src/functions/generic_wrappers.dart", + "line": 21, + "column": 32 + }, + "end": { + "offset": 921, + "uri": "package:celest_backend/src/functions/generic_wrappers.dart", + "line": 21, + "column": 50 + }, + "text": "listOfListOfString" + } + }, + { + "name": "listOfListOfUri", + "type": { + "$": "TypeReference", + "symbol": "IList", + "url": "package:fast_immutable_collections/src/ilist/ilist.dart", + "types": [ + { + "$": "TypeReference", + "symbol": "IList", + "url": "package:fast_immutable_collections/src/ilist/ilist.dart", + "types": [ + { + "$": "Reference", + "symbol": "Uri", + "url": "dart:core" + } + ], + "isNullable": false + } + ], + "isNullable": false + }, + "required": true, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 952, + "uri": "package:celest_backend/src/functions/generic_wrappers.dart", + "line": 22, + "column": 29 + }, + "end": { + "offset": 967, + "uri": "package:celest_backend/src/functions/generic_wrappers.dart", + "line": 22, + "column": 44 + }, + "text": "listOfListOfUri" + } + }, + { + "name": "listOfListOfSimpleClass", + "type": { + "$": "TypeReference", + "symbol": "IList", + "url": "package:fast_immutable_collections/src/ilist/ilist.dart", + "types": [ + { + "$": "TypeReference", + "symbol": "IList", + "url": "package:fast_immutable_collections/src/ilist/ilist.dart", + "types": [ + { + "$": "TypeReference", + "symbol": "SimpleClass", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": false + } + ], + "isNullable": false + } + ], + "isNullable": false + }, + "required": true, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 1006, + "uri": "package:celest_backend/src/functions/generic_wrappers.dart", + "line": 23, + "column": 37 + }, + "end": { + "offset": 1029, + "uri": "package:celest_backend/src/functions/generic_wrappers.dart", + "line": 23, + "column": 60 + }, + "text": "listOfListOfSimpleClass" + } + }, + { + "name": "mapOfString", + "type": { + "$": "TypeReference", + "symbol": "IMap", + "url": "package:fast_immutable_collections/src/imap/imap.dart", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + }, + "required": true, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 1063, + "uri": "package:celest_backend/src/functions/generic_wrappers.dart", + "line": 24, + "column": 32 + }, + "end": { + "offset": 1074, + "uri": "package:celest_backend/src/functions/generic_wrappers.dart", + "line": 24, + "column": 43 + }, + "text": "mapOfString" + } + }, + { + "name": "mapOfUri", + "type": { + "$": "TypeReference", + "symbol": "IMap", + "url": "package:fast_immutable_collections/src/imap/imap.dart", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "Reference", + "symbol": "Uri", + "url": "dart:core" + } + ], + "isNullable": false + }, + "required": true, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 1105, + "uri": "package:celest_backend/src/functions/generic_wrappers.dart", + "line": 25, + "column": 29 + }, + "end": { + "offset": 1113, + "uri": "package:celest_backend/src/functions/generic_wrappers.dart", + "line": 25, + "column": 37 + }, + "text": "mapOfUri" + } + }, + { + "name": "mapOfSimpleClass", + "type": { + "$": "TypeReference", + "symbol": "IMap", + "url": "package:fast_immutable_collections/src/imap/imap.dart", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "SimpleClass", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": false + } + ], + "isNullable": false + }, + "required": true, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 1152, + "uri": "package:celest_backend/src/functions/generic_wrappers.dart", + "line": 26, + "column": 37 + }, + "end": { + "offset": 1168, + "uri": "package:celest_backend/src/functions/generic_wrappers.dart", + "line": 26, + "column": 53 + }, + "text": "mapOfSimpleClass" + } + }, + { + "name": "mapOfListOfString", + "type": { + "$": "TypeReference", + "symbol": "IMap", + "url": "package:fast_immutable_collections/src/imap/imap.dart", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "IList", + "url": "package:fast_immutable_collections/src/ilist/ilist.dart", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + } + ], + "isNullable": false + }, + "required": true, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 1209, + "uri": "package:celest_backend/src/functions/generic_wrappers.dart", + "line": 27, + "column": 39 + }, + "end": { + "offset": 1226, + "uri": "package:celest_backend/src/functions/generic_wrappers.dart", + "line": 27, + "column": 56 + }, + "text": "mapOfListOfString" + } + }, + { + "name": "mapOfListOfUri", + "type": { + "$": "TypeReference", + "symbol": "IMap", + "url": "package:fast_immutable_collections/src/imap/imap.dart", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "IList", + "url": "package:fast_immutable_collections/src/ilist/ilist.dart", + "types": [ + { + "$": "Reference", + "symbol": "Uri", + "url": "dart:core" + } + ], + "isNullable": false + } + ], + "isNullable": false + }, + "required": true, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 1264, + "uri": "package:celest_backend/src/functions/generic_wrappers.dart", + "line": 28, + "column": 36 + }, + "end": { + "offset": 1278, + "uri": "package:celest_backend/src/functions/generic_wrappers.dart", + "line": 28, + "column": 50 + }, + "text": "mapOfListOfUri" + } + }, + { + "name": "mapOfListOfSimpleClass", + "type": { + "$": "TypeReference", + "symbol": "IMap", + "url": "package:fast_immutable_collections/src/imap/imap.dart", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "IList", + "url": "package:fast_immutable_collections/src/ilist/ilist.dart", + "types": [ + { + "$": "TypeReference", + "symbol": "SimpleClass", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": false + } + ], + "isNullable": false + } + ], + "isNullable": false + }, + "required": true, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 1324, + "uri": "package:celest_backend/src/functions/generic_wrappers.dart", + "line": 29, + "column": 44 + }, + "end": { + "offset": 1346, + "uri": "package:celest_backend/src/functions/generic_wrappers.dart", + "line": 29, + "column": 66 + }, + "text": "mapOfListOfSimpleClass" + } + }, + { + "name": "mapOfMapOfString", + "type": { + "$": "TypeReference", + "symbol": "IMap", + "url": "package:fast_immutable_collections/src/imap/imap.dart", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "IMap", + "url": "package:fast_immutable_collections/src/imap/imap.dart", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + } + ], + "isNullable": false + }, + "required": true, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 1394, + "uri": "package:celest_backend/src/functions/generic_wrappers.dart", + "line": 30, + "column": 46 + }, + "end": { + "offset": 1410, + "uri": "package:celest_backend/src/functions/generic_wrappers.dart", + "line": 30, + "column": 62 + }, + "text": "mapOfMapOfString" + } + }, + { + "name": "mapOfMapOfUri", + "type": { + "$": "TypeReference", + "symbol": "IMap", + "url": "package:fast_immutable_collections/src/imap/imap.dart", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "IMap", + "url": "package:fast_immutable_collections/src/imap/imap.dart", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "Reference", + "symbol": "Uri", + "url": "dart:core" + } + ], + "isNullable": false + } + ], + "isNullable": false + }, + "required": true, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 1455, + "uri": "package:celest_backend/src/functions/generic_wrappers.dart", + "line": 31, + "column": 43 + }, + "end": { + "offset": 1468, + "uri": "package:celest_backend/src/functions/generic_wrappers.dart", + "line": 31, + "column": 56 + }, + "text": "mapOfMapOfUri" + } + }, + { + "name": "mapOfMapOfSimpleClass", + "type": { + "$": "TypeReference", + "symbol": "IMap", + "url": "package:fast_immutable_collections/src/imap/imap.dart", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "IMap", + "url": "package:fast_immutable_collections/src/imap/imap.dart", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "SimpleClass", + "url": "package:celest_backend/models/parameter_types.dart", + "isNullable": false + } + ], + "isNullable": false + } + ], + "isNullable": false + }, + "required": true, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 1521, + "uri": "package:celest_backend/src/functions/generic_wrappers.dart", + "line": 32, + "column": 51 + }, + "end": { + "offset": 1542, + "uri": "package:celest_backend/src/functions/generic_wrappers.dart", + "line": 32, + "column": 72 + }, + "text": "mapOfMapOfSimpleClass" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "GenericWrappers", + "url": "package:celest_backend/models/generic_wrappers.dart", + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "GenericWrappers", + "url": "package:celest_backend/models/generic_wrappers.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 723, + "uri": "package:celest_backend/src/functions/generic_wrappers.dart", + "line": 17, + "column": 16 + }, + "end": { + "offset": 747, + "uri": "package:celest_backend/src/functions/generic_wrappers.dart", + "line": 17, + "column": 40 + }, + "text": "genericWrapperParameters" + } + } + }, + "docs": [ + "/// Tests that classes which wrap generic types are generated correctly when", + "/// those generic types follow the specifications of `json_serializable`, e.g.", + "/// having a `toJson` method with function parameters for mapping the", + "/// underlying types to JSON (Object Function(T) toJsonT)." + ], + "exceptionTypes": [ + { + "$": "TypeReference", + "symbol": "CloudException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "CancelledException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnknownError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "BadRequestException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnauthorizedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "NotFoundException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AlreadyExistsException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "PermissionDeniedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ResourceExhaustedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "FailedPreconditionException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AbortedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "OutOfRangeException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnimplementedError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "InternalServerError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnavailableError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "DataLossError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "DeadlineExceededError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "SerializationException", + "url": "package:celest_core/src/exception/serialization_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "Error", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AssertionError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "TypeError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ArgumentError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "RangeError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "IndexError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnsupportedError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnimplementedError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "StateError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ConcurrentModificationError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "OutOfMemoryError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "StackOverflowError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "Exception", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "FormatException", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "IntegerDivisionByZeroException", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AsyncError", + "url": "dart:async", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "TimeoutException", + "url": "dart:async", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "JsonUnsupportedObjectError", + "url": "dart:convert", + "isNullable": false + } + ], + "location": { + "start": { + "offset": 0, + "uri": "package:celest_backend/src/functions/generic_wrappers.dart", + "line": 0, + "column": 0 + }, + "end": { + "offset": 0, + "uri": "package:celest_backend/src/functions/generic_wrappers.dart", + "line": 0, + "column": 0 + }, + "text": "" + } + }, + "demo": { + "name": "demo", + "metadata": [], + "functions": { + "sayHello": { + "name": "sayHello", + "apiName": "demo", + "typeParameters": [], + "parameters": [ + { + "name": "person", + "type": { + "$": "TypeReference", + "symbol": "Person", + "url": "package:celest_backend/models/demo.dart", + "isNullable": false + }, + "required": true, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 331, + "uri": "package:celest_backend/src/functions/demo.dart", + "line": 9, + "column": 41 + }, + "end": { + "offset": 337, + "uri": "package:celest_backend/src/functions/demo.dart", + "line": 9, + "column": 47 + }, + "text": "person" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "Future", + "url": "dart:async", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [ + "/// Says hello to a [person]." + ], + "location": { + "start": { + "offset": 305, + "uri": "package:celest_backend/src/functions/demo.dart", + "line": 9, + "column": 15 + }, + "end": { + "offset": 313, + "uri": "package:celest_backend/src/functions/demo.dart", + "line": 9, + "column": 23 + }, + "text": "sayHello" + } + } + }, + "docs": [], + "exceptionTypes": [ + { + "$": "TypeReference", + "symbol": "CloudException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "CancelledException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnknownError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "BadRequestException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnauthorizedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "NotFoundException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AlreadyExistsException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "PermissionDeniedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ResourceExhaustedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "FailedPreconditionException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AbortedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "OutOfRangeException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnimplementedError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "InternalServerError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnavailableError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "DataLossError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "DeadlineExceededError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "SerializationException", + "url": "package:celest_core/src/exception/serialization_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "Error", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AssertionError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "TypeError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ArgumentError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "RangeError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "IndexError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnsupportedError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnimplementedError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "StateError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ConcurrentModificationError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "OutOfMemoryError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "StackOverflowError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "Exception", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "FormatException", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "IntegerDivisionByZeroException", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AsyncError", + "url": "dart:async", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "TimeoutException", + "url": "dart:async", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "JsonUnsupportedObjectError", + "url": "dart:convert", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "BadNameException", + "url": "package:celest_backend/exceptions/demo.dart", + "isNullable": false + } + ], + "location": { + "start": { + "offset": 0, + "uri": "package:celest_backend/src/functions/demo.dart", + "line": 0, + "column": 0 + }, + "end": { + "offset": 0, + "uri": "package:celest_backend/src/functions/demo.dart", + "line": 0, + "column": 0 + }, + "text": "" + } + }, + "asserts": { + "name": "asserts", + "metadata": [], + "functions": { + "assertsEnabled": { + "name": "assertsEnabled", + "apiName": "asserts", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "TypeReference", + "symbol": "bool", + "url": "dart:core", + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "bool", + "url": "dart:core", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [ + "/// Tests that asserts are enabled when running the local API." + ], + "location": { + "start": { + "offset": 113, + "uri": "package:celest_backend/src/functions/asserts.dart", + "line": 4, + "column": 5 + }, + "end": { + "offset": 127, + "uri": "package:celest_backend/src/functions/asserts.dart", + "line": 4, + "column": 19 + }, + "text": "assertsEnabled" + } + } + }, + "docs": [], + "exceptionTypes": [ + { + "$": "TypeReference", + "symbol": "CloudException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "CancelledException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnknownError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "BadRequestException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnauthorizedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "NotFoundException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AlreadyExistsException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "PermissionDeniedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ResourceExhaustedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "FailedPreconditionException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AbortedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "OutOfRangeException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnimplementedError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "InternalServerError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnavailableError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "DataLossError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "DeadlineExceededError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "SerializationException", + "url": "package:celest_core/src/exception/serialization_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "Error", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AssertionError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "TypeError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ArgumentError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "RangeError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "IndexError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnsupportedError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnimplementedError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "StateError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ConcurrentModificationError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "OutOfMemoryError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "StackOverflowError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "Exception", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "FormatException", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "IntegerDivisionByZeroException", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AsyncError", + "url": "dart:async", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "TimeoutException", + "url": "dart:async", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "JsonUnsupportedObjectError", + "url": "dart:convert", + "isNullable": false + } + ], + "location": { + "start": { + "offset": 0, + "uri": "package:celest_backend/src/functions/asserts.dart", + "line": 0, + "column": 0 + }, + "end": { + "offset": 0, + "uri": "package:celest_backend/src/functions/asserts.dart", + "line": 0, + "column": 0 + }, + "text": "" + } + } + }, + "variables": [], + "secrets": [], + "databases": {}, + "sdkConfig": { + "celest": "1.0.6+2", + "dart": { + "type": "dart", + "version": "3.29.0", + "enabledExperiments": [] + }, + "targetSdk": "dart", + "featureFlags": [ + "streaming" + ], + "flutter": { + "type": "flutter", + "version": "3.29.0", + "enabledExperiments": [] + } + }, + "location": { + "start": { + "offset": 44, + "uri": "project.dart", + "line": 2, + "column": 6 + }, + "end": { + "offset": 74, + "uri": "project.dart", + "line": 2, + "column": 36 + }, + "text": "project = Project(name: 'api')" + } +} \ No newline at end of file diff --git a/apps/cli/fixtures/legacy/api/goldens/ast.resolved.json b/apps/cli/fixtures/legacy/api/goldens/ast.resolved.json new file mode 100644 index 000000000..040d3652e --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/ast.resolved.json @@ -0,0 +1,3631 @@ +{ + "projectId": "api", + "environmentId": "local", + "apis": { + "records": { + "apiId": "records", + "functions": { + "nonAliasedNamedFields": { + "functionId": "nonAliasedNamedFields", + "apiId": "records", + "httpConfig": { + "route": { + "method": "POST", + "path": "/records/non-aliased-named-fields" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "asyncNonAliasedNamedFields": { + "functionId": "asyncNonAliasedNamedFields", + "apiId": "records", + "httpConfig": { + "route": { + "method": "POST", + "path": "/records/async-non-aliased-named-fields" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "aliasedNamedFields": { + "functionId": "aliasedNamedFields", + "apiId": "records", + "httpConfig": { + "route": { + "method": "POST", + "path": "/records/aliased-named-fields" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "asyncAliasedNamedFields": { + "functionId": "asyncAliasedNamedFields", + "apiId": "records", + "httpConfig": { + "route": { + "method": "POST", + "path": "/records/async-aliased-named-fields" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "namedFields": { + "functionId": "namedFields", + "apiId": "records", + "httpConfig": { + "route": { + "method": "POST", + "path": "/records/named-fields" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "asyncNamedFields": { + "functionId": "asyncNamedFields", + "apiId": "records", + "httpConfig": { + "route": { + "method": "POST", + "path": "/records/async-named-fields" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "nested": { + "functionId": "nested", + "apiId": "records", + "httpConfig": { + "route": { + "method": "POST", + "path": "/records/nested" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "asyncNested": { + "functionId": "asyncNested", + "apiId": "records", + "httpConfig": { + "route": { + "method": "POST", + "path": "/records/async-nested" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "nullableNested": { + "functionId": "nullableNested", + "apiId": "records", + "httpConfig": { + "route": { + "method": "POST", + "path": "/records/nullable-nested" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "asyncNullableNested": { + "functionId": "asyncNullableNested", + "apiId": "records", + "httpConfig": { + "route": { + "method": "POST", + "path": "/records/async-nullable-nested" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + } + } + }, + "sealed_classes": { + "apiId": "sealed_classes", + "functions": { + "area": { + "functionId": "area", + "apiId": "sealed_classes", + "httpConfig": { + "route": { + "method": "POST", + "path": "/sealed-classes/area" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "sealedClass": { + "functionId": "sealedClass", + "apiId": "sealed_classes", + "httpConfig": { + "route": { + "method": "POST", + "path": "/sealed-classes/sealed-class" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "rectangle": { + "functionId": "rectangle", + "apiId": "sealed_classes", + "httpConfig": { + "route": { + "method": "POST", + "path": "/sealed-classes/rectangle" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "circle": { + "functionId": "circle", + "apiId": "sealed_classes", + "httpConfig": { + "route": { + "method": "POST", + "path": "/sealed-classes/circle" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "sealedClassWithInheritedCustomJson": { + "functionId": "sealedClassWithInheritedCustomJson", + "apiId": "sealed_classes", + "httpConfig": { + "route": { + "method": "POST", + "path": "/sealed-classes/sealed-class-with-inherited-custom-json" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "sealedClassWithCustomJson": { + "functionId": "sealedClassWithCustomJson", + "apiId": "sealed_classes", + "httpConfig": { + "route": { + "method": "POST", + "path": "/sealed-classes/sealed-class-with-custom-json" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "sealedClassWithOverriddenCustomJson": { + "functionId": "sealedClassWithOverriddenCustomJson", + "apiId": "sealed_classes", + "httpConfig": { + "route": { + "method": "POST", + "path": "/sealed-classes/sealed-class-with-overridden-custom-json" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "rectangleWithOverriddenCustomJson": { + "functionId": "rectangleWithOverriddenCustomJson", + "apiId": "sealed_classes", + "httpConfig": { + "route": { + "method": "POST", + "path": "/sealed-classes/rectangle-with-overridden-custom-json" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "circleWithOverriddenCustomJson": { + "functionId": "circleWithOverriddenCustomJson", + "apiId": "sealed_classes", + "httpConfig": { + "route": { + "method": "POST", + "path": "/sealed-classes/circle-with-overridden-custom-json" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "okShapeResults": { + "functionId": "okShapeResults", + "apiId": "sealed_classes", + "httpConfig": { + "route": { + "method": "POST", + "path": "/sealed-classes/ok-shape-results" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "errShapeResults": { + "functionId": "errShapeResults", + "apiId": "sealed_classes", + "httpConfig": { + "route": { + "method": "POST", + "path": "/sealed-classes/err-shape-results" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "shapeResults": { + "functionId": "shapeResults", + "apiId": "sealed_classes", + "httpConfig": { + "route": { + "method": "POST", + "path": "/sealed-classes/shape-results" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "aliasedOkShapeResults": { + "functionId": "aliasedOkShapeResults", + "apiId": "sealed_classes", + "httpConfig": { + "route": { + "method": "POST", + "path": "/sealed-classes/aliased-ok-shape-results" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "aliasedErrShapeResults": { + "functionId": "aliasedErrShapeResults", + "apiId": "sealed_classes", + "httpConfig": { + "route": { + "method": "POST", + "path": "/sealed-classes/aliased-err-shape-results" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "aliasedShapeResults": { + "functionId": "aliasedShapeResults", + "apiId": "sealed_classes", + "httpConfig": { + "route": { + "method": "POST", + "path": "/sealed-classes/aliased-shape-results" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "swappedResult": { + "functionId": "swappedResult", + "apiId": "sealed_classes", + "httpConfig": { + "route": { + "method": "POST", + "path": "/sealed-classes/swapped-result" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "genericResult": { + "functionId": "genericResult", + "apiId": "sealed_classes", + "httpConfig": { + "route": { + "method": "POST", + "path": "/sealed-classes/generic-result" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "multipleGenericResult": { + "functionId": "multipleGenericResult", + "apiId": "sealed_classes", + "httpConfig": { + "route": { + "method": "POST", + "path": "/sealed-classes/multiple-generic-result" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "okShapeResult": { + "functionId": "okShapeResult", + "apiId": "sealed_classes", + "httpConfig": { + "route": { + "method": "POST", + "path": "/sealed-classes/ok-shape-result" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + } + } + }, + "parameter_types": { + "apiId": "parameter_types", + "functions": { + "simple": { + "functionId": "simple", + "apiId": "parameter_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/parameter-types/simple" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "simpleOptional": { + "functionId": "simpleOptional", + "apiId": "parameter_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/parameter-types/simple-optional" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "complex": { + "functionId": "complex", + "apiId": "parameter_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/parameter-types/complex" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + } + } + }, + "cycles": { + "apiId": "cycles", + "functions": { + "createTree": { + "functionId": "createTree", + "apiId": "cycles", + "httpConfig": { + "route": { + "method": "POST", + "path": "/cycles/create-tree" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "printTree": { + "functionId": "printTree", + "apiId": "cycles", + "httpConfig": { + "route": { + "method": "POST", + "path": "/cycles/print-tree" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "combineTrees": { + "functionId": "combineTrees", + "apiId": "cycles", + "httpConfig": { + "route": { + "method": "POST", + "path": "/cycles/combine-trees" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "selfReferencing": { + "functionId": "selfReferencing", + "apiId": "cycles", + "httpConfig": { + "route": { + "method": "POST", + "path": "/cycles/self-referencing" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + } + } + }, + "extension_types": { + "apiId": "extension_types", + "functions": { + "string": { + "functionId": "string", + "apiId": "extension_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/extension-types/string" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "asyncOrString": { + "functionId": "asyncOrString", + "apiId": "extension_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/extension-types/async-or-string" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "asyncString": { + "functionId": "asyncString", + "apiId": "extension_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/extension-types/async-string" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "stringImpl": { + "functionId": "stringImpl", + "apiId": "extension_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/extension-types/string-impl" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "stringToFromJson": { + "functionId": "stringToFromJson", + "apiId": "extension_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/extension-types/string-to-from-json" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "stringToJson": { + "functionId": "stringToJson", + "apiId": "extension_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/extension-types/string-to-json" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "stringToJsonImpl": { + "functionId": "stringToJsonImpl", + "apiId": "extension_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/extension-types/string-to-json-impl" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "stringFromJson": { + "functionId": "stringFromJson", + "apiId": "extension_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/extension-types/string-from-json" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "stringFromJsonImpl": { + "functionId": "stringFromJsonImpl", + "apiId": "extension_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/extension-types/string-from-json-impl" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "stringFromJsonStatic": { + "functionId": "stringFromJsonStatic", + "apiId": "extension_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/extension-types/string-from-json-static" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "stringPrivateField": { + "functionId": "stringPrivateField", + "apiId": "extension_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/extension-types/string-private-field" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "stringPrivateFieldImpl": { + "functionId": "stringPrivateFieldImpl", + "apiId": "extension_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/extension-types/string-private-field-impl" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "stringPrivateCtor": { + "functionId": "stringPrivateCtor", + "apiId": "extension_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/extension-types/string-private-ctor" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "stringPrivateCtorImpl": { + "functionId": "stringPrivateCtorImpl", + "apiId": "extension_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/extension-types/string-private-ctor-impl" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "value": { + "functionId": "value", + "apiId": "extension_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/extension-types/value" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "valueX": { + "functionId": "valueX", + "apiId": "extension_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/extension-types/value-x" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "valueXImpl": { + "functionId": "valueXImpl", + "apiId": "extension_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/extension-types/value-x-impl" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "valueXToFromJson": { + "functionId": "valueXToFromJson", + "apiId": "extension_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/extension-types/value-x-to-from-json" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "valueXToJson": { + "functionId": "valueXToJson", + "apiId": "extension_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/extension-types/value-x-to-json" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "valueXToJsonImpl": { + "functionId": "valueXToJsonImpl", + "apiId": "extension_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/extension-types/value-x-to-json-impl" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "valueXFromJson": { + "functionId": "valueXFromJson", + "apiId": "extension_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/extension-types/value-x-from-json" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "valueXFromJsonImpl": { + "functionId": "valueXFromJsonImpl", + "apiId": "extension_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/extension-types/value-x-from-json-impl" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "valueXFromJsonStatic": { + "functionId": "valueXFromJsonStatic", + "apiId": "extension_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/extension-types/value-x-from-json-static" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "color": { + "functionId": "color", + "apiId": "extension_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/extension-types/color" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "colorX": { + "functionId": "colorX", + "apiId": "extension_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/extension-types/color-x" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "colorXImpl": { + "functionId": "colorXImpl", + "apiId": "extension_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/extension-types/color-x-impl" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "colorXToFromJson": { + "functionId": "colorXToFromJson", + "apiId": "extension_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/extension-types/color-x-to-from-json" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "colorXToJson": { + "functionId": "colorXToJson", + "apiId": "extension_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/extension-types/color-x-to-json" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "colorXToJsonImpl": { + "functionId": "colorXToJsonImpl", + "apiId": "extension_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/extension-types/color-x-to-json-impl" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "colorXFromJson": { + "functionId": "colorXFromJson", + "apiId": "extension_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/extension-types/color-x-from-json" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "colorXFromJsonImpl": { + "functionId": "colorXFromJsonImpl", + "apiId": "extension_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/extension-types/color-x-from-json-impl" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "colorXFromJsonStatic": { + "functionId": "colorXFromJsonStatic", + "apiId": "extension_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/extension-types/color-x-from-json-static" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "jsonValue": { + "functionId": "jsonValue", + "apiId": "extension_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/extension-types/json-value" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "jsonString": { + "functionId": "jsonString", + "apiId": "extension_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/extension-types/json-string" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "jsonNum": { + "functionId": "jsonNum", + "apiId": "extension_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/extension-types/json-num" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "jsonInt": { + "functionId": "jsonInt", + "apiId": "extension_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/extension-types/json-int" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "jsonDouble": { + "functionId": "jsonDouble", + "apiId": "extension_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/extension-types/json-double" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "jsonBool": { + "functionId": "jsonBool", + "apiId": "extension_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/extension-types/json-bool" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "jsonList": { + "functionId": "jsonList", + "apiId": "extension_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/extension-types/json-list" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "jsonMap": { + "functionId": "jsonMap", + "apiId": "extension_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/extension-types/json-map" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + } + } + }, + "typedefs": { + "apiId": "typedefs", + "functions": { + "portfolio": { + "functionId": "portfolio", + "apiId": "typedefs", + "httpConfig": { + "route": { + "method": "POST", + "path": "/typedefs/portfolio" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "json": { + "functionId": "json", + "apiId": "typedefs", + "httpConfig": { + "route": { + "method": "POST", + "path": "/typedefs/json" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "nullableJson": { + "functionId": "nullableJson", + "apiId": "typedefs", + "httpConfig": { + "route": { + "method": "POST", + "path": "/typedefs/nullable-json" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "mixedJson": { + "functionId": "mixedJson", + "apiId": "typedefs", + "httpConfig": { + "route": { + "method": "POST", + "path": "/typedefs/mixed-json" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + } + } + }, + "return_types": { + "apiId": "return_types", + "functions": { + "asyncVoidReturn": { + "functionId": "asyncVoidReturn", + "apiId": "return_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/return-types/async-void-return" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "asyncStringReturn": { + "functionId": "asyncStringReturn", + "apiId": "return_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/return-types/async-string-return" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "asyncIntReturn": { + "functionId": "asyncIntReturn", + "apiId": "return_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/return-types/async-int-return" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "asyncDoubleReturn": { + "functionId": "asyncDoubleReturn", + "apiId": "return_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/return-types/async-double-return" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "asyncBoolReturn": { + "functionId": "asyncBoolReturn", + "apiId": "return_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/return-types/async-bool-return" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "asyncIterableReturn": { + "functionId": "asyncIterableReturn", + "apiId": "return_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/return-types/async-iterable-return" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "asyncListReturn": { + "functionId": "asyncListReturn", + "apiId": "return_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/return-types/async-list-return" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "asyncMapReturn": { + "functionId": "asyncMapReturn", + "apiId": "return_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/return-types/async-map-return" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "asyncStructReturn": { + "functionId": "asyncStructReturn", + "apiId": "return_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/return-types/async-struct-return" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "asyncStructReturnNullable": { + "functionId": "asyncStructReturnNullable", + "apiId": "return_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/return-types/async-struct-return-nullable" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "asyncComplexStructReturn": { + "functionId": "asyncComplexStructReturn", + "apiId": "return_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/return-types/async-complex-struct-return" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "asyncComplexStructReturnNullable": { + "functionId": "asyncComplexStructReturnNullable", + "apiId": "return_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/return-types/async-complex-struct-return-nullable" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "asyncComplexClassReturn": { + "functionId": "asyncComplexClassReturn", + "apiId": "return_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/return-types/async-complex-class-return" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "asyncClassReturnNullable": { + "functionId": "asyncClassReturnNullable", + "apiId": "return_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/return-types/async-class-return-nullable" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "asyncOrVoidReturn": { + "functionId": "asyncOrVoidReturn", + "apiId": "return_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/return-types/async-or-void-return" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "asyncOrStringReturn": { + "functionId": "asyncOrStringReturn", + "apiId": "return_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/return-types/async-or-string-return" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "asyncOrIntReturn": { + "functionId": "asyncOrIntReturn", + "apiId": "return_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/return-types/async-or-int-return" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "asyncOrDoubleReturn": { + "functionId": "asyncOrDoubleReturn", + "apiId": "return_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/return-types/async-or-double-return" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "asyncOrBoolReturn": { + "functionId": "asyncOrBoolReturn", + "apiId": "return_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/return-types/async-or-bool-return" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "asyncOrIterableReturn": { + "functionId": "asyncOrIterableReturn", + "apiId": "return_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/return-types/async-or-iterable-return" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "asyncOrListReturn": { + "functionId": "asyncOrListReturn", + "apiId": "return_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/return-types/async-or-list-return" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "asyncOrMapReturn": { + "functionId": "asyncOrMapReturn", + "apiId": "return_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/return-types/async-or-map-return" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "asyncOrStructReturn": { + "functionId": "asyncOrStructReturn", + "apiId": "return_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/return-types/async-or-struct-return" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "asyncOrComplexStructReturn": { + "functionId": "asyncOrComplexStructReturn", + "apiId": "return_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/return-types/async-or-complex-struct-return" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "asyncOrVoidReturnNullable": { + "functionId": "asyncOrVoidReturnNullable", + "apiId": "return_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/return-types/async-or-void-return-nullable" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "asyncOrStringReturnNullable": { + "functionId": "asyncOrStringReturnNullable", + "apiId": "return_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/return-types/async-or-string-return-nullable" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "asyncOrIntReturnNullable": { + "functionId": "asyncOrIntReturnNullable", + "apiId": "return_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/return-types/async-or-int-return-nullable" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "asyncOrDoubleReturnNullable": { + "functionId": "asyncOrDoubleReturnNullable", + "apiId": "return_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/return-types/async-or-double-return-nullable" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "asyncOrBoolReturnNullable": { + "functionId": "asyncOrBoolReturnNullable", + "apiId": "return_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/return-types/async-or-bool-return-nullable" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "asyncOrIterableReturnNullable": { + "functionId": "asyncOrIterableReturnNullable", + "apiId": "return_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/return-types/async-or-iterable-return-nullable" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "asyncOrListReturnNullable": { + "functionId": "asyncOrListReturnNullable", + "apiId": "return_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/return-types/async-or-list-return-nullable" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "asyncOrMapReturnNullable": { + "functionId": "asyncOrMapReturnNullable", + "apiId": "return_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/return-types/async-or-map-return-nullable" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "asyncOrStructReturnNullable": { + "functionId": "asyncOrStructReturnNullable", + "apiId": "return_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/return-types/async-or-struct-return-nullable" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "asyncOrComplexStructReturnNullable": { + "functionId": "asyncOrComplexStructReturnNullable", + "apiId": "return_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/return-types/async-or-complex-struct-return-nullable" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "asyncOrSimpleClassReturnNullable": { + "functionId": "asyncOrSimpleClassReturnNullable", + "apiId": "return_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/return-types/async-or-simple-class-return-nullable" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "asyncOrComplexClassReturnNullable": { + "functionId": "asyncOrComplexClassReturnNullable", + "apiId": "return_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/return-types/async-or-complex-class-return-nullable" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "voidReturn": { + "functionId": "voidReturn", + "apiId": "return_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/return-types/void-return" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "stringReturn": { + "functionId": "stringReturn", + "apiId": "return_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/return-types/string-return" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "intReturn": { + "functionId": "intReturn", + "apiId": "return_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/return-types/int-return" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "doubleReturn": { + "functionId": "doubleReturn", + "apiId": "return_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/return-types/double-return" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "boolReturn": { + "functionId": "boolReturn", + "apiId": "return_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/return-types/bool-return" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "iterableReturn": { + "functionId": "iterableReturn", + "apiId": "return_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/return-types/iterable-return" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "listReturn": { + "functionId": "listReturn", + "apiId": "return_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/return-types/list-return" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "mapReturn": { + "functionId": "mapReturn", + "apiId": "return_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/return-types/map-return" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "structReturn": { + "functionId": "structReturn", + "apiId": "return_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/return-types/struct-return" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "complexReturn": { + "functionId": "complexReturn", + "apiId": "return_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/return-types/complex-return" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "simpleClassReturn": { + "functionId": "simpleClassReturn", + "apiId": "return_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/return-types/simple-class-return" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "complexClassReturn": { + "functionId": "complexClassReturn", + "apiId": "return_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/return-types/complex-class-return" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "stringReturnNullable": { + "functionId": "stringReturnNullable", + "apiId": "return_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/return-types/string-return-nullable" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "intReturnNullable": { + "functionId": "intReturnNullable", + "apiId": "return_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/return-types/int-return-nullable" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "doubleReturnNullable": { + "functionId": "doubleReturnNullable", + "apiId": "return_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/return-types/double-return-nullable" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "boolReturnNullable": { + "functionId": "boolReturnNullable", + "apiId": "return_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/return-types/bool-return-nullable" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "iterableReturnNullable": { + "functionId": "iterableReturnNullable", + "apiId": "return_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/return-types/iterable-return-nullable" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "listReturnNullable": { + "functionId": "listReturnNullable", + "apiId": "return_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/return-types/list-return-nullable" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "mapReturnNullable": { + "functionId": "mapReturnNullable", + "apiId": "return_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/return-types/map-return-nullable" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "structReturnNullable": { + "functionId": "structReturnNullable", + "apiId": "return_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/return-types/struct-return-nullable" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "complexReturnNullable": { + "functionId": "complexReturnNullable", + "apiId": "return_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/return-types/complex-return-nullable" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "simpleClassReturnNullable": { + "functionId": "simpleClassReturnNullable", + "apiId": "return_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/return-types/simple-class-return-nullable" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "complexClassReturnNullable": { + "functionId": "complexClassReturnNullable", + "apiId": "return_types", + "httpConfig": { + "route": { + "method": "POST", + "path": "/return-types/complex-class-return-nullable" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + } + } + }, + "overrides": { + "apiId": "overrides", + "functions": { + "commonNestedParent": { + "functionId": "commonNestedParent", + "apiId": "overrides", + "httpConfig": { + "route": { + "method": "POST", + "path": "/overrides/common-nested-parent" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "commonNestedChild": { + "functionId": "commonNestedChild", + "apiId": "overrides", + "httpConfig": { + "route": { + "method": "POST", + "path": "/overrides/common-nested-child" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "nestedGrandparent": { + "functionId": "nestedGrandparent", + "apiId": "overrides", + "httpConfig": { + "route": { + "method": "POST", + "path": "/overrides/nested-grandparent" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "nestedParent": { + "functionId": "nestedParent", + "apiId": "overrides", + "httpConfig": { + "route": { + "method": "POST", + "path": "/overrides/nested-parent" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "nestedChild": { + "functionId": "nestedChild", + "apiId": "overrides", + "httpConfig": { + "route": { + "method": "POST", + "path": "/overrides/nested-child" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "callsThrowsCommonOverriddenException": { + "functionId": "callsThrowsCommonOverriddenException", + "apiId": "overrides", + "httpConfig": { + "route": { + "method": "POST", + "path": "/overrides/calls-throws-common-overridden-exception" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "throwsCommonOverriddenException": { + "functionId": "throwsCommonOverriddenException", + "apiId": "overrides", + "httpConfig": { + "route": { + "method": "POST", + "path": "/overrides/throws-common-overridden-exception" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "throwsOverriddenException": { + "functionId": "throwsOverriddenException", + "apiId": "overrides", + "httpConfig": { + "route": { + "method": "POST", + "path": "/overrides/throws-overridden-exception" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "callsThrowsOverriddenException": { + "functionId": "callsThrowsOverriddenException", + "apiId": "overrides", + "httpConfig": { + "route": { + "method": "POST", + "path": "/overrides/calls-throws-overridden-exception" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + } + } + }, + "classes": { + "apiId": "classes", + "functions": { + "empty": { + "functionId": "empty", + "apiId": "classes", + "httpConfig": { + "route": { + "method": "POST", + "path": "/classes/empty" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "asyncEmpty": { + "functionId": "asyncEmpty", + "apiId": "classes", + "httpConfig": { + "route": { + "method": "POST", + "path": "/classes/async-empty" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "fields": { + "functionId": "fields", + "apiId": "classes", + "httpConfig": { + "route": { + "method": "POST", + "path": "/classes/fields" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "asyncFields": { + "functionId": "asyncFields", + "apiId": "classes", + "httpConfig": { + "route": { + "method": "POST", + "path": "/classes/async-fields" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "nullableFields": { + "functionId": "nullableFields", + "apiId": "classes", + "httpConfig": { + "route": { + "method": "POST", + "path": "/classes/nullable-fields" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "asyncNullableFields": { + "functionId": "asyncNullableFields", + "apiId": "classes", + "httpConfig": { + "route": { + "method": "POST", + "path": "/classes/async-nullable-fields" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "namedFields": { + "functionId": "namedFields", + "apiId": "classes", + "httpConfig": { + "route": { + "method": "POST", + "path": "/classes/named-fields" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "asyncNamedFields": { + "functionId": "asyncNamedFields", + "apiId": "classes", + "httpConfig": { + "route": { + "method": "POST", + "path": "/classes/async-named-fields" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "mixedFields": { + "functionId": "mixedFields", + "apiId": "classes", + "httpConfig": { + "route": { + "method": "POST", + "path": "/classes/mixed-fields" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "asyncMixedFields": { + "functionId": "asyncMixedFields", + "apiId": "classes", + "httpConfig": { + "route": { + "method": "POST", + "path": "/classes/async-mixed-fields" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "defaultValues": { + "functionId": "defaultValues", + "apiId": "classes", + "httpConfig": { + "route": { + "method": "POST", + "path": "/classes/default-values" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "asyncDefaultValues": { + "functionId": "asyncDefaultValues", + "apiId": "classes", + "httpConfig": { + "route": { + "method": "POST", + "path": "/classes/async-default-values" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "nestedClass": { + "functionId": "nestedClass", + "apiId": "classes", + "httpConfig": { + "route": { + "method": "POST", + "path": "/classes/nested-class" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "asyncNestedClass": { + "functionId": "asyncNestedClass", + "apiId": "classes", + "httpConfig": { + "route": { + "method": "POST", + "path": "/classes/async-nested-class" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "onlyFromJson": { + "functionId": "onlyFromJson", + "apiId": "classes", + "httpConfig": { + "route": { + "method": "POST", + "path": "/classes/only-from-json" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "asyncOnlyFromJson": { + "functionId": "asyncOnlyFromJson", + "apiId": "classes", + "httpConfig": { + "route": { + "method": "POST", + "path": "/classes/async-only-from-json" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "onlyToJson": { + "functionId": "onlyToJson", + "apiId": "classes", + "httpConfig": { + "route": { + "method": "POST", + "path": "/classes/only-to-json" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "asyncOnlyToJson": { + "functionId": "asyncOnlyToJson", + "apiId": "classes", + "httpConfig": { + "route": { + "method": "POST", + "path": "/classes/async-only-to-json" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "onlyToJsonWithDefaults": { + "functionId": "onlyToJsonWithDefaults", + "apiId": "classes", + "httpConfig": { + "route": { + "method": "POST", + "path": "/classes/only-to-json-with-defaults" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "asyncOnlyToJsonWithDefaults": { + "functionId": "asyncOnlyToJsonWithDefaults", + "apiId": "classes", + "httpConfig": { + "route": { + "method": "POST", + "path": "/classes/async-only-to-json-with-defaults" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "fromAndToJson": { + "functionId": "fromAndToJson", + "apiId": "classes", + "httpConfig": { + "route": { + "method": "POST", + "path": "/classes/from-and-to-json" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "asyncFromAndToJson": { + "functionId": "asyncFromAndToJson", + "apiId": "classes", + "httpConfig": { + "route": { + "method": "POST", + "path": "/classes/async-from-and-to-json" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "nonMapToJson": { + "functionId": "nonMapToJson", + "apiId": "classes", + "httpConfig": { + "route": { + "method": "POST", + "path": "/classes/non-map-to-json" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "asyncNonMapToJson": { + "functionId": "asyncNonMapToJson", + "apiId": "classes", + "httpConfig": { + "route": { + "method": "POST", + "path": "/classes/async-non-map-to-json" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "nonMapToJsonWithDefaults": { + "functionId": "nonMapToJsonWithDefaults", + "apiId": "classes", + "httpConfig": { + "route": { + "method": "POST", + "path": "/classes/non-map-to-json-with-defaults" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "asyncNonMapToJsonWithDefaults": { + "functionId": "asyncNonMapToJsonWithDefaults", + "apiId": "classes", + "httpConfig": { + "route": { + "method": "POST", + "path": "/classes/async-non-map-to-json-with-defaults" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "nonMapFromAndToJson": { + "functionId": "nonMapFromAndToJson", + "apiId": "classes", + "httpConfig": { + "route": { + "method": "POST", + "path": "/classes/non-map-from-and-to-json" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "asyncNonMapFromAndToJson": { + "functionId": "asyncNonMapFromAndToJson", + "apiId": "classes", + "httpConfig": { + "route": { + "method": "POST", + "path": "/classes/async-non-map-from-and-to-json" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "fromJsonStatic": { + "functionId": "fromJsonStatic", + "apiId": "classes", + "httpConfig": { + "route": { + "method": "POST", + "path": "/classes/from-json-static" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + } + } + }, + "exceptions": { + "apiId": "exceptions", + "functions": { + "throwsException": { + "functionId": "throwsException", + "apiId": "exceptions", + "httpConfig": { + "route": { + "method": "POST", + "path": "/exceptions/throws-exception" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "throwsError": { + "functionId": "throwsError", + "apiId": "exceptions", + "httpConfig": { + "route": { + "method": "POST", + "path": "/exceptions/throws-error" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "throwsCustomException": { + "functionId": "throwsCustomException", + "apiId": "exceptions", + "httpConfig": { + "route": { + "method": "POST", + "path": "/exceptions/throws-custom-exception" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "throwsCustomExceptionToFromJson": { + "functionId": "throwsCustomExceptionToFromJson", + "apiId": "exceptions", + "httpConfig": { + "route": { + "method": "POST", + "path": "/exceptions/throws-custom-exception-to-from-json" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "throwsCustomError": { + "functionId": "throwsCustomError", + "apiId": "exceptions", + "httpConfig": { + "route": { + "method": "POST", + "path": "/exceptions/throws-custom-error" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "throwsCustomErrorToFromJson": { + "functionId": "throwsCustomErrorToFromJson", + "apiId": "exceptions", + "httpConfig": { + "route": { + "method": "POST", + "path": "/exceptions/throws-custom-error-to-from-json" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "throwsCustomErrorWithStackTrace": { + "functionId": "throwsCustomErrorWithStackTrace", + "apiId": "exceptions", + "httpConfig": { + "route": { + "method": "POST", + "path": "/exceptions/throws-custom-error-with-stack-trace" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + } + } + }, + "metadata": { + "apiId": "metadata", + "functions": { + "hasDocComments": { + "functionId": "hasDocComments", + "apiId": "metadata", + "httpConfig": { + "route": { + "method": "POST", + "path": "/metadata/has-doc-comments" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "hasDeprecatedAnnotation": { + "functionId": "hasDeprecatedAnnotation", + "apiId": "metadata", + "httpConfig": { + "route": { + "method": "POST", + "path": "/metadata/has-deprecated-annotation" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "hasConstructedDeprecatedAnnotation": { + "functionId": "hasConstructedDeprecatedAnnotation", + "apiId": "metadata", + "httpConfig": { + "route": { + "method": "POST", + "path": "/metadata/has-constructed-deprecated-annotation" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "hasNamedConstructedAnnotation": { + "functionId": "hasNamedConstructedAnnotation", + "apiId": "metadata", + "httpConfig": { + "route": { + "method": "POST", + "path": "/metadata/has-named-constructed-annotation" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "hasLiteralsAnnotation": { + "functionId": "hasLiteralsAnnotation", + "apiId": "metadata", + "httpConfig": { + "route": { + "method": "POST", + "path": "/metadata/has-literals-annotation" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "hasExportableAnnotation": { + "functionId": "hasExportableAnnotation", + "apiId": "metadata", + "httpConfig": { + "route": { + "method": "POST", + "path": "/metadata/has-exportable-annotation" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "hasExportableConstructedAnnotation": { + "functionId": "hasExportableConstructedAnnotation", + "apiId": "metadata", + "httpConfig": { + "route": { + "method": "POST", + "path": "/metadata/has-exportable-constructed-annotation" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "hasNotExportableAnnotation": { + "functionId": "hasNotExportableAnnotation", + "apiId": "metadata", + "httpConfig": { + "route": { + "method": "POST", + "path": "/metadata/has-not-exportable-annotation" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "positionalDefaultValues": { + "functionId": "positionalDefaultValues", + "apiId": "metadata", + "httpConfig": { + "route": { + "method": "POST", + "path": "/metadata/positional-default-values" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "nullablePositionalDefaultValues": { + "functionId": "nullablePositionalDefaultValues", + "apiId": "metadata", + "httpConfig": { + "route": { + "method": "POST", + "path": "/metadata/nullable-positional-default-values" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "namedDefaultValues": { + "functionId": "namedDefaultValues", + "apiId": "metadata", + "httpConfig": { + "route": { + "method": "POST", + "path": "/metadata/named-default-values" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "nullableNamedDefaultValues": { + "functionId": "nullableNamedDefaultValues", + "apiId": "metadata", + "httpConfig": { + "route": { + "method": "POST", + "path": "/metadata/nullable-named-default-values" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "positionalDefaultValueVars": { + "functionId": "positionalDefaultValueVars", + "apiId": "metadata", + "httpConfig": { + "route": { + "method": "POST", + "path": "/metadata/positional-default-value-vars" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "nullablePositionalDefaultValueVars": { + "functionId": "nullablePositionalDefaultValueVars", + "apiId": "metadata", + "httpConfig": { + "route": { + "method": "POST", + "path": "/metadata/nullable-positional-default-value-vars" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "namedDefaultValueVars": { + "functionId": "namedDefaultValueVars", + "apiId": "metadata", + "httpConfig": { + "route": { + "method": "POST", + "path": "/metadata/named-default-value-vars" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "nullableNamedDefaultValueVars": { + "functionId": "nullableNamedDefaultValueVars", + "apiId": "metadata", + "httpConfig": { + "route": { + "method": "POST", + "path": "/metadata/nullable-named-default-value-vars" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "positionalDefaultValueVarsPrivate": { + "functionId": "positionalDefaultValueVarsPrivate", + "apiId": "metadata", + "httpConfig": { + "route": { + "method": "POST", + "path": "/metadata/positional-default-value-vars-private" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "nullablePositionalDefaultValueVarsPrivate": { + "functionId": "nullablePositionalDefaultValueVarsPrivate", + "apiId": "metadata", + "httpConfig": { + "route": { + "method": "POST", + "path": "/metadata/nullable-positional-default-value-vars-private" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "namedDefaultValueVarsPrivate": { + "functionId": "namedDefaultValueVarsPrivate", + "apiId": "metadata", + "httpConfig": { + "route": { + "method": "POST", + "path": "/metadata/named-default-value-vars-private" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "nullableNamedDefaultValueVarsPrivate": { + "functionId": "nullableNamedDefaultValueVarsPrivate", + "apiId": "metadata", + "httpConfig": { + "route": { + "method": "POST", + "path": "/metadata/nullable-named-default-value-vars-private" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + } + } + }, + "parameters": { + "apiId": "parameters", + "functions": { + "optionalPositional": { + "functionId": "optionalPositional", + "apiId": "parameters", + "httpConfig": { + "route": { + "method": "POST", + "path": "/parameters/optional-positional" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "optionalNamed": { + "functionId": "optionalNamed", + "apiId": "parameters", + "httpConfig": { + "route": { + "method": "POST", + "path": "/parameters/optional-named" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "requiredPositional": { + "functionId": "requiredPositional", + "apiId": "parameters", + "httpConfig": { + "route": { + "method": "POST", + "path": "/parameters/required-positional" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "requiredNamed": { + "functionId": "requiredNamed", + "apiId": "parameters", + "httpConfig": { + "route": { + "method": "POST", + "path": "/parameters/required-named" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + } + } + }, + "collections": { + "apiId": "collections", + "functions": { + "simpleList": { + "functionId": "simpleList", + "apiId": "collections", + "httpConfig": { + "route": { + "method": "POST", + "path": "/collections/simple-list" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "complexList": { + "functionId": "complexList", + "apiId": "collections", + "httpConfig": { + "route": { + "method": "POST", + "path": "/collections/complex-list" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "simpleMap": { + "functionId": "simpleMap", + "apiId": "collections", + "httpConfig": { + "route": { + "method": "POST", + "path": "/collections/simple-map" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "dynamicMap": { + "functionId": "dynamicMap", + "apiId": "collections", + "httpConfig": { + "route": { + "method": "POST", + "path": "/collections/dynamic-map" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "objectMap": { + "functionId": "objectMap", + "apiId": "collections", + "httpConfig": { + "route": { + "method": "POST", + "path": "/collections/object-map" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "objectNullableMap": { + "functionId": "objectNullableMap", + "apiId": "collections", + "httpConfig": { + "route": { + "method": "POST", + "path": "/collections/object-nullable-map" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "complexMap": { + "functionId": "complexMap", + "apiId": "collections", + "httpConfig": { + "route": { + "method": "POST", + "path": "/collections/complex-map" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + } + } + }, + "generic_wrappers": { + "apiId": "generic_wrappers", + "functions": { + "genericWrappers": { + "functionId": "genericWrappers", + "apiId": "generic_wrappers", + "httpConfig": { + "route": { + "method": "POST", + "path": "/generic-wrappers/generic-wrappers" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "genericWrappersAsync": { + "functionId": "genericWrappersAsync", + "apiId": "generic_wrappers", + "httpConfig": { + "route": { + "method": "POST", + "path": "/generic-wrappers/generic-wrappers-async" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "genericWrapperParameters": { + "functionId": "genericWrapperParameters", + "apiId": "generic_wrappers", + "httpConfig": { + "route": { + "method": "POST", + "path": "/generic-wrappers/generic-wrapper-parameters" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + } + } + }, + "demo": { + "apiId": "demo", + "functions": { + "sayHello": { + "functionId": "sayHello", + "apiId": "demo", + "httpConfig": { + "route": { + "method": "POST", + "path": "/demo/say-hello" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + } + } + }, + "asserts": { + "apiId": "asserts", + "functions": { + "assertsEnabled": { + "functionId": "assertsEnabled", + "apiId": "asserts", + "httpConfig": { + "route": { + "method": "POST", + "path": "/asserts/asserts-enabled" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + } + } + } + }, + "variables": [ + { + "name": "CELEST_ENVIRONMENT", + "value": "local" + } + ], + "secrets": [], + "databases": {}, + "sdkConfig": { + "celest": "1.0.6+2", + "dart": { + "type": "dart", + "version": "3.29.0", + "enabledExperiments": [] + }, + "targetSdk": "dart", + "featureFlags": [ + "streaming" + ], + "flutter": { + "type": "flutter", + "version": "3.29.0", + "enabledExperiments": [] + } + } +} \ No newline at end of file diff --git a/apps/cli/fixtures/legacy/api/goldens/celest.json b/apps/cli/fixtures/legacy/api/goldens/celest.json new file mode 100644 index 000000000..7ca179c25 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/celest.json @@ -0,0 +1,3426 @@ +{ + "projectId": "api", + "environmentId": "local", + "apis": { + "records": { + "apiId": "records", + "functions": { + "nonAliasedNamedFields": { + "functionId": "nonAliasedNamedFields", + "parentId": "records", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/records/non-aliased-named-fields" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "asyncNonAliasedNamedFields": { + "functionId": "asyncNonAliasedNamedFields", + "parentId": "records", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/records/async-non-aliased-named-fields" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "aliasedNamedFields": { + "functionId": "aliasedNamedFields", + "parentId": "records", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/records/aliased-named-fields" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "asyncAliasedNamedFields": { + "functionId": "asyncAliasedNamedFields", + "parentId": "records", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/records/async-aliased-named-fields" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "namedFields": { + "functionId": "namedFields", + "parentId": "records", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/records/named-fields" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "asyncNamedFields": { + "functionId": "asyncNamedFields", + "parentId": "records", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/records/async-named-fields" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "nested": { + "functionId": "nested", + "parentId": "records", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/records/nested" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "asyncNested": { + "functionId": "asyncNested", + "parentId": "records", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/records/async-nested" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "nullableNested": { + "functionId": "nullableNested", + "parentId": "records", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/records/nullable-nested" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "asyncNullableNested": { + "functionId": "asyncNullableNested", + "parentId": "records", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/records/async-nullable-nested" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + } + } + }, + "sealed_classes": { + "apiId": "sealed_classes", + "functions": { + "area": { + "functionId": "area", + "parentId": "sealed_classes", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/sealed-classes/area" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "sealedClass": { + "functionId": "sealedClass", + "parentId": "sealed_classes", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/sealed-classes/sealed-class" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "rectangle": { + "functionId": "rectangle", + "parentId": "sealed_classes", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/sealed-classes/rectangle" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "circle": { + "functionId": "circle", + "parentId": "sealed_classes", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/sealed-classes/circle" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "sealedClassWithInheritedCustomJson": { + "functionId": "sealedClassWithInheritedCustomJson", + "parentId": "sealed_classes", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/sealed-classes/sealed-class-with-inherited-custom-json" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "sealedClassWithCustomJson": { + "functionId": "sealedClassWithCustomJson", + "parentId": "sealed_classes", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/sealed-classes/sealed-class-with-custom-json" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "sealedClassWithOverriddenCustomJson": { + "functionId": "sealedClassWithOverriddenCustomJson", + "parentId": "sealed_classes", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/sealed-classes/sealed-class-with-overridden-custom-json" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "rectangleWithOverriddenCustomJson": { + "functionId": "rectangleWithOverriddenCustomJson", + "parentId": "sealed_classes", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/sealed-classes/rectangle-with-overridden-custom-json" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "circleWithOverriddenCustomJson": { + "functionId": "circleWithOverriddenCustomJson", + "parentId": "sealed_classes", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/sealed-classes/circle-with-overridden-custom-json" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "okShapeResults": { + "functionId": "okShapeResults", + "parentId": "sealed_classes", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/sealed-classes/ok-shape-results" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "errShapeResults": { + "functionId": "errShapeResults", + "parentId": "sealed_classes", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/sealed-classes/err-shape-results" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "shapeResults": { + "functionId": "shapeResults", + "parentId": "sealed_classes", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/sealed-classes/shape-results" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "aliasedOkShapeResults": { + "functionId": "aliasedOkShapeResults", + "parentId": "sealed_classes", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/sealed-classes/aliased-ok-shape-results" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "aliasedErrShapeResults": { + "functionId": "aliasedErrShapeResults", + "parentId": "sealed_classes", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/sealed-classes/aliased-err-shape-results" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "aliasedShapeResults": { + "functionId": "aliasedShapeResults", + "parentId": "sealed_classes", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/sealed-classes/aliased-shape-results" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "swappedResult": { + "functionId": "swappedResult", + "parentId": "sealed_classes", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/sealed-classes/swapped-result" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "genericResult": { + "functionId": "genericResult", + "parentId": "sealed_classes", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/sealed-classes/generic-result" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "multipleGenericResult": { + "functionId": "multipleGenericResult", + "parentId": "sealed_classes", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/sealed-classes/multiple-generic-result" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "okShapeResult": { + "functionId": "okShapeResult", + "parentId": "sealed_classes", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/sealed-classes/ok-shape-result" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + } + } + }, + "parameter_types": { + "apiId": "parameter_types", + "functions": { + "simple": { + "functionId": "simple", + "parentId": "parameter_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/parameter-types/simple" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "simpleOptional": { + "functionId": "simpleOptional", + "parentId": "parameter_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/parameter-types/simple-optional" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "complex": { + "functionId": "complex", + "parentId": "parameter_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/parameter-types/complex" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + } + } + }, + "cycles": { + "apiId": "cycles", + "functions": { + "createTree": { + "functionId": "createTree", + "parentId": "cycles", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/cycles/create-tree" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "printTree": { + "functionId": "printTree", + "parentId": "cycles", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/cycles/print-tree" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "combineTrees": { + "functionId": "combineTrees", + "parentId": "cycles", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/cycles/combine-trees" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "selfReferencing": { + "functionId": "selfReferencing", + "parentId": "cycles", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/cycles/self-referencing" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + } + } + }, + "extension_types": { + "apiId": "extension_types", + "functions": { + "string": { + "functionId": "string", + "parentId": "extension_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/extension-types/string" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "asyncOrString": { + "functionId": "asyncOrString", + "parentId": "extension_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/extension-types/async-or-string" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "asyncString": { + "functionId": "asyncString", + "parentId": "extension_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/extension-types/async-string" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "stringImpl": { + "functionId": "stringImpl", + "parentId": "extension_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/extension-types/string-impl" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "stringToFromJson": { + "functionId": "stringToFromJson", + "parentId": "extension_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/extension-types/string-to-from-json" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "stringToJson": { + "functionId": "stringToJson", + "parentId": "extension_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/extension-types/string-to-json" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "stringToJsonImpl": { + "functionId": "stringToJsonImpl", + "parentId": "extension_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/extension-types/string-to-json-impl" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "stringFromJson": { + "functionId": "stringFromJson", + "parentId": "extension_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/extension-types/string-from-json" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "stringFromJsonImpl": { + "functionId": "stringFromJsonImpl", + "parentId": "extension_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/extension-types/string-from-json-impl" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "stringFromJsonStatic": { + "functionId": "stringFromJsonStatic", + "parentId": "extension_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/extension-types/string-from-json-static" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "stringPrivateField": { + "functionId": "stringPrivateField", + "parentId": "extension_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/extension-types/string-private-field" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "stringPrivateFieldImpl": { + "functionId": "stringPrivateFieldImpl", + "parentId": "extension_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/extension-types/string-private-field-impl" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "stringPrivateCtor": { + "functionId": "stringPrivateCtor", + "parentId": "extension_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/extension-types/string-private-ctor" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "stringPrivateCtorImpl": { + "functionId": "stringPrivateCtorImpl", + "parentId": "extension_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/extension-types/string-private-ctor-impl" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "value": { + "functionId": "value", + "parentId": "extension_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/extension-types/value" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "valueX": { + "functionId": "valueX", + "parentId": "extension_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/extension-types/value-x" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "valueXImpl": { + "functionId": "valueXImpl", + "parentId": "extension_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/extension-types/value-x-impl" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "valueXToFromJson": { + "functionId": "valueXToFromJson", + "parentId": "extension_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/extension-types/value-x-to-from-json" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "valueXToJson": { + "functionId": "valueXToJson", + "parentId": "extension_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/extension-types/value-x-to-json" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "valueXToJsonImpl": { + "functionId": "valueXToJsonImpl", + "parentId": "extension_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/extension-types/value-x-to-json-impl" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "valueXFromJson": { + "functionId": "valueXFromJson", + "parentId": "extension_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/extension-types/value-x-from-json" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "valueXFromJsonImpl": { + "functionId": "valueXFromJsonImpl", + "parentId": "extension_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/extension-types/value-x-from-json-impl" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "valueXFromJsonStatic": { + "functionId": "valueXFromJsonStatic", + "parentId": "extension_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/extension-types/value-x-from-json-static" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "color": { + "functionId": "color", + "parentId": "extension_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/extension-types/color" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "colorX": { + "functionId": "colorX", + "parentId": "extension_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/extension-types/color-x" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "colorXImpl": { + "functionId": "colorXImpl", + "parentId": "extension_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/extension-types/color-x-impl" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "colorXToFromJson": { + "functionId": "colorXToFromJson", + "parentId": "extension_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/extension-types/color-x-to-from-json" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "colorXToJson": { + "functionId": "colorXToJson", + "parentId": "extension_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/extension-types/color-x-to-json" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "colorXToJsonImpl": { + "functionId": "colorXToJsonImpl", + "parentId": "extension_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/extension-types/color-x-to-json-impl" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "colorXFromJson": { + "functionId": "colorXFromJson", + "parentId": "extension_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/extension-types/color-x-from-json" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "colorXFromJsonImpl": { + "functionId": "colorXFromJsonImpl", + "parentId": "extension_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/extension-types/color-x-from-json-impl" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "colorXFromJsonStatic": { + "functionId": "colorXFromJsonStatic", + "parentId": "extension_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/extension-types/color-x-from-json-static" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "jsonValue": { + "functionId": "jsonValue", + "parentId": "extension_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/extension-types/json-value" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "jsonString": { + "functionId": "jsonString", + "parentId": "extension_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/extension-types/json-string" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "jsonNum": { + "functionId": "jsonNum", + "parentId": "extension_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/extension-types/json-num" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "jsonInt": { + "functionId": "jsonInt", + "parentId": "extension_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/extension-types/json-int" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "jsonDouble": { + "functionId": "jsonDouble", + "parentId": "extension_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/extension-types/json-double" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "jsonBool": { + "functionId": "jsonBool", + "parentId": "extension_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/extension-types/json-bool" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "jsonList": { + "functionId": "jsonList", + "parentId": "extension_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/extension-types/json-list" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "jsonMap": { + "functionId": "jsonMap", + "parentId": "extension_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/extension-types/json-map" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + } + } + }, + "typedefs": { + "apiId": "typedefs", + "functions": { + "portfolio": { + "functionId": "portfolio", + "parentId": "typedefs", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/typedefs/portfolio" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "json": { + "functionId": "json", + "parentId": "typedefs", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/typedefs/json" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "nullableJson": { + "functionId": "nullableJson", + "parentId": "typedefs", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/typedefs/nullable-json" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "mixedJson": { + "functionId": "mixedJson", + "parentId": "typedefs", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/typedefs/mixed-json" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + } + } + }, + "return_types": { + "apiId": "return_types", + "functions": { + "asyncVoidReturn": { + "functionId": "asyncVoidReturn", + "parentId": "return_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/return-types/async-void-return" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "asyncStringReturn": { + "functionId": "asyncStringReturn", + "parentId": "return_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/return-types/async-string-return" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "asyncIntReturn": { + "functionId": "asyncIntReturn", + "parentId": "return_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/return-types/async-int-return" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "asyncDoubleReturn": { + "functionId": "asyncDoubleReturn", + "parentId": "return_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/return-types/async-double-return" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "asyncBoolReturn": { + "functionId": "asyncBoolReturn", + "parentId": "return_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/return-types/async-bool-return" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "asyncIterableReturn": { + "functionId": "asyncIterableReturn", + "parentId": "return_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/return-types/async-iterable-return" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "asyncListReturn": { + "functionId": "asyncListReturn", + "parentId": "return_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/return-types/async-list-return" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "asyncMapReturn": { + "functionId": "asyncMapReturn", + "parentId": "return_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/return-types/async-map-return" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "asyncStructReturn": { + "functionId": "asyncStructReturn", + "parentId": "return_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/return-types/async-struct-return" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "asyncStructReturnNullable": { + "functionId": "asyncStructReturnNullable", + "parentId": "return_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/return-types/async-struct-return-nullable" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "asyncComplexStructReturn": { + "functionId": "asyncComplexStructReturn", + "parentId": "return_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/return-types/async-complex-struct-return" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "asyncComplexStructReturnNullable": { + "functionId": "asyncComplexStructReturnNullable", + "parentId": "return_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/return-types/async-complex-struct-return-nullable" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "asyncComplexClassReturn": { + "functionId": "asyncComplexClassReturn", + "parentId": "return_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/return-types/async-complex-class-return" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "asyncClassReturnNullable": { + "functionId": "asyncClassReturnNullable", + "parentId": "return_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/return-types/async-class-return-nullable" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "asyncOrVoidReturn": { + "functionId": "asyncOrVoidReturn", + "parentId": "return_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/return-types/async-or-void-return" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "asyncOrStringReturn": { + "functionId": "asyncOrStringReturn", + "parentId": "return_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/return-types/async-or-string-return" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "asyncOrIntReturn": { + "functionId": "asyncOrIntReturn", + "parentId": "return_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/return-types/async-or-int-return" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "asyncOrDoubleReturn": { + "functionId": "asyncOrDoubleReturn", + "parentId": "return_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/return-types/async-or-double-return" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "asyncOrBoolReturn": { + "functionId": "asyncOrBoolReturn", + "parentId": "return_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/return-types/async-or-bool-return" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "asyncOrIterableReturn": { + "functionId": "asyncOrIterableReturn", + "parentId": "return_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/return-types/async-or-iterable-return" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "asyncOrListReturn": { + "functionId": "asyncOrListReturn", + "parentId": "return_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/return-types/async-or-list-return" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "asyncOrMapReturn": { + "functionId": "asyncOrMapReturn", + "parentId": "return_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/return-types/async-or-map-return" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "asyncOrStructReturn": { + "functionId": "asyncOrStructReturn", + "parentId": "return_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/return-types/async-or-struct-return" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "asyncOrComplexStructReturn": { + "functionId": "asyncOrComplexStructReturn", + "parentId": "return_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/return-types/async-or-complex-struct-return" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "asyncOrVoidReturnNullable": { + "functionId": "asyncOrVoidReturnNullable", + "parentId": "return_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/return-types/async-or-void-return-nullable" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "asyncOrStringReturnNullable": { + "functionId": "asyncOrStringReturnNullable", + "parentId": "return_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/return-types/async-or-string-return-nullable" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "asyncOrIntReturnNullable": { + "functionId": "asyncOrIntReturnNullable", + "parentId": "return_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/return-types/async-or-int-return-nullable" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "asyncOrDoubleReturnNullable": { + "functionId": "asyncOrDoubleReturnNullable", + "parentId": "return_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/return-types/async-or-double-return-nullable" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "asyncOrBoolReturnNullable": { + "functionId": "asyncOrBoolReturnNullable", + "parentId": "return_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/return-types/async-or-bool-return-nullable" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "asyncOrIterableReturnNullable": { + "functionId": "asyncOrIterableReturnNullable", + "parentId": "return_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/return-types/async-or-iterable-return-nullable" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "asyncOrListReturnNullable": { + "functionId": "asyncOrListReturnNullable", + "parentId": "return_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/return-types/async-or-list-return-nullable" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "asyncOrMapReturnNullable": { + "functionId": "asyncOrMapReturnNullable", + "parentId": "return_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/return-types/async-or-map-return-nullable" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "asyncOrStructReturnNullable": { + "functionId": "asyncOrStructReturnNullable", + "parentId": "return_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/return-types/async-or-struct-return-nullable" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "asyncOrComplexStructReturnNullable": { + "functionId": "asyncOrComplexStructReturnNullable", + "parentId": "return_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/return-types/async-or-complex-struct-return-nullable" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "asyncOrSimpleClassReturnNullable": { + "functionId": "asyncOrSimpleClassReturnNullable", + "parentId": "return_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/return-types/async-or-simple-class-return-nullable" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "asyncOrComplexClassReturnNullable": { + "functionId": "asyncOrComplexClassReturnNullable", + "parentId": "return_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/return-types/async-or-complex-class-return-nullable" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "voidReturn": { + "functionId": "voidReturn", + "parentId": "return_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/return-types/void-return" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "stringReturn": { + "functionId": "stringReturn", + "parentId": "return_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/return-types/string-return" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "intReturn": { + "functionId": "intReturn", + "parentId": "return_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/return-types/int-return" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "doubleReturn": { + "functionId": "doubleReturn", + "parentId": "return_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/return-types/double-return" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "boolReturn": { + "functionId": "boolReturn", + "parentId": "return_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/return-types/bool-return" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "iterableReturn": { + "functionId": "iterableReturn", + "parentId": "return_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/return-types/iterable-return" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "listReturn": { + "functionId": "listReturn", + "parentId": "return_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/return-types/list-return" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "mapReturn": { + "functionId": "mapReturn", + "parentId": "return_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/return-types/map-return" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "structReturn": { + "functionId": "structReturn", + "parentId": "return_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/return-types/struct-return" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "complexReturn": { + "functionId": "complexReturn", + "parentId": "return_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/return-types/complex-return" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "simpleClassReturn": { + "functionId": "simpleClassReturn", + "parentId": "return_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/return-types/simple-class-return" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "complexClassReturn": { + "functionId": "complexClassReturn", + "parentId": "return_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/return-types/complex-class-return" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "stringReturnNullable": { + "functionId": "stringReturnNullable", + "parentId": "return_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/return-types/string-return-nullable" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "intReturnNullable": { + "functionId": "intReturnNullable", + "parentId": "return_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/return-types/int-return-nullable" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "doubleReturnNullable": { + "functionId": "doubleReturnNullable", + "parentId": "return_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/return-types/double-return-nullable" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "boolReturnNullable": { + "functionId": "boolReturnNullable", + "parentId": "return_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/return-types/bool-return-nullable" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "iterableReturnNullable": { + "functionId": "iterableReturnNullable", + "parentId": "return_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/return-types/iterable-return-nullable" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "listReturnNullable": { + "functionId": "listReturnNullable", + "parentId": "return_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/return-types/list-return-nullable" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "mapReturnNullable": { + "functionId": "mapReturnNullable", + "parentId": "return_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/return-types/map-return-nullable" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "structReturnNullable": { + "functionId": "structReturnNullable", + "parentId": "return_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/return-types/struct-return-nullable" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "complexReturnNullable": { + "functionId": "complexReturnNullable", + "parentId": "return_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/return-types/complex-return-nullable" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "simpleClassReturnNullable": { + "functionId": "simpleClassReturnNullable", + "parentId": "return_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/return-types/simple-class-return-nullable" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "complexClassReturnNullable": { + "functionId": "complexClassReturnNullable", + "parentId": "return_types", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/return-types/complex-class-return-nullable" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + } + } + }, + "overrides": { + "apiId": "overrides", + "functions": { + "commonNestedParent": { + "functionId": "commonNestedParent", + "parentId": "overrides", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/overrides/common-nested-parent" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "commonNestedChild": { + "functionId": "commonNestedChild", + "parentId": "overrides", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/overrides/common-nested-child" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "nestedGrandparent": { + "functionId": "nestedGrandparent", + "parentId": "overrides", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/overrides/nested-grandparent" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "nestedParent": { + "functionId": "nestedParent", + "parentId": "overrides", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/overrides/nested-parent" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "nestedChild": { + "functionId": "nestedChild", + "parentId": "overrides", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/overrides/nested-child" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "callsThrowsCommonOverriddenException": { + "functionId": "callsThrowsCommonOverriddenException", + "parentId": "overrides", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/overrides/calls-throws-common-overridden-exception" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "throwsCommonOverriddenException": { + "functionId": "throwsCommonOverriddenException", + "parentId": "overrides", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/overrides/throws-common-overridden-exception" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "throwsOverriddenException": { + "functionId": "throwsOverriddenException", + "parentId": "overrides", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/overrides/throws-overridden-exception" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "callsThrowsOverriddenException": { + "functionId": "callsThrowsOverriddenException", + "parentId": "overrides", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/overrides/calls-throws-overridden-exception" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + } + } + }, + "classes": { + "apiId": "classes", + "functions": { + "empty": { + "functionId": "empty", + "parentId": "classes", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/classes/empty" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "asyncEmpty": { + "functionId": "asyncEmpty", + "parentId": "classes", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/classes/async-empty" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "fields": { + "functionId": "fields", + "parentId": "classes", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/classes/fields" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "asyncFields": { + "functionId": "asyncFields", + "parentId": "classes", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/classes/async-fields" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "nullableFields": { + "functionId": "nullableFields", + "parentId": "classes", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/classes/nullable-fields" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "asyncNullableFields": { + "functionId": "asyncNullableFields", + "parentId": "classes", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/classes/async-nullable-fields" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "namedFields": { + "functionId": "namedFields", + "parentId": "classes", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/classes/named-fields" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "asyncNamedFields": { + "functionId": "asyncNamedFields", + "parentId": "classes", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/classes/async-named-fields" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "mixedFields": { + "functionId": "mixedFields", + "parentId": "classes", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/classes/mixed-fields" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "asyncMixedFields": { + "functionId": "asyncMixedFields", + "parentId": "classes", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/classes/async-mixed-fields" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "defaultValues": { + "functionId": "defaultValues", + "parentId": "classes", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/classes/default-values" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "asyncDefaultValues": { + "functionId": "asyncDefaultValues", + "parentId": "classes", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/classes/async-default-values" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "nestedClass": { + "functionId": "nestedClass", + "parentId": "classes", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/classes/nested-class" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "asyncNestedClass": { + "functionId": "asyncNestedClass", + "parentId": "classes", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/classes/async-nested-class" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "onlyFromJson": { + "functionId": "onlyFromJson", + "parentId": "classes", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/classes/only-from-json" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "asyncOnlyFromJson": { + "functionId": "asyncOnlyFromJson", + "parentId": "classes", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/classes/async-only-from-json" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "onlyToJson": { + "functionId": "onlyToJson", + "parentId": "classes", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/classes/only-to-json" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "asyncOnlyToJson": { + "functionId": "asyncOnlyToJson", + "parentId": "classes", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/classes/async-only-to-json" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "onlyToJsonWithDefaults": { + "functionId": "onlyToJsonWithDefaults", + "parentId": "classes", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/classes/only-to-json-with-defaults" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "asyncOnlyToJsonWithDefaults": { + "functionId": "asyncOnlyToJsonWithDefaults", + "parentId": "classes", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/classes/async-only-to-json-with-defaults" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "fromAndToJson": { + "functionId": "fromAndToJson", + "parentId": "classes", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/classes/from-and-to-json" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "asyncFromAndToJson": { + "functionId": "asyncFromAndToJson", + "parentId": "classes", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/classes/async-from-and-to-json" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "nonMapToJson": { + "functionId": "nonMapToJson", + "parentId": "classes", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/classes/non-map-to-json" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "asyncNonMapToJson": { + "functionId": "asyncNonMapToJson", + "parentId": "classes", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/classes/async-non-map-to-json" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "nonMapToJsonWithDefaults": { + "functionId": "nonMapToJsonWithDefaults", + "parentId": "classes", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/classes/non-map-to-json-with-defaults" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "asyncNonMapToJsonWithDefaults": { + "functionId": "asyncNonMapToJsonWithDefaults", + "parentId": "classes", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/classes/async-non-map-to-json-with-defaults" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "nonMapFromAndToJson": { + "functionId": "nonMapFromAndToJson", + "parentId": "classes", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/classes/non-map-from-and-to-json" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "asyncNonMapFromAndToJson": { + "functionId": "asyncNonMapFromAndToJson", + "parentId": "classes", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/classes/async-non-map-from-and-to-json" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "fromJsonStatic": { + "functionId": "fromJsonStatic", + "parentId": "classes", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/classes/from-json-static" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + } + } + }, + "exceptions": { + "apiId": "exceptions", + "functions": { + "throwsException": { + "functionId": "throwsException", + "parentId": "exceptions", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/exceptions/throws-exception" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "throwsError": { + "functionId": "throwsError", + "parentId": "exceptions", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/exceptions/throws-error" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "throwsCustomException": { + "functionId": "throwsCustomException", + "parentId": "exceptions", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/exceptions/throws-custom-exception" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "throwsCustomExceptionToFromJson": { + "functionId": "throwsCustomExceptionToFromJson", + "parentId": "exceptions", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/exceptions/throws-custom-exception-to-from-json" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "throwsCustomError": { + "functionId": "throwsCustomError", + "parentId": "exceptions", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/exceptions/throws-custom-error" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "throwsCustomErrorToFromJson": { + "functionId": "throwsCustomErrorToFromJson", + "parentId": "exceptions", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/exceptions/throws-custom-error-to-from-json" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "throwsCustomErrorWithStackTrace": { + "functionId": "throwsCustomErrorWithStackTrace", + "parentId": "exceptions", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/exceptions/throws-custom-error-with-stack-trace" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + } + } + }, + "metadata": { + "apiId": "metadata", + "functions": { + "hasDocComments": { + "functionId": "hasDocComments", + "parentId": "metadata", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/metadata/has-doc-comments" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "hasDeprecatedAnnotation": { + "functionId": "hasDeprecatedAnnotation", + "parentId": "metadata", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/metadata/has-deprecated-annotation" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "hasConstructedDeprecatedAnnotation": { + "functionId": "hasConstructedDeprecatedAnnotation", + "parentId": "metadata", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/metadata/has-constructed-deprecated-annotation" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "hasNamedConstructedAnnotation": { + "functionId": "hasNamedConstructedAnnotation", + "parentId": "metadata", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/metadata/has-named-constructed-annotation" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "hasLiteralsAnnotation": { + "functionId": "hasLiteralsAnnotation", + "parentId": "metadata", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/metadata/has-literals-annotation" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "hasExportableAnnotation": { + "functionId": "hasExportableAnnotation", + "parentId": "metadata", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/metadata/has-exportable-annotation" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "hasExportableConstructedAnnotation": { + "functionId": "hasExportableConstructedAnnotation", + "parentId": "metadata", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/metadata/has-exportable-constructed-annotation" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "hasNotExportableAnnotation": { + "functionId": "hasNotExportableAnnotation", + "parentId": "metadata", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/metadata/has-not-exportable-annotation" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "positionalDefaultValues": { + "functionId": "positionalDefaultValues", + "parentId": "metadata", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/metadata/positional-default-values" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "nullablePositionalDefaultValues": { + "functionId": "nullablePositionalDefaultValues", + "parentId": "metadata", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/metadata/nullable-positional-default-values" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "namedDefaultValues": { + "functionId": "namedDefaultValues", + "parentId": "metadata", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/metadata/named-default-values" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "nullableNamedDefaultValues": { + "functionId": "nullableNamedDefaultValues", + "parentId": "metadata", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/metadata/nullable-named-default-values" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "positionalDefaultValueVars": { + "functionId": "positionalDefaultValueVars", + "parentId": "metadata", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/metadata/positional-default-value-vars" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "nullablePositionalDefaultValueVars": { + "functionId": "nullablePositionalDefaultValueVars", + "parentId": "metadata", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/metadata/nullable-positional-default-value-vars" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "namedDefaultValueVars": { + "functionId": "namedDefaultValueVars", + "parentId": "metadata", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/metadata/named-default-value-vars" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "nullableNamedDefaultValueVars": { + "functionId": "nullableNamedDefaultValueVars", + "parentId": "metadata", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/metadata/nullable-named-default-value-vars" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "positionalDefaultValueVarsPrivate": { + "functionId": "positionalDefaultValueVarsPrivate", + "parentId": "metadata", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/metadata/positional-default-value-vars-private" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "nullablePositionalDefaultValueVarsPrivate": { + "functionId": "nullablePositionalDefaultValueVarsPrivate", + "parentId": "metadata", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/metadata/nullable-positional-default-value-vars-private" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "namedDefaultValueVarsPrivate": { + "functionId": "namedDefaultValueVarsPrivate", + "parentId": "metadata", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/metadata/named-default-value-vars-private" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "nullableNamedDefaultValueVarsPrivate": { + "functionId": "nullableNamedDefaultValueVarsPrivate", + "parentId": "metadata", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/metadata/nullable-named-default-value-vars-private" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + } + } + }, + "parameters": { + "apiId": "parameters", + "functions": { + "optionalPositional": { + "functionId": "optionalPositional", + "parentId": "parameters", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/parameters/optional-positional" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "optionalNamed": { + "functionId": "optionalNamed", + "parentId": "parameters", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/parameters/optional-named" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "requiredPositional": { + "functionId": "requiredPositional", + "parentId": "parameters", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/parameters/required-positional" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "requiredNamed": { + "functionId": "requiredNamed", + "parentId": "parameters", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/parameters/required-named" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + } + } + }, + "collections": { + "apiId": "collections", + "functions": { + "simpleList": { + "functionId": "simpleList", + "parentId": "collections", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/collections/simple-list" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "complexList": { + "functionId": "complexList", + "parentId": "collections", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/collections/complex-list" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "simpleMap": { + "functionId": "simpleMap", + "parentId": "collections", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/collections/simple-map" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "dynamicMap": { + "functionId": "dynamicMap", + "parentId": "collections", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/collections/dynamic-map" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "objectMap": { + "functionId": "objectMap", + "parentId": "collections", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/collections/object-map" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "objectNullableMap": { + "functionId": "objectNullableMap", + "parentId": "collections", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/collections/object-nullable-map" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "complexMap": { + "functionId": "complexMap", + "parentId": "collections", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/collections/complex-map" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + } + } + }, + "generic_wrappers": { + "apiId": "generic_wrappers", + "functions": { + "genericWrappers": { + "functionId": "genericWrappers", + "parentId": "generic_wrappers", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/generic-wrappers/generic-wrappers" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "genericWrappersAsync": { + "functionId": "genericWrappersAsync", + "parentId": "generic_wrappers", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/generic-wrappers/generic-wrappers-async" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "genericWrapperParameters": { + "functionId": "genericWrapperParameters", + "parentId": "generic_wrappers", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/generic-wrappers/generic-wrapper-parameters" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + } + } + }, + "demo": { + "apiId": "demo", + "functions": { + "sayHello": { + "functionId": "sayHello", + "parentId": "demo", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/demo/say-hello" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + } + } + }, + "asserts": { + "apiId": "asserts", + "functions": { + "assertsEnabled": { + "functionId": "assertsEnabled", + "parentId": "asserts", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/asserts/asserts-enabled" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + } + } + } + }, + "variables": [ + { + "name": "CELEST_ENVIRONMENT", + "value": "local" + } + ], + "databases": {}, + "sdkConfig": { + "celest": { + "major": 1, + "minor": 0, + "patch": 6, + "build": [ + 2.0 + ], + "canonicalizedVersion": "1.0.6+2" + }, + "dart": { + "type": "DART", + "version": { + "major": 3, + "minor": 29, + "patch": 0, + "canonicalizedVersion": "3.29.0" + } + }, + "flutter": { + "type": "FLUTTER", + "version": { + "major": 3, + "minor": 29, + "patch": 0, + "canonicalizedVersion": "3.29.0" + } + }, + "targetSdk": "DART", + "featureFlags": [ + "STREAMING" + ] + } +} \ No newline at end of file diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/asserts/assertsEnabled.dart b/apps/cli/fixtures/legacy/api/goldens/functions/asserts/assertsEnabled.dart new file mode 100644 index 000000000..742c88e0e --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/asserts/assertsEnabled.dart @@ -0,0 +1,1685 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i9; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/asserts.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i10; +import 'package:celest_core/src/serialization/json_value.dart' as _i11; +import 'package:shelf/shelf.dart' as _i2; + +final class AssertsEnabledTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'assertsEnabled'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.assertsEnabled(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(response), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i9.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i10.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i9.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i10.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i11.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': AssertsEnabledTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/classes/asyncDefaultValues.dart b/apps/cli/fixtures/legacy/api/goldens/functions/classes/asyncDefaultValues.dart new file mode 100644 index 000000000..39c030c57 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/classes/asyncDefaultValues.dart @@ -0,0 +1,1715 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/classes.dart' as _i5; +import 'package:celest_backend/src/functions/classes.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class AsyncDefaultValuesTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'asyncDefaultValues'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = await _i3.asyncDefaultValues( + _i4.Serializers.instance.deserialize<_i5.DefaultValues>( + request[r'value'], + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.DefaultValues>(response), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DefaultValues, Map?>( + serialize: + ($value) => { + r'field': $value.field, + if ($value.nullableField case final nullableField?) + r'nullableField': nullableField, + if ($value.nullableFieldWithDefault + case final nullableFieldWithDefault?) + r'nullableFieldWithDefault': nullableFieldWithDefault, + r'fieldWithoutInitializer': $value.fieldWithoutInitializer, + }, + deserialize: ($serialized) { + return _i5.DefaultValues( + field: (($serialized?[r'field'] as String?)) ?? 'default', + nullableField: ($serialized?[r'nullableField'] as String?), + nullableFieldWithDefault: + (($serialized?[r'nullableFieldWithDefault'] as String?)) ?? + 'default', + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': AsyncDefaultValuesTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/classes/asyncEmpty.dart b/apps/cli/fixtures/legacy/api/goldens/functions/classes/asyncEmpty.dart new file mode 100644 index 000000000..47042f973 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/classes/asyncEmpty.dart @@ -0,0 +1,1698 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/classes.dart' as _i5; +import 'package:celest_backend/src/functions/classes.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class AsyncEmptyTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'asyncEmpty'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = await _i3.asyncEmpty( + _i4.Serializers.instance.deserialize<_i5.Empty>(request[r'value']), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.Empty>(response), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.Empty, Map?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return _i5.Empty(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': AsyncEmptyTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/classes/asyncFields.dart b/apps/cli/fixtures/legacy/api/goldens/functions/classes/asyncFields.dart new file mode 100644 index 000000000..7e885b596 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/classes/asyncFields.dart @@ -0,0 +1,1705 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/classes.dart' as _i5; +import 'package:celest_backend/src/functions/classes.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class AsyncFieldsTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'asyncFields'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = await _i3.asyncFields( + _i4.Serializers.instance.deserialize<_i5.Fields>(request[r'value']), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.Fields>(response), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.Fields, Map>( + serialize: + ($value) => { + r'superField': $value.superField, + r'field': $value.field, + }, + deserialize: ($serialized) { + return _i5.Fields( + ($serialized[r'superField'] as String), + ($serialized[r'field'] as String), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': AsyncFieldsTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/classes/asyncFromAndToJson.dart b/apps/cli/fixtures/legacy/api/goldens/functions/classes/asyncFromAndToJson.dart new file mode 100644 index 000000000..86f56d638 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/classes/asyncFromAndToJson.dart @@ -0,0 +1,1700 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/classes.dart' as _i5; +import 'package:celest_backend/src/functions/classes.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class AsyncFromAndToJsonTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'asyncFromAndToJson'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = await _i3.asyncFromAndToJson( + _i4.Serializers.instance.deserialize<_i5.FromJsonAndToJson>( + request[r'value'], + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.FromJsonAndToJson>(response), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.FromJsonAndToJson, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i5.FromJsonAndToJson.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': AsyncFromAndToJsonTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/classes/asyncMixedFields.dart b/apps/cli/fixtures/legacy/api/goldens/functions/classes/asyncMixedFields.dart new file mode 100644 index 000000000..2bf0de0e1 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/classes/asyncMixedFields.dart @@ -0,0 +1,1707 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/classes.dart' as _i5; +import 'package:celest_backend/src/functions/classes.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class AsyncMixedFieldsTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'asyncMixedFields'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = await _i3.asyncMixedFields( + _i4.Serializers.instance.deserialize<_i5.MixedFields>( + request[r'value'], + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.MixedFields>(response), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.MixedFields, Map>( + serialize: + ($value) => { + r'superField': $value.superField, + r'field': $value.field, + }, + deserialize: ($serialized) { + return _i5.MixedFields( + ($serialized[r'superField'] as String), + field: ($serialized[r'field'] as String), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': AsyncMixedFieldsTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/classes/asyncNamedFields.dart b/apps/cli/fixtures/legacy/api/goldens/functions/classes/asyncNamedFields.dart new file mode 100644 index 000000000..d0724e68b --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/classes/asyncNamedFields.dart @@ -0,0 +1,1707 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/classes.dart' as _i5; +import 'package:celest_backend/src/functions/classes.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class AsyncNamedFieldsTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'asyncNamedFields'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = await _i3.asyncNamedFields( + _i4.Serializers.instance.deserialize<_i5.NamedFields>( + request[r'value'], + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.NamedFields>(response), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NamedFields, Map>( + serialize: + ($value) => { + r'superField': $value.superField, + r'field': $value.field, + }, + deserialize: ($serialized) { + return _i5.NamedFields( + superField: ($serialized[r'superField'] as String), + field: ($serialized[r'field'] as String), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': AsyncNamedFieldsTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/classes/asyncNestedClass.dart b/apps/cli/fixtures/legacy/api/goldens/functions/classes/asyncNestedClass.dart new file mode 100644 index 000000000..dc3e47297 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/classes/asyncNestedClass.dart @@ -0,0 +1,1732 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/classes.dart' as _i5; +import 'package:celest_backend/src/functions/classes.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class AsyncNestedClassTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'asyncNestedClass'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = await _i3.asyncNestedClass( + _i4.Serializers.instance.deserialize<_i5.NestedClass>( + request[r'value'], + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.NestedClass>(response), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.Fields, Map>( + serialize: + ($value) => { + r'superField': $value.superField, + r'field': $value.field, + }, + deserialize: ($serialized) { + return _i5.Fields( + ($serialized[r'superField'] as String), + ($serialized[r'field'] as String), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NestedClass, Map>( + serialize: + ($value) => { + r'fields': _i4.Serializers.instance.serialize<_i5.Fields>( + $value.fields, + ), + if (_i4.Serializers.instance.serialize<_i5.Fields?>( + $value.nullableFields, + ) + case final nullableFields?) + r'nullableFields': nullableFields, + }, + deserialize: ($serialized) { + return _i5.NestedClass( + _i4.Serializers.instance.deserialize<_i5.Fields>( + $serialized[r'fields'], + ), + _i4.Serializers.instance.deserialize<_i5.Fields?>( + $serialized[r'nullableFields'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': AsyncNestedClassTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/classes/asyncNonMapFromAndToJson.dart b/apps/cli/fixtures/legacy/api/goldens/functions/classes/asyncNonMapFromAndToJson.dart new file mode 100644 index 000000000..239c2e6ef --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/classes/asyncNonMapFromAndToJson.dart @@ -0,0 +1,1700 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/classes.dart' as _i5; +import 'package:celest_backend/src/functions/classes.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class AsyncNonMapFromAndToJsonTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'asyncNonMapFromAndToJson'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = await _i3.asyncNonMapFromAndToJson( + _i4.Serializers.instance.deserialize<_i5.NonMapFromAndToJson>( + request[r'value'], + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.NonMapFromAndToJson>(response), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NonMapFromAndToJson, String>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i5.NonMapFromAndToJson.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': AsyncNonMapFromAndToJsonTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/classes/asyncNonMapToJson.dart b/apps/cli/fixtures/legacy/api/goldens/functions/classes/asyncNonMapToJson.dart new file mode 100644 index 000000000..33ab06fc1 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/classes/asyncNonMapToJson.dart @@ -0,0 +1,1700 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/classes.dart' as _i5; +import 'package:celest_backend/src/functions/classes.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class AsyncNonMapToJsonTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'asyncNonMapToJson'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = await _i3.asyncNonMapToJson( + _i4.Serializers.instance.deserialize<_i5.NonMapToJson>( + request[r'value'], + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.NonMapToJson>(response), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NonMapToJson, String>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i5.NonMapToJson(($serialized as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': AsyncNonMapToJsonTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/classes/asyncNonMapToJsonWithDefaults.dart b/apps/cli/fixtures/legacy/api/goldens/functions/classes/asyncNonMapToJsonWithDefaults.dart new file mode 100644 index 000000000..21f10fbf5 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/classes/asyncNonMapToJsonWithDefaults.dart @@ -0,0 +1,1705 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/classes.dart' as _i5; +import 'package:celest_backend/src/functions/classes.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class AsyncNonMapToJsonWithDefaultsTarget + extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'asyncNonMapToJsonWithDefaults'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = await _i3.asyncNonMapToJsonWithDefaults( + _i4.Serializers.instance.deserialize<_i5.NonMapToJsonWithDefaults>( + request[r'value'], + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.NonMapToJsonWithDefaults>( + response, + ), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NonMapToJsonWithDefaults, String?>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i5.NonMapToJsonWithDefaults( + (($serialized as String?)) ?? 'default', + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': AsyncNonMapToJsonWithDefaultsTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/classes/asyncNullableFields.dart b/apps/cli/fixtures/legacy/api/goldens/functions/classes/asyncNullableFields.dart new file mode 100644 index 000000000..fc6466eb1 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/classes/asyncNullableFields.dart @@ -0,0 +1,1705 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/classes.dart' as _i5; +import 'package:celest_backend/src/functions/classes.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class AsyncNullableFieldsTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'asyncNullableFields'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = await _i3.asyncNullableFields( + _i4.Serializers.instance.deserialize<_i5.Fields?>(request[r'value']), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.Fields?>(response), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.Fields, Map>( + serialize: + ($value) => { + r'superField': $value.superField, + r'field': $value.field, + }, + deserialize: ($serialized) { + return _i5.Fields( + ($serialized[r'superField'] as String), + ($serialized[r'field'] as String), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': AsyncNullableFieldsTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/classes/asyncOnlyFromJson.dart b/apps/cli/fixtures/legacy/api/goldens/functions/classes/asyncOnlyFromJson.dart new file mode 100644 index 000000000..bae920b2c --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/classes/asyncOnlyFromJson.dart @@ -0,0 +1,1700 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/classes.dart' as _i5; +import 'package:celest_backend/src/functions/classes.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class AsyncOnlyFromJsonTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'asyncOnlyFromJson'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = await _i3.asyncOnlyFromJson( + _i4.Serializers.instance.deserialize<_i5.OnlyFromJson>( + request[r'value'], + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.OnlyFromJson>(response), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OnlyFromJson, Map>( + serialize: ($value) => {r'field': $value.field}, + deserialize: ($serialized) { + return _i5.OnlyFromJson.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': AsyncOnlyFromJsonTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/classes/asyncOnlyToJson.dart b/apps/cli/fixtures/legacy/api/goldens/functions/classes/asyncOnlyToJson.dart new file mode 100644 index 000000000..f02ab2785 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/classes/asyncOnlyToJson.dart @@ -0,0 +1,1698 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/classes.dart' as _i5; +import 'package:celest_backend/src/functions/classes.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class AsyncOnlyToJsonTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'asyncOnlyToJson'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = await _i3.asyncOnlyToJson( + _i4.Serializers.instance.deserialize<_i5.OnlyToJson>(request[r'value']), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.OnlyToJson>(response), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OnlyToJson, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i5.OnlyToJson(($serialized[r'field'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': AsyncOnlyToJsonTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/classes/asyncOnlyToJsonWithDefaults.dart b/apps/cli/fixtures/legacy/api/goldens/functions/classes/asyncOnlyToJsonWithDefaults.dart new file mode 100644 index 000000000..d8a1a78cf --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/classes/asyncOnlyToJsonWithDefaults.dart @@ -0,0 +1,1705 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/classes.dart' as _i5; +import 'package:celest_backend/src/functions/classes.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class AsyncOnlyToJsonWithDefaultsTarget + extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'asyncOnlyToJsonWithDefaults'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = await _i3.asyncOnlyToJsonWithDefaults( + _i4.Serializers.instance.deserialize<_i5.OnlyToJsonWithDefaults>( + request[r'value'], + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.OnlyToJsonWithDefaults>( + response, + ), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OnlyToJsonWithDefaults, Map?>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i5.OnlyToJsonWithDefaults( + (($serialized?[r'field'] as String?)) ?? 'default', + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': AsyncOnlyToJsonWithDefaultsTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/classes/defaultValues.dart b/apps/cli/fixtures/legacy/api/goldens/functions/classes/defaultValues.dart new file mode 100644 index 000000000..2d82cbb8f --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/classes/defaultValues.dart @@ -0,0 +1,1715 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/classes.dart' as _i5; +import 'package:celest_backend/src/functions/classes.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class DefaultValuesTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'defaultValues'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.defaultValues( + _i4.Serializers.instance.deserialize<_i5.DefaultValues>( + request[r'value'], + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.DefaultValues>(response), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DefaultValues, Map?>( + serialize: + ($value) => { + r'field': $value.field, + if ($value.nullableField case final nullableField?) + r'nullableField': nullableField, + if ($value.nullableFieldWithDefault + case final nullableFieldWithDefault?) + r'nullableFieldWithDefault': nullableFieldWithDefault, + r'fieldWithoutInitializer': $value.fieldWithoutInitializer, + }, + deserialize: ($serialized) { + return _i5.DefaultValues( + field: (($serialized?[r'field'] as String?)) ?? 'default', + nullableField: ($serialized?[r'nullableField'] as String?), + nullableFieldWithDefault: + (($serialized?[r'nullableFieldWithDefault'] as String?)) ?? + 'default', + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': DefaultValuesTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/classes/empty.dart b/apps/cli/fixtures/legacy/api/goldens/functions/classes/empty.dart new file mode 100644 index 000000000..20443455b --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/classes/empty.dart @@ -0,0 +1,1698 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/classes.dart' as _i5; +import 'package:celest_backend/src/functions/classes.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class EmptyTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'empty'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.empty( + _i4.Serializers.instance.deserialize<_i5.Empty>(request[r'value']), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.Empty>(response), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.Empty, Map?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return _i5.Empty(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': EmptyTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/classes/fields.dart b/apps/cli/fixtures/legacy/api/goldens/functions/classes/fields.dart new file mode 100644 index 000000000..84d094c7f --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/classes/fields.dart @@ -0,0 +1,1705 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/classes.dart' as _i5; +import 'package:celest_backend/src/functions/classes.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class FieldsTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'fields'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.fields( + _i4.Serializers.instance.deserialize<_i5.Fields>(request[r'value']), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.Fields>(response), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.Fields, Map>( + serialize: + ($value) => { + r'superField': $value.superField, + r'field': $value.field, + }, + deserialize: ($serialized) { + return _i5.Fields( + ($serialized[r'superField'] as String), + ($serialized[r'field'] as String), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': FieldsTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/classes/fromAndToJson.dart b/apps/cli/fixtures/legacy/api/goldens/functions/classes/fromAndToJson.dart new file mode 100644 index 000000000..12f1706ab --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/classes/fromAndToJson.dart @@ -0,0 +1,1700 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/classes.dart' as _i5; +import 'package:celest_backend/src/functions/classes.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class FromAndToJsonTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'fromAndToJson'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.fromAndToJson( + _i4.Serializers.instance.deserialize<_i5.FromJsonAndToJson>( + request[r'value'], + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.FromJsonAndToJson>(response), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.FromJsonAndToJson, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i5.FromJsonAndToJson.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': FromAndToJsonTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/classes/fromJsonStatic.dart b/apps/cli/fixtures/legacy/api/goldens/functions/classes/fromJsonStatic.dart new file mode 100644 index 000000000..46d1f8603 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/classes/fromJsonStatic.dart @@ -0,0 +1,1700 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/classes.dart' as _i5; +import 'package:celest_backend/src/functions/classes.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class FromJsonStaticTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'fromJsonStatic'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.fromJsonStatic( + _i4.Serializers.instance.deserialize<_i5.FromJsonStatic>( + request[r'value'], + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.FromJsonStatic>(response), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.FromJsonStatic, String>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i5.FromJsonStatic.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': FromJsonStaticTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/classes/mixedFields.dart b/apps/cli/fixtures/legacy/api/goldens/functions/classes/mixedFields.dart new file mode 100644 index 000000000..90edbf19a --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/classes/mixedFields.dart @@ -0,0 +1,1707 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/classes.dart' as _i5; +import 'package:celest_backend/src/functions/classes.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class MixedFieldsTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'mixedFields'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.mixedFields( + _i4.Serializers.instance.deserialize<_i5.MixedFields>( + request[r'value'], + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.MixedFields>(response), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.MixedFields, Map>( + serialize: + ($value) => { + r'superField': $value.superField, + r'field': $value.field, + }, + deserialize: ($serialized) { + return _i5.MixedFields( + ($serialized[r'superField'] as String), + field: ($serialized[r'field'] as String), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': MixedFieldsTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/classes/namedFields.dart b/apps/cli/fixtures/legacy/api/goldens/functions/classes/namedFields.dart new file mode 100644 index 000000000..a5e8203de --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/classes/namedFields.dart @@ -0,0 +1,1707 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/classes.dart' as _i5; +import 'package:celest_backend/src/functions/classes.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class NamedFieldsTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'namedFields'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.namedFields( + _i4.Serializers.instance.deserialize<_i5.NamedFields>( + request[r'value'], + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.NamedFields>(response), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NamedFields, Map>( + serialize: + ($value) => { + r'superField': $value.superField, + r'field': $value.field, + }, + deserialize: ($serialized) { + return _i5.NamedFields( + superField: ($serialized[r'superField'] as String), + field: ($serialized[r'field'] as String), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': NamedFieldsTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/classes/nestedClass.dart b/apps/cli/fixtures/legacy/api/goldens/functions/classes/nestedClass.dart new file mode 100644 index 000000000..81b1e1dd5 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/classes/nestedClass.dart @@ -0,0 +1,1732 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/classes.dart' as _i5; +import 'package:celest_backend/src/functions/classes.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class NestedClassTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'nestedClass'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.nestedClass( + _i4.Serializers.instance.deserialize<_i5.NestedClass>( + request[r'value'], + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.NestedClass>(response), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.Fields, Map>( + serialize: + ($value) => { + r'superField': $value.superField, + r'field': $value.field, + }, + deserialize: ($serialized) { + return _i5.Fields( + ($serialized[r'superField'] as String), + ($serialized[r'field'] as String), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NestedClass, Map>( + serialize: + ($value) => { + r'fields': _i4.Serializers.instance.serialize<_i5.Fields>( + $value.fields, + ), + if (_i4.Serializers.instance.serialize<_i5.Fields?>( + $value.nullableFields, + ) + case final nullableFields?) + r'nullableFields': nullableFields, + }, + deserialize: ($serialized) { + return _i5.NestedClass( + _i4.Serializers.instance.deserialize<_i5.Fields>( + $serialized[r'fields'], + ), + _i4.Serializers.instance.deserialize<_i5.Fields?>( + $serialized[r'nullableFields'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': NestedClassTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/classes/nonMapFromAndToJson.dart b/apps/cli/fixtures/legacy/api/goldens/functions/classes/nonMapFromAndToJson.dart new file mode 100644 index 000000000..56c4eb7ff --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/classes/nonMapFromAndToJson.dart @@ -0,0 +1,1700 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/classes.dart' as _i5; +import 'package:celest_backend/src/functions/classes.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class NonMapFromAndToJsonTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'nonMapFromAndToJson'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.nonMapFromAndToJson( + _i4.Serializers.instance.deserialize<_i5.NonMapFromAndToJson>( + request[r'value'], + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.NonMapFromAndToJson>(response), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NonMapFromAndToJson, String>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i5.NonMapFromAndToJson.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': NonMapFromAndToJsonTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/classes/nonMapToJson.dart b/apps/cli/fixtures/legacy/api/goldens/functions/classes/nonMapToJson.dart new file mode 100644 index 000000000..8eaff9b1a --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/classes/nonMapToJson.dart @@ -0,0 +1,1700 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/classes.dart' as _i5; +import 'package:celest_backend/src/functions/classes.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class NonMapToJsonTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'nonMapToJson'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.nonMapToJson( + _i4.Serializers.instance.deserialize<_i5.NonMapToJson>( + request[r'value'], + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.NonMapToJson>(response), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NonMapToJson, String>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i5.NonMapToJson(($serialized as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': NonMapToJsonTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/classes/nonMapToJsonWithDefaults.dart b/apps/cli/fixtures/legacy/api/goldens/functions/classes/nonMapToJsonWithDefaults.dart new file mode 100644 index 000000000..7267908ba --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/classes/nonMapToJsonWithDefaults.dart @@ -0,0 +1,1704 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/classes.dart' as _i5; +import 'package:celest_backend/src/functions/classes.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class NonMapToJsonWithDefaultsTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'nonMapToJsonWithDefaults'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.nonMapToJsonWithDefaults( + _i4.Serializers.instance.deserialize<_i5.NonMapToJsonWithDefaults>( + request[r'value'], + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.NonMapToJsonWithDefaults>( + response, + ), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NonMapToJsonWithDefaults, String?>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i5.NonMapToJsonWithDefaults( + (($serialized as String?)) ?? 'default', + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': NonMapToJsonWithDefaultsTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/classes/nullableFields.dart b/apps/cli/fixtures/legacy/api/goldens/functions/classes/nullableFields.dart new file mode 100644 index 000000000..686603875 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/classes/nullableFields.dart @@ -0,0 +1,1705 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/classes.dart' as _i5; +import 'package:celest_backend/src/functions/classes.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class NullableFieldsTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'nullableFields'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.nullableFields( + _i4.Serializers.instance.deserialize<_i5.Fields?>(request[r'value']), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.Fields?>(response), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.Fields, Map>( + serialize: + ($value) => { + r'superField': $value.superField, + r'field': $value.field, + }, + deserialize: ($serialized) { + return _i5.Fields( + ($serialized[r'superField'] as String), + ($serialized[r'field'] as String), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': NullableFieldsTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/classes/onlyFromJson.dart b/apps/cli/fixtures/legacy/api/goldens/functions/classes/onlyFromJson.dart new file mode 100644 index 000000000..d1a6740e9 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/classes/onlyFromJson.dart @@ -0,0 +1,1700 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/classes.dart' as _i5; +import 'package:celest_backend/src/functions/classes.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class OnlyFromJsonTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'onlyFromJson'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.onlyFromJson( + _i4.Serializers.instance.deserialize<_i5.OnlyFromJson>( + request[r'value'], + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.OnlyFromJson>(response), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OnlyFromJson, Map>( + serialize: ($value) => {r'field': $value.field}, + deserialize: ($serialized) { + return _i5.OnlyFromJson.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': OnlyFromJsonTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/classes/onlyToJson.dart b/apps/cli/fixtures/legacy/api/goldens/functions/classes/onlyToJson.dart new file mode 100644 index 000000000..1831b28bf --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/classes/onlyToJson.dart @@ -0,0 +1,1698 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/classes.dart' as _i5; +import 'package:celest_backend/src/functions/classes.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class OnlyToJsonTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'onlyToJson'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.onlyToJson( + _i4.Serializers.instance.deserialize<_i5.OnlyToJson>(request[r'value']), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.OnlyToJson>(response), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OnlyToJson, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i5.OnlyToJson(($serialized[r'field'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': OnlyToJsonTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/classes/onlyToJsonWithDefaults.dart b/apps/cli/fixtures/legacy/api/goldens/functions/classes/onlyToJsonWithDefaults.dart new file mode 100644 index 000000000..2ebcb7a23 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/classes/onlyToJsonWithDefaults.dart @@ -0,0 +1,1704 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/classes.dart' as _i5; +import 'package:celest_backend/src/functions/classes.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class OnlyToJsonWithDefaultsTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'onlyToJsonWithDefaults'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.onlyToJsonWithDefaults( + _i4.Serializers.instance.deserialize<_i5.OnlyToJsonWithDefaults>( + request[r'value'], + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.OnlyToJsonWithDefaults>( + response, + ), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OnlyToJsonWithDefaults, Map?>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i5.OnlyToJsonWithDefaults( + (($serialized?[r'field'] as String?)) ?? 'default', + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': OnlyToJsonWithDefaultsTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/collections/complexList.dart b/apps/cli/fixtures/legacy/api/goldens/functions/collections/complexList.dart new file mode 100644 index 000000000..5cfab3e48 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/collections/complexList.dart @@ -0,0 +1,1706 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/parameter_types.dart' as _i5; +import 'package:celest_backend/src/functions/collections.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class ComplexListTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'complexList'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = await _i3.complexList( + (request[r'list'] as Iterable) + .map( + (el) => _i4.Serializers.instance.deserialize<_i5.SimpleClass>(el), + ) + .toList(), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + response + .map( + (el) => _i4.Serializers.instance.serialize<_i5.SimpleClass>(el), + ) + .toList(), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.SimpleClass, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i5.SimpleClass.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': ComplexListTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/collections/complexMap.dart b/apps/cli/fixtures/legacy/api/goldens/functions/collections/complexMap.dart new file mode 100644 index 000000000..31fc07d84 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/collections/complexMap.dart @@ -0,0 +1,1708 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/parameter_types.dart' as _i5; +import 'package:celest_backend/src/functions/collections.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class ComplexMapTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'complexMap'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = await _i3.complexMap( + (request[r'map'] as Map).map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize<_i5.SimpleClass>(value), + ), + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + response.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.serialize<_i5.SimpleClass>(value), + ), + ), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.SimpleClass, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i5.SimpleClass.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': ComplexMapTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/collections/dynamicMap.dart b/apps/cli/fixtures/legacy/api/goldens/functions/collections/dynamicMap.dart new file mode 100644 index 000000000..6d16838ec --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/collections/dynamicMap.dart @@ -0,0 +1,1687 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i9; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/collections.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i10; +import 'package:celest_core/src/serialization/json_value.dart' as _i11; +import 'package:shelf/shelf.dart' as _i2; + +final class DynamicMapTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'dynamicMap'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = await _i3.dynamicMap( + (request[r'map'] as Map), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(response), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i9.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i10.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i9.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i10.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i11.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': DynamicMapTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/collections/objectMap.dart b/apps/cli/fixtures/legacy/api/goldens/functions/collections/objectMap.dart new file mode 100644 index 000000000..7e8da78f7 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/collections/objectMap.dart @@ -0,0 +1,1689 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i9; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/collections.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i10; +import 'package:celest_core/src/serialization/json_value.dart' as _i11; +import 'package:shelf/shelf.dart' as _i2; + +final class ObjectMapTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'objectMap'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = await _i3.objectMap( + (request[r'map'] as Map).map( + (key, value) => MapEntry(key, value!), + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(response), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i9.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i10.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i9.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i10.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i11.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': ObjectMapTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/collections/objectNullableMap.dart b/apps/cli/fixtures/legacy/api/goldens/functions/collections/objectNullableMap.dart new file mode 100644 index 000000000..b5f360e4b --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/collections/objectNullableMap.dart @@ -0,0 +1,1687 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i9; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/collections.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i10; +import 'package:celest_core/src/serialization/json_value.dart' as _i11; +import 'package:shelf/shelf.dart' as _i2; + +final class ObjectNullableMapTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'objectNullableMap'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = await _i3.objectNullableMap( + (request[r'map'] as Map), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(response), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i9.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i10.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i9.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i10.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i11.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': ObjectNullableMapTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/collections/simpleList.dart b/apps/cli/fixtures/legacy/api/goldens/functions/collections/simpleList.dart new file mode 100644 index 000000000..6eb261327 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/collections/simpleList.dart @@ -0,0 +1,1689 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i9; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/collections.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i10; +import 'package:celest_core/src/serialization/json_value.dart' as _i11; +import 'package:shelf/shelf.dart' as _i2; + +final class SimpleListTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'simpleList'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = await _i3.simpleList( + (request[r'list'] as Iterable) + .map((el) => (el as String)) + .toList(), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(response), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i9.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i10.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i9.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i10.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i11.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': SimpleListTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/collections/simpleMap.dart b/apps/cli/fixtures/legacy/api/goldens/functions/collections/simpleMap.dart new file mode 100644 index 000000000..f9cc513dd --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/collections/simpleMap.dart @@ -0,0 +1,1689 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i9; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/collections.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i10; +import 'package:celest_core/src/serialization/json_value.dart' as _i11; +import 'package:shelf/shelf.dart' as _i2; + +final class SimpleMapTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'simpleMap'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = await _i3.simpleMap( + (request[r'map'] as Map).map( + (key, value) => MapEntry(key, (value as String)), + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(response), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i9.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i10.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i9.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i10.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i11.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': SimpleMapTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/cycles/combineTrees.dart b/apps/cli/fixtures/legacy/api/goldens/functions/cycles/combineTrees.dart new file mode 100644 index 000000000..e4714d09d --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/cycles/combineTrees.dart @@ -0,0 +1,1783 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/cycles.dart' as _i5; +import 'package:celest_backend/src/functions/cycles.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class CombineTreesTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'combineTrees'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.combineTrees( + _i4.Serializers.instance.deserialize<_i5.Node>(request[r'tree1']), + _i4.Serializers.instance.deserialize<_i5.Parent?>(request[r'tree2']), + _i4.Serializers.instance.deserialize<_i5.Node?>(request[r'tree3']), + ((request[r'additionalChildren'] as Iterable?) + ?.map( + (el) => _i4.Serializers.instance.deserialize<_i5.Node?>(el), + ) + .toList()) ?? + const [], + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.Node>(response), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.Child, Map>( + serialize: + ($value) => { + r'name': $value.name, + r'children': + $value.children + .map( + (el) => + _i4.Serializers.instance.serialize<_i5.Node>(el), + ) + .toList(), + }, + deserialize: ($serialized) { + return _i5.Child(($serialized[r'name'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.Node, Map>( + serialize: ($value) { + if ($value is _i5.Parent) { + return { + ...(_i4.Serializers.instance.serialize<_i5.Parent>($value) + as Map), + r'$type': r'Parent', + }; + } + if ($value is _i5.Child) { + return { + ...(_i4.Serializers.instance.serialize<_i5.Child>($value) + as Map), + r'$type': r'Child', + }; + } + throw _i4.SerializationException( + (StringBuffer('Unknown subtype of ') + ..write(r'Node') + ..write(': ') + ..write($value.runtimeType)) + .toString(), + ); + }, + deserialize: ($serialized) { + if ($serialized[r'$type'] == r'Parent') { + return _i4.Serializers.instance.deserialize<_i5.Parent>( + $serialized, + ); + } + if ($serialized[r'$type'] == r'Child') { + return _i4.Serializers.instance.deserialize<_i5.Child>($serialized); + } + throw _i4.SerializationException( + (StringBuffer('Unknown subtype of ') + ..write(r'Node') + ..write(': ') + ..write($serialized[r'$type'])) + .toString(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.Parent, Map>( + serialize: + ($value) => { + r'name': $value.name, + r'children': + $value.children + .map( + (el) => + _i4.Serializers.instance.serialize<_i5.Node>(el), + ) + .toList(), + }, + deserialize: ($serialized) { + return _i5.Parent( + ($serialized[r'name'] as String), + ($serialized[r'children'] as Iterable) + .map((el) => _i4.Serializers.instance.deserialize<_i5.Node>(el)) + .toList(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': CombineTreesTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/cycles/createTree.dart b/apps/cli/fixtures/legacy/api/goldens/functions/cycles/createTree.dart new file mode 100644 index 000000000..3943cc3a6 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/cycles/createTree.dart @@ -0,0 +1,1773 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/cycles.dart' as _i5; +import 'package:celest_backend/src/functions/cycles.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class CreateTreeTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'createTree'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.createTree(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.Node>(response), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.Child, Map>( + serialize: + ($value) => { + r'name': $value.name, + r'children': + $value.children + .map( + (el) => + _i4.Serializers.instance.serialize<_i5.Node>(el), + ) + .toList(), + }, + deserialize: ($serialized) { + return _i5.Child(($serialized[r'name'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.Node, Map>( + serialize: ($value) { + if ($value is _i5.Parent) { + return { + ...(_i4.Serializers.instance.serialize<_i5.Parent>($value) + as Map), + r'$type': r'Parent', + }; + } + if ($value is _i5.Child) { + return { + ...(_i4.Serializers.instance.serialize<_i5.Child>($value) + as Map), + r'$type': r'Child', + }; + } + throw _i4.SerializationException( + (StringBuffer('Unknown subtype of ') + ..write(r'Node') + ..write(': ') + ..write($value.runtimeType)) + .toString(), + ); + }, + deserialize: ($serialized) { + if ($serialized[r'$type'] == r'Parent') { + return _i4.Serializers.instance.deserialize<_i5.Parent>( + $serialized, + ); + } + if ($serialized[r'$type'] == r'Child') { + return _i4.Serializers.instance.deserialize<_i5.Child>($serialized); + } + throw _i4.SerializationException( + (StringBuffer('Unknown subtype of ') + ..write(r'Node') + ..write(': ') + ..write($serialized[r'$type'])) + .toString(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.Parent, Map>( + serialize: + ($value) => { + r'name': $value.name, + r'children': + $value.children + .map( + (el) => + _i4.Serializers.instance.serialize<_i5.Node>(el), + ) + .toList(), + }, + deserialize: ($serialized) { + return _i5.Parent( + ($serialized[r'name'] as String), + ($serialized[r'children'] as Iterable) + .map((el) => _i4.Serializers.instance.deserialize<_i5.Node>(el)) + .toList(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': CreateTreeTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/cycles/printTree.dart b/apps/cli/fixtures/legacy/api/goldens/functions/cycles/printTree.dart new file mode 100644 index 000000000..73c92d0ba --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/cycles/printTree.dart @@ -0,0 +1,1773 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/cycles.dart' as _i5; +import 'package:celest_backend/src/functions/cycles.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class PrintTreeTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'printTree'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + _i3.printTree( + _i4.Serializers.instance.deserialize<_i5.Node>(request[r'node']), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(null), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.Child, Map>( + serialize: + ($value) => { + r'name': $value.name, + r'children': + $value.children + .map( + (el) => + _i4.Serializers.instance.serialize<_i5.Node>(el), + ) + .toList(), + }, + deserialize: ($serialized) { + return _i5.Child(($serialized[r'name'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.Node, Map>( + serialize: ($value) { + if ($value is _i5.Parent) { + return { + ...(_i4.Serializers.instance.serialize<_i5.Parent>($value) + as Map), + r'$type': r'Parent', + }; + } + if ($value is _i5.Child) { + return { + ...(_i4.Serializers.instance.serialize<_i5.Child>($value) + as Map), + r'$type': r'Child', + }; + } + throw _i4.SerializationException( + (StringBuffer('Unknown subtype of ') + ..write(r'Node') + ..write(': ') + ..write($value.runtimeType)) + .toString(), + ); + }, + deserialize: ($serialized) { + if ($serialized[r'$type'] == r'Parent') { + return _i4.Serializers.instance.deserialize<_i5.Parent>( + $serialized, + ); + } + if ($serialized[r'$type'] == r'Child') { + return _i4.Serializers.instance.deserialize<_i5.Child>($serialized); + } + throw _i4.SerializationException( + (StringBuffer('Unknown subtype of ') + ..write(r'Node') + ..write(': ') + ..write($serialized[r'$type'])) + .toString(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.Parent, Map>( + serialize: + ($value) => { + r'name': $value.name, + r'children': + $value.children + .map( + (el) => + _i4.Serializers.instance.serialize<_i5.Node>(el), + ) + .toList(), + }, + deserialize: ($serialized) { + return _i5.Parent( + ($serialized[r'name'] as String), + ($serialized[r'children'] as Iterable) + .map((el) => _i4.Serializers.instance.deserialize<_i5.Node>(el)) + .toList(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': PrintTreeTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/cycles/selfReferencing.dart b/apps/cli/fixtures/legacy/api/goldens/functions/cycles/selfReferencing.dart new file mode 100644 index 000000000..0b5d18319 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/cycles/selfReferencing.dart @@ -0,0 +1,1750 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/cycles.dart' as _i5; +import 'package:celest_backend/src/functions/cycles.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class SelfReferencingTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'selfReferencing'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.selfReferencing( + _i4.Serializers.instance.deserialize<_i5.SelfReferencing>( + request[r'selfReferencing'], + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.SelfReferencing>(response), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.SelfReferencing, Map>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize<_i5.SelfReferencing?>( + $value.value, + ) + case final value?) + r'value': value, + if (_i4.Serializers.instance + .serialize<_i5.SelfReferencingWrapper?>($value.wrapper) + case final wrapper?) + r'wrapper': wrapper, + r'list': + $value.list + .map( + (el) => _i4.Serializers.instance + .serialize<_i5.SelfReferencing>(el), + ) + .toList(), + }, + deserialize: ($serialized) { + return _i5.SelfReferencing( + value: _i4.Serializers.instance.deserialize<_i5.SelfReferencing?>( + $serialized[r'value'], + ), + wrapper: _i4.Serializers.instance + .deserialize<_i5.SelfReferencingWrapper?>( + $serialized[r'wrapper'], + ), + list: + ($serialized[r'list'] as Iterable) + .map( + (el) => _i4.Serializers.instance + .deserialize<_i5.SelfReferencing>(el), + ) + .toList(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.SelfReferencingWrapper, Map>( + serialize: + ($value) => { + r'value': _i4.Serializers.instance.serialize<_i5.SelfReferencing>( + $value.value, + ), + }, + deserialize: ($serialized) { + return _i5.SelfReferencingWrapper( + value: _i4.Serializers.instance.deserialize<_i5.SelfReferencing>( + $serialized[r'value'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': SelfReferencingTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/demo/sayHello.dart b/apps/cli/fixtures/legacy/api/goldens/functions/demo/sayHello.dart new file mode 100644 index 000000000..a6254b18d --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/demo/sayHello.dart @@ -0,0 +1,1733 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i11; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/exceptions/demo.dart' as _i10; +import 'package:celest_backend/models/demo.dart' as _i5; +import 'package:celest_backend/src/functions/demo.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i12; +import 'package:celest_core/src/serialization/json_value.dart' as _i13; +import 'package:shelf/shelf.dart' as _i2; + +final class SayHelloTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'sayHello'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = await _i3.sayHello( + person: _i4.Serializers.instance.deserialize<_i5.Person>( + request[r'person'], + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(response), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.BadNameException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'api.v1.BadNameException', + 'value': _i4.Serializers.instance + .serialize<_i10.BadNameException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i11.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i12.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i12.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i11.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i11.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.BadNameException, Map>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return _i10.BadNameException(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.Person, Map>( + serialize: ($value) => {r'name': $value.name}, + deserialize: ($serialized) { + return _i5.Person(name: ($serialized[r'name'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i12.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i13.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': SayHelloTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/exceptions/throwsCustomError.dart b/apps/cli/fixtures/legacy/api/goldens/functions/exceptions/throwsCustomError.dart new file mode 100644 index 000000000..30ec3e2a8 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/exceptions/throwsCustomError.dart @@ -0,0 +1,1898 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/exceptions/exceptions.dart' as _i9; +import 'package:celest_backend/src/functions/exceptions.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class ThrowsCustomErrorTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'throwsCustomError'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + _i3.throwsCustomError(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(null), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.CustomErrorToFromJson catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'api.v1.CustomErrorToFromJson', + 'value': _i4.Serializers.instance + .serialize<_i9.CustomErrorToFromJson>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.CustomError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'api.v1.CustomError', + 'value': _i4.Serializers.instance.serialize<_i9.CustomError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.CustomErrorWithStackTrace catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'api.v1.CustomErrorWithStackTrace', + 'value': _i4.Serializers.instance + .serialize<_i9.CustomErrorWithStackTrace>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.CustomExceptionToFromJson catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'api.v1.CustomExceptionToFromJson', + 'value': _i4.Serializers.instance + .serialize<_i9.CustomExceptionToFromJson>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.CustomException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'api.v1.CustomException', + 'value': _i4.Serializers.instance.serialize<_i9.CustomException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.CustomError, Map?>( + serialize: + ($value) => { + r'message': $value.message, + r'additionalInfo': _i4.Serializers.instance + .serialize<_i12.JsonMap>( + $value.additionalInfo, + const _i4.TypeToken<_i12.JsonMap>('JsonMap'), + ), + }, + deserialize: ($serialized) { + return _i9.CustomError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.CustomErrorToFromJson, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i9.CustomErrorToFromJson.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.CustomErrorWithStackTrace, + Map? + >( + serialize: + ($value) => { + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + r'message': $value.message, + r'additionalInfo': $value.additionalInfo, + }, + deserialize: ($serialized) { + return _i9.CustomErrorWithStackTrace( + stackTrace: _i4.Serializers.instance.deserialize( + $serialized?[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.CustomException, Map?>( + serialize: + ($value) => { + r'message': $value.message, + r'additionalInfo': _i4.Serializers.instance + .serialize<_i12.JsonMap>( + $value.additionalInfo, + const _i4.TypeToken<_i12.JsonMap>('JsonMap'), + ), + }, + deserialize: ($serialized) { + return _i9.CustomException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.CustomExceptionToFromJson, + Map + >( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i9.CustomExceptionToFromJson.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonMap, Map>( + serialize: ($value) => $value, + deserialize: ($serialized) { + return _i12.JsonMap(($serialized as Map)); + }, + ), + const _i4.TypeToken<_i12.JsonMap>('JsonMap'), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': ThrowsCustomErrorTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/exceptions/throwsCustomErrorToFromJson.dart b/apps/cli/fixtures/legacy/api/goldens/functions/exceptions/throwsCustomErrorToFromJson.dart new file mode 100644 index 000000000..862f1ca00 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/exceptions/throwsCustomErrorToFromJson.dart @@ -0,0 +1,1899 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/exceptions/exceptions.dart' as _i9; +import 'package:celest_backend/src/functions/exceptions.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class ThrowsCustomErrorToFromJsonTarget + extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'throwsCustomErrorToFromJson'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + _i3.throwsCustomErrorToFromJson(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(null), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.CustomErrorToFromJson catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'api.v1.CustomErrorToFromJson', + 'value': _i4.Serializers.instance + .serialize<_i9.CustomErrorToFromJson>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.CustomError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'api.v1.CustomError', + 'value': _i4.Serializers.instance.serialize<_i9.CustomError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.CustomErrorWithStackTrace catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'api.v1.CustomErrorWithStackTrace', + 'value': _i4.Serializers.instance + .serialize<_i9.CustomErrorWithStackTrace>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.CustomExceptionToFromJson catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'api.v1.CustomExceptionToFromJson', + 'value': _i4.Serializers.instance + .serialize<_i9.CustomExceptionToFromJson>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.CustomException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'api.v1.CustomException', + 'value': _i4.Serializers.instance.serialize<_i9.CustomException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.CustomError, Map?>( + serialize: + ($value) => { + r'message': $value.message, + r'additionalInfo': _i4.Serializers.instance + .serialize<_i12.JsonMap>( + $value.additionalInfo, + const _i4.TypeToken<_i12.JsonMap>('JsonMap'), + ), + }, + deserialize: ($serialized) { + return _i9.CustomError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.CustomErrorToFromJson, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i9.CustomErrorToFromJson.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.CustomErrorWithStackTrace, + Map? + >( + serialize: + ($value) => { + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + r'message': $value.message, + r'additionalInfo': $value.additionalInfo, + }, + deserialize: ($serialized) { + return _i9.CustomErrorWithStackTrace( + stackTrace: _i4.Serializers.instance.deserialize( + $serialized?[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.CustomException, Map?>( + serialize: + ($value) => { + r'message': $value.message, + r'additionalInfo': _i4.Serializers.instance + .serialize<_i12.JsonMap>( + $value.additionalInfo, + const _i4.TypeToken<_i12.JsonMap>('JsonMap'), + ), + }, + deserialize: ($serialized) { + return _i9.CustomException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.CustomExceptionToFromJson, + Map + >( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i9.CustomExceptionToFromJson.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonMap, Map>( + serialize: ($value) => $value, + deserialize: ($serialized) { + return _i12.JsonMap(($serialized as Map)); + }, + ), + const _i4.TypeToken<_i12.JsonMap>('JsonMap'), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': ThrowsCustomErrorToFromJsonTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/exceptions/throwsCustomErrorWithStackTrace.dart b/apps/cli/fixtures/legacy/api/goldens/functions/exceptions/throwsCustomErrorWithStackTrace.dart new file mode 100644 index 000000000..b2be15d6d --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/exceptions/throwsCustomErrorWithStackTrace.dart @@ -0,0 +1,1899 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/exceptions/exceptions.dart' as _i9; +import 'package:celest_backend/src/functions/exceptions.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class ThrowsCustomErrorWithStackTraceTarget + extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'throwsCustomErrorWithStackTrace'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + _i3.throwsCustomErrorWithStackTrace(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(null), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.CustomErrorToFromJson catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'api.v1.CustomErrorToFromJson', + 'value': _i4.Serializers.instance + .serialize<_i9.CustomErrorToFromJson>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.CustomError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'api.v1.CustomError', + 'value': _i4.Serializers.instance.serialize<_i9.CustomError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.CustomErrorWithStackTrace catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'api.v1.CustomErrorWithStackTrace', + 'value': _i4.Serializers.instance + .serialize<_i9.CustomErrorWithStackTrace>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.CustomExceptionToFromJson catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'api.v1.CustomExceptionToFromJson', + 'value': _i4.Serializers.instance + .serialize<_i9.CustomExceptionToFromJson>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.CustomException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'api.v1.CustomException', + 'value': _i4.Serializers.instance.serialize<_i9.CustomException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.CustomError, Map?>( + serialize: + ($value) => { + r'message': $value.message, + r'additionalInfo': _i4.Serializers.instance + .serialize<_i12.JsonMap>( + $value.additionalInfo, + const _i4.TypeToken<_i12.JsonMap>('JsonMap'), + ), + }, + deserialize: ($serialized) { + return _i9.CustomError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.CustomErrorToFromJson, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i9.CustomErrorToFromJson.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.CustomErrorWithStackTrace, + Map? + >( + serialize: + ($value) => { + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + r'message': $value.message, + r'additionalInfo': $value.additionalInfo, + }, + deserialize: ($serialized) { + return _i9.CustomErrorWithStackTrace( + stackTrace: _i4.Serializers.instance.deserialize( + $serialized?[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.CustomException, Map?>( + serialize: + ($value) => { + r'message': $value.message, + r'additionalInfo': _i4.Serializers.instance + .serialize<_i12.JsonMap>( + $value.additionalInfo, + const _i4.TypeToken<_i12.JsonMap>('JsonMap'), + ), + }, + deserialize: ($serialized) { + return _i9.CustomException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.CustomExceptionToFromJson, + Map + >( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i9.CustomExceptionToFromJson.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonMap, Map>( + serialize: ($value) => $value, + deserialize: ($serialized) { + return _i12.JsonMap(($serialized as Map)); + }, + ), + const _i4.TypeToken<_i12.JsonMap>('JsonMap'), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': ThrowsCustomErrorWithStackTraceTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/exceptions/throwsCustomException.dart b/apps/cli/fixtures/legacy/api/goldens/functions/exceptions/throwsCustomException.dart new file mode 100644 index 000000000..c8387fc14 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/exceptions/throwsCustomException.dart @@ -0,0 +1,1898 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/exceptions/exceptions.dart' as _i9; +import 'package:celest_backend/src/functions/exceptions.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class ThrowsCustomExceptionTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'throwsCustomException'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + _i3.throwsCustomException(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(null), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.CustomErrorToFromJson catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'api.v1.CustomErrorToFromJson', + 'value': _i4.Serializers.instance + .serialize<_i9.CustomErrorToFromJson>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.CustomError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'api.v1.CustomError', + 'value': _i4.Serializers.instance.serialize<_i9.CustomError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.CustomErrorWithStackTrace catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'api.v1.CustomErrorWithStackTrace', + 'value': _i4.Serializers.instance + .serialize<_i9.CustomErrorWithStackTrace>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.CustomExceptionToFromJson catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'api.v1.CustomExceptionToFromJson', + 'value': _i4.Serializers.instance + .serialize<_i9.CustomExceptionToFromJson>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.CustomException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'api.v1.CustomException', + 'value': _i4.Serializers.instance.serialize<_i9.CustomException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.CustomError, Map?>( + serialize: + ($value) => { + r'message': $value.message, + r'additionalInfo': _i4.Serializers.instance + .serialize<_i12.JsonMap>( + $value.additionalInfo, + const _i4.TypeToken<_i12.JsonMap>('JsonMap'), + ), + }, + deserialize: ($serialized) { + return _i9.CustomError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.CustomErrorToFromJson, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i9.CustomErrorToFromJson.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.CustomErrorWithStackTrace, + Map? + >( + serialize: + ($value) => { + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + r'message': $value.message, + r'additionalInfo': $value.additionalInfo, + }, + deserialize: ($serialized) { + return _i9.CustomErrorWithStackTrace( + stackTrace: _i4.Serializers.instance.deserialize( + $serialized?[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.CustomException, Map?>( + serialize: + ($value) => { + r'message': $value.message, + r'additionalInfo': _i4.Serializers.instance + .serialize<_i12.JsonMap>( + $value.additionalInfo, + const _i4.TypeToken<_i12.JsonMap>('JsonMap'), + ), + }, + deserialize: ($serialized) { + return _i9.CustomException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.CustomExceptionToFromJson, + Map + >( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i9.CustomExceptionToFromJson.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonMap, Map>( + serialize: ($value) => $value, + deserialize: ($serialized) { + return _i12.JsonMap(($serialized as Map)); + }, + ), + const _i4.TypeToken<_i12.JsonMap>('JsonMap'), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': ThrowsCustomExceptionTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/exceptions/throwsCustomExceptionToFromJson.dart b/apps/cli/fixtures/legacy/api/goldens/functions/exceptions/throwsCustomExceptionToFromJson.dart new file mode 100644 index 000000000..b89089ebe --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/exceptions/throwsCustomExceptionToFromJson.dart @@ -0,0 +1,1899 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/exceptions/exceptions.dart' as _i9; +import 'package:celest_backend/src/functions/exceptions.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class ThrowsCustomExceptionToFromJsonTarget + extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'throwsCustomExceptionToFromJson'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + _i3.throwsCustomExceptionToFromJson(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(null), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.CustomErrorToFromJson catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'api.v1.CustomErrorToFromJson', + 'value': _i4.Serializers.instance + .serialize<_i9.CustomErrorToFromJson>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.CustomError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'api.v1.CustomError', + 'value': _i4.Serializers.instance.serialize<_i9.CustomError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.CustomErrorWithStackTrace catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'api.v1.CustomErrorWithStackTrace', + 'value': _i4.Serializers.instance + .serialize<_i9.CustomErrorWithStackTrace>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.CustomExceptionToFromJson catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'api.v1.CustomExceptionToFromJson', + 'value': _i4.Serializers.instance + .serialize<_i9.CustomExceptionToFromJson>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.CustomException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'api.v1.CustomException', + 'value': _i4.Serializers.instance.serialize<_i9.CustomException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.CustomError, Map?>( + serialize: + ($value) => { + r'message': $value.message, + r'additionalInfo': _i4.Serializers.instance + .serialize<_i12.JsonMap>( + $value.additionalInfo, + const _i4.TypeToken<_i12.JsonMap>('JsonMap'), + ), + }, + deserialize: ($serialized) { + return _i9.CustomError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.CustomErrorToFromJson, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i9.CustomErrorToFromJson.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.CustomErrorWithStackTrace, + Map? + >( + serialize: + ($value) => { + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + r'message': $value.message, + r'additionalInfo': $value.additionalInfo, + }, + deserialize: ($serialized) { + return _i9.CustomErrorWithStackTrace( + stackTrace: _i4.Serializers.instance.deserialize( + $serialized?[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.CustomException, Map?>( + serialize: + ($value) => { + r'message': $value.message, + r'additionalInfo': _i4.Serializers.instance + .serialize<_i12.JsonMap>( + $value.additionalInfo, + const _i4.TypeToken<_i12.JsonMap>('JsonMap'), + ), + }, + deserialize: ($serialized) { + return _i9.CustomException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.CustomExceptionToFromJson, + Map + >( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i9.CustomExceptionToFromJson.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonMap, Map>( + serialize: ($value) => $value, + deserialize: ($serialized) { + return _i12.JsonMap(($serialized as Map)); + }, + ), + const _i4.TypeToken<_i12.JsonMap>('JsonMap'), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': ThrowsCustomExceptionToFromJsonTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/exceptions/throwsError.dart b/apps/cli/fixtures/legacy/api/goldens/functions/exceptions/throwsError.dart new file mode 100644 index 000000000..9e6d42286 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/exceptions/throwsError.dart @@ -0,0 +1,1911 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i11; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/exceptions/exceptions.dart' as _i10; +import 'package:celest_backend/models/exceptions.dart' as _i5; +import 'package:celest_backend/src/functions/exceptions.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i12; +import 'package:celest_core/src/serialization/json_value.dart' as _i13; +import 'package:shelf/shelf.dart' as _i2; + +final class ThrowsErrorTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'throwsError'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + _i3.throwsError( + type: _i4.Serializers.instance.deserialize<_i5.SupportedErrorType>( + request[r'type'], + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(null), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomErrorToFromJson catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'api.v1.CustomErrorToFromJson', + 'value': _i4.Serializers.instance + .serialize<_i10.CustomErrorToFromJson>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'api.v1.CustomError', + 'value': _i4.Serializers.instance.serialize<_i10.CustomError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomErrorWithStackTrace catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'api.v1.CustomErrorWithStackTrace', + 'value': _i4.Serializers.instance + .serialize<_i10.CustomErrorWithStackTrace>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomExceptionToFromJson catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'api.v1.CustomExceptionToFromJson', + 'value': _i4.Serializers.instance + .serialize<_i10.CustomExceptionToFromJson>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'api.v1.CustomException', + 'value': _i4.Serializers.instance.serialize<_i10.CustomException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i11.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i12.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i12.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i11.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i11.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.CustomError, Map?>( + serialize: + ($value) => { + r'message': $value.message, + r'additionalInfo': _i4.Serializers.instance + .serialize<_i13.JsonMap>( + $value.additionalInfo, + const _i4.TypeToken<_i13.JsonMap>('JsonMap'), + ), + }, + deserialize: ($serialized) { + return _i10.CustomError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.CustomErrorToFromJson, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i10.CustomErrorToFromJson.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.CustomErrorWithStackTrace, + Map? + >( + serialize: + ($value) => { + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + r'message': $value.message, + r'additionalInfo': $value.additionalInfo, + }, + deserialize: ($serialized) { + return _i10.CustomErrorWithStackTrace( + stackTrace: _i4.Serializers.instance.deserialize( + $serialized?[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.CustomException, Map?>( + serialize: + ($value) => { + r'message': $value.message, + r'additionalInfo': _i4.Serializers.instance + .serialize<_i13.JsonMap>( + $value.additionalInfo, + const _i4.TypeToken<_i13.JsonMap>('JsonMap'), + ), + }, + deserialize: ($serialized) { + return _i10.CustomException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.CustomExceptionToFromJson, + Map + >( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i10.CustomExceptionToFromJson.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.SupportedErrorType, String>( + serialize: ($value) => $value.name, + deserialize: ($serialized) { + return _i5.SupportedErrorType.values.byName($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i12.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.JsonMap, Map>( + serialize: ($value) => $value, + deserialize: ($serialized) { + return _i13.JsonMap(($serialized as Map)); + }, + ), + const _i4.TypeToken<_i13.JsonMap>('JsonMap'), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i13.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': ThrowsErrorTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/exceptions/throwsException.dart b/apps/cli/fixtures/legacy/api/goldens/functions/exceptions/throwsException.dart new file mode 100644 index 000000000..ce4ba7a70 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/exceptions/throwsException.dart @@ -0,0 +1,1911 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i11; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/exceptions/exceptions.dart' as _i10; +import 'package:celest_backend/models/exceptions.dart' as _i5; +import 'package:celest_backend/src/functions/exceptions.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i12; +import 'package:celest_core/src/serialization/json_value.dart' as _i13; +import 'package:shelf/shelf.dart' as _i2; + +final class ThrowsExceptionTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'throwsException'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + _i3.throwsException( + type: _i4.Serializers.instance.deserialize<_i5.SupportedExceptionType>( + request[r'type'], + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(null), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomErrorToFromJson catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'api.v1.CustomErrorToFromJson', + 'value': _i4.Serializers.instance + .serialize<_i10.CustomErrorToFromJson>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'api.v1.CustomError', + 'value': _i4.Serializers.instance.serialize<_i10.CustomError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomErrorWithStackTrace catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'api.v1.CustomErrorWithStackTrace', + 'value': _i4.Serializers.instance + .serialize<_i10.CustomErrorWithStackTrace>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomExceptionToFromJson catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'api.v1.CustomExceptionToFromJson', + 'value': _i4.Serializers.instance + .serialize<_i10.CustomExceptionToFromJson>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'api.v1.CustomException', + 'value': _i4.Serializers.instance.serialize<_i10.CustomException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i11.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i12.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i12.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i11.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i11.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.CustomError, Map?>( + serialize: + ($value) => { + r'message': $value.message, + r'additionalInfo': _i4.Serializers.instance + .serialize<_i13.JsonMap>( + $value.additionalInfo, + const _i4.TypeToken<_i13.JsonMap>('JsonMap'), + ), + }, + deserialize: ($serialized) { + return _i10.CustomError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.CustomErrorToFromJson, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i10.CustomErrorToFromJson.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.CustomErrorWithStackTrace, + Map? + >( + serialize: + ($value) => { + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + r'message': $value.message, + r'additionalInfo': $value.additionalInfo, + }, + deserialize: ($serialized) { + return _i10.CustomErrorWithStackTrace( + stackTrace: _i4.Serializers.instance.deserialize( + $serialized?[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.CustomException, Map?>( + serialize: + ($value) => { + r'message': $value.message, + r'additionalInfo': _i4.Serializers.instance + .serialize<_i13.JsonMap>( + $value.additionalInfo, + const _i4.TypeToken<_i13.JsonMap>('JsonMap'), + ), + }, + deserialize: ($serialized) { + return _i10.CustomException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.CustomExceptionToFromJson, + Map + >( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i10.CustomExceptionToFromJson.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.SupportedExceptionType, String>( + serialize: ($value) => $value.name, + deserialize: ($serialized) { + return _i5.SupportedExceptionType.values.byName($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i12.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.JsonMap, Map>( + serialize: ($value) => $value, + deserialize: ($serialized) { + return _i13.JsonMap(($serialized as Map)); + }, + ), + const _i4.TypeToken<_i13.JsonMap>('JsonMap'), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i13.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': ThrowsExceptionTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/asyncOrString.dart b/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/asyncOrString.dart new file mode 100644 index 000000000..e5743dadf --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/asyncOrString.dart @@ -0,0 +1,1705 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/extension_types.dart' as _i5; +import 'package:celest_backend/src/functions/extension_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class AsyncOrStringTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'asyncOrString'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = await _i3.asyncOrString( + _i4.Serializers.instance.deserialize<_i5.StringX>( + request[r's'], + const _i4.TypeToken<_i5.StringX>('StringX'), + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.StringX>( + response, + const _i4.TypeToken<_i5.StringX>('StringX'), + ), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.StringX, String>( + serialize: ($value) => $value.s, + deserialize: ($serialized) { + return _i5.StringX(($serialized as String)); + }, + ), + const _i4.TypeToken<_i5.StringX>('StringX'), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': AsyncOrStringTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/asyncString.dart b/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/asyncString.dart new file mode 100644 index 000000000..2fc476cce --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/asyncString.dart @@ -0,0 +1,1705 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/extension_types.dart' as _i5; +import 'package:celest_backend/src/functions/extension_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class AsyncStringTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'asyncString'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = await _i3.asyncString( + _i4.Serializers.instance.deserialize<_i5.StringX>( + request[r's'], + const _i4.TypeToken<_i5.StringX>('StringX'), + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.StringX>( + response, + const _i4.TypeToken<_i5.StringX>('StringX'), + ), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.StringX, String>( + serialize: ($value) => $value.s, + deserialize: ($serialized) { + return _i5.StringX(($serialized as String)); + }, + ), + const _i4.TypeToken<_i5.StringX>('StringX'), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': AsyncStringTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/color.dart b/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/color.dart new file mode 100644 index 000000000..112044ffa --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/color.dart @@ -0,0 +1,1698 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/extension_types.dart' as _i5; +import 'package:celest_backend/src/functions/extension_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class ColorTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'color'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.color( + _i4.Serializers.instance.deserialize<_i5.Color>(request[r'color']), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.Color>(response), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.Color, String>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i5.Color.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': ColorTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/colorX.dart b/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/colorX.dart new file mode 100644 index 000000000..8dab35249 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/colorX.dart @@ -0,0 +1,1725 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/extension_types.dart' as _i5; +import 'package:celest_backend/src/functions/extension_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class ColorXTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'colorX'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.colorX( + _i4.Serializers.instance.deserialize<_i5.ColorX>( + request[r'color'], + const _i4.TypeToken<_i5.ColorX>('ColorX'), + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.ColorX>( + response, + const _i4.TypeToken<_i5.ColorX>('ColorX'), + ), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + ColorXSerializer(), + const _i4.TypeToken<_i5.ColorX>('ColorX'), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': ColorXTarget()}, + setup: (_i7.Context context) async {}, + ); +} + +final class ColorXSerializer extends _i4.Serializer<_i5.ColorX> { + ColorXSerializer() { + $serializers..put( + _i4.Serializer.define<_i5.Color, String>( + serialize: ($value) => $value.name, + deserialize: ($serialized) { + return _i5.Color.values.byName($serialized); + }, + ), + ); + } + + final _i4.Serializers $serializers = _i4.Serializers(); + + @override + _i5.ColorX deserialize(Object? $value) { + final $serialized = assertWireType($value); + return _i5.ColorX($serializers.deserialize<_i5.Color>($serialized)); + } + + @override + Object? serialize(_i5.ColorX $value) => + $serializers.serialize<_i5.Color>($value.c); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/colorXFromJson.dart b/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/colorXFromJson.dart new file mode 100644 index 000000000..4d3d4aa21 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/colorXFromJson.dart @@ -0,0 +1,1726 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/extension_types.dart' as _i5; +import 'package:celest_backend/src/functions/extension_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class ColorXFromJsonTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'colorXFromJson'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.colorXFromJson( + _i4.Serializers.instance.deserialize<_i5.ColorXFromJson>( + request[r'color'], + const _i4.TypeToken<_i5.ColorXFromJson>('ColorXFromJson'), + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.ColorXFromJson>( + response, + const _i4.TypeToken<_i5.ColorXFromJson>('ColorXFromJson'), + ), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + ColorXFromJsonSerializer(), + const _i4.TypeToken<_i5.ColorXFromJson>('ColorXFromJson'), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': ColorXFromJsonTarget()}, + setup: (_i7.Context context) async {}, + ); +} + +final class ColorXFromJsonSerializer + extends _i4.Serializer<_i5.ColorXFromJson> { + ColorXFromJsonSerializer() { + $serializers..put( + _i4.Serializer.define<_i5.Color, String>( + serialize: ($value) => $value.name, + deserialize: ($serialized) { + return _i5.Color.values.byName($serialized); + }, + ), + ); + } + + final _i4.Serializers $serializers = _i4.Serializers(); + + @override + _i5.ColorXFromJson deserialize(Object? $value) { + final $serialized = assertWireType($value); + return _i5.ColorXFromJson.fromJson($serialized); + } + + @override + Object? serialize(_i5.ColorXFromJson $value) => + $serializers.serialize<_i5.Color>($value.c); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/colorXFromJsonImpl.dart b/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/colorXFromJsonImpl.dart new file mode 100644 index 000000000..848a16350 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/colorXFromJsonImpl.dart @@ -0,0 +1,1725 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/extension_types.dart' as _i5; +import 'package:celest_backend/src/functions/extension_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class ColorXFromJsonImplTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'colorXFromJsonImpl'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.colorXFromJsonImpl( + _i4.Serializers.instance.deserialize<_i5.ColorXFromJsonImpl>( + request[r'color'], + const _i4.TypeToken<_i5.ColorXFromJsonImpl>('ColorXFromJsonImpl'), + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.ColorXFromJsonImpl>( + response, + const _i4.TypeToken<_i5.ColorXFromJsonImpl>('ColorXFromJsonImpl'), + ), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + ColorXFromJsonImplSerializer(), + const _i4.TypeToken<_i5.ColorXFromJsonImpl>('ColorXFromJsonImpl'), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': ColorXFromJsonImplTarget()}, + setup: (_i7.Context context) async {}, + ); +} + +final class ColorXFromJsonImplSerializer + extends _i4.Serializer<_i5.ColorXFromJsonImpl> { + ColorXFromJsonImplSerializer() { + $serializers..put( + _i4.Serializer.define<_i5.Color, String>( + serialize: ($value) => $value.name, + deserialize: ($serialized) { + return _i5.Color.values.byName($serialized); + }, + ), + ); + } + + final _i4.Serializers $serializers = _i4.Serializers(); + + @override + _i5.ColorXFromJsonImpl deserialize(Object? $value) { + final $serialized = assertWireType($value); + return _i5.ColorXFromJsonImpl.fromJson($serialized); + } + + @override + Object? serialize(_i5.ColorXFromJsonImpl $value) => $value.toJson(); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/colorXFromJsonStatic.dart b/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/colorXFromJsonStatic.dart new file mode 100644 index 000000000..562197c2b --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/colorXFromJsonStatic.dart @@ -0,0 +1,1728 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/extension_types.dart' as _i5; +import 'package:celest_backend/src/functions/extension_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class ColorXFromJsonStaticTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'colorXFromJsonStatic'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.colorXFromJsonStatic( + _i4.Serializers.instance.deserialize<_i5.ColorXFromJsonStatic>( + request[r'color'], + const _i4.TypeToken<_i5.ColorXFromJsonStatic>('ColorXFromJsonStatic'), + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.ColorXFromJsonStatic>( + response, + const _i4.TypeToken<_i5.ColorXFromJsonStatic>( + 'ColorXFromJsonStatic', + ), + ), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + ColorXFromJsonStaticSerializer(), + const _i4.TypeToken<_i5.ColorXFromJsonStatic>('ColorXFromJsonStatic'), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': ColorXFromJsonStaticTarget()}, + setup: (_i7.Context context) async {}, + ); +} + +final class ColorXFromJsonStaticSerializer + extends _i4.Serializer<_i5.ColorXFromJsonStatic> { + ColorXFromJsonStaticSerializer() { + $serializers..put( + _i4.Serializer.define<_i5.Color, String>( + serialize: ($value) => $value.name, + deserialize: ($serialized) { + return _i5.Color.values.byName($serialized); + }, + ), + ); + } + + final _i4.Serializers $serializers = _i4.Serializers(); + + @override + _i5.ColorXFromJsonStatic deserialize(Object? $value) { + final $serialized = assertWireType($value); + return _i5.ColorXFromJsonStatic.fromJson($serialized); + } + + @override + Object? serialize(_i5.ColorXFromJsonStatic $value) => + $serializers.serialize<_i5.Color>($value.c); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/colorXImpl.dart b/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/colorXImpl.dart new file mode 100644 index 000000000..8e1e76aaa --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/colorXImpl.dart @@ -0,0 +1,1725 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/extension_types.dart' as _i5; +import 'package:celest_backend/src/functions/extension_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class ColorXImplTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'colorXImpl'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.colorXImpl( + _i4.Serializers.instance.deserialize<_i5.ColorXImpl>( + request[r'color'], + const _i4.TypeToken<_i5.ColorXImpl>('ColorXImpl'), + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.ColorXImpl>( + response, + const _i4.TypeToken<_i5.ColorXImpl>('ColorXImpl'), + ), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + ColorXImplSerializer(), + const _i4.TypeToken<_i5.ColorXImpl>('ColorXImpl'), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': ColorXImplTarget()}, + setup: (_i7.Context context) async {}, + ); +} + +final class ColorXImplSerializer extends _i4.Serializer<_i5.ColorXImpl> { + ColorXImplSerializer() { + $serializers..put( + _i4.Serializer.define<_i5.Color, String>( + serialize: ($value) => $value.name, + deserialize: ($serialized) { + return _i5.Color.values.byName($serialized); + }, + ), + ); + } + + final _i4.Serializers $serializers = _i4.Serializers(); + + @override + _i5.ColorXImpl deserialize(Object? $value) { + final $serialized = assertWireType($value); + return _i5.ColorXImpl($serializers.deserialize<_i5.Color>($serialized)); + } + + @override + Object? serialize(_i5.ColorXImpl $value) => + $serializers.serialize<_i5.Color>($value); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/colorXToFromJson.dart b/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/colorXToFromJson.dart new file mode 100644 index 000000000..5c12669f0 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/colorXToFromJson.dart @@ -0,0 +1,1725 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/extension_types.dart' as _i5; +import 'package:celest_backend/src/functions/extension_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class ColorXToFromJsonTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'colorXToFromJson'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.colorXToFromJson( + _i4.Serializers.instance.deserialize<_i5.ColorXToFromJson>( + request[r'color'], + const _i4.TypeToken<_i5.ColorXToFromJson>('ColorXToFromJson'), + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.ColorXToFromJson>( + response, + const _i4.TypeToken<_i5.ColorXToFromJson>('ColorXToFromJson'), + ), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + ColorXToFromJsonSerializer(), + const _i4.TypeToken<_i5.ColorXToFromJson>('ColorXToFromJson'), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': ColorXToFromJsonTarget()}, + setup: (_i7.Context context) async {}, + ); +} + +final class ColorXToFromJsonSerializer + extends _i4.Serializer<_i5.ColorXToFromJson> { + ColorXToFromJsonSerializer() { + $serializers..put( + _i4.Serializer.define<_i5.Color, String>( + serialize: ($value) => $value.name, + deserialize: ($serialized) { + return _i5.Color.values.byName($serialized); + }, + ), + ); + } + + final _i4.Serializers $serializers = _i4.Serializers(); + + @override + _i5.ColorXToFromJson deserialize(Object? $value) { + final $serialized = assertWireType($value); + return _i5.ColorXToFromJson.fromJson($serialized); + } + + @override + Object? serialize(_i5.ColorXToFromJson $value) => $value.toJson(); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/colorXToJson.dart b/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/colorXToJson.dart new file mode 100644 index 000000000..8e9b43966 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/colorXToJson.dart @@ -0,0 +1,1724 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/extension_types.dart' as _i5; +import 'package:celest_backend/src/functions/extension_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class ColorXToJsonTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'colorXToJson'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.colorXToJson( + _i4.Serializers.instance.deserialize<_i5.ColorXToJson>( + request[r'color'], + const _i4.TypeToken<_i5.ColorXToJson>('ColorXToJson'), + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.ColorXToJson>( + response, + const _i4.TypeToken<_i5.ColorXToJson>('ColorXToJson'), + ), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + ColorXToJsonSerializer(), + const _i4.TypeToken<_i5.ColorXToJson>('ColorXToJson'), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': ColorXToJsonTarget()}, + setup: (_i7.Context context) async {}, + ); +} + +final class ColorXToJsonSerializer extends _i4.Serializer<_i5.ColorXToJson> { + ColorXToJsonSerializer() { + $serializers..put( + _i4.Serializer.define<_i5.Color, String>( + serialize: ($value) => $value.name, + deserialize: ($serialized) { + return _i5.Color.values.byName($serialized); + }, + ), + ); + } + + final _i4.Serializers $serializers = _i4.Serializers(); + + @override + _i5.ColorXToJson deserialize(Object? $value) { + final $serialized = assertWireType($value); + return _i5.ColorXToJson($serializers.deserialize<_i5.Color>($serialized)); + } + + @override + Object? serialize(_i5.ColorXToJson $value) => $value.toJson(); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/colorXToJsonImpl.dart b/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/colorXToJsonImpl.dart new file mode 100644 index 000000000..3dab4d817 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/colorXToJsonImpl.dart @@ -0,0 +1,1727 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/extension_types.dart' as _i5; +import 'package:celest_backend/src/functions/extension_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class ColorXToJsonImplTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'colorXToJsonImpl'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.colorXToJsonImpl( + _i4.Serializers.instance.deserialize<_i5.ColorXToJsonImpl>( + request[r'color'], + const _i4.TypeToken<_i5.ColorXToJsonImpl>('ColorXToJsonImpl'), + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.ColorXToJsonImpl>( + response, + const _i4.TypeToken<_i5.ColorXToJsonImpl>('ColorXToJsonImpl'), + ), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + ColorXToJsonImplSerializer(), + const _i4.TypeToken<_i5.ColorXToJsonImpl>('ColorXToJsonImpl'), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': ColorXToJsonImplTarget()}, + setup: (_i7.Context context) async {}, + ); +} + +final class ColorXToJsonImplSerializer + extends _i4.Serializer<_i5.ColorXToJsonImpl> { + ColorXToJsonImplSerializer() { + $serializers..put( + _i4.Serializer.define<_i5.Color, String>( + serialize: ($value) => $value.name, + deserialize: ($serialized) { + return _i5.Color.values.byName($serialized); + }, + ), + ); + } + + final _i4.Serializers $serializers = _i4.Serializers(); + + @override + _i5.ColorXToJsonImpl deserialize(Object? $value) { + final $serialized = assertWireType($value); + return _i5.ColorXToJsonImpl( + $serializers.deserialize<_i5.Color>($serialized), + ); + } + + @override + Object? serialize(_i5.ColorXToJsonImpl $value) => $value.toJson(); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/jsonBool.dart b/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/jsonBool.dart new file mode 100644 index 000000000..c8a248856 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/jsonBool.dart @@ -0,0 +1,1704 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/extension_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i5; +import 'package:shelf/shelf.dart' as _i2; + +final class JsonBoolTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'jsonBool'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.jsonBool( + _i4.Serializers.instance.deserialize<_i5.JsonBool>( + request[r'value'], + const _i4.TypeToken<_i5.JsonBool>('JsonBool'), + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.JsonBool>( + response, + const _i4.TypeToken<_i5.JsonBool>('JsonBool'), + ), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.JsonBool, bool>( + serialize: ($value) => $value, + deserialize: ($serialized) { + return _i5.JsonBool(($serialized as bool)); + }, + ), + const _i4.TypeToken<_i5.JsonBool>('JsonBool'), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i5.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': JsonBoolTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/jsonDouble.dart b/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/jsonDouble.dart new file mode 100644 index 000000000..3e4c2a3f8 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/jsonDouble.dart @@ -0,0 +1,1704 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/extension_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i5; +import 'package:shelf/shelf.dart' as _i2; + +final class JsonDoubleTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'jsonDouble'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.jsonDouble( + _i4.Serializers.instance.deserialize<_i5.JsonDouble>( + request[r'value'], + const _i4.TypeToken<_i5.JsonDouble>('JsonDouble'), + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.JsonDouble>( + response, + const _i4.TypeToken<_i5.JsonDouble>('JsonDouble'), + ), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.JsonDouble, double>( + serialize: ($value) => $value, + deserialize: ($serialized) { + return _i5.JsonDouble(($serialized as num).toDouble()); + }, + ), + const _i4.TypeToken<_i5.JsonDouble>('JsonDouble'), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i5.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': JsonDoubleTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/jsonInt.dart b/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/jsonInt.dart new file mode 100644 index 000000000..2dc2847c4 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/jsonInt.dart @@ -0,0 +1,1704 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/extension_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i5; +import 'package:shelf/shelf.dart' as _i2; + +final class JsonIntTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'jsonInt'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.jsonInt( + _i4.Serializers.instance.deserialize<_i5.JsonInt>( + request[r'value'], + const _i4.TypeToken<_i5.JsonInt>('JsonInt'), + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.JsonInt>( + response, + const _i4.TypeToken<_i5.JsonInt>('JsonInt'), + ), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.JsonInt, int>( + serialize: ($value) => $value, + deserialize: ($serialized) { + return _i5.JsonInt(($serialized as num).toInt()); + }, + ), + const _i4.TypeToken<_i5.JsonInt>('JsonInt'), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i5.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': JsonIntTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/jsonList.dart b/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/jsonList.dart new file mode 100644 index 000000000..7d3e826ad --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/jsonList.dart @@ -0,0 +1,1704 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/extension_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i5; +import 'package:shelf/shelf.dart' as _i2; + +final class JsonListTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'jsonList'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.jsonList( + _i4.Serializers.instance.deserialize<_i5.JsonList>( + request[r'value'], + const _i4.TypeToken<_i5.JsonList>('JsonList'), + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.JsonList>( + response, + const _i4.TypeToken<_i5.JsonList>('JsonList'), + ), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.JsonList, List>( + serialize: ($value) => $value, + deserialize: ($serialized) { + return _i5.JsonList(($serialized as Iterable).toList()); + }, + ), + const _i4.TypeToken<_i5.JsonList>('JsonList'), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i5.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': JsonListTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/jsonMap.dart b/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/jsonMap.dart new file mode 100644 index 000000000..e9e484152 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/jsonMap.dart @@ -0,0 +1,1704 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/extension_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i5; +import 'package:shelf/shelf.dart' as _i2; + +final class JsonMapTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'jsonMap'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.jsonMap( + _i4.Serializers.instance.deserialize<_i5.JsonMap>( + request[r'value'], + const _i4.TypeToken<_i5.JsonMap>('JsonMap'), + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.JsonMap>( + response, + const _i4.TypeToken<_i5.JsonMap>('JsonMap'), + ), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.JsonMap, Map>( + serialize: ($value) => $value, + deserialize: ($serialized) { + return _i5.JsonMap(($serialized as Map)); + }, + ), + const _i4.TypeToken<_i5.JsonMap>('JsonMap'), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i5.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': JsonMapTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/jsonNum.dart b/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/jsonNum.dart new file mode 100644 index 000000000..eee45ad0b --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/jsonNum.dart @@ -0,0 +1,1704 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/extension_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i5; +import 'package:shelf/shelf.dart' as _i2; + +final class JsonNumTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'jsonNum'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.jsonNum( + _i4.Serializers.instance.deserialize<_i5.JsonNum>( + request[r'value'], + const _i4.TypeToken<_i5.JsonNum>('JsonNum'), + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.JsonNum>( + response, + const _i4.TypeToken<_i5.JsonNum>('JsonNum'), + ), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.JsonNum, num>( + serialize: ($value) => $value, + deserialize: ($serialized) { + return _i5.JsonNum(($serialized as num)); + }, + ), + const _i4.TypeToken<_i5.JsonNum>('JsonNum'), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i5.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': JsonNumTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/jsonString.dart b/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/jsonString.dart new file mode 100644 index 000000000..d4b71939a --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/jsonString.dart @@ -0,0 +1,1704 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/extension_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i5; +import 'package:shelf/shelf.dart' as _i2; + +final class JsonStringTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'jsonString'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.jsonString( + _i4.Serializers.instance.deserialize<_i5.JsonString>( + request[r'value'], + const _i4.TypeToken<_i5.JsonString>('JsonString'), + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.JsonString>( + response, + const _i4.TypeToken<_i5.JsonString>('JsonString'), + ), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.JsonString, String>( + serialize: ($value) => $value, + deserialize: ($serialized) { + return _i5.JsonString(($serialized as String)); + }, + ), + const _i4.TypeToken<_i5.JsonString>('JsonString'), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i5.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': JsonStringTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/jsonValue.dart b/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/jsonValue.dart new file mode 100644 index 000000000..da63ce20a --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/jsonValue.dart @@ -0,0 +1,1695 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/extension_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i5; +import 'package:shelf/shelf.dart' as _i2; + +final class JsonValueTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'jsonValue'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.jsonValue( + _i4.Serializers.instance.deserialize<_i5.JsonValue>( + request[r'value'], + const _i4.TypeToken<_i5.JsonValue>('JsonValue'), + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.JsonValue>( + response, + const _i4.TypeToken<_i5.JsonValue>('JsonValue'), + ), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i5.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i5.JsonValue>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': JsonValueTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/string.dart b/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/string.dart new file mode 100644 index 000000000..8883267f0 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/string.dart @@ -0,0 +1,1705 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/extension_types.dart' as _i5; +import 'package:celest_backend/src/functions/extension_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class StringTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'string'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.string( + _i4.Serializers.instance.deserialize<_i5.StringX>( + request[r's'], + const _i4.TypeToken<_i5.StringX>('StringX'), + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.StringX>( + response, + const _i4.TypeToken<_i5.StringX>('StringX'), + ), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.StringX, String>( + serialize: ($value) => $value.s, + deserialize: ($serialized) { + return _i5.StringX(($serialized as String)); + }, + ), + const _i4.TypeToken<_i5.StringX>('StringX'), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': StringTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/stringFromJson.dart b/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/stringFromJson.dart new file mode 100644 index 000000000..9b2422cac --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/stringFromJson.dart @@ -0,0 +1,1705 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/extension_types.dart' as _i5; +import 'package:celest_backend/src/functions/extension_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class StringFromJsonTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'stringFromJson'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.stringFromJson( + _i4.Serializers.instance.deserialize<_i5.StringXFromJson>( + request[r's'], + const _i4.TypeToken<_i5.StringXFromJson>('StringXFromJson'), + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.StringXFromJson>( + response, + const _i4.TypeToken<_i5.StringXFromJson>('StringXFromJson'), + ), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.StringXFromJson, String>( + serialize: ($value) => $value.s, + deserialize: ($serialized) { + return _i5.StringXFromJson.fromJson($serialized); + }, + ), + const _i4.TypeToken<_i5.StringXFromJson>('StringXFromJson'), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': StringFromJsonTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/stringFromJsonImpl.dart b/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/stringFromJsonImpl.dart new file mode 100644 index 000000000..2b68119d0 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/stringFromJsonImpl.dart @@ -0,0 +1,1705 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/extension_types.dart' as _i5; +import 'package:celest_backend/src/functions/extension_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class StringFromJsonImplTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'stringFromJsonImpl'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.stringFromJsonImpl( + _i4.Serializers.instance.deserialize<_i5.StringXFromJsonImpl>( + request[r's'], + const _i4.TypeToken<_i5.StringXFromJsonImpl>('StringXFromJsonImpl'), + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.StringXFromJsonImpl>( + response, + const _i4.TypeToken<_i5.StringXFromJsonImpl>('StringXFromJsonImpl'), + ), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.StringXFromJsonImpl, String>( + serialize: ($value) => $value, + deserialize: ($serialized) { + return _i5.StringXFromJsonImpl.fromJson($serialized); + }, + ), + const _i4.TypeToken<_i5.StringXFromJsonImpl>('StringXFromJsonImpl'), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': StringFromJsonImplTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/stringFromJsonStatic.dart b/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/stringFromJsonStatic.dart new file mode 100644 index 000000000..5b4ed5cd4 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/stringFromJsonStatic.dart @@ -0,0 +1,1709 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/extension_types.dart' as _i5; +import 'package:celest_backend/src/functions/extension_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class StringFromJsonStaticTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'stringFromJsonStatic'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.stringFromJsonStatic( + _i4.Serializers.instance.deserialize<_i5.StringXFromJsonStatic>( + request[r's'], + const _i4.TypeToken<_i5.StringXFromJsonStatic>( + 'StringXFromJsonStatic', + ), + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.StringXFromJsonStatic>( + response, + const _i4.TypeToken<_i5.StringXFromJsonStatic>( + 'StringXFromJsonStatic', + ), + ), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.StringXFromJsonStatic, String>( + serialize: ($value) => $value.s, + deserialize: ($serialized) { + return _i5.StringXFromJsonStatic.fromJson($serialized); + }, + ), + const _i4.TypeToken<_i5.StringXFromJsonStatic>('StringXFromJsonStatic'), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': StringFromJsonStaticTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/stringImpl.dart b/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/stringImpl.dart new file mode 100644 index 000000000..ac3929253 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/stringImpl.dart @@ -0,0 +1,1705 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/extension_types.dart' as _i5; +import 'package:celest_backend/src/functions/extension_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class StringImplTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'stringImpl'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.stringImpl( + _i4.Serializers.instance.deserialize<_i5.StringXImpl>( + request[r's'], + const _i4.TypeToken<_i5.StringXImpl>('StringXImpl'), + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.StringXImpl>( + response, + const _i4.TypeToken<_i5.StringXImpl>('StringXImpl'), + ), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.StringXImpl, String>( + serialize: ($value) => $value, + deserialize: ($serialized) { + return _i5.StringXImpl(($serialized as String)); + }, + ), + const _i4.TypeToken<_i5.StringXImpl>('StringXImpl'), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': StringImplTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/stringPrivateCtor.dart b/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/stringPrivateCtor.dart new file mode 100644 index 000000000..745db5f18 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/stringPrivateCtor.dart @@ -0,0 +1,1705 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/extension_types.dart' as _i5; +import 'package:celest_backend/src/functions/extension_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class StringPrivateCtorTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'stringPrivateCtor'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.stringPrivateCtor( + _i4.Serializers.instance.deserialize<_i5.StringXPrivateCtor>( + request[r's'], + const _i4.TypeToken<_i5.StringXPrivateCtor>('StringXPrivateCtor'), + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.StringXPrivateCtor>( + response, + const _i4.TypeToken<_i5.StringXPrivateCtor>('StringXPrivateCtor'), + ), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.StringXPrivateCtor, String?>( + serialize: ($value) => $value.s, + deserialize: ($serialized) { + return (($serialized as String) as _i5.StringXPrivateCtor); + }, + ), + const _i4.TypeToken<_i5.StringXPrivateCtor>('StringXPrivateCtor'), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': StringPrivateCtorTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/stringPrivateCtorImpl.dart b/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/stringPrivateCtorImpl.dart new file mode 100644 index 000000000..9739dfe7c --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/stringPrivateCtorImpl.dart @@ -0,0 +1,1709 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/extension_types.dart' as _i5; +import 'package:celest_backend/src/functions/extension_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class StringPrivateCtorImplTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'stringPrivateCtorImpl'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.stringPrivateCtorImpl( + _i4.Serializers.instance.deserialize<_i5.StringXPrivateCtorImpl>( + request[r's'], + const _i4.TypeToken<_i5.StringXPrivateCtorImpl>( + 'StringXPrivateCtorImpl', + ), + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.StringXPrivateCtorImpl>( + response, + const _i4.TypeToken<_i5.StringXPrivateCtorImpl>( + 'StringXPrivateCtorImpl', + ), + ), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.StringXPrivateCtorImpl, String?>( + serialize: ($value) => $value, + deserialize: ($serialized) { + return (($serialized as String) as _i5.StringXPrivateCtorImpl); + }, + ), + const _i4.TypeToken<_i5.StringXPrivateCtorImpl>('StringXPrivateCtorImpl'), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': StringPrivateCtorImplTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/stringPrivateField.dart b/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/stringPrivateField.dart new file mode 100644 index 000000000..6753c0d85 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/stringPrivateField.dart @@ -0,0 +1,1705 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/extension_types.dart' as _i5; +import 'package:celest_backend/src/functions/extension_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class StringPrivateFieldTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'stringPrivateField'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.stringPrivateField( + _i4.Serializers.instance.deserialize<_i5.StringXPrivateField>( + request[r's'], + const _i4.TypeToken<_i5.StringXPrivateField>('StringXPrivateField'), + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.StringXPrivateField>( + response, + const _i4.TypeToken<_i5.StringXPrivateField>('StringXPrivateField'), + ), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.StringXPrivateField, String>( + serialize: ($value) => ($value as String), + deserialize: ($serialized) { + return _i5.StringXPrivateField(($serialized as String)); + }, + ), + const _i4.TypeToken<_i5.StringXPrivateField>('StringXPrivateField'), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': StringPrivateFieldTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/stringPrivateFieldImpl.dart b/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/stringPrivateFieldImpl.dart new file mode 100644 index 000000000..7c47d977c --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/stringPrivateFieldImpl.dart @@ -0,0 +1,1711 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/extension_types.dart' as _i5; +import 'package:celest_backend/src/functions/extension_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class StringPrivateFieldImplTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'stringPrivateFieldImpl'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.stringPrivateFieldImpl( + _i4.Serializers.instance.deserialize<_i5.StringXPrivateFieldImpl>( + request[r's'], + const _i4.TypeToken<_i5.StringXPrivateFieldImpl>( + 'StringXPrivateFieldImpl', + ), + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.StringXPrivateFieldImpl>( + response, + const _i4.TypeToken<_i5.StringXPrivateFieldImpl>( + 'StringXPrivateFieldImpl', + ), + ), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.StringXPrivateFieldImpl, String>( + serialize: ($value) => $value, + deserialize: ($serialized) { + return _i5.StringXPrivateFieldImpl(($serialized as String)); + }, + ), + const _i4.TypeToken<_i5.StringXPrivateFieldImpl>( + 'StringXPrivateFieldImpl', + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': StringPrivateFieldImplTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/stringToFromJson.dart b/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/stringToFromJson.dart new file mode 100644 index 000000000..e288cc1a0 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/stringToFromJson.dart @@ -0,0 +1,1705 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/extension_types.dart' as _i5; +import 'package:celest_backend/src/functions/extension_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class StringToFromJsonTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'stringToFromJson'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.stringToFromJson( + _i4.Serializers.instance.deserialize<_i5.StringXToFromJson>( + request[r's'], + const _i4.TypeToken<_i5.StringXToFromJson>('StringXToFromJson'), + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.StringXToFromJson>( + response, + const _i4.TypeToken<_i5.StringXToFromJson>('StringXToFromJson'), + ), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.StringXToFromJson, String>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i5.StringXToFromJson.fromJson($serialized); + }, + ), + const _i4.TypeToken<_i5.StringXToFromJson>('StringXToFromJson'), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': StringToFromJsonTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/stringToJson.dart b/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/stringToJson.dart new file mode 100644 index 000000000..d85707771 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/stringToJson.dart @@ -0,0 +1,1705 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/extension_types.dart' as _i5; +import 'package:celest_backend/src/functions/extension_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class StringToJsonTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'stringToJson'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.stringToJson( + _i4.Serializers.instance.deserialize<_i5.StringXToJson>( + request[r's'], + const _i4.TypeToken<_i5.StringXToJson>('StringXToJson'), + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.StringXToJson>( + response, + const _i4.TypeToken<_i5.StringXToJson>('StringXToJson'), + ), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.StringXToJson, String>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i5.StringXToJson(($serialized as String)); + }, + ), + const _i4.TypeToken<_i5.StringXToJson>('StringXToJson'), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': StringToJsonTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/stringToJsonImpl.dart b/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/stringToJsonImpl.dart new file mode 100644 index 000000000..bac45d407 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/stringToJsonImpl.dart @@ -0,0 +1,1705 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/extension_types.dart' as _i5; +import 'package:celest_backend/src/functions/extension_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class StringToJsonImplTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'stringToJsonImpl'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.stringToJsonImpl( + _i4.Serializers.instance.deserialize<_i5.StringXToJsonImpl>( + request[r's'], + const _i4.TypeToken<_i5.StringXToJsonImpl>('StringXToJsonImpl'), + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.StringXToJsonImpl>( + response, + const _i4.TypeToken<_i5.StringXToJsonImpl>('StringXToJsonImpl'), + ), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.StringXToJsonImpl, String>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i5.StringXToJsonImpl(($serialized as String)); + }, + ), + const _i4.TypeToken<_i5.StringXToJsonImpl>('StringXToJsonImpl'), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': StringToJsonImplTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/value.dart b/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/value.dart new file mode 100644 index 000000000..57e4a3e64 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/value.dart @@ -0,0 +1,1698 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/extension_types.dart' as _i5; +import 'package:celest_backend/src/functions/extension_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class ValueTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'value'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.value( + _i4.Serializers.instance.deserialize<_i5.Value>(request[r'v']), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.Value>(response), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.Value, String>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i5.Value.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': ValueTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/valueX.dart b/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/valueX.dart new file mode 100644 index 000000000..3fa7f4242 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/valueX.dart @@ -0,0 +1,1725 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/extension_types.dart' as _i5; +import 'package:celest_backend/src/functions/extension_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class ValueXTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'valueX'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.valueX( + _i4.Serializers.instance.deserialize<_i5.ValueX>( + request[r'v'], + const _i4.TypeToken<_i5.ValueX>('ValueX'), + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.ValueX>( + response, + const _i4.TypeToken<_i5.ValueX>('ValueX'), + ), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + ValueXSerializer(), + const _i4.TypeToken<_i5.ValueX>('ValueX'), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': ValueXTarget()}, + setup: (_i7.Context context) async {}, + ); +} + +final class ValueXSerializer extends _i4.Serializer<_i5.ValueX> { + ValueXSerializer() { + $serializers..put( + _i4.Serializer.define<_i5.Value, Map>( + serialize: ($value) => {r'value': $value.value}, + deserialize: ($serialized) { + return _i5.Value(($serialized[r'value'] as String)); + }, + ), + ); + } + + final _i4.Serializers $serializers = _i4.Serializers(); + + @override + _i5.ValueX deserialize(Object? $value) { + final $serialized = assertWireType>($value); + return _i5.ValueX($serializers.deserialize<_i5.Value>($serialized)); + } + + @override + Object? serialize(_i5.ValueX $value) => + $serializers.serialize<_i5.Value>($value.v); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/valueXFromJson.dart b/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/valueXFromJson.dart new file mode 100644 index 000000000..7a2a0acb3 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/valueXFromJson.dart @@ -0,0 +1,1726 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/extension_types.dart' as _i5; +import 'package:celest_backend/src/functions/extension_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class ValueXFromJsonTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'valueXFromJson'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.valueXFromJson( + _i4.Serializers.instance.deserialize<_i5.ValueXFromJson>( + request[r'v'], + const _i4.TypeToken<_i5.ValueXFromJson>('ValueXFromJson'), + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.ValueXFromJson>( + response, + const _i4.TypeToken<_i5.ValueXFromJson>('ValueXFromJson'), + ), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + ValueXFromJsonSerializer(), + const _i4.TypeToken<_i5.ValueXFromJson>('ValueXFromJson'), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': ValueXFromJsonTarget()}, + setup: (_i7.Context context) async {}, + ); +} + +final class ValueXFromJsonSerializer + extends _i4.Serializer<_i5.ValueXFromJson> { + ValueXFromJsonSerializer() { + $serializers..put( + _i4.Serializer.define<_i5.Value, Map>( + serialize: ($value) => {r'value': $value.value}, + deserialize: ($serialized) { + return _i5.Value(($serialized[r'value'] as String)); + }, + ), + ); + } + + final _i4.Serializers $serializers = _i4.Serializers(); + + @override + _i5.ValueXFromJson deserialize(Object? $value) { + final $serialized = assertWireType>($value); + return _i5.ValueXFromJson.fromJson($serialized); + } + + @override + Object? serialize(_i5.ValueXFromJson $value) => + $serializers.serialize<_i5.Value>($value.v); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/valueXFromJsonImpl.dart b/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/valueXFromJsonImpl.dart new file mode 100644 index 000000000..1198183d4 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/valueXFromJsonImpl.dart @@ -0,0 +1,1725 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/extension_types.dart' as _i5; +import 'package:celest_backend/src/functions/extension_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class ValueXFromJsonImplTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'valueXFromJsonImpl'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.valueXFromJsonImpl( + _i4.Serializers.instance.deserialize<_i5.ValueXFromJsonImpl>( + request[r'v'], + const _i4.TypeToken<_i5.ValueXFromJsonImpl>('ValueXFromJsonImpl'), + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.ValueXFromJsonImpl>( + response, + const _i4.TypeToken<_i5.ValueXFromJsonImpl>('ValueXFromJsonImpl'), + ), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + ValueXFromJsonImplSerializer(), + const _i4.TypeToken<_i5.ValueXFromJsonImpl>('ValueXFromJsonImpl'), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': ValueXFromJsonImplTarget()}, + setup: (_i7.Context context) async {}, + ); +} + +final class ValueXFromJsonImplSerializer + extends _i4.Serializer<_i5.ValueXFromJsonImpl> { + ValueXFromJsonImplSerializer() { + $serializers..put( + _i4.Serializer.define<_i5.Value, String>( + serialize: ($value) => {r'value': $value.value}, + deserialize: ($serialized) { + return _i5.Value(($serialized as String)); + }, + ), + ); + } + + final _i4.Serializers $serializers = _i4.Serializers(); + + @override + _i5.ValueXFromJsonImpl deserialize(Object? $value) { + final $serialized = assertWireType($value); + return _i5.ValueXFromJsonImpl.fromJson($serialized); + } + + @override + Object? serialize(_i5.ValueXFromJsonImpl $value) => $value.toJson(); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/valueXFromJsonStatic.dart b/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/valueXFromJsonStatic.dart new file mode 100644 index 000000000..35dd45332 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/valueXFromJsonStatic.dart @@ -0,0 +1,1728 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/extension_types.dart' as _i5; +import 'package:celest_backend/src/functions/extension_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class ValueXFromJsonStaticTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'valueXFromJsonStatic'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.valueXFromJsonStatic( + _i4.Serializers.instance.deserialize<_i5.ValueXFromJsonStatic>( + request[r'v'], + const _i4.TypeToken<_i5.ValueXFromJsonStatic>('ValueXFromJsonStatic'), + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.ValueXFromJsonStatic>( + response, + const _i4.TypeToken<_i5.ValueXFromJsonStatic>( + 'ValueXFromJsonStatic', + ), + ), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + ValueXFromJsonStaticSerializer(), + const _i4.TypeToken<_i5.ValueXFromJsonStatic>('ValueXFromJsonStatic'), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': ValueXFromJsonStaticTarget()}, + setup: (_i7.Context context) async {}, + ); +} + +final class ValueXFromJsonStaticSerializer + extends _i4.Serializer<_i5.ValueXFromJsonStatic> { + ValueXFromJsonStaticSerializer() { + $serializers..put( + _i4.Serializer.define<_i5.Value, Map>( + serialize: ($value) => {r'value': $value.value}, + deserialize: ($serialized) { + return _i5.Value(($serialized[r'value'] as String)); + }, + ), + ); + } + + final _i4.Serializers $serializers = _i4.Serializers(); + + @override + _i5.ValueXFromJsonStatic deserialize(Object? $value) { + final $serialized = assertWireType>($value); + return _i5.ValueXFromJsonStatic.fromJson($serialized); + } + + @override + Object? serialize(_i5.ValueXFromJsonStatic $value) => + $serializers.serialize<_i5.Value>($value.v); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/valueXImpl.dart b/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/valueXImpl.dart new file mode 100644 index 000000000..ef22b6950 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/valueXImpl.dart @@ -0,0 +1,1725 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/extension_types.dart' as _i5; +import 'package:celest_backend/src/functions/extension_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class ValueXImplTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'valueXImpl'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.valueXImpl( + _i4.Serializers.instance.deserialize<_i5.ValueXImpl>( + request[r'v'], + const _i4.TypeToken<_i5.ValueXImpl>('ValueXImpl'), + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.ValueXImpl>( + response, + const _i4.TypeToken<_i5.ValueXImpl>('ValueXImpl'), + ), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + ValueXImplSerializer(), + const _i4.TypeToken<_i5.ValueXImpl>('ValueXImpl'), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': ValueXImplTarget()}, + setup: (_i7.Context context) async {}, + ); +} + +final class ValueXImplSerializer extends _i4.Serializer<_i5.ValueXImpl> { + ValueXImplSerializer() { + $serializers..put( + _i4.Serializer.define<_i5.Value, Map>( + serialize: ($value) => {r'value': $value.value}, + deserialize: ($serialized) { + return _i5.Value(($serialized[r'value'] as String)); + }, + ), + ); + } + + final _i4.Serializers $serializers = _i4.Serializers(); + + @override + _i5.ValueXImpl deserialize(Object? $value) { + final $serialized = assertWireType>($value); + return _i5.ValueXImpl($serializers.deserialize<_i5.Value>($serialized)); + } + + @override + Object? serialize(_i5.ValueXImpl $value) => + $serializers.serialize<_i5.Value>($value); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/valueXToFromJson.dart b/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/valueXToFromJson.dart new file mode 100644 index 000000000..da2371209 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/valueXToFromJson.dart @@ -0,0 +1,1725 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/extension_types.dart' as _i5; +import 'package:celest_backend/src/functions/extension_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class ValueXToFromJsonTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'valueXToFromJson'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.valueXToFromJson( + _i4.Serializers.instance.deserialize<_i5.ValueXToFromJson>( + request[r'v'], + const _i4.TypeToken<_i5.ValueXToFromJson>('ValueXToFromJson'), + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.ValueXToFromJson>( + response, + const _i4.TypeToken<_i5.ValueXToFromJson>('ValueXToFromJson'), + ), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + ValueXToFromJsonSerializer(), + const _i4.TypeToken<_i5.ValueXToFromJson>('ValueXToFromJson'), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': ValueXToFromJsonTarget()}, + setup: (_i7.Context context) async {}, + ); +} + +final class ValueXToFromJsonSerializer + extends _i4.Serializer<_i5.ValueXToFromJson> { + ValueXToFromJsonSerializer() { + $serializers..put( + _i4.Serializer.define<_i5.Value, String>( + serialize: ($value) => {r'value': $value.value}, + deserialize: ($serialized) { + return _i5.Value(($serialized as String)); + }, + ), + ); + } + + final _i4.Serializers $serializers = _i4.Serializers(); + + @override + _i5.ValueXToFromJson deserialize(Object? $value) { + final $serialized = assertWireType($value); + return _i5.ValueXToFromJson.fromJson($serialized); + } + + @override + Object? serialize(_i5.ValueXToFromJson $value) => $value.toJson(); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/valueXToJson.dart b/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/valueXToJson.dart new file mode 100644 index 000000000..d9e118728 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/valueXToJson.dart @@ -0,0 +1,1724 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/extension_types.dart' as _i5; +import 'package:celest_backend/src/functions/extension_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class ValueXToJsonTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'valueXToJson'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.valueXToJson( + _i4.Serializers.instance.deserialize<_i5.ValueXToJson>( + request[r'v'], + const _i4.TypeToken<_i5.ValueXToJson>('ValueXToJson'), + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.ValueXToJson>( + response, + const _i4.TypeToken<_i5.ValueXToJson>('ValueXToJson'), + ), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + ValueXToJsonSerializer(), + const _i4.TypeToken<_i5.ValueXToJson>('ValueXToJson'), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': ValueXToJsonTarget()}, + setup: (_i7.Context context) async {}, + ); +} + +final class ValueXToJsonSerializer extends _i4.Serializer<_i5.ValueXToJson> { + ValueXToJsonSerializer() { + $serializers..put( + _i4.Serializer.define<_i5.Value, Map>( + serialize: ($value) => {r'value': $value.value}, + deserialize: ($serialized) { + return _i5.Value(($serialized[r'value'] as String)); + }, + ), + ); + } + + final _i4.Serializers $serializers = _i4.Serializers(); + + @override + _i5.ValueXToJson deserialize(Object? $value) { + final $serialized = assertWireType>($value); + return _i5.ValueXToJson($serializers.deserialize<_i5.Value>($serialized)); + } + + @override + Object? serialize(_i5.ValueXToJson $value) => $value.toJson(); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/valueXToJsonImpl.dart b/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/valueXToJsonImpl.dart new file mode 100644 index 000000000..d2244d05a --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/extension_types/valueXToJsonImpl.dart @@ -0,0 +1,1727 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/extension_types.dart' as _i5; +import 'package:celest_backend/src/functions/extension_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class ValueXToJsonImplTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'valueXToJsonImpl'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.valueXToJsonImpl( + _i4.Serializers.instance.deserialize<_i5.ValueXToJsonImpl>( + request[r'v'], + const _i4.TypeToken<_i5.ValueXToJsonImpl>('ValueXToJsonImpl'), + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.ValueXToJsonImpl>( + response, + const _i4.TypeToken<_i5.ValueXToJsonImpl>('ValueXToJsonImpl'), + ), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + ValueXToJsonImplSerializer(), + const _i4.TypeToken<_i5.ValueXToJsonImpl>('ValueXToJsonImpl'), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': ValueXToJsonImplTarget()}, + setup: (_i7.Context context) async {}, + ); +} + +final class ValueXToJsonImplSerializer + extends _i4.Serializer<_i5.ValueXToJsonImpl> { + ValueXToJsonImplSerializer() { + $serializers..put( + _i4.Serializer.define<_i5.Value, String>( + serialize: ($value) => {r'value': $value.value}, + deserialize: ($serialized) { + return _i5.Value(($serialized as String)); + }, + ), + ); + } + + final _i4.Serializers $serializers = _i4.Serializers(); + + @override + _i5.ValueXToJsonImpl deserialize(Object? $value) { + final $serialized = assertWireType($value); + return _i5.ValueXToJsonImpl( + $serializers.deserialize<_i5.Value>($serialized), + ); + } + + @override + Object? serialize(_i5.ValueXToJsonImpl $value) => $value.toJson(); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/generic_wrappers/genericWrapperParameters.dart b/apps/cli/fixtures/legacy/api/goldens/functions/generic_wrappers/genericWrapperParameters.dart new file mode 100644 index 000000000..1e04f748a --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/generic_wrappers/genericWrapperParameters.dart @@ -0,0 +1,2134 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i12; +import 'dart:convert' as _i13; + +import 'package:celest/celest.dart' as _i11; +import 'package:celest/src/core/context.dart' as _i10; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/generic_wrappers.dart' as _i8; +import 'package:celest_backend/models/parameter_types.dart' as _i6; +import 'package:celest_backend/src/functions/generic_wrappers.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i9; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i14; +import 'package:celest_core/src/serialization/json_value.dart' as _i15; +import 'package:fast_immutable_collections/src/ilist/ilist.dart' as _i5; +import 'package:fast_immutable_collections/src/imap/imap.dart' as _i7; +import 'package:shelf/shelf.dart' as _i2; + +final class GenericWrapperParametersTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'genericWrapperParameters'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.genericWrapperParameters( + listOfString: _i4.Serializers.instance.deserialize<_i5.IList>( + request[r'listOfString'], + ), + listOfUri: _i4.Serializers.instance.deserialize<_i5.IList>( + request[r'listOfUri'], + ), + listOfSimpleClass: _i4.Serializers.instance + .deserialize<_i5.IList<_i6.SimpleClass>>( + request[r'listOfSimpleClass'], + ), + listOfListOfString: _i4.Serializers.instance + .deserialize<_i5.IList<_i5.IList>>( + request[r'listOfListOfString'], + ), + listOfListOfUri: _i4.Serializers.instance + .deserialize<_i5.IList<_i5.IList>>( + request[r'listOfListOfUri'], + ), + listOfListOfSimpleClass: _i4.Serializers.instance + .deserialize<_i5.IList<_i5.IList<_i6.SimpleClass>>>( + request[r'listOfListOfSimpleClass'], + ), + mapOfString: _i4.Serializers.instance + .deserialize<_i7.IMap>(request[r'mapOfString']), + mapOfUri: _i4.Serializers.instance.deserialize<_i7.IMap>( + request[r'mapOfUri'], + ), + mapOfSimpleClass: _i4.Serializers.instance + .deserialize<_i7.IMap>( + request[r'mapOfSimpleClass'], + ), + mapOfListOfString: _i4.Serializers.instance + .deserialize<_i7.IMap>>( + request[r'mapOfListOfString'], + ), + mapOfListOfUri: _i4.Serializers.instance + .deserialize<_i7.IMap>>( + request[r'mapOfListOfUri'], + ), + mapOfListOfSimpleClass: _i4.Serializers.instance + .deserialize<_i7.IMap>>( + request[r'mapOfListOfSimpleClass'], + ), + mapOfMapOfString: _i4.Serializers.instance + .deserialize<_i7.IMap>>( + request[r'mapOfMapOfString'], + ), + mapOfMapOfUri: _i4.Serializers.instance + .deserialize<_i7.IMap>>( + request[r'mapOfMapOfUri'], + ), + mapOfMapOfSimpleClass: _i4.Serializers.instance + .deserialize<_i7.IMap>>( + request[r'mapOfMapOfSimpleClass'], + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i8.GenericWrappers>(response), + ), + ); + } on _i9.AbortedException catch (e, st) { + const statusCode = 409; + _i10.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i9.AbortedException>( + e, + ), + }, + if (_i10.context.environment != _i11.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i10.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i9.AlreadyExistsException>(e), + }, + if (_i10.context.environment != _i11.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i10.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i10.context.environment != _i11.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i12.AsyncError catch (e, st) { + const statusCode = 500; + _i10.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i12.AsyncError>(e), + }, + if (_i10.context.environment != _i11.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.CancelledException catch (e, st) { + const statusCode = 499; + _i10.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i9.CancelledException>(e), + }, + if (_i10.context.environment != _i11.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i10.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i10.context.environment != _i11.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.DataLossError catch (e, st) { + const statusCode = 500; + _i10.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i9.DataLossError>(e), + }, + if (_i10.context.environment != _i11.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i10.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i9.DeadlineExceededError>(e), + }, + if (_i10.context.environment != _i11.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i10.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i9.FailedPreconditionException>(e), + }, + if (_i10.context.environment != _i11.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i10.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i10.context.environment != _i11.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i10.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i10.context.environment != _i11.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.InternalServerError catch (e, st) { + const statusCode = 500; + _i10.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i9.InternalServerError>(e), + }, + if (_i10.context.environment != _i11.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i13.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i10.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i13.JsonUnsupportedObjectError>(e), + }, + if (_i10.context.environment != _i11.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.NotFoundException catch (e, st) { + const statusCode = 404; + _i10.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i9.NotFoundException>(e), + }, + if (_i10.context.environment != _i11.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i10.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i10.context.environment != _i11.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i10.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i9.OutOfRangeException>(e), + }, + if (_i10.context.environment != _i11.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i10.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i9.PermissionDeniedException>(e), + }, + if (_i10.context.environment != _i11.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i10.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i10.context.environment != _i11.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i10.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i10.context.environment != _i11.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i10.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i9.ResourceExhaustedException>(e), + }, + if (_i10.context.environment != _i11.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i14.SerializationException catch (e, st) { + const statusCode = 400; + _i10.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i14.SerializationException>(e), + }, + if (_i10.context.environment != _i11.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.BadRequestException catch (e, st) { + const statusCode = 400; + _i10.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i9.BadRequestException>(e), + }, + if (_i10.context.environment != _i11.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i10.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i10.context.environment != _i11.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i10.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i10.context.environment != _i11.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i10.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i10.context.environment != _i11.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i12.TimeoutException catch (e, st) { + const statusCode = 400; + _i10.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance + .serialize<_i12.TimeoutException>(e), + }, + if (_i10.context.environment != _i11.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i10.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i10.context.environment != _i11.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i10.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i9.UnauthorizedException>(e), + }, + if (_i10.context.environment != _i11.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.UnavailableError catch (e, st) { + const statusCode = 503; + _i10.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i9.UnavailableError>( + e, + ), + }, + if (_i10.context.environment != _i11.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.UnimplementedError catch (e, st) { + const statusCode = 501; + _i10.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i9.UnimplementedError>(e), + }, + if (_i10.context.environment != _i11.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i10.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i10.context.environment != _i11.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.UnknownError catch (e, st) { + const statusCode = 500; + _i10.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i9.UnknownError>(e), + }, + if (_i10.context.environment != _i11.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.CloudException catch (e, st) { + const statusCode = 400; + _i10.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i9.CloudException>( + e, + ), + }, + if (_i10.context.environment != _i11.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i10.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i10.context.environment != _i11.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i10.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i10.context.environment != _i11.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i10.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i10.context.environment != _i11.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i12.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i12.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i13.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i13.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.GenericWrappers, Map>( + serialize: + ($value) => { + r'listOfString': _i4.Serializers.instance + .serialize<_i5.IList>($value.listOfString), + r'listOfUri': _i4.Serializers.instance.serialize<_i5.IList>( + $value.listOfUri, + ), + r'listOfSimpleClass': _i4.Serializers.instance + .serialize<_i5.IList<_i6.SimpleClass>>( + $value.listOfSimpleClass, + ), + r'listOfListOfString': _i4.Serializers.instance + .serialize<_i5.IList<_i5.IList>>( + $value.listOfListOfString, + ), + r'listOfListOfUri': _i4.Serializers.instance + .serialize<_i5.IList<_i5.IList>>($value.listOfListOfUri), + r'listOfListOfSimpleClass': _i4.Serializers.instance + .serialize<_i5.IList<_i5.IList<_i6.SimpleClass>>>( + $value.listOfListOfSimpleClass, + ), + r'mapOfString': _i4.Serializers.instance + .serialize<_i7.IMap>($value.mapOfString), + r'mapOfUri': _i4.Serializers.instance + .serialize<_i7.IMap>($value.mapOfUri), + r'mapOfSimpleClass': _i4.Serializers.instance + .serialize<_i7.IMap>( + $value.mapOfSimpleClass, + ), + r'mapOfListOfString': _i4.Serializers.instance + .serialize<_i7.IMap>>( + $value.mapOfListOfString, + ), + r'mapOfListOfUri': _i4.Serializers.instance + .serialize<_i7.IMap>>( + $value.mapOfListOfUri, + ), + r'mapOfListOfSimpleClass': _i4.Serializers.instance + .serialize<_i7.IMap>>( + $value.mapOfListOfSimpleClass, + ), + r'mapOfMapOfString': _i4.Serializers.instance + .serialize<_i7.IMap>>( + $value.mapOfMapOfString, + ), + r'mapOfMapOfUri': _i4.Serializers.instance + .serialize<_i7.IMap>>( + $value.mapOfMapOfUri, + ), + r'mapOfMapOfSimpleClass': _i4.Serializers.instance.serialize< + _i7.IMap> + >($value.mapOfMapOfSimpleClass), + }, + deserialize: ($serialized) { + return _i8.GenericWrappers( + listOfString: _i4.Serializers.instance + .deserialize<_i5.IList>($serialized[r'listOfString']), + listOfUri: _i4.Serializers.instance.deserialize<_i5.IList>( + $serialized[r'listOfUri'], + ), + listOfSimpleClass: _i4.Serializers.instance + .deserialize<_i5.IList<_i6.SimpleClass>>( + $serialized[r'listOfSimpleClass'], + ), + listOfListOfString: _i4.Serializers.instance + .deserialize<_i5.IList<_i5.IList>>( + $serialized[r'listOfListOfString'], + ), + listOfListOfUri: _i4.Serializers.instance + .deserialize<_i5.IList<_i5.IList>>( + $serialized[r'listOfListOfUri'], + ), + listOfListOfSimpleClass: _i4.Serializers.instance + .deserialize<_i5.IList<_i5.IList<_i6.SimpleClass>>>( + $serialized[r'listOfListOfSimpleClass'], + ), + mapOfString: _i4.Serializers.instance + .deserialize<_i7.IMap>( + $serialized[r'mapOfString'], + ), + mapOfUri: _i4.Serializers.instance + .deserialize<_i7.IMap>($serialized[r'mapOfUri']), + mapOfSimpleClass: _i4.Serializers.instance + .deserialize<_i7.IMap>( + $serialized[r'mapOfSimpleClass'], + ), + mapOfListOfString: _i4.Serializers.instance + .deserialize<_i7.IMap>>( + $serialized[r'mapOfListOfString'], + ), + mapOfListOfUri: _i4.Serializers.instance + .deserialize<_i7.IMap>>( + $serialized[r'mapOfListOfUri'], + ), + mapOfListOfSimpleClass: _i4.Serializers.instance + .deserialize<_i7.IMap>>( + $serialized[r'mapOfListOfSimpleClass'], + ), + mapOfMapOfString: _i4.Serializers.instance + .deserialize<_i7.IMap>>( + $serialized[r'mapOfMapOfString'], + ), + mapOfMapOfUri: _i4.Serializers.instance + .deserialize<_i7.IMap>>( + $serialized[r'mapOfMapOfUri'], + ), + mapOfMapOfSimpleClass: _i4.Serializers.instance.deserialize< + _i7.IMap> + >($serialized[r'mapOfMapOfSimpleClass']), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.SimpleClass, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i6.SimpleClass.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i9.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i15.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i9.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i15.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i9.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i15.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i9.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i15.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i9.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i9.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i15.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i9.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i15.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i9.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i15.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i9.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i15.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i9.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i15.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i9.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i15.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i9.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i15.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i9.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i15.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i9.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i15.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i9.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i15.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i9.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i15.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i9.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i15.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i14.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i14.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i15.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i15.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.IList, dynamic>( + serialize: ($value) => $value.toJson((value) => value), + deserialize: ($serialized) { + return _i5.IList.fromJson( + $serialized, + (value) => (value as String), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.IList, dynamic>( + serialize: + ($value) => $value.toJson( + (value) => _i4.Serializers.instance.serialize(value), + ), + deserialize: ($serialized) { + return _i5.IList.fromJson( + $serialized, + (value) => _i4.Serializers.instance.deserialize(value), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.IList<_i6.SimpleClass>, dynamic>( + serialize: + ($value) => $value.toJson( + (value) => + _i4.Serializers.instance.serialize<_i6.SimpleClass>(value), + ), + deserialize: ($serialized) { + return _i5.IList<_i6.SimpleClass>.fromJson( + $serialized, + (value) => + _i4.Serializers.instance.deserialize<_i6.SimpleClass>(value), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.IList<_i5.IList>, dynamic>( + serialize: + ($value) => $value.toJson( + (value) => + _i4.Serializers.instance.serialize<_i5.IList>(value), + ), + deserialize: ($serialized) { + return _i5.IList<_i5.IList>.fromJson( + $serialized, + (value) => + _i4.Serializers.instance.deserialize<_i5.IList>(value), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.IList<_i5.IList>, dynamic>( + serialize: + ($value) => $value.toJson( + (value) => + _i4.Serializers.instance.serialize<_i5.IList>(value), + ), + deserialize: ($serialized) { + return _i5.IList<_i5.IList>.fromJson( + $serialized, + (value) => + _i4.Serializers.instance.deserialize<_i5.IList>(value), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.IList<_i5.IList<_i6.SimpleClass>>, dynamic>( + serialize: + ($value) => $value.toJson( + (value) => _i4.Serializers.instance + .serialize<_i5.IList<_i6.SimpleClass>>(value), + ), + deserialize: ($serialized) { + return _i5.IList<_i5.IList<_i6.SimpleClass>>.fromJson( + $serialized, + (value) => _i4.Serializers.instance + .deserialize<_i5.IList<_i6.SimpleClass>>(value), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i7.IMap, Map>( + serialize: + ($value) => $value.toJson((value) => value, (value) => value), + deserialize: ($serialized) { + return _i7.IMap.fromJson( + $serialized, + (value) => (value as String), + (value) => (value as String), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i7.IMap, Map>( + serialize: + ($value) => $value.toJson( + (value) => value, + (value) => _i4.Serializers.instance.serialize(value), + ), + deserialize: ($serialized) { + return _i7.IMap.fromJson( + $serialized, + (value) => (value as String), + (value) => _i4.Serializers.instance.deserialize(value), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i7.IMap, + Map + >( + serialize: + ($value) => $value.toJson( + (value) => value, + (value) => + _i4.Serializers.instance.serialize<_i6.SimpleClass>(value), + ), + deserialize: ($serialized) { + return _i7.IMap.fromJson( + $serialized, + (value) => (value as String), + (value) => + _i4.Serializers.instance.deserialize<_i6.SimpleClass>(value), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i7.IMap>, + Map + >( + serialize: + ($value) => $value.toJson( + (value) => value, + (value) => + _i4.Serializers.instance.serialize<_i5.IList>(value), + ), + deserialize: ($serialized) { + return _i7.IMap>.fromJson( + $serialized, + (value) => (value as String), + (value) => + _i4.Serializers.instance.deserialize<_i5.IList>(value), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i7.IMap>, + Map + >( + serialize: + ($value) => $value.toJson( + (value) => value, + (value) => + _i4.Serializers.instance.serialize<_i5.IList>(value), + ), + deserialize: ($serialized) { + return _i7.IMap>.fromJson( + $serialized, + (value) => (value as String), + (value) => + _i4.Serializers.instance.deserialize<_i5.IList>(value), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i7.IMap>, + Map + >( + serialize: + ($value) => $value.toJson( + (value) => value, + (value) => _i4.Serializers.instance + .serialize<_i5.IList<_i6.SimpleClass>>(value), + ), + deserialize: ($serialized) { + return _i7.IMap>.fromJson( + $serialized, + (value) => (value as String), + (value) => _i4.Serializers.instance + .deserialize<_i5.IList<_i6.SimpleClass>>(value), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i7.IMap>, + Map + >( + serialize: + ($value) => $value.toJson( + (value) => value, + (value) => _i4.Serializers.instance + .serialize<_i7.IMap>(value), + ), + deserialize: ($serialized) { + return _i7.IMap>.fromJson( + $serialized, + (value) => (value as String), + (value) => _i4.Serializers.instance + .deserialize<_i7.IMap>(value), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i7.IMap>, + Map + >( + serialize: + ($value) => $value.toJson( + (value) => value, + (value) => _i4.Serializers.instance + .serialize<_i7.IMap>(value), + ), + deserialize: ($serialized) { + return _i7.IMap>.fromJson( + $serialized, + (value) => (value as String), + (value) => _i4.Serializers.instance + .deserialize<_i7.IMap>(value), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i7.IMap>, + Map + >( + serialize: + ($value) => $value.toJson( + (value) => value, + (value) => _i4.Serializers.instance + .serialize<_i7.IMap>(value), + ), + deserialize: ($serialized) { + return _i7.IMap>.fromJson( + $serialized, + (value) => (value as String), + (value) => _i4.Serializers.instance + .deserialize<_i7.IMap>(value), + ); + }, + ), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': GenericWrapperParametersTarget()}, + setup: (_i10.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/generic_wrappers/genericWrappers.dart b/apps/cli/fixtures/legacy/api/goldens/functions/generic_wrappers/genericWrappers.dart new file mode 100644 index 000000000..7502277ca --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/generic_wrappers/genericWrappers.dart @@ -0,0 +1,2088 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/generic_wrappers.dart' as _i5; +import 'package:celest_backend/models/parameter_types.dart' as _i13; +import 'package:celest_backend/src/functions/generic_wrappers.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i15; +import 'package:fast_immutable_collections/src/ilist/ilist.dart' as _i12; +import 'package:fast_immutable_collections/src/imap/imap.dart' as _i14; +import 'package:shelf/shelf.dart' as _i2; + +final class GenericWrappersTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'genericWrappers'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.genericWrappers( + _i4.Serializers.instance.deserialize<_i5.GenericWrappers>( + request[r'value'], + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.GenericWrappers>(response), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.GenericWrappers, Map>( + serialize: + ($value) => { + r'listOfString': _i4.Serializers.instance + .serialize<_i12.IList>($value.listOfString), + r'listOfUri': _i4.Serializers.instance.serialize<_i12.IList>( + $value.listOfUri, + ), + r'listOfSimpleClass': _i4.Serializers.instance + .serialize<_i12.IList<_i13.SimpleClass>>( + $value.listOfSimpleClass, + ), + r'listOfListOfString': _i4.Serializers.instance + .serialize<_i12.IList<_i12.IList>>( + $value.listOfListOfString, + ), + r'listOfListOfUri': _i4.Serializers.instance + .serialize<_i12.IList<_i12.IList>>( + $value.listOfListOfUri, + ), + r'listOfListOfSimpleClass': _i4.Serializers.instance + .serialize<_i12.IList<_i12.IList<_i13.SimpleClass>>>( + $value.listOfListOfSimpleClass, + ), + r'mapOfString': _i4.Serializers.instance + .serialize<_i14.IMap>($value.mapOfString), + r'mapOfUri': _i4.Serializers.instance + .serialize<_i14.IMap>($value.mapOfUri), + r'mapOfSimpleClass': _i4.Serializers.instance + .serialize<_i14.IMap>( + $value.mapOfSimpleClass, + ), + r'mapOfListOfString': _i4.Serializers.instance + .serialize<_i14.IMap>>( + $value.mapOfListOfString, + ), + r'mapOfListOfUri': _i4.Serializers.instance + .serialize<_i14.IMap>>( + $value.mapOfListOfUri, + ), + r'mapOfListOfSimpleClass': _i4.Serializers.instance + .serialize<_i14.IMap>>( + $value.mapOfListOfSimpleClass, + ), + r'mapOfMapOfString': _i4.Serializers.instance + .serialize<_i14.IMap>>( + $value.mapOfMapOfString, + ), + r'mapOfMapOfUri': _i4.Serializers.instance + .serialize<_i14.IMap>>( + $value.mapOfMapOfUri, + ), + r'mapOfMapOfSimpleClass': _i4.Serializers.instance.serialize< + _i14.IMap> + >($value.mapOfMapOfSimpleClass), + }, + deserialize: ($serialized) { + return _i5.GenericWrappers( + listOfString: _i4.Serializers.instance + .deserialize<_i12.IList>($serialized[r'listOfString']), + listOfUri: _i4.Serializers.instance.deserialize<_i12.IList>( + $serialized[r'listOfUri'], + ), + listOfSimpleClass: _i4.Serializers.instance + .deserialize<_i12.IList<_i13.SimpleClass>>( + $serialized[r'listOfSimpleClass'], + ), + listOfListOfString: _i4.Serializers.instance + .deserialize<_i12.IList<_i12.IList>>( + $serialized[r'listOfListOfString'], + ), + listOfListOfUri: _i4.Serializers.instance + .deserialize<_i12.IList<_i12.IList>>( + $serialized[r'listOfListOfUri'], + ), + listOfListOfSimpleClass: _i4.Serializers.instance + .deserialize<_i12.IList<_i12.IList<_i13.SimpleClass>>>( + $serialized[r'listOfListOfSimpleClass'], + ), + mapOfString: _i4.Serializers.instance + .deserialize<_i14.IMap>( + $serialized[r'mapOfString'], + ), + mapOfUri: _i4.Serializers.instance + .deserialize<_i14.IMap>($serialized[r'mapOfUri']), + mapOfSimpleClass: _i4.Serializers.instance + .deserialize<_i14.IMap>( + $serialized[r'mapOfSimpleClass'], + ), + mapOfListOfString: _i4.Serializers.instance + .deserialize<_i14.IMap>>( + $serialized[r'mapOfListOfString'], + ), + mapOfListOfUri: _i4.Serializers.instance + .deserialize<_i14.IMap>>( + $serialized[r'mapOfListOfUri'], + ), + mapOfListOfSimpleClass: _i4.Serializers.instance + .deserialize<_i14.IMap>>( + $serialized[r'mapOfListOfSimpleClass'], + ), + mapOfMapOfString: _i4.Serializers.instance + .deserialize<_i14.IMap>>( + $serialized[r'mapOfMapOfString'], + ), + mapOfMapOfUri: _i4.Serializers.instance + .deserialize<_i14.IMap>>( + $serialized[r'mapOfMapOfUri'], + ), + mapOfMapOfSimpleClass: _i4.Serializers.instance.deserialize< + _i14.IMap> + >($serialized[r'mapOfMapOfSimpleClass']), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.SimpleClass, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i13.SimpleClass.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i15.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i15.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i15.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i15.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i15.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i15.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i15.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i15.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i15.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i15.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i15.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i15.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i15.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i15.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i15.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i15.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i15.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i15.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.IList, dynamic>( + serialize: ($value) => $value.toJson((value) => value), + deserialize: ($serialized) { + return _i12.IList.fromJson( + $serialized, + (value) => (value as String), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.IList, dynamic>( + serialize: + ($value) => $value.toJson( + (value) => _i4.Serializers.instance.serialize(value), + ), + deserialize: ($serialized) { + return _i12.IList.fromJson( + $serialized, + (value) => _i4.Serializers.instance.deserialize(value), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.IList<_i13.SimpleClass>, dynamic>( + serialize: + ($value) => $value.toJson( + (value) => + _i4.Serializers.instance.serialize<_i13.SimpleClass>(value), + ), + deserialize: ($serialized) { + return _i12.IList<_i13.SimpleClass>.fromJson( + $serialized, + (value) => + _i4.Serializers.instance.deserialize<_i13.SimpleClass>(value), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.IList<_i12.IList>, dynamic>( + serialize: + ($value) => $value.toJson( + (value) => + _i4.Serializers.instance.serialize<_i12.IList>(value), + ), + deserialize: ($serialized) { + return _i12.IList<_i12.IList>.fromJson( + $serialized, + (value) => + _i4.Serializers.instance.deserialize<_i12.IList>(value), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.IList<_i12.IList>, dynamic>( + serialize: + ($value) => $value.toJson( + (value) => + _i4.Serializers.instance.serialize<_i12.IList>(value), + ), + deserialize: ($serialized) { + return _i12.IList<_i12.IList>.fromJson( + $serialized, + (value) => + _i4.Serializers.instance.deserialize<_i12.IList>(value), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.IList<_i12.IList<_i13.SimpleClass>>, dynamic>( + serialize: + ($value) => $value.toJson( + (value) => _i4.Serializers.instance + .serialize<_i12.IList<_i13.SimpleClass>>(value), + ), + deserialize: ($serialized) { + return _i12.IList<_i12.IList<_i13.SimpleClass>>.fromJson( + $serialized, + (value) => _i4.Serializers.instance + .deserialize<_i12.IList<_i13.SimpleClass>>(value), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i14.IMap, Map>( + serialize: + ($value) => $value.toJson((value) => value, (value) => value), + deserialize: ($serialized) { + return _i14.IMap.fromJson( + $serialized, + (value) => (value as String), + (value) => (value as String), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i14.IMap, Map>( + serialize: + ($value) => $value.toJson( + (value) => value, + (value) => _i4.Serializers.instance.serialize(value), + ), + deserialize: ($serialized) { + return _i14.IMap.fromJson( + $serialized, + (value) => (value as String), + (value) => _i4.Serializers.instance.deserialize(value), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i14.IMap, + Map + >( + serialize: + ($value) => $value.toJson( + (value) => value, + (value) => + _i4.Serializers.instance.serialize<_i13.SimpleClass>(value), + ), + deserialize: ($serialized) { + return _i14.IMap.fromJson( + $serialized, + (value) => (value as String), + (value) => + _i4.Serializers.instance.deserialize<_i13.SimpleClass>(value), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i14.IMap>, + Map + >( + serialize: + ($value) => $value.toJson( + (value) => value, + (value) => + _i4.Serializers.instance.serialize<_i12.IList>(value), + ), + deserialize: ($serialized) { + return _i14.IMap>.fromJson( + $serialized, + (value) => (value as String), + (value) => + _i4.Serializers.instance.deserialize<_i12.IList>(value), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i14.IMap>, + Map + >( + serialize: + ($value) => $value.toJson( + (value) => value, + (value) => + _i4.Serializers.instance.serialize<_i12.IList>(value), + ), + deserialize: ($serialized) { + return _i14.IMap>.fromJson( + $serialized, + (value) => (value as String), + (value) => + _i4.Serializers.instance.deserialize<_i12.IList>(value), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i14.IMap>, + Map + >( + serialize: + ($value) => $value.toJson( + (value) => value, + (value) => _i4.Serializers.instance + .serialize<_i12.IList<_i13.SimpleClass>>(value), + ), + deserialize: ($serialized) { + return _i14.IMap>.fromJson( + $serialized, + (value) => (value as String), + (value) => _i4.Serializers.instance + .deserialize<_i12.IList<_i13.SimpleClass>>(value), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i14.IMap>, + Map + >( + serialize: + ($value) => $value.toJson( + (value) => value, + (value) => _i4.Serializers.instance + .serialize<_i14.IMap>(value), + ), + deserialize: ($serialized) { + return _i14.IMap>.fromJson( + $serialized, + (value) => (value as String), + (value) => _i4.Serializers.instance + .deserialize<_i14.IMap>(value), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i14.IMap>, + Map + >( + serialize: + ($value) => $value.toJson( + (value) => value, + (value) => _i4.Serializers.instance + .serialize<_i14.IMap>(value), + ), + deserialize: ($serialized) { + return _i14.IMap>.fromJson( + $serialized, + (value) => (value as String), + (value) => _i4.Serializers.instance + .deserialize<_i14.IMap>(value), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i14.IMap>, + Map + >( + serialize: + ($value) => $value.toJson( + (value) => value, + (value) => _i4.Serializers.instance + .serialize<_i14.IMap>(value), + ), + deserialize: ($serialized) { + return _i14.IMap< + String, + _i14.IMap + >.fromJson( + $serialized, + (value) => (value as String), + (value) => _i4.Serializers.instance + .deserialize<_i14.IMap>(value), + ); + }, + ), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': GenericWrappersTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/generic_wrappers/genericWrappersAsync.dart b/apps/cli/fixtures/legacy/api/goldens/functions/generic_wrappers/genericWrappersAsync.dart new file mode 100644 index 000000000..7c75ddb9f --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/generic_wrappers/genericWrappersAsync.dart @@ -0,0 +1,2088 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/generic_wrappers.dart' as _i5; +import 'package:celest_backend/models/parameter_types.dart' as _i13; +import 'package:celest_backend/src/functions/generic_wrappers.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i15; +import 'package:fast_immutable_collections/src/ilist/ilist.dart' as _i12; +import 'package:fast_immutable_collections/src/imap/imap.dart' as _i14; +import 'package:shelf/shelf.dart' as _i2; + +final class GenericWrappersAsyncTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'genericWrappersAsync'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = await _i3.genericWrappersAsync( + _i4.Serializers.instance.deserialize<_i5.GenericWrappers>( + request[r'value'], + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.GenericWrappers>(response), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.GenericWrappers, Map>( + serialize: + ($value) => { + r'listOfString': _i4.Serializers.instance + .serialize<_i12.IList>($value.listOfString), + r'listOfUri': _i4.Serializers.instance.serialize<_i12.IList>( + $value.listOfUri, + ), + r'listOfSimpleClass': _i4.Serializers.instance + .serialize<_i12.IList<_i13.SimpleClass>>( + $value.listOfSimpleClass, + ), + r'listOfListOfString': _i4.Serializers.instance + .serialize<_i12.IList<_i12.IList>>( + $value.listOfListOfString, + ), + r'listOfListOfUri': _i4.Serializers.instance + .serialize<_i12.IList<_i12.IList>>( + $value.listOfListOfUri, + ), + r'listOfListOfSimpleClass': _i4.Serializers.instance + .serialize<_i12.IList<_i12.IList<_i13.SimpleClass>>>( + $value.listOfListOfSimpleClass, + ), + r'mapOfString': _i4.Serializers.instance + .serialize<_i14.IMap>($value.mapOfString), + r'mapOfUri': _i4.Serializers.instance + .serialize<_i14.IMap>($value.mapOfUri), + r'mapOfSimpleClass': _i4.Serializers.instance + .serialize<_i14.IMap>( + $value.mapOfSimpleClass, + ), + r'mapOfListOfString': _i4.Serializers.instance + .serialize<_i14.IMap>>( + $value.mapOfListOfString, + ), + r'mapOfListOfUri': _i4.Serializers.instance + .serialize<_i14.IMap>>( + $value.mapOfListOfUri, + ), + r'mapOfListOfSimpleClass': _i4.Serializers.instance + .serialize<_i14.IMap>>( + $value.mapOfListOfSimpleClass, + ), + r'mapOfMapOfString': _i4.Serializers.instance + .serialize<_i14.IMap>>( + $value.mapOfMapOfString, + ), + r'mapOfMapOfUri': _i4.Serializers.instance + .serialize<_i14.IMap>>( + $value.mapOfMapOfUri, + ), + r'mapOfMapOfSimpleClass': _i4.Serializers.instance.serialize< + _i14.IMap> + >($value.mapOfMapOfSimpleClass), + }, + deserialize: ($serialized) { + return _i5.GenericWrappers( + listOfString: _i4.Serializers.instance + .deserialize<_i12.IList>($serialized[r'listOfString']), + listOfUri: _i4.Serializers.instance.deserialize<_i12.IList>( + $serialized[r'listOfUri'], + ), + listOfSimpleClass: _i4.Serializers.instance + .deserialize<_i12.IList<_i13.SimpleClass>>( + $serialized[r'listOfSimpleClass'], + ), + listOfListOfString: _i4.Serializers.instance + .deserialize<_i12.IList<_i12.IList>>( + $serialized[r'listOfListOfString'], + ), + listOfListOfUri: _i4.Serializers.instance + .deserialize<_i12.IList<_i12.IList>>( + $serialized[r'listOfListOfUri'], + ), + listOfListOfSimpleClass: _i4.Serializers.instance + .deserialize<_i12.IList<_i12.IList<_i13.SimpleClass>>>( + $serialized[r'listOfListOfSimpleClass'], + ), + mapOfString: _i4.Serializers.instance + .deserialize<_i14.IMap>( + $serialized[r'mapOfString'], + ), + mapOfUri: _i4.Serializers.instance + .deserialize<_i14.IMap>($serialized[r'mapOfUri']), + mapOfSimpleClass: _i4.Serializers.instance + .deserialize<_i14.IMap>( + $serialized[r'mapOfSimpleClass'], + ), + mapOfListOfString: _i4.Serializers.instance + .deserialize<_i14.IMap>>( + $serialized[r'mapOfListOfString'], + ), + mapOfListOfUri: _i4.Serializers.instance + .deserialize<_i14.IMap>>( + $serialized[r'mapOfListOfUri'], + ), + mapOfListOfSimpleClass: _i4.Serializers.instance + .deserialize<_i14.IMap>>( + $serialized[r'mapOfListOfSimpleClass'], + ), + mapOfMapOfString: _i4.Serializers.instance + .deserialize<_i14.IMap>>( + $serialized[r'mapOfMapOfString'], + ), + mapOfMapOfUri: _i4.Serializers.instance + .deserialize<_i14.IMap>>( + $serialized[r'mapOfMapOfUri'], + ), + mapOfMapOfSimpleClass: _i4.Serializers.instance.deserialize< + _i14.IMap> + >($serialized[r'mapOfMapOfSimpleClass']), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.SimpleClass, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i13.SimpleClass.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i15.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i15.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i15.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i15.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i15.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i15.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i15.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i15.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i15.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i15.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i15.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i15.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i15.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i15.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i15.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i15.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i15.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i15.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.IList, dynamic>( + serialize: ($value) => $value.toJson((value) => value), + deserialize: ($serialized) { + return _i12.IList.fromJson( + $serialized, + (value) => (value as String), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.IList, dynamic>( + serialize: + ($value) => $value.toJson( + (value) => _i4.Serializers.instance.serialize(value), + ), + deserialize: ($serialized) { + return _i12.IList.fromJson( + $serialized, + (value) => _i4.Serializers.instance.deserialize(value), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.IList<_i13.SimpleClass>, dynamic>( + serialize: + ($value) => $value.toJson( + (value) => + _i4.Serializers.instance.serialize<_i13.SimpleClass>(value), + ), + deserialize: ($serialized) { + return _i12.IList<_i13.SimpleClass>.fromJson( + $serialized, + (value) => + _i4.Serializers.instance.deserialize<_i13.SimpleClass>(value), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.IList<_i12.IList>, dynamic>( + serialize: + ($value) => $value.toJson( + (value) => + _i4.Serializers.instance.serialize<_i12.IList>(value), + ), + deserialize: ($serialized) { + return _i12.IList<_i12.IList>.fromJson( + $serialized, + (value) => + _i4.Serializers.instance.deserialize<_i12.IList>(value), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.IList<_i12.IList>, dynamic>( + serialize: + ($value) => $value.toJson( + (value) => + _i4.Serializers.instance.serialize<_i12.IList>(value), + ), + deserialize: ($serialized) { + return _i12.IList<_i12.IList>.fromJson( + $serialized, + (value) => + _i4.Serializers.instance.deserialize<_i12.IList>(value), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.IList<_i12.IList<_i13.SimpleClass>>, dynamic>( + serialize: + ($value) => $value.toJson( + (value) => _i4.Serializers.instance + .serialize<_i12.IList<_i13.SimpleClass>>(value), + ), + deserialize: ($serialized) { + return _i12.IList<_i12.IList<_i13.SimpleClass>>.fromJson( + $serialized, + (value) => _i4.Serializers.instance + .deserialize<_i12.IList<_i13.SimpleClass>>(value), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i14.IMap, Map>( + serialize: + ($value) => $value.toJson((value) => value, (value) => value), + deserialize: ($serialized) { + return _i14.IMap.fromJson( + $serialized, + (value) => (value as String), + (value) => (value as String), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i14.IMap, Map>( + serialize: + ($value) => $value.toJson( + (value) => value, + (value) => _i4.Serializers.instance.serialize(value), + ), + deserialize: ($serialized) { + return _i14.IMap.fromJson( + $serialized, + (value) => (value as String), + (value) => _i4.Serializers.instance.deserialize(value), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i14.IMap, + Map + >( + serialize: + ($value) => $value.toJson( + (value) => value, + (value) => + _i4.Serializers.instance.serialize<_i13.SimpleClass>(value), + ), + deserialize: ($serialized) { + return _i14.IMap.fromJson( + $serialized, + (value) => (value as String), + (value) => + _i4.Serializers.instance.deserialize<_i13.SimpleClass>(value), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i14.IMap>, + Map + >( + serialize: + ($value) => $value.toJson( + (value) => value, + (value) => + _i4.Serializers.instance.serialize<_i12.IList>(value), + ), + deserialize: ($serialized) { + return _i14.IMap>.fromJson( + $serialized, + (value) => (value as String), + (value) => + _i4.Serializers.instance.deserialize<_i12.IList>(value), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i14.IMap>, + Map + >( + serialize: + ($value) => $value.toJson( + (value) => value, + (value) => + _i4.Serializers.instance.serialize<_i12.IList>(value), + ), + deserialize: ($serialized) { + return _i14.IMap>.fromJson( + $serialized, + (value) => (value as String), + (value) => + _i4.Serializers.instance.deserialize<_i12.IList>(value), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i14.IMap>, + Map + >( + serialize: + ($value) => $value.toJson( + (value) => value, + (value) => _i4.Serializers.instance + .serialize<_i12.IList<_i13.SimpleClass>>(value), + ), + deserialize: ($serialized) { + return _i14.IMap>.fromJson( + $serialized, + (value) => (value as String), + (value) => _i4.Serializers.instance + .deserialize<_i12.IList<_i13.SimpleClass>>(value), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i14.IMap>, + Map + >( + serialize: + ($value) => $value.toJson( + (value) => value, + (value) => _i4.Serializers.instance + .serialize<_i14.IMap>(value), + ), + deserialize: ($serialized) { + return _i14.IMap>.fromJson( + $serialized, + (value) => (value as String), + (value) => _i4.Serializers.instance + .deserialize<_i14.IMap>(value), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i14.IMap>, + Map + >( + serialize: + ($value) => $value.toJson( + (value) => value, + (value) => _i4.Serializers.instance + .serialize<_i14.IMap>(value), + ), + deserialize: ($serialized) { + return _i14.IMap>.fromJson( + $serialized, + (value) => (value as String), + (value) => _i4.Serializers.instance + .deserialize<_i14.IMap>(value), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i14.IMap>, + Map + >( + serialize: + ($value) => $value.toJson( + (value) => value, + (value) => _i4.Serializers.instance + .serialize<_i14.IMap>(value), + ), + deserialize: ($serialized) { + return _i14.IMap< + String, + _i14.IMap + >.fromJson( + $serialized, + (value) => (value as String), + (value) => _i4.Serializers.instance + .deserialize<_i14.IMap>(value), + ); + }, + ), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': GenericWrappersAsyncTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/metadata/hasConstructedDeprecatedAnnotation.dart b/apps/cli/fixtures/legacy/api/goldens/functions/metadata/hasConstructedDeprecatedAnnotation.dart new file mode 100644 index 000000000..5acca4e43 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/metadata/hasConstructedDeprecatedAnnotation.dart @@ -0,0 +1,1686 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i9; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/metadata.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i10; +import 'package:celest_core/src/serialization/json_value.dart' as _i11; +import 'package:shelf/shelf.dart' as _i2; + +final class HasConstructedDeprecatedAnnotationTarget + extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'hasConstructedDeprecatedAnnotation'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + _i3.hasConstructedDeprecatedAnnotation(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(null), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i9.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i10.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i9.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i10.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i11.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': HasConstructedDeprecatedAnnotationTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/metadata/hasDeprecatedAnnotation.dart b/apps/cli/fixtures/legacy/api/goldens/functions/metadata/hasDeprecatedAnnotation.dart new file mode 100644 index 000000000..f1d3bbdab --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/metadata/hasDeprecatedAnnotation.dart @@ -0,0 +1,1685 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i9; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/metadata.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i10; +import 'package:celest_core/src/serialization/json_value.dart' as _i11; +import 'package:shelf/shelf.dart' as _i2; + +final class HasDeprecatedAnnotationTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'hasDeprecatedAnnotation'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + _i3.hasDeprecatedAnnotation(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(null), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i9.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i10.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i9.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i10.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i11.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': HasDeprecatedAnnotationTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/metadata/hasDocComments.dart b/apps/cli/fixtures/legacy/api/goldens/functions/metadata/hasDocComments.dart new file mode 100644 index 000000000..52ffd9db5 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/metadata/hasDocComments.dart @@ -0,0 +1,1685 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i9; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/metadata.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i10; +import 'package:celest_core/src/serialization/json_value.dart' as _i11; +import 'package:shelf/shelf.dart' as _i2; + +final class HasDocCommentsTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'hasDocComments'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + _i3.hasDocComments(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(null), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i9.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i10.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i9.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i10.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i11.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': HasDocCommentsTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/metadata/hasExportableAnnotation.dart b/apps/cli/fixtures/legacy/api/goldens/functions/metadata/hasExportableAnnotation.dart new file mode 100644 index 000000000..d4468dc98 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/metadata/hasExportableAnnotation.dart @@ -0,0 +1,1688 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i9; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/metadata.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i10; +import 'package:celest_core/src/serialization/json_value.dart' as _i11; +import 'package:shelf/shelf.dart' as _i2; + +final class HasExportableAnnotationTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'hasExportableAnnotation'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + _i3.hasExportableAnnotation( + (request[r'value'] as String), + named: ((request[r'named'] as String?)) ?? 'named', + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(null), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i9.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i10.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i9.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i10.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i11.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': HasExportableAnnotationTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/metadata/hasExportableConstructedAnnotation.dart b/apps/cli/fixtures/legacy/api/goldens/functions/metadata/hasExportableConstructedAnnotation.dart new file mode 100644 index 000000000..b3b2c325c --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/metadata/hasExportableConstructedAnnotation.dart @@ -0,0 +1,1689 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i9; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/metadata.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i10; +import 'package:celest_core/src/serialization/json_value.dart' as _i11; +import 'package:shelf/shelf.dart' as _i2; + +final class HasExportableConstructedAnnotationTarget + extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'hasExportableConstructedAnnotation'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + _i3.hasExportableConstructedAnnotation( + (request[r'value'] as String), + named: ((request[r'named'] as String?)) ?? 'named', + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(null), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i9.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i10.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i9.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i10.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i11.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': HasExportableConstructedAnnotationTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/metadata/hasLiteralsAnnotation.dart b/apps/cli/fixtures/legacy/api/goldens/functions/metadata/hasLiteralsAnnotation.dart new file mode 100644 index 000000000..1ebfdc6c8 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/metadata/hasLiteralsAnnotation.dart @@ -0,0 +1,1688 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i9; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/metadata.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i10; +import 'package:celest_core/src/serialization/json_value.dart' as _i11; +import 'package:shelf/shelf.dart' as _i2; + +final class HasLiteralsAnnotationTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'hasLiteralsAnnotation'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + _i3.hasLiteralsAnnotation( + (request[r'value'] as String), + named: (request[r'named'] as String), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(null), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i9.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i10.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i9.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i10.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i11.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': HasLiteralsAnnotationTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/metadata/hasNamedConstructedAnnotation.dart b/apps/cli/fixtures/legacy/api/goldens/functions/metadata/hasNamedConstructedAnnotation.dart new file mode 100644 index 000000000..6031b09ea --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/metadata/hasNamedConstructedAnnotation.dart @@ -0,0 +1,1686 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i9; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/metadata.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i10; +import 'package:celest_core/src/serialization/json_value.dart' as _i11; +import 'package:shelf/shelf.dart' as _i2; + +final class HasNamedConstructedAnnotationTarget + extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'hasNamedConstructedAnnotation'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + _i3.hasNamedConstructedAnnotation(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(null), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i9.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i10.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i9.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i10.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i11.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': HasNamedConstructedAnnotationTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/metadata/hasNotExportableAnnotation.dart b/apps/cli/fixtures/legacy/api/goldens/functions/metadata/hasNotExportableAnnotation.dart new file mode 100644 index 000000000..d6fac8796 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/metadata/hasNotExportableAnnotation.dart @@ -0,0 +1,1689 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i9; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/metadata.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i10; +import 'package:celest_core/src/serialization/json_value.dart' as _i11; +import 'package:shelf/shelf.dart' as _i2; + +final class HasNotExportableAnnotationTarget + extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'hasNotExportableAnnotation'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + _i3.hasNotExportableAnnotation( + (request[r'value'] as String), + named: ((request[r'named'] as String?)) ?? 'named', + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(null), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i9.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i10.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i9.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i10.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i11.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': HasNotExportableAnnotationTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/metadata/namedDefaultValueVars.dart b/apps/cli/fixtures/legacy/api/goldens/functions/metadata/namedDefaultValueVars.dart new file mode 100644 index 000000000..e81ef9fc8 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/metadata/namedDefaultValueVars.dart @@ -0,0 +1,1771 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/metadata.dart' as _i5; +import 'package:celest_backend/src/functions/metadata.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class NamedDefaultValueVarsTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'namedDefaultValueVars'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + _i3.namedDefaultValueVars( + value: ((request[r'value'] as num?)?.toInt()) ?? _i3.defaultInt, + doubleValue: + ((request[r'doubleValue'] as num?)?.toDouble()) ?? + _i3.defaultDouble, + boolValue: ((request[r'boolValue'] as bool?)) ?? _i3.defaultBool, + stringValue: + ((request[r'stringValue'] as String?)) ?? _i3.defaultString, + listValue: + ((request[r'listValue'] as Iterable?) + ?.map((el) => (el as String)) + .toList()) ?? + _i3.defaultList, + mapValue: + ((request[r'mapValue'] as Map?)?.map( + (key, value) => MapEntry(key, (value as String)), + )) ?? + _i3.defaultMap, + enumValue: + (_i4.Serializers.instance.deserialize<_i5.LiteralEnum?>( + request[r'enumValue'], + )) ?? + _i3.defaultEnum, + recordValue: + (_i4.Serializers.instance + .deserialize<({String a, String b, String c})?>( + request[r'recordValue'], + )) ?? + _i3.defaultRecord, + exportable: + (_i4.Serializers.instance.deserialize<_i5.Exportable?>( + request[r'exportable'], + )) ?? + _i3.defaultExportable, + serializable: + (_i4.Serializers.instance.deserialize<_i5.Serializable?>( + request[r'serializable'], + )) ?? + _i3.defaultSerializable, + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(null), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + r'a': $value.a, + r'b': $value.b, + r'c': $value.c, + }, + deserialize: ($serialized) { + return ( + a: ($serialized[r'a'] as String), + b: ($serialized[r'b'] as String), + c: ($serialized[r'c'] as String), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.Exportable, Map?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return _i5.Exportable(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.LiteralEnum, String>( + serialize: ($value) => $value.name, + deserialize: ($serialized) { + return _i5.LiteralEnum.values.byName($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.Serializable, Map?>( + serialize: + ($value) => { + if ($value.type case final type?) r'type': type, + }, + deserialize: ($serialized) { + return _i5.Serializable(($serialized?[r'type'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': NamedDefaultValueVarsTarget()}, + setup: (_i7.Context context) async {}, + ); +} + +typedef Record$k7x4l9 = ({String a, String b, String c}); diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/metadata/namedDefaultValueVarsPrivate.dart b/apps/cli/fixtures/legacy/api/goldens/functions/metadata/namedDefaultValueVarsPrivate.dart new file mode 100644 index 000000000..f182216fc --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/metadata/namedDefaultValueVarsPrivate.dart @@ -0,0 +1,1769 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/metadata.dart' as _i5; +import 'package:celest_backend/src/functions/metadata.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class NamedDefaultValueVarsPrivateTarget + extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'namedDefaultValueVarsPrivate'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + _i3.namedDefaultValueVarsPrivate( + value: ((request[r'value'] as num?)?.toInt()) ?? 42, + doubleValue: ((request[r'doubleValue'] as num?)?.toDouble()) ?? 42.0, + boolValue: ((request[r'boolValue'] as bool?)) ?? true, + stringValue: ((request[r'stringValue'] as String?)) ?? 'default', + listValue: + ((request[r'listValue'] as Iterable?) + ?.map((el) => (el as String)) + .toList()) ?? + const ['default'], + mapValue: + ((request[r'mapValue'] as Map?)?.map( + (key, value) => MapEntry(key, (value as String)), + )) ?? + const {'default': 'default'}, + enumValue: + (_i4.Serializers.instance.deserialize<_i5.LiteralEnum?>( + request[r'enumValue'], + )) ?? + _i5.LiteralEnum.a, + recordValue: + (_i4.Serializers.instance + .deserialize<({String a, String b, String c})?>( + request[r'recordValue'], + )) ?? + const (a: 'a', b: 'b', c: 'c'), + exportable: + (_i4.Serializers.instance.deserialize<_i5.Exportable?>( + request[r'exportable'], + )) ?? + const _i5.Exportable(), + serializable: + (_i4.Serializers.instance.deserialize<_i5.Serializable?>( + request[r'serializable'], + )) ?? + const _i5.Serializable.forType('String'), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(null), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + r'a': $value.a, + r'b': $value.b, + r'c': $value.c, + }, + deserialize: ($serialized) { + return ( + a: ($serialized[r'a'] as String), + b: ($serialized[r'b'] as String), + c: ($serialized[r'c'] as String), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.Exportable, Map?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return _i5.Exportable(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.LiteralEnum, String>( + serialize: ($value) => $value.name, + deserialize: ($serialized) { + return _i5.LiteralEnum.values.byName($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.Serializable, Map?>( + serialize: + ($value) => { + if ($value.type case final type?) r'type': type, + }, + deserialize: ($serialized) { + return _i5.Serializable(($serialized?[r'type'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': NamedDefaultValueVarsPrivateTarget()}, + setup: (_i7.Context context) async {}, + ); +} + +typedef Record$k7x4l9 = ({String a, String b, String c}); diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/metadata/namedDefaultValues.dart b/apps/cli/fixtures/legacy/api/goldens/functions/metadata/namedDefaultValues.dart new file mode 100644 index 000000000..55a70afef --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/metadata/namedDefaultValues.dart @@ -0,0 +1,1768 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/metadata.dart' as _i5; +import 'package:celest_backend/src/functions/metadata.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class NamedDefaultValuesTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'namedDefaultValues'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + _i3.namedDefaultValues( + value: ((request[r'value'] as String?)) ?? 'value', + intValue: ((request[r'intValue'] as num?)?.toInt()) ?? 1, + doubleValue: ((request[r'doubleValue'] as num?)?.toDouble()) ?? 1.0, + boolValue: ((request[r'boolValue'] as bool?)) ?? true, + list: + ((request[r'list'] as Iterable?) + ?.map((el) => (el as String)) + .toList()) ?? + const ['list'], + map: + ((request[r'map'] as Map?)?.map( + (key, value) => MapEntry(key, (value as String)), + )) ?? + const {'map': 'map'}, + exportable: + (_i4.Serializers.instance.deserialize<_i5.Exportable?>( + request[r'exportable'], + )) ?? + const _i5.Exportable(), + serializable: + (_i4.Serializers.instance.deserialize<_i5.Serializable?>( + request[r'serializable'], + )) ?? + const _i5.Serializable.forType('String'), + enumValue: + (_i4.Serializers.instance.deserialize<_i5.LiteralEnum?>( + request[r'enumValue'], + )) ?? + _i5.LiteralEnum.a, + recordValue: + (_i4.Serializers.instance + .deserialize<({String a, String b, String c})?>( + request[r'recordValue'], + )) ?? + const (a: 'a', b: 'b', c: 'c'), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(null), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + r'a': $value.a, + r'b': $value.b, + r'c': $value.c, + }, + deserialize: ($serialized) { + return ( + a: ($serialized[r'a'] as String), + b: ($serialized[r'b'] as String), + c: ($serialized[r'c'] as String), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.Exportable, Map?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return _i5.Exportable(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.LiteralEnum, String>( + serialize: ($value) => $value.name, + deserialize: ($serialized) { + return _i5.LiteralEnum.values.byName($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.Serializable, Map?>( + serialize: + ($value) => { + if ($value.type case final type?) r'type': type, + }, + deserialize: ($serialized) { + return _i5.Serializable(($serialized?[r'type'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': NamedDefaultValuesTarget()}, + setup: (_i7.Context context) async {}, + ); +} + +typedef Record$k7x4l9 = ({String a, String b, String c}); diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/metadata/nullableNamedDefaultValueVars.dart b/apps/cli/fixtures/legacy/api/goldens/functions/metadata/nullableNamedDefaultValueVars.dart new file mode 100644 index 000000000..e4e18b679 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/metadata/nullableNamedDefaultValueVars.dart @@ -0,0 +1,1772 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/metadata.dart' as _i5; +import 'package:celest_backend/src/functions/metadata.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class NullableNamedDefaultValueVarsTarget + extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'nullableNamedDefaultValueVars'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + _i3.nullableNamedDefaultValueVars( + value: ((request[r'value'] as num?)?.toInt()) ?? _i3.defaultInt, + doubleValue: + ((request[r'doubleValue'] as num?)?.toDouble()) ?? + _i3.defaultDouble, + boolValue: ((request[r'boolValue'] as bool?)) ?? _i3.defaultBool, + stringValue: + ((request[r'stringValue'] as String?)) ?? _i3.defaultString, + listValue: + ((request[r'listValue'] as Iterable?) + ?.map((el) => (el as String)) + .toList()) ?? + _i3.defaultList, + mapValue: + ((request[r'mapValue'] as Map?)?.map( + (key, value) => MapEntry(key, (value as String)), + )) ?? + _i3.defaultMap, + enumValue: + (_i4.Serializers.instance.deserialize<_i5.LiteralEnum?>( + request[r'enumValue'], + )) ?? + _i3.defaultEnum, + recordValue: + (_i4.Serializers.instance + .deserialize<({String a, String b, String c})?>( + request[r'recordValue'], + )) ?? + _i3.defaultRecord, + exportable: + (_i4.Serializers.instance.deserialize<_i5.Exportable?>( + request[r'exportable'], + )) ?? + _i3.defaultExportable, + serializable: + (_i4.Serializers.instance.deserialize<_i5.Serializable?>( + request[r'serializable'], + )) ?? + _i3.defaultSerializable, + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(null), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + r'a': $value.a, + r'b': $value.b, + r'c': $value.c, + }, + deserialize: ($serialized) { + return ( + a: ($serialized[r'a'] as String), + b: ($serialized[r'b'] as String), + c: ($serialized[r'c'] as String), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.Exportable, Map?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return _i5.Exportable(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.LiteralEnum, String>( + serialize: ($value) => $value.name, + deserialize: ($serialized) { + return _i5.LiteralEnum.values.byName($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.Serializable, Map?>( + serialize: + ($value) => { + if ($value.type case final type?) r'type': type, + }, + deserialize: ($serialized) { + return _i5.Serializable(($serialized?[r'type'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': NullableNamedDefaultValueVarsTarget()}, + setup: (_i7.Context context) async {}, + ); +} + +typedef Record$k7x4l9 = ({String a, String b, String c}); diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/metadata/nullableNamedDefaultValueVarsPrivate.dart b/apps/cli/fixtures/legacy/api/goldens/functions/metadata/nullableNamedDefaultValueVarsPrivate.dart new file mode 100644 index 000000000..162f98e3a --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/metadata/nullableNamedDefaultValueVarsPrivate.dart @@ -0,0 +1,1769 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/metadata.dart' as _i5; +import 'package:celest_backend/src/functions/metadata.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class NullableNamedDefaultValueVarsPrivateTarget + extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'nullableNamedDefaultValueVarsPrivate'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + _i3.nullableNamedDefaultValueVarsPrivate( + value: ((request[r'value'] as num?)?.toInt()) ?? 42, + doubleValue: ((request[r'doubleValue'] as num?)?.toDouble()) ?? 42.0, + boolValue: ((request[r'boolValue'] as bool?)) ?? true, + stringValue: ((request[r'stringValue'] as String?)) ?? 'default', + listValue: + ((request[r'listValue'] as Iterable?) + ?.map((el) => (el as String)) + .toList()) ?? + const ['default'], + mapValue: + ((request[r'mapValue'] as Map?)?.map( + (key, value) => MapEntry(key, (value as String)), + )) ?? + const {'default': 'default'}, + enumValue: + (_i4.Serializers.instance.deserialize<_i5.LiteralEnum?>( + request[r'enumValue'], + )) ?? + _i5.LiteralEnum.a, + recordValue: + (_i4.Serializers.instance + .deserialize<({String a, String b, String c})?>( + request[r'recordValue'], + )) ?? + const (a: 'a', b: 'b', c: 'c'), + exportable: + (_i4.Serializers.instance.deserialize<_i5.Exportable?>( + request[r'exportable'], + )) ?? + const _i5.Exportable(), + serializable: + (_i4.Serializers.instance.deserialize<_i5.Serializable?>( + request[r'serializable'], + )) ?? + const _i5.Serializable.forType('String'), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(null), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + r'a': $value.a, + r'b': $value.b, + r'c': $value.c, + }, + deserialize: ($serialized) { + return ( + a: ($serialized[r'a'] as String), + b: ($serialized[r'b'] as String), + c: ($serialized[r'c'] as String), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.Exportable, Map?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return _i5.Exportable(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.LiteralEnum, String>( + serialize: ($value) => $value.name, + deserialize: ($serialized) { + return _i5.LiteralEnum.values.byName($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.Serializable, Map?>( + serialize: + ($value) => { + if ($value.type case final type?) r'type': type, + }, + deserialize: ($serialized) { + return _i5.Serializable(($serialized?[r'type'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': NullableNamedDefaultValueVarsPrivateTarget()}, + setup: (_i7.Context context) async {}, + ); +} + +typedef Record$k7x4l9 = ({String a, String b, String c}); diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/metadata/nullableNamedDefaultValues.dart b/apps/cli/fixtures/legacy/api/goldens/functions/metadata/nullableNamedDefaultValues.dart new file mode 100644 index 000000000..211f3344c --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/metadata/nullableNamedDefaultValues.dart @@ -0,0 +1,1769 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/metadata.dart' as _i5; +import 'package:celest_backend/src/functions/metadata.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class NullableNamedDefaultValuesTarget + extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'nullableNamedDefaultValues'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + _i3.nullableNamedDefaultValues( + value: ((request[r'value'] as String?)) ?? 'value', + intValue: ((request[r'intValue'] as num?)?.toInt()) ?? 1, + doubleValue: ((request[r'doubleValue'] as num?)?.toDouble()) ?? 1.0, + boolValue: ((request[r'boolValue'] as bool?)) ?? true, + list: + ((request[r'list'] as Iterable?) + ?.map((el) => (el as String)) + .toList()) ?? + const ['list'], + map: + ((request[r'map'] as Map?)?.map( + (key, value) => MapEntry(key, (value as String)), + )) ?? + const {'map': 'map'}, + exportable: + (_i4.Serializers.instance.deserialize<_i5.Exportable?>( + request[r'exportable'], + )) ?? + const _i5.Exportable(), + serializable: + (_i4.Serializers.instance.deserialize<_i5.Serializable?>( + request[r'serializable'], + )) ?? + const _i5.Serializable.forType('String'), + enumValue: + (_i4.Serializers.instance.deserialize<_i5.LiteralEnum?>( + request[r'enumValue'], + )) ?? + _i5.LiteralEnum.a, + recordValue: + (_i4.Serializers.instance + .deserialize<({String a, String b, String c})?>( + request[r'recordValue'], + )) ?? + const (a: 'a', b: 'b', c: 'c'), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(null), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + r'a': $value.a, + r'b': $value.b, + r'c': $value.c, + }, + deserialize: ($serialized) { + return ( + a: ($serialized[r'a'] as String), + b: ($serialized[r'b'] as String), + c: ($serialized[r'c'] as String), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.Exportable, Map?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return _i5.Exportable(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.LiteralEnum, String>( + serialize: ($value) => $value.name, + deserialize: ($serialized) { + return _i5.LiteralEnum.values.byName($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.Serializable, Map?>( + serialize: + ($value) => { + if ($value.type case final type?) r'type': type, + }, + deserialize: ($serialized) { + return _i5.Serializable(($serialized?[r'type'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': NullableNamedDefaultValuesTarget()}, + setup: (_i7.Context context) async {}, + ); +} + +typedef Record$k7x4l9 = ({String a, String b, String c}); diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/metadata/nullablePositionalDefaultValueVars.dart b/apps/cli/fixtures/legacy/api/goldens/functions/metadata/nullablePositionalDefaultValueVars.dart new file mode 100644 index 000000000..7e33004bd --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/metadata/nullablePositionalDefaultValueVars.dart @@ -0,0 +1,1763 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/metadata.dart' as _i5; +import 'package:celest_backend/src/functions/metadata.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class NullablePositionalDefaultValueVarsTarget + extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'nullablePositionalDefaultValueVars'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + _i3.nullablePositionalDefaultValueVars( + ((request[r'value'] as num?)?.toInt()) ?? _i3.defaultInt, + ((request[r'doubleValue'] as num?)?.toDouble()) ?? _i3.defaultDouble, + ((request[r'boolValue'] as bool?)) ?? _i3.defaultBool, + ((request[r'stringValue'] as String?)) ?? _i3.defaultString, + ((request[r'listValue'] as Iterable?) + ?.map((el) => (el as String)) + .toList()) ?? + _i3.defaultList, + ((request[r'mapValue'] as Map?)?.map( + (key, value) => MapEntry(key, (value as String)), + )) ?? + _i3.defaultMap, + (_i4.Serializers.instance.deserialize<_i5.LiteralEnum?>( + request[r'enumValue'], + )) ?? + _i3.defaultEnum, + (_i4.Serializers.instance + .deserialize<({String a, String b, String c})?>( + request[r'recordValue'], + )) ?? + _i3.defaultRecord, + (_i4.Serializers.instance.deserialize<_i5.Exportable?>( + request[r'exportable'], + )) ?? + _i3.defaultExportable, + (_i4.Serializers.instance.deserialize<_i5.Serializable?>( + request[r'serializable'], + )) ?? + _i3.defaultSerializable, + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(null), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + r'a': $value.a, + r'b': $value.b, + r'c': $value.c, + }, + deserialize: ($serialized) { + return ( + a: ($serialized[r'a'] as String), + b: ($serialized[r'b'] as String), + c: ($serialized[r'c'] as String), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.Exportable, Map?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return _i5.Exportable(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.LiteralEnum, String>( + serialize: ($value) => $value.name, + deserialize: ($serialized) { + return _i5.LiteralEnum.values.byName($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.Serializable, Map?>( + serialize: + ($value) => { + if ($value.type case final type?) r'type': type, + }, + deserialize: ($serialized) { + return _i5.Serializable(($serialized?[r'type'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': NullablePositionalDefaultValueVarsTarget()}, + setup: (_i7.Context context) async {}, + ); +} + +typedef Record$k7x4l9 = ({String a, String b, String c}); diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/metadata/nullablePositionalDefaultValueVarsPrivate.dart b/apps/cli/fixtures/legacy/api/goldens/functions/metadata/nullablePositionalDefaultValueVarsPrivate.dart new file mode 100644 index 000000000..ec5a2eb09 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/metadata/nullablePositionalDefaultValueVarsPrivate.dart @@ -0,0 +1,1763 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/metadata.dart' as _i5; +import 'package:celest_backend/src/functions/metadata.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class NullablePositionalDefaultValueVarsPrivateTarget + extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'nullablePositionalDefaultValueVarsPrivate'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + _i3.nullablePositionalDefaultValueVarsPrivate( + ((request[r'value'] as num?)?.toInt()) ?? 42, + ((request[r'doubleValue'] as num?)?.toDouble()) ?? 42.0, + ((request[r'boolValue'] as bool?)) ?? true, + ((request[r'stringValue'] as String?)) ?? 'default', + ((request[r'listValue'] as Iterable?) + ?.map((el) => (el as String)) + .toList()) ?? + const ['default'], + ((request[r'mapValue'] as Map?)?.map( + (key, value) => MapEntry(key, (value as String)), + )) ?? + const {'default': 'default'}, + (_i4.Serializers.instance.deserialize<_i5.LiteralEnum?>( + request[r'enumValue'], + )) ?? + _i5.LiteralEnum.a, + (_i4.Serializers.instance + .deserialize<({String a, String b, String c})?>( + request[r'recordValue'], + )) ?? + const (a: 'a', b: 'b', c: 'c'), + (_i4.Serializers.instance.deserialize<_i5.Exportable?>( + request[r'exportable'], + )) ?? + const _i5.Exportable(), + (_i4.Serializers.instance.deserialize<_i5.Serializable?>( + request[r'serializable'], + )) ?? + const _i5.Serializable.forType('String'), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(null), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + r'a': $value.a, + r'b': $value.b, + r'c': $value.c, + }, + deserialize: ($serialized) { + return ( + a: ($serialized[r'a'] as String), + b: ($serialized[r'b'] as String), + c: ($serialized[r'c'] as String), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.Exportable, Map?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return _i5.Exportable(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.LiteralEnum, String>( + serialize: ($value) => $value.name, + deserialize: ($serialized) { + return _i5.LiteralEnum.values.byName($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.Serializable, Map?>( + serialize: + ($value) => { + if ($value.type case final type?) r'type': type, + }, + deserialize: ($serialized) { + return _i5.Serializable(($serialized?[r'type'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': NullablePositionalDefaultValueVarsPrivateTarget()}, + setup: (_i7.Context context) async {}, + ); +} + +typedef Record$k7x4l9 = ({String a, String b, String c}); diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/metadata/nullablePositionalDefaultValues.dart b/apps/cli/fixtures/legacy/api/goldens/functions/metadata/nullablePositionalDefaultValues.dart new file mode 100644 index 000000000..af5bd4117 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/metadata/nullablePositionalDefaultValues.dart @@ -0,0 +1,1763 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/metadata.dart' as _i5; +import 'package:celest_backend/src/functions/metadata.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class NullablePositionalDefaultValuesTarget + extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'nullablePositionalDefaultValues'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + _i3.nullablePositionalDefaultValues( + ((request[r'value'] as String?)) ?? 'value', + ((request[r'intValue'] as num?)?.toInt()) ?? 1, + ((request[r'doubleValue'] as num?)?.toDouble()) ?? 1.0, + ((request[r'boolValue'] as bool?)) ?? true, + ((request[r'list'] as Iterable?) + ?.map((el) => (el as String)) + .toList()) ?? + const ['list'], + ((request[r'map'] as Map?)?.map( + (key, value) => MapEntry(key, (value as String)), + )) ?? + const {'map': 'map'}, + (_i4.Serializers.instance.deserialize<_i5.Exportable?>( + request[r'exportable'], + )) ?? + const _i5.Exportable(), + (_i4.Serializers.instance.deserialize<_i5.Serializable?>( + request[r'serializable'], + )) ?? + const _i5.Serializable.forType('String'), + (_i4.Serializers.instance.deserialize<_i5.LiteralEnum?>( + request[r'enumValue'], + )) ?? + _i5.LiteralEnum.a, + (_i4.Serializers.instance + .deserialize<({String a, String b, String c})?>( + request[r'recordValue'], + )) ?? + const (a: 'a', b: 'b', c: 'c'), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(null), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + r'a': $value.a, + r'b': $value.b, + r'c': $value.c, + }, + deserialize: ($serialized) { + return ( + a: ($serialized[r'a'] as String), + b: ($serialized[r'b'] as String), + c: ($serialized[r'c'] as String), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.Exportable, Map?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return _i5.Exportable(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.LiteralEnum, String>( + serialize: ($value) => $value.name, + deserialize: ($serialized) { + return _i5.LiteralEnum.values.byName($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.Serializable, Map?>( + serialize: + ($value) => { + if ($value.type case final type?) r'type': type, + }, + deserialize: ($serialized) { + return _i5.Serializable(($serialized?[r'type'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': NullablePositionalDefaultValuesTarget()}, + setup: (_i7.Context context) async {}, + ); +} + +typedef Record$k7x4l9 = ({String a, String b, String c}); diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/metadata/positionalDefaultValueVars.dart b/apps/cli/fixtures/legacy/api/goldens/functions/metadata/positionalDefaultValueVars.dart new file mode 100644 index 000000000..c4a1fc882 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/metadata/positionalDefaultValueVars.dart @@ -0,0 +1,1763 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/metadata.dart' as _i5; +import 'package:celest_backend/src/functions/metadata.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class PositionalDefaultValueVarsTarget + extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'positionalDefaultValueVars'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + _i3.positionalDefaultValueVars( + ((request[r'value'] as num?)?.toInt()) ?? _i3.defaultInt, + ((request[r'doubleValue'] as num?)?.toDouble()) ?? _i3.defaultDouble, + ((request[r'boolValue'] as bool?)) ?? _i3.defaultBool, + ((request[r'stringValue'] as String?)) ?? _i3.defaultString, + ((request[r'listValue'] as Iterable?) + ?.map((el) => (el as String)) + .toList()) ?? + _i3.defaultList, + ((request[r'mapValue'] as Map?)?.map( + (key, value) => MapEntry(key, (value as String)), + )) ?? + _i3.defaultMap, + (_i4.Serializers.instance.deserialize<_i5.LiteralEnum?>( + request[r'enumValue'], + )) ?? + _i3.defaultEnum, + (_i4.Serializers.instance + .deserialize<({String a, String b, String c})?>( + request[r'recordValue'], + )) ?? + _i3.defaultRecord, + (_i4.Serializers.instance.deserialize<_i5.Exportable?>( + request[r'exportable'], + )) ?? + _i3.defaultExportable, + (_i4.Serializers.instance.deserialize<_i5.Serializable?>( + request[r'serializable'], + )) ?? + _i3.defaultSerializable, + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(null), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + r'a': $value.a, + r'b': $value.b, + r'c': $value.c, + }, + deserialize: ($serialized) { + return ( + a: ($serialized[r'a'] as String), + b: ($serialized[r'b'] as String), + c: ($serialized[r'c'] as String), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.Exportable, Map?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return _i5.Exportable(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.LiteralEnum, String>( + serialize: ($value) => $value.name, + deserialize: ($serialized) { + return _i5.LiteralEnum.values.byName($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.Serializable, Map?>( + serialize: + ($value) => { + if ($value.type case final type?) r'type': type, + }, + deserialize: ($serialized) { + return _i5.Serializable(($serialized?[r'type'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': PositionalDefaultValueVarsTarget()}, + setup: (_i7.Context context) async {}, + ); +} + +typedef Record$k7x4l9 = ({String a, String b, String c}); diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/metadata/positionalDefaultValueVarsPrivate.dart b/apps/cli/fixtures/legacy/api/goldens/functions/metadata/positionalDefaultValueVarsPrivate.dart new file mode 100644 index 000000000..1339abd3d --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/metadata/positionalDefaultValueVarsPrivate.dart @@ -0,0 +1,1763 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/metadata.dart' as _i5; +import 'package:celest_backend/src/functions/metadata.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class PositionalDefaultValueVarsPrivateTarget + extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'positionalDefaultValueVarsPrivate'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + _i3.positionalDefaultValueVarsPrivate( + ((request[r'value'] as num?)?.toInt()) ?? 42, + ((request[r'doubleValue'] as num?)?.toDouble()) ?? 42.0, + ((request[r'boolValue'] as bool?)) ?? true, + ((request[r'stringValue'] as String?)) ?? 'default', + ((request[r'listValue'] as Iterable?) + ?.map((el) => (el as String)) + .toList()) ?? + const ['default'], + ((request[r'mapValue'] as Map?)?.map( + (key, value) => MapEntry(key, (value as String)), + )) ?? + const {'default': 'default'}, + (_i4.Serializers.instance.deserialize<_i5.LiteralEnum?>( + request[r'enumValue'], + )) ?? + _i5.LiteralEnum.a, + (_i4.Serializers.instance + .deserialize<({String a, String b, String c})?>( + request[r'recordValue'], + )) ?? + const (a: 'a', b: 'b', c: 'c'), + (_i4.Serializers.instance.deserialize<_i5.Exportable?>( + request[r'exportable'], + )) ?? + const _i5.Exportable(), + (_i4.Serializers.instance.deserialize<_i5.Serializable?>( + request[r'serializable'], + )) ?? + const _i5.Serializable.forType('String'), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(null), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + r'a': $value.a, + r'b': $value.b, + r'c': $value.c, + }, + deserialize: ($serialized) { + return ( + a: ($serialized[r'a'] as String), + b: ($serialized[r'b'] as String), + c: ($serialized[r'c'] as String), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.Exportable, Map?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return _i5.Exportable(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.LiteralEnum, String>( + serialize: ($value) => $value.name, + deserialize: ($serialized) { + return _i5.LiteralEnum.values.byName($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.Serializable, Map?>( + serialize: + ($value) => { + if ($value.type case final type?) r'type': type, + }, + deserialize: ($serialized) { + return _i5.Serializable(($serialized?[r'type'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': PositionalDefaultValueVarsPrivateTarget()}, + setup: (_i7.Context context) async {}, + ); +} + +typedef Record$k7x4l9 = ({String a, String b, String c}); diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/metadata/positionalDefaultValues.dart b/apps/cli/fixtures/legacy/api/goldens/functions/metadata/positionalDefaultValues.dart new file mode 100644 index 000000000..4976125f6 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/metadata/positionalDefaultValues.dart @@ -0,0 +1,1762 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/metadata.dart' as _i5; +import 'package:celest_backend/src/functions/metadata.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class PositionalDefaultValuesTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'positionalDefaultValues'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + _i3.positionalDefaultValues( + ((request[r'value'] as String?)) ?? 'value', + ((request[r'intValue'] as num?)?.toInt()) ?? 1, + ((request[r'doubleValue'] as num?)?.toDouble()) ?? 1.0, + ((request[r'boolValue'] as bool?)) ?? true, + ((request[r'list'] as Iterable?) + ?.map((el) => (el as String)) + .toList()) ?? + const ['list'], + ((request[r'map'] as Map?)?.map( + (key, value) => MapEntry(key, (value as String)), + )) ?? + const {'map': 'map'}, + (_i4.Serializers.instance.deserialize<_i5.Exportable?>( + request[r'exportable'], + )) ?? + const _i5.Exportable(), + (_i4.Serializers.instance.deserialize<_i5.Serializable?>( + request[r'serializable'], + )) ?? + const _i5.Serializable.forType('String'), + (_i4.Serializers.instance.deserialize<_i5.LiteralEnum?>( + request[r'enumValue'], + )) ?? + _i5.LiteralEnum.a, + (_i4.Serializers.instance + .deserialize<({String a, String b, String c})?>( + request[r'recordValue'], + )) ?? + const (a: 'a', b: 'b', c: 'c'), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(null), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + r'a': $value.a, + r'b': $value.b, + r'c': $value.c, + }, + deserialize: ($serialized) { + return ( + a: ($serialized[r'a'] as String), + b: ($serialized[r'b'] as String), + c: ($serialized[r'c'] as String), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.Exportable, Map?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return _i5.Exportable(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.LiteralEnum, String>( + serialize: ($value) => $value.name, + deserialize: ($serialized) { + return _i5.LiteralEnum.values.byName($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.Serializable, Map?>( + serialize: + ($value) => { + if ($value.type case final type?) r'type': type, + }, + deserialize: ($serialized) { + return _i5.Serializable(($serialized?[r'type'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': PositionalDefaultValuesTarget()}, + setup: (_i7.Context context) async {}, + ); +} + +typedef Record$k7x4l9 = ({String a, String b, String c}); diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/overrides/callsThrowsCommonOverriddenException.dart b/apps/cli/fixtures/legacy/api/goldens/functions/overrides/callsThrowsCommonOverriddenException.dart new file mode 100644 index 000000000..c4d6344f0 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/overrides/callsThrowsCommonOverriddenException.dart @@ -0,0 +1,1793 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i10; + +import 'package:_common/_common.dart' as _i9; +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/exceptions/overrides.dart' as _i11; +import 'package:celest_backend/src/functions/overrides.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i12; +import 'package:celest_core/src/serialization/json_value.dart' as _i13; +import 'package:shelf/shelf.dart' as _i2; + +final class CallsThrowsCommonOverriddenExceptionTarget + extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'callsThrowsCommonOverriddenException'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + _i3.callsThrowsCommonOverriddenException(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(null), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.CommonException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': '_common.CommonException', + 'value': _i4.Serializers.instance.serialize<_i9.CommonException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.CustomException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': '_common.CustomException', + 'value': _i4.Serializers.instance.serialize<_i9.CustomException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.OverriddenException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'api.v1.OverriddenException', + 'value': _i4.Serializers.instance + .serialize<_i11.OverriddenException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i12.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i12.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.CommonException, Map>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return _i9.CommonException(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.CustomException, Map>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return _i9.CustomException(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.OverriddenException, Map>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return (_i9.OverriddenException(($serialized[r'message'] as String)) + as _i11.OverriddenException); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i12.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i13.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': CallsThrowsCommonOverriddenExceptionTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/overrides/callsThrowsOverriddenException.dart b/apps/cli/fixtures/legacy/api/goldens/functions/overrides/callsThrowsOverriddenException.dart new file mode 100644 index 000000000..634290a36 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/overrides/callsThrowsOverriddenException.dart @@ -0,0 +1,1793 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i10; + +import 'package:_common/_common.dart' as _i9; +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/exceptions/overrides.dart' as _i11; +import 'package:celest_backend/src/functions/overrides.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i12; +import 'package:celest_core/src/serialization/json_value.dart' as _i13; +import 'package:shelf/shelf.dart' as _i2; + +final class CallsThrowsOverriddenExceptionTarget + extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'callsThrowsOverriddenException'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + _i3.callsThrowsOverriddenException(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(null), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.CommonException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': '_common.CommonException', + 'value': _i4.Serializers.instance.serialize<_i9.CommonException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.CustomException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': '_common.CustomException', + 'value': _i4.Serializers.instance.serialize<_i9.CustomException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.OverriddenException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'api.v1.OverriddenException', + 'value': _i4.Serializers.instance + .serialize<_i11.OverriddenException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i12.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i12.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.CommonException, Map>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return _i9.CommonException(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.CustomException, Map>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return _i9.CustomException(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.OverriddenException, Map>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return (_i9.OverriddenException(($serialized[r'message'] as String)) + as _i11.OverriddenException); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i12.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i13.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': CallsThrowsOverriddenExceptionTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/overrides/commonNestedChild.dart b/apps/cli/fixtures/legacy/api/goldens/functions/overrides/commonNestedChild.dart new file mode 100644 index 000000000..cb8ac6acd --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/overrides/commonNestedChild.dart @@ -0,0 +1,1807 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:_common/_common.dart' as _i5; +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/exceptions/overrides.dart' as _i11; +import 'package:celest_backend/models/overrides.dart' as _i13; +import 'package:celest_backend/src/functions/overrides.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i12; +import 'package:celest_core/src/serialization/json_value.dart' as _i14; +import 'package:shelf/shelf.dart' as _i2; + +final class CommonNestedChildTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'commonNestedChild'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.commonNestedChild( + _i4.Serializers.instance.deserialize<_i5.NestedChild>( + request[r'child'], + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.NestedChild>(response), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CommonException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': '_common.CommonException', + 'value': _i4.Serializers.instance.serialize<_i5.CommonException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CustomException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': '_common.CustomException', + 'value': _i4.Serializers.instance.serialize<_i5.CustomException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.OverriddenException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'api.v1.OverriddenException', + 'value': _i4.Serializers.instance + .serialize<_i11.OverriddenException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i12.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i12.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CommonException, Map>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return _i5.CommonException(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CustomException, Map>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return _i5.CustomException(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.OverriddenException, Map>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return (_i5.OverriddenException(($serialized[r'message'] as String)) + as _i11.OverriddenException); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.NestedChild, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i13.NestedChild.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i12.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i14.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i14.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': CommonNestedChildTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/overrides/commonNestedParent.dart b/apps/cli/fixtures/legacy/api/goldens/functions/overrides/commonNestedParent.dart new file mode 100644 index 000000000..d71884dd5 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/overrides/commonNestedParent.dart @@ -0,0 +1,1825 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:_common/_common.dart' as _i5; +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/exceptions/overrides.dart' as _i11; +import 'package:celest_backend/models/overrides.dart' as _i13; +import 'package:celest_backend/src/functions/overrides.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i12; +import 'package:celest_core/src/serialization/json_value.dart' as _i14; +import 'package:shelf/shelf.dart' as _i2; + +final class CommonNestedParentTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'commonNestedParent'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.commonNestedParent( + _i4.Serializers.instance.deserialize<_i5.NestedParent>( + request[r'parent'], + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.NestedParent>(response), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CommonException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': '_common.CommonException', + 'value': _i4.Serializers.instance.serialize<_i5.CommonException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CustomException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': '_common.CustomException', + 'value': _i4.Serializers.instance.serialize<_i5.CustomException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.OverriddenException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'api.v1.OverriddenException', + 'value': _i4.Serializers.instance + .serialize<_i11.OverriddenException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i12.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i12.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CommonException, Map>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return _i5.CommonException(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CustomException, Map>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return _i5.CustomException(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.OverriddenException, Map>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return (_i5.OverriddenException(($serialized[r'message'] as String)) + as _i11.OverriddenException); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.NestedChild, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i13.NestedChild.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.NestedParent, Map>( + serialize: + ($value) => { + r'child': _i4.Serializers.instance.serialize<_i5.NestedChild>( + $value.child, + ), + }, + deserialize: ($serialized) { + return (_i5.NestedParent( + _i4.Serializers.instance.deserialize<_i5.NestedChild>( + $serialized[r'child'], + ), + ) + as _i13.NestedParent); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i12.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i14.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i14.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': CommonNestedParentTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/overrides/nestedChild.dart b/apps/cli/fixtures/legacy/api/goldens/functions/overrides/nestedChild.dart new file mode 100644 index 000000000..315f1a9b8 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/overrides/nestedChild.dart @@ -0,0 +1,1807 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i11; + +import 'package:_common/_common.dart' as _i10; +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/exceptions/overrides.dart' as _i12; +import 'package:celest_backend/models/overrides.dart' as _i5; +import 'package:celest_backend/src/functions/overrides.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i13; +import 'package:celest_core/src/serialization/json_value.dart' as _i14; +import 'package:shelf/shelf.dart' as _i2; + +final class NestedChildTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'nestedChild'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.nestedChild( + _i4.Serializers.instance.deserialize<_i5.NestedChild>( + request[r'child'], + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.NestedChild>(response), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CommonException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': '_common.CommonException', + 'value': _i4.Serializers.instance.serialize<_i10.CommonException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': '_common.CustomException', + 'value': _i4.Serializers.instance.serialize<_i10.CustomException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i11.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i12.OverriddenException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'api.v1.OverriddenException', + 'value': _i4.Serializers.instance + .serialize<_i12.OverriddenException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i13.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i13.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i11.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i11.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.CommonException, Map>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return _i10.CommonException(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.CustomException, Map>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return _i10.CustomException(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.OverriddenException, Map>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return (_i10.OverriddenException(($serialized[r'message'] as String)) + as _i12.OverriddenException); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NestedChild, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i5.NestedChild.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i13.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i14.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i14.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': NestedChildTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/overrides/nestedGrandparent.dart b/apps/cli/fixtures/legacy/api/goldens/functions/overrides/nestedGrandparent.dart new file mode 100644 index 000000000..edfad4a2d --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/overrides/nestedGrandparent.dart @@ -0,0 +1,1842 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i11; + +import 'package:_common/_common.dart' as _i10; +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/exceptions/overrides.dart' as _i12; +import 'package:celest_backend/models/overrides.dart' as _i5; +import 'package:celest_backend/src/functions/overrides.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i13; +import 'package:celest_core/src/serialization/json_value.dart' as _i14; +import 'package:shelf/shelf.dart' as _i2; + +final class NestedGrandparentTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'nestedGrandparent'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.nestedGrandparent( + _i4.Serializers.instance.deserialize<_i5.NestedGrandparent>( + request[r'grandparent'], + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.NestedGrandparent>(response), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CommonException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': '_common.CommonException', + 'value': _i4.Serializers.instance.serialize<_i10.CommonException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': '_common.CustomException', + 'value': _i4.Serializers.instance.serialize<_i10.CustomException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i11.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i12.OverriddenException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'api.v1.OverriddenException', + 'value': _i4.Serializers.instance + .serialize<_i12.OverriddenException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i13.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i13.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i11.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i11.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.CommonException, Map>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return _i10.CommonException(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.CustomException, Map>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return _i10.CustomException(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.OverriddenException, Map>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return (_i10.OverriddenException(($serialized[r'message'] as String)) + as _i12.OverriddenException); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NestedChild, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i5.NestedChild.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NestedGrandparent, Map>( + serialize: + ($value) => { + r'parent': _i4.Serializers.instance.serialize<_i10.NestedParent>( + $value.parent, + ), + }, + deserialize: ($serialized) { + return _i5.NestedGrandparent( + _i4.Serializers.instance.deserialize<_i10.NestedParent>( + $serialized[r'parent'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NestedParent, Map>( + serialize: + ($value) => { + r'child': _i4.Serializers.instance.serialize<_i10.NestedChild>( + $value.child, + ), + }, + deserialize: ($serialized) { + return (_i10.NestedParent( + _i4.Serializers.instance.deserialize<_i10.NestedChild>( + $serialized[r'child'], + ), + ) + as _i5.NestedParent); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i13.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i14.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i14.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': NestedGrandparentTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/overrides/nestedParent.dart b/apps/cli/fixtures/legacy/api/goldens/functions/overrides/nestedParent.dart new file mode 100644 index 000000000..92118e865 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/overrides/nestedParent.dart @@ -0,0 +1,1825 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i11; + +import 'package:_common/_common.dart' as _i10; +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/exceptions/overrides.dart' as _i12; +import 'package:celest_backend/models/overrides.dart' as _i5; +import 'package:celest_backend/src/functions/overrides.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i13; +import 'package:celest_core/src/serialization/json_value.dart' as _i14; +import 'package:shelf/shelf.dart' as _i2; + +final class NestedParentTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'nestedParent'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.nestedParent( + _i4.Serializers.instance.deserialize<_i5.NestedParent>( + request[r'parent'], + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.NestedParent>(response), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CommonException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': '_common.CommonException', + 'value': _i4.Serializers.instance.serialize<_i10.CommonException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': '_common.CustomException', + 'value': _i4.Serializers.instance.serialize<_i10.CustomException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i11.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i12.OverriddenException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'api.v1.OverriddenException', + 'value': _i4.Serializers.instance + .serialize<_i12.OverriddenException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i13.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i13.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i11.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i11.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.CommonException, Map>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return _i10.CommonException(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.CustomException, Map>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return _i10.CustomException(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.OverriddenException, Map>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return (_i10.OverriddenException(($serialized[r'message'] as String)) + as _i12.OverriddenException); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NestedChild, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i5.NestedChild.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NestedParent, Map>( + serialize: + ($value) => { + r'child': _i4.Serializers.instance.serialize<_i10.NestedChild>( + $value.child, + ), + }, + deserialize: ($serialized) { + return (_i10.NestedParent( + _i4.Serializers.instance.deserialize<_i10.NestedChild>( + $serialized[r'child'], + ), + ) + as _i5.NestedParent); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i13.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i14.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i14.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': NestedParentTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/overrides/throwsCommonOverriddenException.dart b/apps/cli/fixtures/legacy/api/goldens/functions/overrides/throwsCommonOverriddenException.dart new file mode 100644 index 000000000..3d602c6d1 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/overrides/throwsCommonOverriddenException.dart @@ -0,0 +1,1793 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i10; + +import 'package:_common/_common.dart' as _i9; +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/exceptions/overrides.dart' as _i11; +import 'package:celest_backend/src/functions/overrides.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i12; +import 'package:celest_core/src/serialization/json_value.dart' as _i13; +import 'package:shelf/shelf.dart' as _i2; + +final class ThrowsCommonOverriddenExceptionTarget + extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'throwsCommonOverriddenException'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + _i3.throwsCommonOverriddenException(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(null), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.CommonException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': '_common.CommonException', + 'value': _i4.Serializers.instance.serialize<_i9.CommonException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.CustomException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': '_common.CustomException', + 'value': _i4.Serializers.instance.serialize<_i9.CustomException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.OverriddenException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'api.v1.OverriddenException', + 'value': _i4.Serializers.instance + .serialize<_i11.OverriddenException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i12.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i12.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.CommonException, Map>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return _i9.CommonException(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.CustomException, Map>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return _i9.CustomException(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.OverriddenException, Map>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return (_i9.OverriddenException(($serialized[r'message'] as String)) + as _i11.OverriddenException); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i12.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i13.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': ThrowsCommonOverriddenExceptionTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/overrides/throwsOverriddenException.dart b/apps/cli/fixtures/legacy/api/goldens/functions/overrides/throwsOverriddenException.dart new file mode 100644 index 000000000..347c3b5f4 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/overrides/throwsOverriddenException.dart @@ -0,0 +1,1793 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i10; + +import 'package:_common/_common.dart' as _i9; +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/exceptions/overrides.dart' as _i11; +import 'package:celest_backend/src/functions/overrides.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i12; +import 'package:celest_core/src/serialization/json_value.dart' as _i13; +import 'package:shelf/shelf.dart' as _i2; + +final class ThrowsOverriddenExceptionTarget + extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'throwsOverriddenException'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + _i3.throwsOverriddenException(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(null), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.CommonException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': '_common.CommonException', + 'value': _i4.Serializers.instance.serialize<_i9.CommonException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.CustomException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': '_common.CustomException', + 'value': _i4.Serializers.instance.serialize<_i9.CustomException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.OverriddenException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'api.v1.OverriddenException', + 'value': _i4.Serializers.instance + .serialize<_i11.OverriddenException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i12.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i12.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.CommonException, Map>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return _i9.CommonException(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.CustomException, Map>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return _i9.CustomException(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.OverriddenException, Map>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return (_i9.OverriddenException(($serialized[r'message'] as String)) + as _i11.OverriddenException); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i12.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i13.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': ThrowsOverriddenExceptionTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/parameter_types/complex.dart b/apps/cli/fixtures/legacy/api/goldens/functions/parameter_types/complex.dart new file mode 100644 index 000000000..f1c112dfe --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/parameter_types/complex.dart @@ -0,0 +1,2413 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; +import 'dart:typed_data' as _i12; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/parameter_types.dart' as _i5; +import 'package:celest_backend/src/functions/parameter_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i13; +import 'package:shelf/shelf.dart' as _i2; + +final class ComplexTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'complex'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + await _i3.complex( + _i4.Serializers.instance.deserialize<_i5.SimpleStruct>( + request[r'aSimpleStruct'], + ), + _i4.Serializers.instance.deserialize<_i5.ComplexStruct>( + request[r'aComplexStruct'], + ), + _i4.Serializers.instance.deserialize<_i5.SimpleClass>( + request[r'aSimpleClass'], + ), + _i4.Serializers.instance.deserialize<_i5.ComplexClass>( + request[r'aComplexClass'], + ), + _i4.Serializers.instance.deserialize<_i5.SimpleStruct?>( + request[r'aNullableSimpleStruct'], + ), + _i4.Serializers.instance.deserialize<_i5.ComplexStruct?>( + request[r'aNullableComplexStruct'], + ), + _i4.Serializers.instance.deserialize<_i5.SimpleClass?>( + request[r'aNullableSimpleClass'], + ), + _i4.Serializers.instance.deserialize<_i5.ComplexClass?>( + request[r'aNullableComplexClass'], + ), + (request[r'anIterableOfSimpleStruct'] as Iterable) + .map( + (el) => + _i4.Serializers.instance.deserialize<_i5.SimpleStruct>(el), + ) + .toList(), + (request[r'anIterableOfComplexStruct'] as Iterable) + .map( + (el) => + _i4.Serializers.instance.deserialize<_i5.ComplexStruct>(el), + ) + .toList(), + (request[r'anIterableOfSimpleClass'] as Iterable) + .map( + (el) => _i4.Serializers.instance.deserialize<_i5.SimpleClass>(el), + ) + .toList(), + (request[r'anIterableOfComplexClass'] as Iterable) + .map( + (el) => + _i4.Serializers.instance.deserialize<_i5.ComplexClass>(el), + ) + .toList(), + (request[r'aNullableIterableOfSimpleStruct'] as Iterable?) + ?.map( + (el) => + _i4.Serializers.instance.deserialize<_i5.SimpleStruct>(el), + ) + .toList(), + (request[r'aNullableIterableOfComplexStruct'] as Iterable?) + ?.map( + (el) => + _i4.Serializers.instance.deserialize<_i5.ComplexStruct>(el), + ) + .toList(), + (request[r'aNullableIterableOfSimpleClass'] as Iterable?) + ?.map( + (el) => _i4.Serializers.instance.deserialize<_i5.SimpleClass>(el), + ) + .toList(), + (request[r'aNullableIterableOfComplexClass'] as Iterable?) + ?.map( + (el) => + _i4.Serializers.instance.deserialize<_i5.ComplexClass>(el), + ) + .toList(), + (request[r'anIterableOfNullableSimpleStruct'] as Iterable) + .map( + (el) => + _i4.Serializers.instance.deserialize<_i5.SimpleStruct?>(el), + ) + .toList(), + (request[r'anIterableOfNullableComplexStruct'] as Iterable) + .map( + (el) => + _i4.Serializers.instance.deserialize<_i5.ComplexStruct?>(el), + ) + .toList(), + (request[r'anIterableOfNullableSimpleClass'] as Iterable) + .map( + (el) => + _i4.Serializers.instance.deserialize<_i5.SimpleClass?>(el), + ) + .toList(), + (request[r'anIterableOfNullableComplexClass'] as Iterable) + .map( + (el) => + _i4.Serializers.instance.deserialize<_i5.ComplexClass?>(el), + ) + .toList(), + (request[r'aListOfSimpleStruct'] as Iterable) + .map( + (el) => + _i4.Serializers.instance.deserialize<_i5.SimpleStruct>(el), + ) + .toList(), + (request[r'aListOfComplexStruct'] as Iterable) + .map( + (el) => + _i4.Serializers.instance.deserialize<_i5.ComplexStruct>(el), + ) + .toList(), + (request[r'aListOfSimpleClass'] as Iterable) + .map( + (el) => _i4.Serializers.instance.deserialize<_i5.SimpleClass>(el), + ) + .toList(), + (request[r'aListOfComplexClass'] as Iterable) + .map( + (el) => + _i4.Serializers.instance.deserialize<_i5.ComplexClass>(el), + ) + .toList(), + (request[r'aNullableListOfSimpleStruct'] as Iterable?) + ?.map( + (el) => + _i4.Serializers.instance.deserialize<_i5.SimpleStruct>(el), + ) + .toList(), + (request[r'aNullableListOfComplexStruct'] as Iterable?) + ?.map( + (el) => + _i4.Serializers.instance.deserialize<_i5.ComplexStruct>(el), + ) + .toList(), + (request[r'aNullableListOfSimpleClass'] as Iterable?) + ?.map( + (el) => _i4.Serializers.instance.deserialize<_i5.SimpleClass>(el), + ) + .toList(), + (request[r'aNullableListOfComplexClass'] as Iterable?) + ?.map( + (el) => + _i4.Serializers.instance.deserialize<_i5.ComplexClass>(el), + ) + .toList(), + (request[r'aListOfNullableSimpleStruct'] as Iterable) + .map( + (el) => + _i4.Serializers.instance.deserialize<_i5.SimpleStruct?>(el), + ) + .toList(), + (request[r'aListOfNullableComplexStruct'] as Iterable) + .map( + (el) => + _i4.Serializers.instance.deserialize<_i5.ComplexStruct?>(el), + ) + .toList(), + (request[r'aListOfNullableSimpleClass'] as Iterable) + .map( + (el) => + _i4.Serializers.instance.deserialize<_i5.SimpleClass?>(el), + ) + .toList(), + (request[r'aListOfNullableComplexClass'] as Iterable) + .map( + (el) => + _i4.Serializers.instance.deserialize<_i5.ComplexClass?>(el), + ) + .toList(), + (request[r'aMapOfSimpleStruct'] as Map).map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize<_i5.SimpleStruct>(value), + ), + ), + (request[r'aMapOfComplexStruct'] as Map).map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize<_i5.ComplexStruct>(value), + ), + ), + (request[r'aMapOfSimpleClass'] as Map).map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize<_i5.SimpleClass>(value), + ), + ), + (request[r'aMapOfComplexClass'] as Map).map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize<_i5.ComplexClass>(value), + ), + ), + (request[r'aNullableMapOfSimpleStruct'] as Map?)?.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize<_i5.SimpleStruct>(value), + ), + ), + (request[r'aNullableMapOfComplexStruct'] as Map?)?.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize<_i5.ComplexStruct>(value), + ), + ), + (request[r'aNullableMapOfSimpleClass'] as Map?)?.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize<_i5.SimpleClass>(value), + ), + ), + (request[r'aNullableMapOfComplexClass'] as Map?)?.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize<_i5.ComplexClass>(value), + ), + ), + (request[r'aMapOfNullableSimpleStruct'] as Map).map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize<_i5.SimpleStruct?>(value), + ), + ), + (request[r'aMapOfNullableComplexStruct'] as Map).map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize<_i5.ComplexStruct?>(value), + ), + ), + (request[r'aMapOfNullableSimpleClass'] as Map).map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize<_i5.SimpleClass?>(value), + ), + ), + (request[r'aMapOfNullableComplexClass'] as Map).map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize<_i5.ComplexClass?>(value), + ), + ), + (request[r'aNullableMapOfNullableSimpleStruct'] + as Map?) + ?.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize<_i5.SimpleStruct?>(value), + ), + ), + (request[r'aNullableMapOfNullableComplexStruct'] + as Map?) + ?.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize<_i5.ComplexStruct?>(value), + ), + ), + (request[r'aNullableMapOfNullableSimpleClass'] as Map?) + ?.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize<_i5.SimpleClass?>(value), + ), + ), + (request[r'aNullableMapOfNullableComplexClass'] + as Map?) + ?.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize<_i5.ComplexClass?>(value), + ), + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(null), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.ComplexClass, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i5.ComplexClass.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.ComplexStruct, Map>( + serialize: + ($value) => { + r'aBigInt': _i4.Serializers.instance.serialize( + $value.aBigInt, + ), + r'aBool': $value.aBool, + r'aDateTime': _i4.Serializers.instance.serialize( + $value.aDateTime, + ), + r'aDouble': $value.aDouble, + r'aDuration': _i4.Serializers.instance.serialize( + $value.aDuration, + ), + r'aListOfBigInt': + $value.aListOfBigInt + .map( + (el) => _i4.Serializers.instance.serialize(el), + ) + .toList(), + r'aListOfBool': $value.aListOfBool, + r'aListOfDateTime': + $value.aListOfDateTime + .map( + (el) => + _i4.Serializers.instance.serialize(el), + ) + .toList(), + r'aListOfDouble': $value.aListOfDouble, + r'aListOfDuration': + $value.aListOfDuration + .map( + (el) => + _i4.Serializers.instance.serialize(el), + ) + .toList(), + r'aListOfEnum': + $value.aListOfEnum + .map( + (el) => + _i4.Serializers.instance.serialize<_i5.MyEnum>(el), + ) + .toList(), + r'aListOfInt': $value.aListOfInt, + r'aListOfNull': $value.aListOfNull, + r'aListOfRegExp': + $value.aListOfRegExp + .map( + (el) => _i4.Serializers.instance.serialize(el), + ) + .toList(), + r'aListOfSimpleClass': + $value.aListOfSimpleClass + .map( + (el) => _i4.Serializers.instance + .serialize<_i5.SimpleClass>(el), + ) + .toList(), + r'aListOfSimpleStruct': + $value.aListOfSimpleStruct + .map( + (el) => _i4.Serializers.instance + .serialize<_i5.SimpleStruct>(el), + ) + .toList(), + r'aListOfStackTrace': + $value.aListOfStackTrace + .map( + (el) => + _i4.Serializers.instance.serialize(el), + ) + .toList(), + r'aListOfString': $value.aListOfString, + r'aListOfUint8List': + $value.aListOfUint8List + .map( + (el) => _i4.Serializers.instance + .serialize<_i12.Uint8List>(el), + ) + .toList(), + r'aListOfUri': + $value.aListOfUri + .map((el) => _i4.Serializers.instance.serialize(el)) + .toList(), + r'aListOfUriData': + $value.aListOfUriData + .map( + (el) => _i4.Serializers.instance.serialize(el), + ) + .toList(), + r'aMapOfBigInt': $value.aMapOfBigInt.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.serialize(value), + ), + ), + r'aMapOfBool': $value.aMapOfBool, + r'aMapOfDateTime': $value.aMapOfDateTime.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.serialize(value), + ), + ), + r'aMapOfDouble': $value.aMapOfDouble, + r'aMapOfDuration': $value.aMapOfDuration.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.serialize(value), + ), + ), + r'aMapOfEnum': $value.aMapOfEnum.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.serialize<_i5.MyEnum>(value), + ), + ), + r'aMapOfInt': $value.aMapOfInt, + r'aMapOfNull': $value.aMapOfNull, + r'aMapOfRegExp': $value.aMapOfRegExp.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.serialize(value), + ), + ), + r'aMapOfSimpleClass': $value.aMapOfSimpleClass.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.serialize<_i5.SimpleClass>(value), + ), + ), + r'aMapOfSimpleStruct': $value.aMapOfSimpleStruct.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.serialize<_i5.SimpleStruct>(value), + ), + ), + r'aMapOfStackTrace': $value.aMapOfStackTrace.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.serialize(value), + ), + ), + r'aMapOfString': $value.aMapOfString, + r'aMapOfUint8List': $value.aMapOfUint8List.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.serialize<_i12.Uint8List>(value), + ), + ), + r'aMapOfUri': $value.aMapOfUri.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.serialize(value), + ), + ), + r'aMapOfUriData': $value.aMapOfUriData.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.serialize(value), + ), + ), + r'aNull': $value.aNull, + r'aRegExp': _i4.Serializers.instance.serialize( + $value.aRegExp, + ), + r'aSimpleClass': _i4.Serializers.instance + .serialize<_i5.SimpleClass>($value.aSimpleClass), + r'aSimpleStruct': _i4.Serializers.instance + .serialize<_i5.SimpleStruct>($value.aSimpleStruct), + r'aStackTrace': _i4.Serializers.instance.serialize( + $value.aStackTrace, + ), + r'aString': $value.aString, + r'aUint8List': _i4.Serializers.instance.serialize<_i12.Uint8List>( + $value.aUint8List, + ), + r'aUri': _i4.Serializers.instance.serialize($value.aUri), + r'aUriData': _i4.Serializers.instance.serialize( + $value.aUriData, + ), + r'anEnum': _i4.Serializers.instance.serialize<_i5.MyEnum>( + $value.anEnum, + ), + r'anInt': $value.anInt, + r'anIterableOfSimpleClass': + $value.anIterableOfSimpleClass + .map( + (el) => _i4.Serializers.instance + .serialize<_i5.SimpleClass>(el), + ) + .toList(), + }, + deserialize: ($serialized) { + return ( + aBigInt: _i4.Serializers.instance.deserialize( + $serialized[r'aBigInt'], + ), + aBool: ($serialized[r'aBool'] as bool), + aDateTime: _i4.Serializers.instance.deserialize( + $serialized[r'aDateTime'], + ), + aDouble: ($serialized[r'aDouble'] as num).toDouble(), + aDuration: _i4.Serializers.instance.deserialize( + $serialized[r'aDuration'], + ), + aListOfBigInt: + ($serialized[r'aListOfBigInt'] as Iterable) + .map( + (el) => _i4.Serializers.instance.deserialize(el), + ) + .toList(), + aListOfBool: + ($serialized[r'aListOfBool'] as Iterable) + .map((el) => (el as bool)) + .toList(), + aListOfDateTime: + ($serialized[r'aListOfDateTime'] as Iterable) + .map( + (el) => + _i4.Serializers.instance.deserialize(el), + ) + .toList(), + aListOfDouble: + ($serialized[r'aListOfDouble'] as Iterable) + .map((el) => (el as num).toDouble()) + .toList(), + aListOfDuration: + ($serialized[r'aListOfDuration'] as Iterable) + .map( + (el) => + _i4.Serializers.instance.deserialize(el), + ) + .toList(), + aListOfEnum: + ($serialized[r'aListOfEnum'] as Iterable) + .map( + (el) => + _i4.Serializers.instance.deserialize<_i5.MyEnum>(el), + ) + .toList(), + aListOfInt: + ($serialized[r'aListOfInt'] as Iterable) + .map((el) => (el as num).toInt()) + .toList(), + aListOfNull: + ($serialized[r'aListOfNull'] as Iterable) + .map((el) => (el as Null)) + .toList(), + aListOfRegExp: + ($serialized[r'aListOfRegExp'] as Iterable) + .map( + (el) => _i4.Serializers.instance.deserialize(el), + ) + .toList(), + aListOfSimpleClass: + ($serialized[r'aListOfSimpleClass'] as Iterable) + .map( + (el) => _i4.Serializers.instance + .deserialize<_i5.SimpleClass>(el), + ) + .toList(), + aListOfSimpleStruct: + ($serialized[r'aListOfSimpleStruct'] as Iterable) + .map( + (el) => _i4.Serializers.instance + .deserialize<_i5.SimpleStruct>(el), + ) + .toList(), + aListOfStackTrace: + ($serialized[r'aListOfStackTrace'] as Iterable) + .map( + (el) => + _i4.Serializers.instance.deserialize(el), + ) + .toList(), + aListOfString: + ($serialized[r'aListOfString'] as Iterable) + .map((el) => (el as String)) + .toList(), + aListOfUint8List: + ($serialized[r'aListOfUint8List'] as Iterable) + .map( + (el) => _i4.Serializers.instance + .deserialize<_i12.Uint8List>(el), + ) + .toList(), + aListOfUri: + ($serialized[r'aListOfUri'] as Iterable) + .map((el) => _i4.Serializers.instance.deserialize(el)) + .toList(), + aListOfUriData: + ($serialized[r'aListOfUriData'] as Iterable) + .map( + (el) => _i4.Serializers.instance.deserialize(el), + ) + .toList(), + aMapOfBigInt: ($serialized[r'aMapOfBigInt'] as Map) + .map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize(value), + ), + ), + aMapOfBool: ($serialized[r'aMapOfBool'] as Map) + .map((key, value) => MapEntry(key, (value as bool))), + aMapOfDateTime: + ($serialized[r'aMapOfDateTime'] as Map).map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize(value), + ), + ), + aMapOfDouble: ($serialized[r'aMapOfDouble'] as Map) + .map((key, value) => MapEntry(key, (value as num).toDouble())), + aMapOfDuration: + ($serialized[r'aMapOfDuration'] as Map).map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize(value), + ), + ), + aMapOfEnum: ($serialized[r'aMapOfEnum'] as Map) + .map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize<_i5.MyEnum>(value), + ), + ), + aMapOfInt: ($serialized[r'aMapOfInt'] as Map).map( + (key, value) => MapEntry(key, (value as num).toInt()), + ), + aMapOfNull: ($serialized[r'aMapOfNull'] as Map) + .map((key, value) => MapEntry(key, (value as Null))), + aMapOfRegExp: ($serialized[r'aMapOfRegExp'] as Map) + .map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize(value), + ), + ), + aMapOfSimpleClass: + ($serialized[r'aMapOfSimpleClass'] as Map).map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize<_i5.SimpleClass>( + value, + ), + ), + ), + aMapOfSimpleStruct: ($serialized[r'aMapOfSimpleStruct'] + as Map) + .map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize<_i5.SimpleStruct>( + value, + ), + ), + ), + aMapOfStackTrace: + ($serialized[r'aMapOfStackTrace'] as Map).map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize(value), + ), + ), + aMapOfString: ($serialized[r'aMapOfString'] as Map) + .map((key, value) => MapEntry(key, (value as String))), + aMapOfUint8List: + ($serialized[r'aMapOfUint8List'] as Map).map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize<_i12.Uint8List>(value), + ), + ), + aMapOfUri: ($serialized[r'aMapOfUri'] as Map).map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize(value), + ), + ), + aMapOfUriData: + ($serialized[r'aMapOfUriData'] as Map).map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize(value), + ), + ), + aNull: ($serialized[r'aNull'] as Null), + aRegExp: _i4.Serializers.instance.deserialize( + $serialized[r'aRegExp'], + ), + aSimpleClass: _i4.Serializers.instance.deserialize<_i5.SimpleClass>( + $serialized[r'aSimpleClass'], + ), + aSimpleStruct: _i4.Serializers.instance + .deserialize<_i5.SimpleStruct>($serialized[r'aSimpleStruct']), + aStackTrace: _i4.Serializers.instance.deserialize( + $serialized[r'aStackTrace'], + ), + aString: ($serialized[r'aString'] as String), + aUint8List: _i4.Serializers.instance.deserialize<_i12.Uint8List>( + $serialized[r'aUint8List'], + ), + aUri: _i4.Serializers.instance.deserialize( + $serialized[r'aUri'], + ), + aUriData: _i4.Serializers.instance.deserialize( + $serialized[r'aUriData'], + ), + anEnum: _i4.Serializers.instance.deserialize<_i5.MyEnum>( + $serialized[r'anEnum'], + ), + anInt: ($serialized[r'anInt'] as num).toInt(), + anIterableOfSimpleClass: + ($serialized[r'anIterableOfSimpleClass'] as Iterable) + .map( + (el) => _i4.Serializers.instance + .deserialize<_i5.SimpleClass>(el), + ) + .toList(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.MyEnum, String>( + serialize: ($value) => $value.name, + deserialize: ($serialized) { + return _i5.MyEnum.values.byName($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.SimpleClass, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i5.SimpleClass.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.SimpleStruct, Map?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return (); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i13.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': ComplexTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/parameter_types/simple.dart b/apps/cli/fixtures/legacy/api/goldens/functions/parameter_types/simple.dart new file mode 100644 index 000000000..f56181629 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/parameter_types/simple.dart @@ -0,0 +1,1832 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i10; +import 'dart:convert' as _i11; +import 'dart:typed_data' as _i6; + +import 'package:celest/celest.dart' as _i9; +import 'package:celest/src/core/context.dart' as _i8; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/parameter_types.dart' as _i5; +import 'package:celest_backend/src/functions/parameter_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i7; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i12; +import 'package:celest_core/src/serialization/json_value.dart' as _i13; +import 'package:shelf/shelf.dart' as _i2; + +final class SimpleTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'simple'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + await _i3.simple( + (request[r'aString'] as String), + (request[r'anInt'] as num).toInt(), + (request[r'aDouble'] as num).toDouble(), + (request[r'aBool'] as bool), + _i4.Serializers.instance.deserialize<_i5.MyEnum>(request[r'anEnum']), + (request[r'aNull'] as Null), + _i4.Serializers.instance.deserialize(request[r'aBigInt']), + _i4.Serializers.instance.deserialize(request[r'aDateTime']), + _i4.Serializers.instance.deserialize(request[r'aDuration']), + _i4.Serializers.instance.deserialize(request[r'aRegExp']), + _i4.Serializers.instance.deserialize( + request[r'aStackTrace'], + ), + _i4.Serializers.instance.deserialize(request[r'aUri']), + _i4.Serializers.instance.deserialize(request[r'aUriData']), + _i4.Serializers.instance.deserialize<_i6.Uint8List>( + request[r'aUint8List'], + ), + (request[r'anIterableOfString'] as Iterable) + .map((el) => (el as String)) + .toList(), + (request[r'anIterableOfUint8List'] as Iterable) + .map( + (el) => _i4.Serializers.instance.deserialize<_i6.Uint8List>(el), + ) + .toList(), + (request[r'aListOfString'] as Iterable) + .map((el) => (el as String)) + .toList(), + (request[r'aListOfInt'] as Iterable) + .map((el) => (el as num).toInt()) + .toList(), + (request[r'aListOfDouble'] as Iterable) + .map((el) => (el as num).toDouble()) + .toList(), + (request[r'aListOfBool'] as Iterable) + .map((el) => (el as bool)) + .toList(), + (request[r'aListOfEnum'] as Iterable) + .map((el) => _i4.Serializers.instance.deserialize<_i5.MyEnum>(el)) + .toList(), + (request[r'aListOfNull'] as Iterable) + .map((el) => (el as Null)) + .toList(), + (request[r'aListOfBigInt'] as Iterable) + .map((el) => _i4.Serializers.instance.deserialize(el)) + .toList(), + (request[r'aListOfDateTime'] as Iterable) + .map((el) => _i4.Serializers.instance.deserialize(el)) + .toList(), + (request[r'aListOfDuration'] as Iterable) + .map((el) => _i4.Serializers.instance.deserialize(el)) + .toList(), + (request[r'aListOfRegExp'] as Iterable) + .map((el) => _i4.Serializers.instance.deserialize(el)) + .toList(), + (request[r'aListOfStackTrace'] as Iterable) + .map((el) => _i4.Serializers.instance.deserialize(el)) + .toList(), + (request[r'aListOfUri'] as Iterable) + .map((el) => _i4.Serializers.instance.deserialize(el)) + .toList(), + (request[r'aListOfUriData'] as Iterable) + .map((el) => _i4.Serializers.instance.deserialize(el)) + .toList(), + (request[r'aListOfUint8List'] as Iterable) + .map( + (el) => _i4.Serializers.instance.deserialize<_i6.Uint8List>(el), + ) + .toList(), + (request[r'aMapOfString'] as Map).map( + (key, value) => MapEntry(key, (value as String)), + ), + (request[r'aMapOfInt'] as Map).map( + (key, value) => MapEntry(key, (value as num).toInt()), + ), + (request[r'aMapOfDouble'] as Map).map( + (key, value) => MapEntry(key, (value as num).toDouble()), + ), + (request[r'aMapOfBool'] as Map).map( + (key, value) => MapEntry(key, (value as bool)), + ), + (request[r'aMapOfEnum'] as Map).map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize<_i5.MyEnum>(value), + ), + ), + (request[r'aMapOfNull'] as Map).map( + (key, value) => MapEntry(key, (value as Null)), + ), + (request[r'aMapOfBigInt'] as Map).map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize(value), + ), + ), + (request[r'aMapOfDateTime'] as Map).map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize(value), + ), + ), + (request[r'aMapOfDuration'] as Map).map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize(value), + ), + ), + (request[r'aMapOfRegExp'] as Map).map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize(value), + ), + ), + (request[r'aMapOfStackTrace'] as Map).map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize(value), + ), + ), + (request[r'aMapOfUri'] as Map).map( + (key, value) => + MapEntry(key, _i4.Serializers.instance.deserialize(value)), + ), + (request[r'aMapOfUriData'] as Map).map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize(value), + ), + ), + (request[r'aMapOfUint8List'] as Map).map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize<_i6.Uint8List>(value), + ), + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(null), + ); + } on _i7.AbortedException catch (e, st) { + const statusCode = 409; + _i8.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i7.AbortedException>( + e, + ), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i7.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i8.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i7.AlreadyExistsException>(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i8.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.AsyncError catch (e, st) { + const statusCode = 500; + _i8.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i10.AsyncError>(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i7.CancelledException catch (e, st) { + const statusCode = 499; + _i8.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i7.CancelledException>(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i8.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i7.DataLossError catch (e, st) { + const statusCode = 500; + _i8.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i7.DataLossError>(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i7.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i8.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i7.DeadlineExceededError>(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i7.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i8.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i7.FailedPreconditionException>(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i8.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i8.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i7.InternalServerError catch (e, st) { + const statusCode = 500; + _i8.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i7.InternalServerError>(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i8.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i11.JsonUnsupportedObjectError>(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i7.NotFoundException catch (e, st) { + const statusCode = 404; + _i8.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i7.NotFoundException>(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i8.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i7.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i8.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i7.OutOfRangeException>(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i7.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i8.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i7.PermissionDeniedException>(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i8.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i8.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i7.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i8.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i7.ResourceExhaustedException>(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i12.SerializationException catch (e, st) { + const statusCode = 400; + _i8.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i12.SerializationException>(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i7.BadRequestException catch (e, st) { + const statusCode = 400; + _i8.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i7.BadRequestException>(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i8.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i8.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i8.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.TimeoutException catch (e, st) { + const statusCode = 400; + _i8.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance + .serialize<_i10.TimeoutException>(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i8.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i7.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i8.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i7.UnauthorizedException>(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i7.UnavailableError catch (e, st) { + const statusCode = 503; + _i8.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i7.UnavailableError>( + e, + ), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i7.UnimplementedError catch (e, st) { + const statusCode = 501; + _i8.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i7.UnimplementedError>(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i8.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i7.UnknownError catch (e, st) { + const statusCode = 500; + _i8.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i7.UnknownError>(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i7.CloudException catch (e, st) { + const statusCode = 400; + _i8.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i7.CloudException>( + e, + ), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i8.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i8.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i8.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i10.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i10.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i11.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i11.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.MyEnum, String>( + serialize: ($value) => $value.name, + deserialize: ($serialized) { + return _i5.MyEnum.values.byName($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i7.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i7.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i7.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i7.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i7.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i7.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i7.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i7.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i7.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i7.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i7.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i7.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i7.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i7.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i7.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i7.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i7.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i12.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i13.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': SimpleTarget()}, + setup: (_i8.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/parameter_types/simpleOptional.dart b/apps/cli/fixtures/legacy/api/goldens/functions/parameter_types/simpleOptional.dart new file mode 100644 index 000000000..87af516c7 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/parameter_types/simpleOptional.dart @@ -0,0 +1,1832 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i10; +import 'dart:convert' as _i11; +import 'dart:typed_data' as _i6; + +import 'package:celest/celest.dart' as _i9; +import 'package:celest/src/core/context.dart' as _i8; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/parameter_types.dart' as _i5; +import 'package:celest_backend/src/functions/parameter_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i7; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i12; +import 'package:celest_core/src/serialization/json_value.dart' as _i13; +import 'package:shelf/shelf.dart' as _i2; + +final class SimpleOptionalTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'simpleOptional'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + await _i3.simpleOptional( + (request[r'aString'] as String?), + (request[r'anInt'] as num?)?.toInt(), + (request[r'aDouble'] as num?)?.toDouble(), + (request[r'aBool'] as bool?), + _i4.Serializers.instance.deserialize<_i5.MyEnum?>(request[r'anEnum']), + (request[r'aNull'] as Null), + _i4.Serializers.instance.deserialize(request[r'aBigInt']), + _i4.Serializers.instance.deserialize(request[r'aDateTime']), + _i4.Serializers.instance.deserialize(request[r'aDuration']), + _i4.Serializers.instance.deserialize(request[r'aRegExp']), + _i4.Serializers.instance.deserialize( + request[r'aStackTrace'], + ), + _i4.Serializers.instance.deserialize(request[r'aUri']), + _i4.Serializers.instance.deserialize(request[r'aUriData']), + _i4.Serializers.instance.deserialize<_i6.Uint8List?>( + request[r'aUint8List'], + ), + (request[r'anIterableOfString'] as Iterable?) + ?.map((el) => (el as String)) + .toList(), + (request[r'anIterableOfUint8List'] as Iterable?) + ?.map( + (el) => _i4.Serializers.instance.deserialize<_i6.Uint8List>(el), + ) + .toList(), + (request[r'aListOfString'] as Iterable?) + ?.map((el) => (el as String)) + .toList(), + (request[r'aListOfInt'] as Iterable?) + ?.map((el) => (el as num).toInt()) + .toList(), + (request[r'aListOfDouble'] as Iterable?) + ?.map((el) => (el as num).toDouble()) + .toList(), + (request[r'aListOfBool'] as Iterable?) + ?.map((el) => (el as bool)) + .toList(), + (request[r'aListOfEnum'] as Iterable?) + ?.map((el) => _i4.Serializers.instance.deserialize<_i5.MyEnum>(el)) + .toList(), + (request[r'aListOfNull'] as Iterable?) + ?.map((el) => (el as Null)) + .toList(), + (request[r'aListOfBigInt'] as Iterable?) + ?.map((el) => _i4.Serializers.instance.deserialize(el)) + .toList(), + (request[r'aListOfDateTime'] as Iterable?) + ?.map((el) => _i4.Serializers.instance.deserialize(el)) + .toList(), + (request[r'aListOfDuration'] as Iterable?) + ?.map((el) => _i4.Serializers.instance.deserialize(el)) + .toList(), + (request[r'aListOfRegExp'] as Iterable?) + ?.map((el) => _i4.Serializers.instance.deserialize(el)) + .toList(), + (request[r'aListOfStackTrace'] as Iterable?) + ?.map((el) => _i4.Serializers.instance.deserialize(el)) + .toList(), + (request[r'aListOfUri'] as Iterable?) + ?.map((el) => _i4.Serializers.instance.deserialize(el)) + .toList(), + (request[r'aListOfUriData'] as Iterable?) + ?.map((el) => _i4.Serializers.instance.deserialize(el)) + .toList(), + (request[r'aListOfUint8List'] as Iterable?) + ?.map( + (el) => _i4.Serializers.instance.deserialize<_i6.Uint8List>(el), + ) + .toList(), + (request[r'aMapOfString'] as Map?)?.map( + (key, value) => MapEntry(key, (value as String)), + ), + (request[r'aMapOfInt'] as Map?)?.map( + (key, value) => MapEntry(key, (value as num).toInt()), + ), + (request[r'aMapOfDouble'] as Map?)?.map( + (key, value) => MapEntry(key, (value as num).toDouble()), + ), + (request[r'aMapOfBool'] as Map?)?.map( + (key, value) => MapEntry(key, (value as bool)), + ), + (request[r'aMapOfEnum'] as Map?)?.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize<_i5.MyEnum>(value), + ), + ), + (request[r'aMapOfNull'] as Map?)?.map( + (key, value) => MapEntry(key, (value as Null)), + ), + (request[r'aMapOfBigInt'] as Map?)?.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize(value), + ), + ), + (request[r'aMapOfDateTime'] as Map?)?.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize(value), + ), + ), + (request[r'aMapOfDuration'] as Map?)?.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize(value), + ), + ), + (request[r'aMapOfRegExp'] as Map?)?.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize(value), + ), + ), + (request[r'aMapOfStackTrace'] as Map?)?.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize(value), + ), + ), + (request[r'aMapOfUri'] as Map?)?.map( + (key, value) => + MapEntry(key, _i4.Serializers.instance.deserialize(value)), + ), + (request[r'aMapOfUriData'] as Map?)?.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize(value), + ), + ), + (request[r'aMapOfUint8List'] as Map?)?.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize<_i6.Uint8List>(value), + ), + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(null), + ); + } on _i7.AbortedException catch (e, st) { + const statusCode = 409; + _i8.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i7.AbortedException>( + e, + ), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i7.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i8.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i7.AlreadyExistsException>(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i8.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.AsyncError catch (e, st) { + const statusCode = 500; + _i8.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i10.AsyncError>(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i7.CancelledException catch (e, st) { + const statusCode = 499; + _i8.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i7.CancelledException>(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i8.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i7.DataLossError catch (e, st) { + const statusCode = 500; + _i8.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i7.DataLossError>(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i7.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i8.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i7.DeadlineExceededError>(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i7.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i8.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i7.FailedPreconditionException>(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i8.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i8.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i7.InternalServerError catch (e, st) { + const statusCode = 500; + _i8.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i7.InternalServerError>(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i8.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i11.JsonUnsupportedObjectError>(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i7.NotFoundException catch (e, st) { + const statusCode = 404; + _i8.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i7.NotFoundException>(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i8.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i7.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i8.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i7.OutOfRangeException>(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i7.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i8.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i7.PermissionDeniedException>(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i8.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i8.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i7.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i8.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i7.ResourceExhaustedException>(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i12.SerializationException catch (e, st) { + const statusCode = 400; + _i8.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i12.SerializationException>(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i7.BadRequestException catch (e, st) { + const statusCode = 400; + _i8.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i7.BadRequestException>(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i8.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i8.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i8.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.TimeoutException catch (e, st) { + const statusCode = 400; + _i8.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance + .serialize<_i10.TimeoutException>(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i8.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i7.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i8.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i7.UnauthorizedException>(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i7.UnavailableError catch (e, st) { + const statusCode = 503; + _i8.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i7.UnavailableError>( + e, + ), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i7.UnimplementedError catch (e, st) { + const statusCode = 501; + _i8.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i7.UnimplementedError>(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i8.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i7.UnknownError catch (e, st) { + const statusCode = 500; + _i8.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i7.UnknownError>(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i7.CloudException catch (e, st) { + const statusCode = 400; + _i8.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i7.CloudException>( + e, + ), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i8.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i8.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i8.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i10.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i10.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i11.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i11.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.MyEnum, String>( + serialize: ($value) => $value.name, + deserialize: ($serialized) { + return _i5.MyEnum.values.byName($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i7.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i7.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i7.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i7.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i7.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i7.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i7.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i7.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i7.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i7.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i7.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i7.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i7.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i7.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i7.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i7.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i7.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i12.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i13.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': SimpleOptionalTarget()}, + setup: (_i8.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/parameters/optionalNamed.dart b/apps/cli/fixtures/legacy/api/goldens/functions/parameters/optionalNamed.dart new file mode 100644 index 000000000..3023eaade --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/parameters/optionalNamed.dart @@ -0,0 +1,1688 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i9; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/parameters.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i10; +import 'package:celest_core/src/serialization/json_value.dart' as _i11; +import 'package:shelf/shelf.dart' as _i2; + +final class OptionalNamedTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'optionalNamed'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + await _i3.optionalNamed( + namedString: (request[r'namedString'] as String?), + namedInt: (request[r'namedInt'] as num?)?.toInt(), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(null), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i9.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i10.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i9.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i10.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i11.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': OptionalNamedTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/parameters/optionalPositional.dart b/apps/cli/fixtures/legacy/api/goldens/functions/parameters/optionalPositional.dart new file mode 100644 index 000000000..31ac5d411 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/parameters/optionalPositional.dart @@ -0,0 +1,1688 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i9; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/parameters.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i10; +import 'package:celest_core/src/serialization/json_value.dart' as _i11; +import 'package:shelf/shelf.dart' as _i2; + +final class OptionalPositionalTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'optionalPositional'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + await _i3.optionalPositional( + (request[r'optionalString'] as String?), + (request[r'optionalInt'] as num?)?.toInt(), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(null), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i9.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i10.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i9.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i10.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i11.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': OptionalPositionalTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/parameters/requiredNamed.dart b/apps/cli/fixtures/legacy/api/goldens/functions/parameters/requiredNamed.dart new file mode 100644 index 000000000..f3710ca36 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/parameters/requiredNamed.dart @@ -0,0 +1,1688 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i9; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/parameters.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i10; +import 'package:celest_core/src/serialization/json_value.dart' as _i11; +import 'package:shelf/shelf.dart' as _i2; + +final class RequiredNamedTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'requiredNamed'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + await _i3.requiredNamed( + requiredString: (request[r'requiredString'] as String), + requiredInt: (request[r'requiredInt'] as num).toInt(), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(null), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i9.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i10.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i9.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i10.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i11.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': RequiredNamedTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/parameters/requiredPositional.dart b/apps/cli/fixtures/legacy/api/goldens/functions/parameters/requiredPositional.dart new file mode 100644 index 000000000..67f1aa4c2 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/parameters/requiredPositional.dart @@ -0,0 +1,1688 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i9; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/parameters.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i10; +import 'package:celest_core/src/serialization/json_value.dart' as _i11; +import 'package:shelf/shelf.dart' as _i2; + +final class RequiredPositionalTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'requiredPositional'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + await _i3.requiredPositional( + (request[r'requiredString'] as String), + (request[r'requiredInt'] as num).toInt(), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(null), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i9.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i10.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i9.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i10.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i11.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': RequiredPositionalTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/records/aliasedNamedFields.dart b/apps/cli/fixtures/legacy/api/goldens/functions/records/aliasedNamedFields.dart new file mode 100644 index 000000000..493175b93 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/records/aliasedNamedFields.dart @@ -0,0 +1,1707 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/records.dart' as _i5; +import 'package:celest_backend/src/functions/records.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class AliasedNamedFieldsTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'aliasedNamedFields'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.aliasedNamedFields( + value: _i4.Serializers.instance.deserialize<_i5.NamedFieldsRecord>( + request[r'value'], + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.NamedFieldsRecord>(response), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NamedFieldsRecord, Map>( + serialize: + ($value) => { + r'anotherField': $value.anotherField, + r'field': $value.field, + }, + deserialize: ($serialized) { + return ( + anotherField: ($serialized[r'anotherField'] as String), + field: ($serialized[r'field'] as String), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': AliasedNamedFieldsTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/records/asyncAliasedNamedFields.dart b/apps/cli/fixtures/legacy/api/goldens/functions/records/asyncAliasedNamedFields.dart new file mode 100644 index 000000000..81dea0ed2 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/records/asyncAliasedNamedFields.dart @@ -0,0 +1,1707 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/records.dart' as _i5; +import 'package:celest_backend/src/functions/records.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class AsyncAliasedNamedFieldsTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'asyncAliasedNamedFields'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = await _i3.asyncAliasedNamedFields( + value: _i4.Serializers.instance.deserialize<_i5.NamedFieldsRecord>( + request[r'value'], + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.NamedFieldsRecord>(response), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NamedFieldsRecord, Map>( + serialize: + ($value) => { + r'anotherField': $value.anotherField, + r'field': $value.field, + }, + deserialize: ($serialized) { + return ( + anotherField: ($serialized[r'anotherField'] as String), + field: ($serialized[r'field'] as String), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': AsyncAliasedNamedFieldsTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/records/asyncNamedFields.dart b/apps/cli/fixtures/legacy/api/goldens/functions/records/asyncNamedFields.dart new file mode 100644 index 000000000..20546f417 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/records/asyncNamedFields.dart @@ -0,0 +1,1761 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/records.dart' as _i5; +import 'package:celest_backend/src/functions/records.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class AsyncNamedFieldsTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'asyncNamedFields'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = await _i3.asyncNamedFields( + nonAliased: _i4.Serializers.instance + .deserialize<({String anotherField, String field})>( + request[r'nonAliased'], + ), + aliased: _i4.Serializers.instance.deserialize<_i5.NamedFieldsRecord>( + request[r'aliased'], + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize< + ({ + _i5.NamedFieldsRecord aliased, + ({String anotherField, String field}) nonAliased, + }) + >(response), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + r'anotherField': $value.anotherField, + r'field': $value.field, + }, + deserialize: ($serialized) { + return ( + anotherField: ($serialized[r'anotherField'] as String), + field: ($serialized[r'field'] as String), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + r'aliased': _i4.Serializers.instance + .serialize<_i5.NamedFieldsRecord>($value.aliased), + r'nonAliased': _i4.Serializers.instance + .serialize<({String anotherField, String field})>( + $value.nonAliased, + ), + }, + deserialize: ($serialized) { + return ( + aliased: _i4.Serializers.instance + .deserialize<_i5.NamedFieldsRecord>($serialized[r'aliased']), + nonAliased: _i4.Serializers.instance + .deserialize<({String anotherField, String field})>( + $serialized[r'nonAliased'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NamedFieldsRecord, Map>( + serialize: + ($value) => { + r'anotherField': $value.anotherField, + r'field': $value.field, + }, + deserialize: ($serialized) { + return ( + anotherField: ($serialized[r'anotherField'] as String), + field: ($serialized[r'field'] as String), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': AsyncNamedFieldsTarget()}, + setup: (_i7.Context context) async {}, + ); +} + +typedef Record$k2phuz = + ({ + _i5.NamedFieldsRecord aliased, + ({String anotherField, String field}) nonAliased, + }); +typedef Record$rmm4wt = ({String anotherField, String field}); diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/records/asyncNested.dart b/apps/cli/fixtures/legacy/api/goldens/functions/records/asyncNested.dart new file mode 100644 index 000000000..d21c0eb77 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/records/asyncNested.dart @@ -0,0 +1,1722 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/records.dart' as _i5; +import 'package:celest_backend/src/functions/records.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class AsyncNestedTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'asyncNested'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = await _i3.asyncNested( + _i4.Serializers.instance.deserialize<_i5.Nested>(request[r'value']), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.Nested>(response), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NamedFieldsRecord, Map>( + serialize: + ($value) => { + r'anotherField': $value.anotherField, + r'field': $value.field, + }, + deserialize: ($serialized) { + return ( + anotherField: ($serialized[r'anotherField'] as String), + field: ($serialized[r'field'] as String), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.Nested, Map>( + serialize: + ($value) => { + r'namedFields': _i4.Serializers.instance + .serialize<_i5.NamedFieldsRecord>($value.namedFields), + }, + deserialize: ($serialized) { + return ( + namedFields: _i4.Serializers.instance + .deserialize<_i5.NamedFieldsRecord>( + $serialized[r'namedFields'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': AsyncNestedTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/records/asyncNonAliasedNamedFields.dart b/apps/cli/fixtures/legacy/api/goldens/functions/records/asyncNonAliasedNamedFields.dart new file mode 100644 index 000000000..6fdba2e15 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/records/asyncNonAliasedNamedFields.dart @@ -0,0 +1,1711 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i9; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/records.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i10; +import 'package:celest_core/src/serialization/json_value.dart' as _i11; +import 'package:shelf/shelf.dart' as _i2; + +final class AsyncNonAliasedNamedFieldsTarget + extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'asyncNonAliasedNamedFields'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = await _i3.asyncNonAliasedNamedFields( + value: _i4.Serializers.instance + .deserialize<({String anotherField, String field})>( + request[r'value'], + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance + .serialize<({String anotherField, String field})>(response), + ), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i9.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i10.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + r'anotherField': $value.anotherField, + r'field': $value.field, + }, + deserialize: ($serialized) { + return ( + anotherField: ($serialized[r'anotherField'] as String), + field: ($serialized[r'field'] as String), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i9.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i10.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i11.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': AsyncNonAliasedNamedFieldsTarget()}, + setup: (_i6.Context context) async {}, + ); +} + +typedef Record$rmm4wt = ({String anotherField, String field}); diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/records/asyncNullableNested.dart b/apps/cli/fixtures/legacy/api/goldens/functions/records/asyncNullableNested.dart new file mode 100644 index 000000000..94c285d9f --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/records/asyncNullableNested.dart @@ -0,0 +1,1727 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/records.dart' as _i5; +import 'package:celest_backend/src/functions/records.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class AsyncNullableNestedTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'asyncNullableNested'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = await _i3.asyncNullableNested( + _i4.Serializers.instance.deserialize<_i5.NullableNested?>( + request[r'value'], + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.NullableNested?>(response), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NamedFieldsRecord, Map>( + serialize: + ($value) => { + r'anotherField': $value.anotherField, + r'field': $value.field, + }, + deserialize: ($serialized) { + return ( + anotherField: ($serialized[r'anotherField'] as String), + field: ($serialized[r'field'] as String), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NullableNested, Map>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize<_i5.NamedFieldsRecord?>( + $value.namedFields, + ) + case final namedFields?) + r'namedFields': namedFields, + }, + deserialize: ($serialized) { + return ( + namedFields: _i4.Serializers.instance + .deserialize<_i5.NamedFieldsRecord?>( + $serialized[r'namedFields'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': AsyncNullableNestedTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/records/namedFields.dart b/apps/cli/fixtures/legacy/api/goldens/functions/records/namedFields.dart new file mode 100644 index 000000000..f7d092b13 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/records/namedFields.dart @@ -0,0 +1,1761 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/records.dart' as _i5; +import 'package:celest_backend/src/functions/records.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class NamedFieldsTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'namedFields'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.namedFields( + nonAliased: _i4.Serializers.instance + .deserialize<({String anotherField, String field})>( + request[r'nonAliased'], + ), + aliased: _i4.Serializers.instance.deserialize<_i5.NamedFieldsRecord>( + request[r'aliased'], + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize< + ({ + _i5.NamedFieldsRecord aliased, + ({String anotherField, String field}) nonAliased, + }) + >(response), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + r'anotherField': $value.anotherField, + r'field': $value.field, + }, + deserialize: ($serialized) { + return ( + anotherField: ($serialized[r'anotherField'] as String), + field: ($serialized[r'field'] as String), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + r'aliased': _i4.Serializers.instance + .serialize<_i5.NamedFieldsRecord>($value.aliased), + r'nonAliased': _i4.Serializers.instance + .serialize<({String anotherField, String field})>( + $value.nonAliased, + ), + }, + deserialize: ($serialized) { + return ( + aliased: _i4.Serializers.instance + .deserialize<_i5.NamedFieldsRecord>($serialized[r'aliased']), + nonAliased: _i4.Serializers.instance + .deserialize<({String anotherField, String field})>( + $serialized[r'nonAliased'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NamedFieldsRecord, Map>( + serialize: + ($value) => { + r'anotherField': $value.anotherField, + r'field': $value.field, + }, + deserialize: ($serialized) { + return ( + anotherField: ($serialized[r'anotherField'] as String), + field: ($serialized[r'field'] as String), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': NamedFieldsTarget()}, + setup: (_i7.Context context) async {}, + ); +} + +typedef Record$k2phuz = + ({ + _i5.NamedFieldsRecord aliased, + ({String anotherField, String field}) nonAliased, + }); +typedef Record$rmm4wt = ({String anotherField, String field}); diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/records/nested.dart b/apps/cli/fixtures/legacy/api/goldens/functions/records/nested.dart new file mode 100644 index 000000000..99c4fbc81 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/records/nested.dart @@ -0,0 +1,1722 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/records.dart' as _i5; +import 'package:celest_backend/src/functions/records.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class NestedTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'nested'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.nested( + _i4.Serializers.instance.deserialize<_i5.Nested>(request[r'value']), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.Nested>(response), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NamedFieldsRecord, Map>( + serialize: + ($value) => { + r'anotherField': $value.anotherField, + r'field': $value.field, + }, + deserialize: ($serialized) { + return ( + anotherField: ($serialized[r'anotherField'] as String), + field: ($serialized[r'field'] as String), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.Nested, Map>( + serialize: + ($value) => { + r'namedFields': _i4.Serializers.instance + .serialize<_i5.NamedFieldsRecord>($value.namedFields), + }, + deserialize: ($serialized) { + return ( + namedFields: _i4.Serializers.instance + .deserialize<_i5.NamedFieldsRecord>( + $serialized[r'namedFields'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': NestedTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/records/nonAliasedNamedFields.dart b/apps/cli/fixtures/legacy/api/goldens/functions/records/nonAliasedNamedFields.dart new file mode 100644 index 000000000..711cfb7ec --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/records/nonAliasedNamedFields.dart @@ -0,0 +1,1710 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i9; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/records.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i10; +import 'package:celest_core/src/serialization/json_value.dart' as _i11; +import 'package:shelf/shelf.dart' as _i2; + +final class NonAliasedNamedFieldsTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'nonAliasedNamedFields'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.nonAliasedNamedFields( + value: _i4.Serializers.instance + .deserialize<({String anotherField, String field})>( + request[r'value'], + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance + .serialize<({String anotherField, String field})>(response), + ), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i9.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i10.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + r'anotherField': $value.anotherField, + r'field': $value.field, + }, + deserialize: ($serialized) { + return ( + anotherField: ($serialized[r'anotherField'] as String), + field: ($serialized[r'field'] as String), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i9.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i10.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i11.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': NonAliasedNamedFieldsTarget()}, + setup: (_i6.Context context) async {}, + ); +} + +typedef Record$rmm4wt = ({String anotherField, String field}); diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/records/nullableNested.dart b/apps/cli/fixtures/legacy/api/goldens/functions/records/nullableNested.dart new file mode 100644 index 000000000..b5d1fd8fe --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/records/nullableNested.dart @@ -0,0 +1,1727 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/records.dart' as _i5; +import 'package:celest_backend/src/functions/records.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class NullableNestedTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'nullableNested'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.nullableNested( + _i4.Serializers.instance.deserialize<_i5.NullableNested?>( + request[r'value'], + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.NullableNested?>(response), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NamedFieldsRecord, Map>( + serialize: + ($value) => { + r'anotherField': $value.anotherField, + r'field': $value.field, + }, + deserialize: ($serialized) { + return ( + anotherField: ($serialized[r'anotherField'] as String), + field: ($serialized[r'field'] as String), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NullableNested, Map>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize<_i5.NamedFieldsRecord?>( + $value.namedFields, + ) + case final namedFields?) + r'namedFields': namedFields, + }, + deserialize: ($serialized) { + return ( + namedFields: _i4.Serializers.instance + .deserialize<_i5.NamedFieldsRecord?>( + $serialized[r'namedFields'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': NullableNestedTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncBoolReturn.dart b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncBoolReturn.dart new file mode 100644 index 000000000..82c4b0259 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncBoolReturn.dart @@ -0,0 +1,1685 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i9; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/return_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i10; +import 'package:celest_core/src/serialization/json_value.dart' as _i11; +import 'package:shelf/shelf.dart' as _i2; + +final class AsyncBoolReturnTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'asyncBoolReturn'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = await _i3.asyncBoolReturn(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(response), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i9.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i10.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i9.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i10.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i11.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': AsyncBoolReturnTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncClassReturnNullable.dart b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncClassReturnNullable.dart new file mode 100644 index 000000000..78f5e5789 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncClassReturnNullable.dart @@ -0,0 +1,1696 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/parameter_types.dart' as _i5; +import 'package:celest_backend/src/functions/return_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class AsyncClassReturnNullableTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'asyncClassReturnNullable'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = await _i3.asyncClassReturnNullable(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.SimpleClass?>(response), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.SimpleClass, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i5.SimpleClass.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': AsyncClassReturnNullableTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncComplexClassReturn.dart b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncComplexClassReturn.dart new file mode 100644 index 000000000..544d65f01 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncComplexClassReturn.dart @@ -0,0 +1,1696 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/parameter_types.dart' as _i5; +import 'package:celest_backend/src/functions/return_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class AsyncComplexClassReturnTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'asyncComplexClassReturn'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = await _i3.asyncComplexClassReturn(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.ComplexClass>(response), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.ComplexClass, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i5.ComplexClass.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': AsyncComplexClassReturnTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncComplexStructReturn.dart b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncComplexStructReturn.dart new file mode 100644 index 000000000..99c08fcd2 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncComplexStructReturn.dart @@ -0,0 +1,2139 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; +import 'dart:typed_data' as _i12; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/parameter_types.dart' as _i5; +import 'package:celest_backend/src/functions/return_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i13; +import 'package:shelf/shelf.dart' as _i2; + +final class AsyncComplexStructReturnTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'asyncComplexStructReturn'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = await _i3.asyncComplexStructReturn(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.ComplexStruct>(response), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.ComplexStruct, Map>( + serialize: + ($value) => { + r'aBigInt': _i4.Serializers.instance.serialize( + $value.aBigInt, + ), + r'aBool': $value.aBool, + r'aDateTime': _i4.Serializers.instance.serialize( + $value.aDateTime, + ), + r'aDouble': $value.aDouble, + r'aDuration': _i4.Serializers.instance.serialize( + $value.aDuration, + ), + r'aListOfBigInt': + $value.aListOfBigInt + .map( + (el) => _i4.Serializers.instance.serialize(el), + ) + .toList(), + r'aListOfBool': $value.aListOfBool, + r'aListOfDateTime': + $value.aListOfDateTime + .map( + (el) => + _i4.Serializers.instance.serialize(el), + ) + .toList(), + r'aListOfDouble': $value.aListOfDouble, + r'aListOfDuration': + $value.aListOfDuration + .map( + (el) => + _i4.Serializers.instance.serialize(el), + ) + .toList(), + r'aListOfEnum': + $value.aListOfEnum + .map( + (el) => + _i4.Serializers.instance.serialize<_i5.MyEnum>(el), + ) + .toList(), + r'aListOfInt': $value.aListOfInt, + r'aListOfNull': $value.aListOfNull, + r'aListOfRegExp': + $value.aListOfRegExp + .map( + (el) => _i4.Serializers.instance.serialize(el), + ) + .toList(), + r'aListOfSimpleClass': + $value.aListOfSimpleClass + .map( + (el) => _i4.Serializers.instance + .serialize<_i5.SimpleClass>(el), + ) + .toList(), + r'aListOfSimpleStruct': + $value.aListOfSimpleStruct + .map( + (el) => _i4.Serializers.instance + .serialize<_i5.SimpleStruct>(el), + ) + .toList(), + r'aListOfStackTrace': + $value.aListOfStackTrace + .map( + (el) => + _i4.Serializers.instance.serialize(el), + ) + .toList(), + r'aListOfString': $value.aListOfString, + r'aListOfUint8List': + $value.aListOfUint8List + .map( + (el) => _i4.Serializers.instance + .serialize<_i12.Uint8List>(el), + ) + .toList(), + r'aListOfUri': + $value.aListOfUri + .map((el) => _i4.Serializers.instance.serialize(el)) + .toList(), + r'aListOfUriData': + $value.aListOfUriData + .map( + (el) => _i4.Serializers.instance.serialize(el), + ) + .toList(), + r'aMapOfBigInt': $value.aMapOfBigInt.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.serialize(value), + ), + ), + r'aMapOfBool': $value.aMapOfBool, + r'aMapOfDateTime': $value.aMapOfDateTime.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.serialize(value), + ), + ), + r'aMapOfDouble': $value.aMapOfDouble, + r'aMapOfDuration': $value.aMapOfDuration.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.serialize(value), + ), + ), + r'aMapOfEnum': $value.aMapOfEnum.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.serialize<_i5.MyEnum>(value), + ), + ), + r'aMapOfInt': $value.aMapOfInt, + r'aMapOfNull': $value.aMapOfNull, + r'aMapOfRegExp': $value.aMapOfRegExp.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.serialize(value), + ), + ), + r'aMapOfSimpleClass': $value.aMapOfSimpleClass.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.serialize<_i5.SimpleClass>(value), + ), + ), + r'aMapOfSimpleStruct': $value.aMapOfSimpleStruct.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.serialize<_i5.SimpleStruct>(value), + ), + ), + r'aMapOfStackTrace': $value.aMapOfStackTrace.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.serialize(value), + ), + ), + r'aMapOfString': $value.aMapOfString, + r'aMapOfUint8List': $value.aMapOfUint8List.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.serialize<_i12.Uint8List>(value), + ), + ), + r'aMapOfUri': $value.aMapOfUri.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.serialize(value), + ), + ), + r'aMapOfUriData': $value.aMapOfUriData.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.serialize(value), + ), + ), + r'aNull': $value.aNull, + r'aRegExp': _i4.Serializers.instance.serialize( + $value.aRegExp, + ), + r'aSimpleClass': _i4.Serializers.instance + .serialize<_i5.SimpleClass>($value.aSimpleClass), + r'aSimpleStruct': _i4.Serializers.instance + .serialize<_i5.SimpleStruct>($value.aSimpleStruct), + r'aStackTrace': _i4.Serializers.instance.serialize( + $value.aStackTrace, + ), + r'aString': $value.aString, + r'aUint8List': _i4.Serializers.instance.serialize<_i12.Uint8List>( + $value.aUint8List, + ), + r'aUri': _i4.Serializers.instance.serialize($value.aUri), + r'aUriData': _i4.Serializers.instance.serialize( + $value.aUriData, + ), + r'anEnum': _i4.Serializers.instance.serialize<_i5.MyEnum>( + $value.anEnum, + ), + r'anInt': $value.anInt, + r'anIterableOfSimpleClass': + $value.anIterableOfSimpleClass + .map( + (el) => _i4.Serializers.instance + .serialize<_i5.SimpleClass>(el), + ) + .toList(), + }, + deserialize: ($serialized) { + return ( + aBigInt: _i4.Serializers.instance.deserialize( + $serialized[r'aBigInt'], + ), + aBool: ($serialized[r'aBool'] as bool), + aDateTime: _i4.Serializers.instance.deserialize( + $serialized[r'aDateTime'], + ), + aDouble: ($serialized[r'aDouble'] as num).toDouble(), + aDuration: _i4.Serializers.instance.deserialize( + $serialized[r'aDuration'], + ), + aListOfBigInt: + ($serialized[r'aListOfBigInt'] as Iterable) + .map( + (el) => _i4.Serializers.instance.deserialize(el), + ) + .toList(), + aListOfBool: + ($serialized[r'aListOfBool'] as Iterable) + .map((el) => (el as bool)) + .toList(), + aListOfDateTime: + ($serialized[r'aListOfDateTime'] as Iterable) + .map( + (el) => + _i4.Serializers.instance.deserialize(el), + ) + .toList(), + aListOfDouble: + ($serialized[r'aListOfDouble'] as Iterable) + .map((el) => (el as num).toDouble()) + .toList(), + aListOfDuration: + ($serialized[r'aListOfDuration'] as Iterable) + .map( + (el) => + _i4.Serializers.instance.deserialize(el), + ) + .toList(), + aListOfEnum: + ($serialized[r'aListOfEnum'] as Iterable) + .map( + (el) => + _i4.Serializers.instance.deserialize<_i5.MyEnum>(el), + ) + .toList(), + aListOfInt: + ($serialized[r'aListOfInt'] as Iterable) + .map((el) => (el as num).toInt()) + .toList(), + aListOfNull: + ($serialized[r'aListOfNull'] as Iterable) + .map((el) => (el as Null)) + .toList(), + aListOfRegExp: + ($serialized[r'aListOfRegExp'] as Iterable) + .map( + (el) => _i4.Serializers.instance.deserialize(el), + ) + .toList(), + aListOfSimpleClass: + ($serialized[r'aListOfSimpleClass'] as Iterable) + .map( + (el) => _i4.Serializers.instance + .deserialize<_i5.SimpleClass>(el), + ) + .toList(), + aListOfSimpleStruct: + ($serialized[r'aListOfSimpleStruct'] as Iterable) + .map( + (el) => _i4.Serializers.instance + .deserialize<_i5.SimpleStruct>(el), + ) + .toList(), + aListOfStackTrace: + ($serialized[r'aListOfStackTrace'] as Iterable) + .map( + (el) => + _i4.Serializers.instance.deserialize(el), + ) + .toList(), + aListOfString: + ($serialized[r'aListOfString'] as Iterable) + .map((el) => (el as String)) + .toList(), + aListOfUint8List: + ($serialized[r'aListOfUint8List'] as Iterable) + .map( + (el) => _i4.Serializers.instance + .deserialize<_i12.Uint8List>(el), + ) + .toList(), + aListOfUri: + ($serialized[r'aListOfUri'] as Iterable) + .map((el) => _i4.Serializers.instance.deserialize(el)) + .toList(), + aListOfUriData: + ($serialized[r'aListOfUriData'] as Iterable) + .map( + (el) => _i4.Serializers.instance.deserialize(el), + ) + .toList(), + aMapOfBigInt: ($serialized[r'aMapOfBigInt'] as Map) + .map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize(value), + ), + ), + aMapOfBool: ($serialized[r'aMapOfBool'] as Map) + .map((key, value) => MapEntry(key, (value as bool))), + aMapOfDateTime: + ($serialized[r'aMapOfDateTime'] as Map).map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize(value), + ), + ), + aMapOfDouble: ($serialized[r'aMapOfDouble'] as Map) + .map((key, value) => MapEntry(key, (value as num).toDouble())), + aMapOfDuration: + ($serialized[r'aMapOfDuration'] as Map).map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize(value), + ), + ), + aMapOfEnum: ($serialized[r'aMapOfEnum'] as Map) + .map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize<_i5.MyEnum>(value), + ), + ), + aMapOfInt: ($serialized[r'aMapOfInt'] as Map).map( + (key, value) => MapEntry(key, (value as num).toInt()), + ), + aMapOfNull: ($serialized[r'aMapOfNull'] as Map) + .map((key, value) => MapEntry(key, (value as Null))), + aMapOfRegExp: ($serialized[r'aMapOfRegExp'] as Map) + .map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize(value), + ), + ), + aMapOfSimpleClass: + ($serialized[r'aMapOfSimpleClass'] as Map).map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize<_i5.SimpleClass>( + value, + ), + ), + ), + aMapOfSimpleStruct: ($serialized[r'aMapOfSimpleStruct'] + as Map) + .map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize<_i5.SimpleStruct>( + value, + ), + ), + ), + aMapOfStackTrace: + ($serialized[r'aMapOfStackTrace'] as Map).map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize(value), + ), + ), + aMapOfString: ($serialized[r'aMapOfString'] as Map) + .map((key, value) => MapEntry(key, (value as String))), + aMapOfUint8List: + ($serialized[r'aMapOfUint8List'] as Map).map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize<_i12.Uint8List>(value), + ), + ), + aMapOfUri: ($serialized[r'aMapOfUri'] as Map).map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize(value), + ), + ), + aMapOfUriData: + ($serialized[r'aMapOfUriData'] as Map).map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize(value), + ), + ), + aNull: ($serialized[r'aNull'] as Null), + aRegExp: _i4.Serializers.instance.deserialize( + $serialized[r'aRegExp'], + ), + aSimpleClass: _i4.Serializers.instance.deserialize<_i5.SimpleClass>( + $serialized[r'aSimpleClass'], + ), + aSimpleStruct: _i4.Serializers.instance + .deserialize<_i5.SimpleStruct>($serialized[r'aSimpleStruct']), + aStackTrace: _i4.Serializers.instance.deserialize( + $serialized[r'aStackTrace'], + ), + aString: ($serialized[r'aString'] as String), + aUint8List: _i4.Serializers.instance.deserialize<_i12.Uint8List>( + $serialized[r'aUint8List'], + ), + aUri: _i4.Serializers.instance.deserialize( + $serialized[r'aUri'], + ), + aUriData: _i4.Serializers.instance.deserialize( + $serialized[r'aUriData'], + ), + anEnum: _i4.Serializers.instance.deserialize<_i5.MyEnum>( + $serialized[r'anEnum'], + ), + anInt: ($serialized[r'anInt'] as num).toInt(), + anIterableOfSimpleClass: + ($serialized[r'anIterableOfSimpleClass'] as Iterable) + .map( + (el) => _i4.Serializers.instance + .deserialize<_i5.SimpleClass>(el), + ) + .toList(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.MyEnum, String>( + serialize: ($value) => $value.name, + deserialize: ($serialized) { + return _i5.MyEnum.values.byName($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.SimpleClass, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i5.SimpleClass.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.SimpleStruct, Map?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return (); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i13.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': AsyncComplexStructReturnTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncComplexStructReturnNullable.dart b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncComplexStructReturnNullable.dart new file mode 100644 index 000000000..b4af14e35 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncComplexStructReturnNullable.dart @@ -0,0 +1,2140 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; +import 'dart:typed_data' as _i12; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/parameter_types.dart' as _i5; +import 'package:celest_backend/src/functions/return_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i13; +import 'package:shelf/shelf.dart' as _i2; + +final class AsyncComplexStructReturnNullableTarget + extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'asyncComplexStructReturnNullable'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = await _i3.asyncComplexStructReturnNullable(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.ComplexStruct?>(response), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.ComplexStruct, Map>( + serialize: + ($value) => { + r'aBigInt': _i4.Serializers.instance.serialize( + $value.aBigInt, + ), + r'aBool': $value.aBool, + r'aDateTime': _i4.Serializers.instance.serialize( + $value.aDateTime, + ), + r'aDouble': $value.aDouble, + r'aDuration': _i4.Serializers.instance.serialize( + $value.aDuration, + ), + r'aListOfBigInt': + $value.aListOfBigInt + .map( + (el) => _i4.Serializers.instance.serialize(el), + ) + .toList(), + r'aListOfBool': $value.aListOfBool, + r'aListOfDateTime': + $value.aListOfDateTime + .map( + (el) => + _i4.Serializers.instance.serialize(el), + ) + .toList(), + r'aListOfDouble': $value.aListOfDouble, + r'aListOfDuration': + $value.aListOfDuration + .map( + (el) => + _i4.Serializers.instance.serialize(el), + ) + .toList(), + r'aListOfEnum': + $value.aListOfEnum + .map( + (el) => + _i4.Serializers.instance.serialize<_i5.MyEnum>(el), + ) + .toList(), + r'aListOfInt': $value.aListOfInt, + r'aListOfNull': $value.aListOfNull, + r'aListOfRegExp': + $value.aListOfRegExp + .map( + (el) => _i4.Serializers.instance.serialize(el), + ) + .toList(), + r'aListOfSimpleClass': + $value.aListOfSimpleClass + .map( + (el) => _i4.Serializers.instance + .serialize<_i5.SimpleClass>(el), + ) + .toList(), + r'aListOfSimpleStruct': + $value.aListOfSimpleStruct + .map( + (el) => _i4.Serializers.instance + .serialize<_i5.SimpleStruct>(el), + ) + .toList(), + r'aListOfStackTrace': + $value.aListOfStackTrace + .map( + (el) => + _i4.Serializers.instance.serialize(el), + ) + .toList(), + r'aListOfString': $value.aListOfString, + r'aListOfUint8List': + $value.aListOfUint8List + .map( + (el) => _i4.Serializers.instance + .serialize<_i12.Uint8List>(el), + ) + .toList(), + r'aListOfUri': + $value.aListOfUri + .map((el) => _i4.Serializers.instance.serialize(el)) + .toList(), + r'aListOfUriData': + $value.aListOfUriData + .map( + (el) => _i4.Serializers.instance.serialize(el), + ) + .toList(), + r'aMapOfBigInt': $value.aMapOfBigInt.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.serialize(value), + ), + ), + r'aMapOfBool': $value.aMapOfBool, + r'aMapOfDateTime': $value.aMapOfDateTime.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.serialize(value), + ), + ), + r'aMapOfDouble': $value.aMapOfDouble, + r'aMapOfDuration': $value.aMapOfDuration.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.serialize(value), + ), + ), + r'aMapOfEnum': $value.aMapOfEnum.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.serialize<_i5.MyEnum>(value), + ), + ), + r'aMapOfInt': $value.aMapOfInt, + r'aMapOfNull': $value.aMapOfNull, + r'aMapOfRegExp': $value.aMapOfRegExp.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.serialize(value), + ), + ), + r'aMapOfSimpleClass': $value.aMapOfSimpleClass.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.serialize<_i5.SimpleClass>(value), + ), + ), + r'aMapOfSimpleStruct': $value.aMapOfSimpleStruct.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.serialize<_i5.SimpleStruct>(value), + ), + ), + r'aMapOfStackTrace': $value.aMapOfStackTrace.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.serialize(value), + ), + ), + r'aMapOfString': $value.aMapOfString, + r'aMapOfUint8List': $value.aMapOfUint8List.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.serialize<_i12.Uint8List>(value), + ), + ), + r'aMapOfUri': $value.aMapOfUri.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.serialize(value), + ), + ), + r'aMapOfUriData': $value.aMapOfUriData.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.serialize(value), + ), + ), + r'aNull': $value.aNull, + r'aRegExp': _i4.Serializers.instance.serialize( + $value.aRegExp, + ), + r'aSimpleClass': _i4.Serializers.instance + .serialize<_i5.SimpleClass>($value.aSimpleClass), + r'aSimpleStruct': _i4.Serializers.instance + .serialize<_i5.SimpleStruct>($value.aSimpleStruct), + r'aStackTrace': _i4.Serializers.instance.serialize( + $value.aStackTrace, + ), + r'aString': $value.aString, + r'aUint8List': _i4.Serializers.instance.serialize<_i12.Uint8List>( + $value.aUint8List, + ), + r'aUri': _i4.Serializers.instance.serialize($value.aUri), + r'aUriData': _i4.Serializers.instance.serialize( + $value.aUriData, + ), + r'anEnum': _i4.Serializers.instance.serialize<_i5.MyEnum>( + $value.anEnum, + ), + r'anInt': $value.anInt, + r'anIterableOfSimpleClass': + $value.anIterableOfSimpleClass + .map( + (el) => _i4.Serializers.instance + .serialize<_i5.SimpleClass>(el), + ) + .toList(), + }, + deserialize: ($serialized) { + return ( + aBigInt: _i4.Serializers.instance.deserialize( + $serialized[r'aBigInt'], + ), + aBool: ($serialized[r'aBool'] as bool), + aDateTime: _i4.Serializers.instance.deserialize( + $serialized[r'aDateTime'], + ), + aDouble: ($serialized[r'aDouble'] as num).toDouble(), + aDuration: _i4.Serializers.instance.deserialize( + $serialized[r'aDuration'], + ), + aListOfBigInt: + ($serialized[r'aListOfBigInt'] as Iterable) + .map( + (el) => _i4.Serializers.instance.deserialize(el), + ) + .toList(), + aListOfBool: + ($serialized[r'aListOfBool'] as Iterable) + .map((el) => (el as bool)) + .toList(), + aListOfDateTime: + ($serialized[r'aListOfDateTime'] as Iterable) + .map( + (el) => + _i4.Serializers.instance.deserialize(el), + ) + .toList(), + aListOfDouble: + ($serialized[r'aListOfDouble'] as Iterable) + .map((el) => (el as num).toDouble()) + .toList(), + aListOfDuration: + ($serialized[r'aListOfDuration'] as Iterable) + .map( + (el) => + _i4.Serializers.instance.deserialize(el), + ) + .toList(), + aListOfEnum: + ($serialized[r'aListOfEnum'] as Iterable) + .map( + (el) => + _i4.Serializers.instance.deserialize<_i5.MyEnum>(el), + ) + .toList(), + aListOfInt: + ($serialized[r'aListOfInt'] as Iterable) + .map((el) => (el as num).toInt()) + .toList(), + aListOfNull: + ($serialized[r'aListOfNull'] as Iterable) + .map((el) => (el as Null)) + .toList(), + aListOfRegExp: + ($serialized[r'aListOfRegExp'] as Iterable) + .map( + (el) => _i4.Serializers.instance.deserialize(el), + ) + .toList(), + aListOfSimpleClass: + ($serialized[r'aListOfSimpleClass'] as Iterable) + .map( + (el) => _i4.Serializers.instance + .deserialize<_i5.SimpleClass>(el), + ) + .toList(), + aListOfSimpleStruct: + ($serialized[r'aListOfSimpleStruct'] as Iterable) + .map( + (el) => _i4.Serializers.instance + .deserialize<_i5.SimpleStruct>(el), + ) + .toList(), + aListOfStackTrace: + ($serialized[r'aListOfStackTrace'] as Iterable) + .map( + (el) => + _i4.Serializers.instance.deserialize(el), + ) + .toList(), + aListOfString: + ($serialized[r'aListOfString'] as Iterable) + .map((el) => (el as String)) + .toList(), + aListOfUint8List: + ($serialized[r'aListOfUint8List'] as Iterable) + .map( + (el) => _i4.Serializers.instance + .deserialize<_i12.Uint8List>(el), + ) + .toList(), + aListOfUri: + ($serialized[r'aListOfUri'] as Iterable) + .map((el) => _i4.Serializers.instance.deserialize(el)) + .toList(), + aListOfUriData: + ($serialized[r'aListOfUriData'] as Iterable) + .map( + (el) => _i4.Serializers.instance.deserialize(el), + ) + .toList(), + aMapOfBigInt: ($serialized[r'aMapOfBigInt'] as Map) + .map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize(value), + ), + ), + aMapOfBool: ($serialized[r'aMapOfBool'] as Map) + .map((key, value) => MapEntry(key, (value as bool))), + aMapOfDateTime: + ($serialized[r'aMapOfDateTime'] as Map).map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize(value), + ), + ), + aMapOfDouble: ($serialized[r'aMapOfDouble'] as Map) + .map((key, value) => MapEntry(key, (value as num).toDouble())), + aMapOfDuration: + ($serialized[r'aMapOfDuration'] as Map).map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize(value), + ), + ), + aMapOfEnum: ($serialized[r'aMapOfEnum'] as Map) + .map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize<_i5.MyEnum>(value), + ), + ), + aMapOfInt: ($serialized[r'aMapOfInt'] as Map).map( + (key, value) => MapEntry(key, (value as num).toInt()), + ), + aMapOfNull: ($serialized[r'aMapOfNull'] as Map) + .map((key, value) => MapEntry(key, (value as Null))), + aMapOfRegExp: ($serialized[r'aMapOfRegExp'] as Map) + .map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize(value), + ), + ), + aMapOfSimpleClass: + ($serialized[r'aMapOfSimpleClass'] as Map).map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize<_i5.SimpleClass>( + value, + ), + ), + ), + aMapOfSimpleStruct: ($serialized[r'aMapOfSimpleStruct'] + as Map) + .map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize<_i5.SimpleStruct>( + value, + ), + ), + ), + aMapOfStackTrace: + ($serialized[r'aMapOfStackTrace'] as Map).map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize(value), + ), + ), + aMapOfString: ($serialized[r'aMapOfString'] as Map) + .map((key, value) => MapEntry(key, (value as String))), + aMapOfUint8List: + ($serialized[r'aMapOfUint8List'] as Map).map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize<_i12.Uint8List>(value), + ), + ), + aMapOfUri: ($serialized[r'aMapOfUri'] as Map).map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize(value), + ), + ), + aMapOfUriData: + ($serialized[r'aMapOfUriData'] as Map).map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize(value), + ), + ), + aNull: ($serialized[r'aNull'] as Null), + aRegExp: _i4.Serializers.instance.deserialize( + $serialized[r'aRegExp'], + ), + aSimpleClass: _i4.Serializers.instance.deserialize<_i5.SimpleClass>( + $serialized[r'aSimpleClass'], + ), + aSimpleStruct: _i4.Serializers.instance + .deserialize<_i5.SimpleStruct>($serialized[r'aSimpleStruct']), + aStackTrace: _i4.Serializers.instance.deserialize( + $serialized[r'aStackTrace'], + ), + aString: ($serialized[r'aString'] as String), + aUint8List: _i4.Serializers.instance.deserialize<_i12.Uint8List>( + $serialized[r'aUint8List'], + ), + aUri: _i4.Serializers.instance.deserialize( + $serialized[r'aUri'], + ), + aUriData: _i4.Serializers.instance.deserialize( + $serialized[r'aUriData'], + ), + anEnum: _i4.Serializers.instance.deserialize<_i5.MyEnum>( + $serialized[r'anEnum'], + ), + anInt: ($serialized[r'anInt'] as num).toInt(), + anIterableOfSimpleClass: + ($serialized[r'anIterableOfSimpleClass'] as Iterable) + .map( + (el) => _i4.Serializers.instance + .deserialize<_i5.SimpleClass>(el), + ) + .toList(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.MyEnum, String>( + serialize: ($value) => $value.name, + deserialize: ($serialized) { + return _i5.MyEnum.values.byName($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.SimpleClass, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i5.SimpleClass.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.SimpleStruct, Map?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return (); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i13.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': AsyncComplexStructReturnNullableTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncDoubleReturn.dart b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncDoubleReturn.dart new file mode 100644 index 000000000..c3fc15a94 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncDoubleReturn.dart @@ -0,0 +1,1685 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i9; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/return_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i10; +import 'package:celest_core/src/serialization/json_value.dart' as _i11; +import 'package:shelf/shelf.dart' as _i2; + +final class AsyncDoubleReturnTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'asyncDoubleReturn'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = await _i3.asyncDoubleReturn(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(response), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i9.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i10.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i9.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i10.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i11.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': AsyncDoubleReturnTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncIntReturn.dart b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncIntReturn.dart new file mode 100644 index 000000000..bd1a13535 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncIntReturn.dart @@ -0,0 +1,1685 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i9; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/return_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i10; +import 'package:celest_core/src/serialization/json_value.dart' as _i11; +import 'package:shelf/shelf.dart' as _i2; + +final class AsyncIntReturnTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'asyncIntReturn'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = await _i3.asyncIntReturn(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(response), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i9.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i10.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i9.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i10.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i11.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': AsyncIntReturnTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncIterableReturn.dart b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncIterableReturn.dart new file mode 100644 index 000000000..eaf6aa9a0 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncIterableReturn.dart @@ -0,0 +1,1685 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i9; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/return_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i10; +import 'package:celest_core/src/serialization/json_value.dart' as _i11; +import 'package:shelf/shelf.dart' as _i2; + +final class AsyncIterableReturnTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'asyncIterableReturn'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = await _i3.asyncIterableReturn(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(response), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i9.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i10.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i9.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i10.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i11.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': AsyncIterableReturnTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncListReturn.dart b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncListReturn.dart new file mode 100644 index 000000000..1854e340c --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncListReturn.dart @@ -0,0 +1,1685 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i9; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/return_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i10; +import 'package:celest_core/src/serialization/json_value.dart' as _i11; +import 'package:shelf/shelf.dart' as _i2; + +final class AsyncListReturnTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'asyncListReturn'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = await _i3.asyncListReturn(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(response), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i9.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i10.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i9.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i10.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i11.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': AsyncListReturnTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncMapReturn.dart b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncMapReturn.dart new file mode 100644 index 000000000..dbb0a716a --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncMapReturn.dart @@ -0,0 +1,1685 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i9; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/return_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i10; +import 'package:celest_core/src/serialization/json_value.dart' as _i11; +import 'package:shelf/shelf.dart' as _i2; + +final class AsyncMapReturnTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'asyncMapReturn'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = await _i3.asyncMapReturn(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(response), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i9.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i10.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i9.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i10.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i11.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': AsyncMapReturnTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncOrBoolReturn.dart b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncOrBoolReturn.dart new file mode 100644 index 000000000..e5054a5f0 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncOrBoolReturn.dart @@ -0,0 +1,1685 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i9; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/return_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i10; +import 'package:celest_core/src/serialization/json_value.dart' as _i11; +import 'package:shelf/shelf.dart' as _i2; + +final class AsyncOrBoolReturnTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'asyncOrBoolReturn'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = await _i3.asyncOrBoolReturn(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(response), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i9.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i10.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i9.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i10.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i11.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': AsyncOrBoolReturnTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncOrBoolReturnNullable.dart b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncOrBoolReturnNullable.dart new file mode 100644 index 000000000..530e9aba7 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncOrBoolReturnNullable.dart @@ -0,0 +1,1686 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i9; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/return_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i10; +import 'package:celest_core/src/serialization/json_value.dart' as _i11; +import 'package:shelf/shelf.dart' as _i2; + +final class AsyncOrBoolReturnNullableTarget + extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'asyncOrBoolReturnNullable'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = await _i3.asyncOrBoolReturnNullable(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(response), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i9.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i10.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i9.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i10.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i11.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': AsyncOrBoolReturnNullableTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncOrComplexClassReturnNullable.dart b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncOrComplexClassReturnNullable.dart new file mode 100644 index 000000000..693e50909 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncOrComplexClassReturnNullable.dart @@ -0,0 +1,1697 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/parameter_types.dart' as _i5; +import 'package:celest_backend/src/functions/return_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class AsyncOrComplexClassReturnNullableTarget + extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'asyncOrComplexClassReturnNullable'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = await _i3.asyncOrComplexClassReturnNullable(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.ComplexClass?>(response), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.ComplexClass, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i5.ComplexClass.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': AsyncOrComplexClassReturnNullableTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncOrComplexStructReturn.dart b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncOrComplexStructReturn.dart new file mode 100644 index 000000000..02dda3a32 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncOrComplexStructReturn.dart @@ -0,0 +1,2140 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; +import 'dart:typed_data' as _i12; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/parameter_types.dart' as _i5; +import 'package:celest_backend/src/functions/return_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i13; +import 'package:shelf/shelf.dart' as _i2; + +final class AsyncOrComplexStructReturnTarget + extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'asyncOrComplexStructReturn'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = await _i3.asyncOrComplexStructReturn(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.ComplexStruct>(response), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.ComplexStruct, Map>( + serialize: + ($value) => { + r'aBigInt': _i4.Serializers.instance.serialize( + $value.aBigInt, + ), + r'aBool': $value.aBool, + r'aDateTime': _i4.Serializers.instance.serialize( + $value.aDateTime, + ), + r'aDouble': $value.aDouble, + r'aDuration': _i4.Serializers.instance.serialize( + $value.aDuration, + ), + r'aListOfBigInt': + $value.aListOfBigInt + .map( + (el) => _i4.Serializers.instance.serialize(el), + ) + .toList(), + r'aListOfBool': $value.aListOfBool, + r'aListOfDateTime': + $value.aListOfDateTime + .map( + (el) => + _i4.Serializers.instance.serialize(el), + ) + .toList(), + r'aListOfDouble': $value.aListOfDouble, + r'aListOfDuration': + $value.aListOfDuration + .map( + (el) => + _i4.Serializers.instance.serialize(el), + ) + .toList(), + r'aListOfEnum': + $value.aListOfEnum + .map( + (el) => + _i4.Serializers.instance.serialize<_i5.MyEnum>(el), + ) + .toList(), + r'aListOfInt': $value.aListOfInt, + r'aListOfNull': $value.aListOfNull, + r'aListOfRegExp': + $value.aListOfRegExp + .map( + (el) => _i4.Serializers.instance.serialize(el), + ) + .toList(), + r'aListOfSimpleClass': + $value.aListOfSimpleClass + .map( + (el) => _i4.Serializers.instance + .serialize<_i5.SimpleClass>(el), + ) + .toList(), + r'aListOfSimpleStruct': + $value.aListOfSimpleStruct + .map( + (el) => _i4.Serializers.instance + .serialize<_i5.SimpleStruct>(el), + ) + .toList(), + r'aListOfStackTrace': + $value.aListOfStackTrace + .map( + (el) => + _i4.Serializers.instance.serialize(el), + ) + .toList(), + r'aListOfString': $value.aListOfString, + r'aListOfUint8List': + $value.aListOfUint8List + .map( + (el) => _i4.Serializers.instance + .serialize<_i12.Uint8List>(el), + ) + .toList(), + r'aListOfUri': + $value.aListOfUri + .map((el) => _i4.Serializers.instance.serialize(el)) + .toList(), + r'aListOfUriData': + $value.aListOfUriData + .map( + (el) => _i4.Serializers.instance.serialize(el), + ) + .toList(), + r'aMapOfBigInt': $value.aMapOfBigInt.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.serialize(value), + ), + ), + r'aMapOfBool': $value.aMapOfBool, + r'aMapOfDateTime': $value.aMapOfDateTime.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.serialize(value), + ), + ), + r'aMapOfDouble': $value.aMapOfDouble, + r'aMapOfDuration': $value.aMapOfDuration.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.serialize(value), + ), + ), + r'aMapOfEnum': $value.aMapOfEnum.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.serialize<_i5.MyEnum>(value), + ), + ), + r'aMapOfInt': $value.aMapOfInt, + r'aMapOfNull': $value.aMapOfNull, + r'aMapOfRegExp': $value.aMapOfRegExp.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.serialize(value), + ), + ), + r'aMapOfSimpleClass': $value.aMapOfSimpleClass.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.serialize<_i5.SimpleClass>(value), + ), + ), + r'aMapOfSimpleStruct': $value.aMapOfSimpleStruct.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.serialize<_i5.SimpleStruct>(value), + ), + ), + r'aMapOfStackTrace': $value.aMapOfStackTrace.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.serialize(value), + ), + ), + r'aMapOfString': $value.aMapOfString, + r'aMapOfUint8List': $value.aMapOfUint8List.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.serialize<_i12.Uint8List>(value), + ), + ), + r'aMapOfUri': $value.aMapOfUri.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.serialize(value), + ), + ), + r'aMapOfUriData': $value.aMapOfUriData.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.serialize(value), + ), + ), + r'aNull': $value.aNull, + r'aRegExp': _i4.Serializers.instance.serialize( + $value.aRegExp, + ), + r'aSimpleClass': _i4.Serializers.instance + .serialize<_i5.SimpleClass>($value.aSimpleClass), + r'aSimpleStruct': _i4.Serializers.instance + .serialize<_i5.SimpleStruct>($value.aSimpleStruct), + r'aStackTrace': _i4.Serializers.instance.serialize( + $value.aStackTrace, + ), + r'aString': $value.aString, + r'aUint8List': _i4.Serializers.instance.serialize<_i12.Uint8List>( + $value.aUint8List, + ), + r'aUri': _i4.Serializers.instance.serialize($value.aUri), + r'aUriData': _i4.Serializers.instance.serialize( + $value.aUriData, + ), + r'anEnum': _i4.Serializers.instance.serialize<_i5.MyEnum>( + $value.anEnum, + ), + r'anInt': $value.anInt, + r'anIterableOfSimpleClass': + $value.anIterableOfSimpleClass + .map( + (el) => _i4.Serializers.instance + .serialize<_i5.SimpleClass>(el), + ) + .toList(), + }, + deserialize: ($serialized) { + return ( + aBigInt: _i4.Serializers.instance.deserialize( + $serialized[r'aBigInt'], + ), + aBool: ($serialized[r'aBool'] as bool), + aDateTime: _i4.Serializers.instance.deserialize( + $serialized[r'aDateTime'], + ), + aDouble: ($serialized[r'aDouble'] as num).toDouble(), + aDuration: _i4.Serializers.instance.deserialize( + $serialized[r'aDuration'], + ), + aListOfBigInt: + ($serialized[r'aListOfBigInt'] as Iterable) + .map( + (el) => _i4.Serializers.instance.deserialize(el), + ) + .toList(), + aListOfBool: + ($serialized[r'aListOfBool'] as Iterable) + .map((el) => (el as bool)) + .toList(), + aListOfDateTime: + ($serialized[r'aListOfDateTime'] as Iterable) + .map( + (el) => + _i4.Serializers.instance.deserialize(el), + ) + .toList(), + aListOfDouble: + ($serialized[r'aListOfDouble'] as Iterable) + .map((el) => (el as num).toDouble()) + .toList(), + aListOfDuration: + ($serialized[r'aListOfDuration'] as Iterable) + .map( + (el) => + _i4.Serializers.instance.deserialize(el), + ) + .toList(), + aListOfEnum: + ($serialized[r'aListOfEnum'] as Iterable) + .map( + (el) => + _i4.Serializers.instance.deserialize<_i5.MyEnum>(el), + ) + .toList(), + aListOfInt: + ($serialized[r'aListOfInt'] as Iterable) + .map((el) => (el as num).toInt()) + .toList(), + aListOfNull: + ($serialized[r'aListOfNull'] as Iterable) + .map((el) => (el as Null)) + .toList(), + aListOfRegExp: + ($serialized[r'aListOfRegExp'] as Iterable) + .map( + (el) => _i4.Serializers.instance.deserialize(el), + ) + .toList(), + aListOfSimpleClass: + ($serialized[r'aListOfSimpleClass'] as Iterable) + .map( + (el) => _i4.Serializers.instance + .deserialize<_i5.SimpleClass>(el), + ) + .toList(), + aListOfSimpleStruct: + ($serialized[r'aListOfSimpleStruct'] as Iterable) + .map( + (el) => _i4.Serializers.instance + .deserialize<_i5.SimpleStruct>(el), + ) + .toList(), + aListOfStackTrace: + ($serialized[r'aListOfStackTrace'] as Iterable) + .map( + (el) => + _i4.Serializers.instance.deserialize(el), + ) + .toList(), + aListOfString: + ($serialized[r'aListOfString'] as Iterable) + .map((el) => (el as String)) + .toList(), + aListOfUint8List: + ($serialized[r'aListOfUint8List'] as Iterable) + .map( + (el) => _i4.Serializers.instance + .deserialize<_i12.Uint8List>(el), + ) + .toList(), + aListOfUri: + ($serialized[r'aListOfUri'] as Iterable) + .map((el) => _i4.Serializers.instance.deserialize(el)) + .toList(), + aListOfUriData: + ($serialized[r'aListOfUriData'] as Iterable) + .map( + (el) => _i4.Serializers.instance.deserialize(el), + ) + .toList(), + aMapOfBigInt: ($serialized[r'aMapOfBigInt'] as Map) + .map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize(value), + ), + ), + aMapOfBool: ($serialized[r'aMapOfBool'] as Map) + .map((key, value) => MapEntry(key, (value as bool))), + aMapOfDateTime: + ($serialized[r'aMapOfDateTime'] as Map).map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize(value), + ), + ), + aMapOfDouble: ($serialized[r'aMapOfDouble'] as Map) + .map((key, value) => MapEntry(key, (value as num).toDouble())), + aMapOfDuration: + ($serialized[r'aMapOfDuration'] as Map).map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize(value), + ), + ), + aMapOfEnum: ($serialized[r'aMapOfEnum'] as Map) + .map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize<_i5.MyEnum>(value), + ), + ), + aMapOfInt: ($serialized[r'aMapOfInt'] as Map).map( + (key, value) => MapEntry(key, (value as num).toInt()), + ), + aMapOfNull: ($serialized[r'aMapOfNull'] as Map) + .map((key, value) => MapEntry(key, (value as Null))), + aMapOfRegExp: ($serialized[r'aMapOfRegExp'] as Map) + .map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize(value), + ), + ), + aMapOfSimpleClass: + ($serialized[r'aMapOfSimpleClass'] as Map).map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize<_i5.SimpleClass>( + value, + ), + ), + ), + aMapOfSimpleStruct: ($serialized[r'aMapOfSimpleStruct'] + as Map) + .map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize<_i5.SimpleStruct>( + value, + ), + ), + ), + aMapOfStackTrace: + ($serialized[r'aMapOfStackTrace'] as Map).map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize(value), + ), + ), + aMapOfString: ($serialized[r'aMapOfString'] as Map) + .map((key, value) => MapEntry(key, (value as String))), + aMapOfUint8List: + ($serialized[r'aMapOfUint8List'] as Map).map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize<_i12.Uint8List>(value), + ), + ), + aMapOfUri: ($serialized[r'aMapOfUri'] as Map).map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize(value), + ), + ), + aMapOfUriData: + ($serialized[r'aMapOfUriData'] as Map).map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize(value), + ), + ), + aNull: ($serialized[r'aNull'] as Null), + aRegExp: _i4.Serializers.instance.deserialize( + $serialized[r'aRegExp'], + ), + aSimpleClass: _i4.Serializers.instance.deserialize<_i5.SimpleClass>( + $serialized[r'aSimpleClass'], + ), + aSimpleStruct: _i4.Serializers.instance + .deserialize<_i5.SimpleStruct>($serialized[r'aSimpleStruct']), + aStackTrace: _i4.Serializers.instance.deserialize( + $serialized[r'aStackTrace'], + ), + aString: ($serialized[r'aString'] as String), + aUint8List: _i4.Serializers.instance.deserialize<_i12.Uint8List>( + $serialized[r'aUint8List'], + ), + aUri: _i4.Serializers.instance.deserialize( + $serialized[r'aUri'], + ), + aUriData: _i4.Serializers.instance.deserialize( + $serialized[r'aUriData'], + ), + anEnum: _i4.Serializers.instance.deserialize<_i5.MyEnum>( + $serialized[r'anEnum'], + ), + anInt: ($serialized[r'anInt'] as num).toInt(), + anIterableOfSimpleClass: + ($serialized[r'anIterableOfSimpleClass'] as Iterable) + .map( + (el) => _i4.Serializers.instance + .deserialize<_i5.SimpleClass>(el), + ) + .toList(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.MyEnum, String>( + serialize: ($value) => $value.name, + deserialize: ($serialized) { + return _i5.MyEnum.values.byName($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.SimpleClass, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i5.SimpleClass.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.SimpleStruct, Map?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return (); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i13.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': AsyncOrComplexStructReturnTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncOrComplexStructReturnNullable.dart b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncOrComplexStructReturnNullable.dart new file mode 100644 index 000000000..f2c7ea175 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncOrComplexStructReturnNullable.dart @@ -0,0 +1,2140 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; +import 'dart:typed_data' as _i12; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/parameter_types.dart' as _i5; +import 'package:celest_backend/src/functions/return_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i13; +import 'package:shelf/shelf.dart' as _i2; + +final class AsyncOrComplexStructReturnNullableTarget + extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'asyncOrComplexStructReturnNullable'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = await _i3.asyncOrComplexStructReturnNullable(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.ComplexStruct?>(response), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.ComplexStruct, Map>( + serialize: + ($value) => { + r'aBigInt': _i4.Serializers.instance.serialize( + $value.aBigInt, + ), + r'aBool': $value.aBool, + r'aDateTime': _i4.Serializers.instance.serialize( + $value.aDateTime, + ), + r'aDouble': $value.aDouble, + r'aDuration': _i4.Serializers.instance.serialize( + $value.aDuration, + ), + r'aListOfBigInt': + $value.aListOfBigInt + .map( + (el) => _i4.Serializers.instance.serialize(el), + ) + .toList(), + r'aListOfBool': $value.aListOfBool, + r'aListOfDateTime': + $value.aListOfDateTime + .map( + (el) => + _i4.Serializers.instance.serialize(el), + ) + .toList(), + r'aListOfDouble': $value.aListOfDouble, + r'aListOfDuration': + $value.aListOfDuration + .map( + (el) => + _i4.Serializers.instance.serialize(el), + ) + .toList(), + r'aListOfEnum': + $value.aListOfEnum + .map( + (el) => + _i4.Serializers.instance.serialize<_i5.MyEnum>(el), + ) + .toList(), + r'aListOfInt': $value.aListOfInt, + r'aListOfNull': $value.aListOfNull, + r'aListOfRegExp': + $value.aListOfRegExp + .map( + (el) => _i4.Serializers.instance.serialize(el), + ) + .toList(), + r'aListOfSimpleClass': + $value.aListOfSimpleClass + .map( + (el) => _i4.Serializers.instance + .serialize<_i5.SimpleClass>(el), + ) + .toList(), + r'aListOfSimpleStruct': + $value.aListOfSimpleStruct + .map( + (el) => _i4.Serializers.instance + .serialize<_i5.SimpleStruct>(el), + ) + .toList(), + r'aListOfStackTrace': + $value.aListOfStackTrace + .map( + (el) => + _i4.Serializers.instance.serialize(el), + ) + .toList(), + r'aListOfString': $value.aListOfString, + r'aListOfUint8List': + $value.aListOfUint8List + .map( + (el) => _i4.Serializers.instance + .serialize<_i12.Uint8List>(el), + ) + .toList(), + r'aListOfUri': + $value.aListOfUri + .map((el) => _i4.Serializers.instance.serialize(el)) + .toList(), + r'aListOfUriData': + $value.aListOfUriData + .map( + (el) => _i4.Serializers.instance.serialize(el), + ) + .toList(), + r'aMapOfBigInt': $value.aMapOfBigInt.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.serialize(value), + ), + ), + r'aMapOfBool': $value.aMapOfBool, + r'aMapOfDateTime': $value.aMapOfDateTime.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.serialize(value), + ), + ), + r'aMapOfDouble': $value.aMapOfDouble, + r'aMapOfDuration': $value.aMapOfDuration.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.serialize(value), + ), + ), + r'aMapOfEnum': $value.aMapOfEnum.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.serialize<_i5.MyEnum>(value), + ), + ), + r'aMapOfInt': $value.aMapOfInt, + r'aMapOfNull': $value.aMapOfNull, + r'aMapOfRegExp': $value.aMapOfRegExp.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.serialize(value), + ), + ), + r'aMapOfSimpleClass': $value.aMapOfSimpleClass.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.serialize<_i5.SimpleClass>(value), + ), + ), + r'aMapOfSimpleStruct': $value.aMapOfSimpleStruct.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.serialize<_i5.SimpleStruct>(value), + ), + ), + r'aMapOfStackTrace': $value.aMapOfStackTrace.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.serialize(value), + ), + ), + r'aMapOfString': $value.aMapOfString, + r'aMapOfUint8List': $value.aMapOfUint8List.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.serialize<_i12.Uint8List>(value), + ), + ), + r'aMapOfUri': $value.aMapOfUri.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.serialize(value), + ), + ), + r'aMapOfUriData': $value.aMapOfUriData.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.serialize(value), + ), + ), + r'aNull': $value.aNull, + r'aRegExp': _i4.Serializers.instance.serialize( + $value.aRegExp, + ), + r'aSimpleClass': _i4.Serializers.instance + .serialize<_i5.SimpleClass>($value.aSimpleClass), + r'aSimpleStruct': _i4.Serializers.instance + .serialize<_i5.SimpleStruct>($value.aSimpleStruct), + r'aStackTrace': _i4.Serializers.instance.serialize( + $value.aStackTrace, + ), + r'aString': $value.aString, + r'aUint8List': _i4.Serializers.instance.serialize<_i12.Uint8List>( + $value.aUint8List, + ), + r'aUri': _i4.Serializers.instance.serialize($value.aUri), + r'aUriData': _i4.Serializers.instance.serialize( + $value.aUriData, + ), + r'anEnum': _i4.Serializers.instance.serialize<_i5.MyEnum>( + $value.anEnum, + ), + r'anInt': $value.anInt, + r'anIterableOfSimpleClass': + $value.anIterableOfSimpleClass + .map( + (el) => _i4.Serializers.instance + .serialize<_i5.SimpleClass>(el), + ) + .toList(), + }, + deserialize: ($serialized) { + return ( + aBigInt: _i4.Serializers.instance.deserialize( + $serialized[r'aBigInt'], + ), + aBool: ($serialized[r'aBool'] as bool), + aDateTime: _i4.Serializers.instance.deserialize( + $serialized[r'aDateTime'], + ), + aDouble: ($serialized[r'aDouble'] as num).toDouble(), + aDuration: _i4.Serializers.instance.deserialize( + $serialized[r'aDuration'], + ), + aListOfBigInt: + ($serialized[r'aListOfBigInt'] as Iterable) + .map( + (el) => _i4.Serializers.instance.deserialize(el), + ) + .toList(), + aListOfBool: + ($serialized[r'aListOfBool'] as Iterable) + .map((el) => (el as bool)) + .toList(), + aListOfDateTime: + ($serialized[r'aListOfDateTime'] as Iterable) + .map( + (el) => + _i4.Serializers.instance.deserialize(el), + ) + .toList(), + aListOfDouble: + ($serialized[r'aListOfDouble'] as Iterable) + .map((el) => (el as num).toDouble()) + .toList(), + aListOfDuration: + ($serialized[r'aListOfDuration'] as Iterable) + .map( + (el) => + _i4.Serializers.instance.deserialize(el), + ) + .toList(), + aListOfEnum: + ($serialized[r'aListOfEnum'] as Iterable) + .map( + (el) => + _i4.Serializers.instance.deserialize<_i5.MyEnum>(el), + ) + .toList(), + aListOfInt: + ($serialized[r'aListOfInt'] as Iterable) + .map((el) => (el as num).toInt()) + .toList(), + aListOfNull: + ($serialized[r'aListOfNull'] as Iterable) + .map((el) => (el as Null)) + .toList(), + aListOfRegExp: + ($serialized[r'aListOfRegExp'] as Iterable) + .map( + (el) => _i4.Serializers.instance.deserialize(el), + ) + .toList(), + aListOfSimpleClass: + ($serialized[r'aListOfSimpleClass'] as Iterable) + .map( + (el) => _i4.Serializers.instance + .deserialize<_i5.SimpleClass>(el), + ) + .toList(), + aListOfSimpleStruct: + ($serialized[r'aListOfSimpleStruct'] as Iterable) + .map( + (el) => _i4.Serializers.instance + .deserialize<_i5.SimpleStruct>(el), + ) + .toList(), + aListOfStackTrace: + ($serialized[r'aListOfStackTrace'] as Iterable) + .map( + (el) => + _i4.Serializers.instance.deserialize(el), + ) + .toList(), + aListOfString: + ($serialized[r'aListOfString'] as Iterable) + .map((el) => (el as String)) + .toList(), + aListOfUint8List: + ($serialized[r'aListOfUint8List'] as Iterable) + .map( + (el) => _i4.Serializers.instance + .deserialize<_i12.Uint8List>(el), + ) + .toList(), + aListOfUri: + ($serialized[r'aListOfUri'] as Iterable) + .map((el) => _i4.Serializers.instance.deserialize(el)) + .toList(), + aListOfUriData: + ($serialized[r'aListOfUriData'] as Iterable) + .map( + (el) => _i4.Serializers.instance.deserialize(el), + ) + .toList(), + aMapOfBigInt: ($serialized[r'aMapOfBigInt'] as Map) + .map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize(value), + ), + ), + aMapOfBool: ($serialized[r'aMapOfBool'] as Map) + .map((key, value) => MapEntry(key, (value as bool))), + aMapOfDateTime: + ($serialized[r'aMapOfDateTime'] as Map).map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize(value), + ), + ), + aMapOfDouble: ($serialized[r'aMapOfDouble'] as Map) + .map((key, value) => MapEntry(key, (value as num).toDouble())), + aMapOfDuration: + ($serialized[r'aMapOfDuration'] as Map).map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize(value), + ), + ), + aMapOfEnum: ($serialized[r'aMapOfEnum'] as Map) + .map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize<_i5.MyEnum>(value), + ), + ), + aMapOfInt: ($serialized[r'aMapOfInt'] as Map).map( + (key, value) => MapEntry(key, (value as num).toInt()), + ), + aMapOfNull: ($serialized[r'aMapOfNull'] as Map) + .map((key, value) => MapEntry(key, (value as Null))), + aMapOfRegExp: ($serialized[r'aMapOfRegExp'] as Map) + .map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize(value), + ), + ), + aMapOfSimpleClass: + ($serialized[r'aMapOfSimpleClass'] as Map).map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize<_i5.SimpleClass>( + value, + ), + ), + ), + aMapOfSimpleStruct: ($serialized[r'aMapOfSimpleStruct'] + as Map) + .map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize<_i5.SimpleStruct>( + value, + ), + ), + ), + aMapOfStackTrace: + ($serialized[r'aMapOfStackTrace'] as Map).map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize(value), + ), + ), + aMapOfString: ($serialized[r'aMapOfString'] as Map) + .map((key, value) => MapEntry(key, (value as String))), + aMapOfUint8List: + ($serialized[r'aMapOfUint8List'] as Map).map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize<_i12.Uint8List>(value), + ), + ), + aMapOfUri: ($serialized[r'aMapOfUri'] as Map).map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize(value), + ), + ), + aMapOfUriData: + ($serialized[r'aMapOfUriData'] as Map).map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize(value), + ), + ), + aNull: ($serialized[r'aNull'] as Null), + aRegExp: _i4.Serializers.instance.deserialize( + $serialized[r'aRegExp'], + ), + aSimpleClass: _i4.Serializers.instance.deserialize<_i5.SimpleClass>( + $serialized[r'aSimpleClass'], + ), + aSimpleStruct: _i4.Serializers.instance + .deserialize<_i5.SimpleStruct>($serialized[r'aSimpleStruct']), + aStackTrace: _i4.Serializers.instance.deserialize( + $serialized[r'aStackTrace'], + ), + aString: ($serialized[r'aString'] as String), + aUint8List: _i4.Serializers.instance.deserialize<_i12.Uint8List>( + $serialized[r'aUint8List'], + ), + aUri: _i4.Serializers.instance.deserialize( + $serialized[r'aUri'], + ), + aUriData: _i4.Serializers.instance.deserialize( + $serialized[r'aUriData'], + ), + anEnum: _i4.Serializers.instance.deserialize<_i5.MyEnum>( + $serialized[r'anEnum'], + ), + anInt: ($serialized[r'anInt'] as num).toInt(), + anIterableOfSimpleClass: + ($serialized[r'anIterableOfSimpleClass'] as Iterable) + .map( + (el) => _i4.Serializers.instance + .deserialize<_i5.SimpleClass>(el), + ) + .toList(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.MyEnum, String>( + serialize: ($value) => $value.name, + deserialize: ($serialized) { + return _i5.MyEnum.values.byName($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.SimpleClass, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i5.SimpleClass.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.SimpleStruct, Map?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return (); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i13.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': AsyncOrComplexStructReturnNullableTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncOrDoubleReturn.dart b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncOrDoubleReturn.dart new file mode 100644 index 000000000..f10a30454 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncOrDoubleReturn.dart @@ -0,0 +1,1685 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i9; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/return_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i10; +import 'package:celest_core/src/serialization/json_value.dart' as _i11; +import 'package:shelf/shelf.dart' as _i2; + +final class AsyncOrDoubleReturnTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'asyncOrDoubleReturn'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = await _i3.asyncOrDoubleReturn(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(response), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i9.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i10.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i9.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i10.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i11.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': AsyncOrDoubleReturnTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncOrDoubleReturnNullable.dart b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncOrDoubleReturnNullable.dart new file mode 100644 index 000000000..6175c9b9a --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncOrDoubleReturnNullable.dart @@ -0,0 +1,1686 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i9; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/return_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i10; +import 'package:celest_core/src/serialization/json_value.dart' as _i11; +import 'package:shelf/shelf.dart' as _i2; + +final class AsyncOrDoubleReturnNullableTarget + extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'asyncOrDoubleReturnNullable'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = await _i3.asyncOrDoubleReturnNullable(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(response), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i9.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i10.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i9.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i10.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i11.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': AsyncOrDoubleReturnNullableTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncOrIntReturn.dart b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncOrIntReturn.dart new file mode 100644 index 000000000..1fb1d6e7e --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncOrIntReturn.dart @@ -0,0 +1,1685 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i9; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/return_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i10; +import 'package:celest_core/src/serialization/json_value.dart' as _i11; +import 'package:shelf/shelf.dart' as _i2; + +final class AsyncOrIntReturnTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'asyncOrIntReturn'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = await _i3.asyncOrIntReturn(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(response), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i9.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i10.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i9.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i10.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i11.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': AsyncOrIntReturnTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncOrIntReturnNullable.dart b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncOrIntReturnNullable.dart new file mode 100644 index 000000000..dbe1a03e6 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncOrIntReturnNullable.dart @@ -0,0 +1,1685 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i9; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/return_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i10; +import 'package:celest_core/src/serialization/json_value.dart' as _i11; +import 'package:shelf/shelf.dart' as _i2; + +final class AsyncOrIntReturnNullableTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'asyncOrIntReturnNullable'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = await _i3.asyncOrIntReturnNullable(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(response), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i9.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i10.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i9.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i10.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i11.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': AsyncOrIntReturnNullableTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncOrIterableReturn.dart b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncOrIterableReturn.dart new file mode 100644 index 000000000..834826af8 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncOrIterableReturn.dart @@ -0,0 +1,1685 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i9; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/return_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i10; +import 'package:celest_core/src/serialization/json_value.dart' as _i11; +import 'package:shelf/shelf.dart' as _i2; + +final class AsyncOrIterableReturnTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'asyncOrIterableReturn'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = await _i3.asyncOrIterableReturn(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(response), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i9.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i10.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i9.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i10.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i11.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': AsyncOrIterableReturnTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncOrIterableReturnNullable.dart b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncOrIterableReturnNullable.dart new file mode 100644 index 000000000..eba9f3879 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncOrIterableReturnNullable.dart @@ -0,0 +1,1686 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i9; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/return_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i10; +import 'package:celest_core/src/serialization/json_value.dart' as _i11; +import 'package:shelf/shelf.dart' as _i2; + +final class AsyncOrIterableReturnNullableTarget + extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'asyncOrIterableReturnNullable'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = await _i3.asyncOrIterableReturnNullable(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(response), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i9.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i10.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i9.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i10.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i11.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': AsyncOrIterableReturnNullableTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncOrListReturn.dart b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncOrListReturn.dart new file mode 100644 index 000000000..b12019d14 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncOrListReturn.dart @@ -0,0 +1,1685 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i9; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/return_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i10; +import 'package:celest_core/src/serialization/json_value.dart' as _i11; +import 'package:shelf/shelf.dart' as _i2; + +final class AsyncOrListReturnTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'asyncOrListReturn'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = await _i3.asyncOrListReturn(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(response), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i9.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i10.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i9.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i10.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i11.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': AsyncOrListReturnTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncOrListReturnNullable.dart b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncOrListReturnNullable.dart new file mode 100644 index 000000000..64d01ae88 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncOrListReturnNullable.dart @@ -0,0 +1,1686 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i9; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/return_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i10; +import 'package:celest_core/src/serialization/json_value.dart' as _i11; +import 'package:shelf/shelf.dart' as _i2; + +final class AsyncOrListReturnNullableTarget + extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'asyncOrListReturnNullable'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = await _i3.asyncOrListReturnNullable(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(response), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i9.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i10.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i9.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i10.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i11.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': AsyncOrListReturnNullableTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncOrMapReturn.dart b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncOrMapReturn.dart new file mode 100644 index 000000000..cd08bf5db --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncOrMapReturn.dart @@ -0,0 +1,1685 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i9; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/return_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i10; +import 'package:celest_core/src/serialization/json_value.dart' as _i11; +import 'package:shelf/shelf.dart' as _i2; + +final class AsyncOrMapReturnTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'asyncOrMapReturn'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = await _i3.asyncOrMapReturn(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(response), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i9.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i10.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i9.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i10.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i11.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': AsyncOrMapReturnTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncOrMapReturnNullable.dart b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncOrMapReturnNullable.dart new file mode 100644 index 000000000..3bf77a6e5 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncOrMapReturnNullable.dart @@ -0,0 +1,1685 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i9; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/return_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i10; +import 'package:celest_core/src/serialization/json_value.dart' as _i11; +import 'package:shelf/shelf.dart' as _i2; + +final class AsyncOrMapReturnNullableTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'asyncOrMapReturnNullable'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = await _i3.asyncOrMapReturnNullable(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(response), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i9.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i10.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i9.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i10.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i11.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': AsyncOrMapReturnNullableTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncOrSimpleClassReturnNullable.dart b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncOrSimpleClassReturnNullable.dart new file mode 100644 index 000000000..6eb90a77c --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncOrSimpleClassReturnNullable.dart @@ -0,0 +1,1697 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/parameter_types.dart' as _i5; +import 'package:celest_backend/src/functions/return_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class AsyncOrSimpleClassReturnNullableTarget + extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'asyncOrSimpleClassReturnNullable'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = await _i3.asyncOrSimpleClassReturnNullable(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.SimpleClass?>(response), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.SimpleClass, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i5.SimpleClass.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': AsyncOrSimpleClassReturnNullableTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncOrStringReturn.dart b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncOrStringReturn.dart new file mode 100644 index 000000000..356aff80d --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncOrStringReturn.dart @@ -0,0 +1,1685 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i9; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/return_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i10; +import 'package:celest_core/src/serialization/json_value.dart' as _i11; +import 'package:shelf/shelf.dart' as _i2; + +final class AsyncOrStringReturnTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'asyncOrStringReturn'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = await _i3.asyncOrStringReturn(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(response), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i9.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i10.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i9.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i10.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i11.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': AsyncOrStringReturnTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncOrStringReturnNullable.dart b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncOrStringReturnNullable.dart new file mode 100644 index 000000000..671d534a6 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncOrStringReturnNullable.dart @@ -0,0 +1,1686 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i9; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/return_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i10; +import 'package:celest_core/src/serialization/json_value.dart' as _i11; +import 'package:shelf/shelf.dart' as _i2; + +final class AsyncOrStringReturnNullableTarget + extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'asyncOrStringReturnNullable'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = await _i3.asyncOrStringReturnNullable(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(response), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i9.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i10.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i9.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i10.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i11.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': AsyncOrStringReturnNullableTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncOrStructReturn.dart b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncOrStructReturn.dart new file mode 100644 index 000000000..93b00b208 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncOrStructReturn.dart @@ -0,0 +1,1696 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/parameter_types.dart' as _i5; +import 'package:celest_backend/src/functions/return_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class AsyncOrStructReturnTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'asyncOrStructReturn'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = await _i3.asyncOrStructReturn(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.SimpleStruct>(response), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.SimpleStruct, Map?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return (); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': AsyncOrStructReturnTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncOrStructReturnNullable.dart b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncOrStructReturnNullable.dart new file mode 100644 index 000000000..f775294a5 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncOrStructReturnNullable.dart @@ -0,0 +1,1697 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/parameter_types.dart' as _i5; +import 'package:celest_backend/src/functions/return_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class AsyncOrStructReturnNullableTarget + extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'asyncOrStructReturnNullable'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = await _i3.asyncOrStructReturnNullable(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.SimpleStruct?>(response), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.SimpleStruct, Map?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return (); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': AsyncOrStructReturnNullableTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncOrVoidReturn.dart b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncOrVoidReturn.dart new file mode 100644 index 000000000..537a4dd7b --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncOrVoidReturn.dart @@ -0,0 +1,1685 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i9; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/return_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i10; +import 'package:celest_core/src/serialization/json_value.dart' as _i11; +import 'package:shelf/shelf.dart' as _i2; + +final class AsyncOrVoidReturnTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'asyncOrVoidReturn'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + await _i3.asyncOrVoidReturn(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(null), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i9.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i10.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i9.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i10.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i11.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': AsyncOrVoidReturnTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncOrVoidReturnNullable.dart b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncOrVoidReturnNullable.dart new file mode 100644 index 000000000..e96381a7a --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncOrVoidReturnNullable.dart @@ -0,0 +1,1686 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i9; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/return_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i10; +import 'package:celest_core/src/serialization/json_value.dart' as _i11; +import 'package:shelf/shelf.dart' as _i2; + +final class AsyncOrVoidReturnNullableTarget + extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'asyncOrVoidReturnNullable'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + await _i3.asyncOrVoidReturnNullable(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(null), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i9.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i10.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i9.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i10.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i11.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': AsyncOrVoidReturnNullableTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncStringReturn.dart b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncStringReturn.dart new file mode 100644 index 000000000..efbd37cd8 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncStringReturn.dart @@ -0,0 +1,1685 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i9; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/return_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i10; +import 'package:celest_core/src/serialization/json_value.dart' as _i11; +import 'package:shelf/shelf.dart' as _i2; + +final class AsyncStringReturnTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'asyncStringReturn'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = await _i3.asyncStringReturn(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(response), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i9.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i10.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i9.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i10.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i11.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': AsyncStringReturnTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncStructReturn.dart b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncStructReturn.dart new file mode 100644 index 000000000..ae537f66a --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncStructReturn.dart @@ -0,0 +1,1696 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/parameter_types.dart' as _i5; +import 'package:celest_backend/src/functions/return_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class AsyncStructReturnTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'asyncStructReturn'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = await _i3.asyncStructReturn(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.SimpleStruct>(response), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.SimpleStruct, Map?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return (); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': AsyncStructReturnTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncStructReturnNullable.dart b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncStructReturnNullable.dart new file mode 100644 index 000000000..6d464f4d5 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncStructReturnNullable.dart @@ -0,0 +1,1697 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/parameter_types.dart' as _i5; +import 'package:celest_backend/src/functions/return_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class AsyncStructReturnNullableTarget + extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'asyncStructReturnNullable'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = await _i3.asyncStructReturnNullable(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.SimpleStruct?>(response), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.SimpleStruct, Map?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return (); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': AsyncStructReturnNullableTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncVoidReturn.dart b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncVoidReturn.dart new file mode 100644 index 000000000..df493f8c0 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/asyncVoidReturn.dart @@ -0,0 +1,1685 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i9; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/return_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i10; +import 'package:celest_core/src/serialization/json_value.dart' as _i11; +import 'package:shelf/shelf.dart' as _i2; + +final class AsyncVoidReturnTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'asyncVoidReturn'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + await _i3.asyncVoidReturn(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(null), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i9.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i10.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i9.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i10.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i11.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': AsyncVoidReturnTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/return_types/boolReturn.dart b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/boolReturn.dart new file mode 100644 index 000000000..072bdcc61 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/boolReturn.dart @@ -0,0 +1,1685 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i9; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/return_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i10; +import 'package:celest_core/src/serialization/json_value.dart' as _i11; +import 'package:shelf/shelf.dart' as _i2; + +final class BoolReturnTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'boolReturn'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.boolReturn(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(response), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i9.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i10.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i9.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i10.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i11.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': BoolReturnTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/return_types/boolReturnNullable.dart b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/boolReturnNullable.dart new file mode 100644 index 000000000..186dbdf47 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/boolReturnNullable.dart @@ -0,0 +1,1685 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i9; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/return_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i10; +import 'package:celest_core/src/serialization/json_value.dart' as _i11; +import 'package:shelf/shelf.dart' as _i2; + +final class BoolReturnNullableTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'boolReturnNullable'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.boolReturnNullable(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(response), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i9.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i10.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i9.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i10.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i11.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': BoolReturnNullableTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/return_types/complexClassReturn.dart b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/complexClassReturn.dart new file mode 100644 index 000000000..531468951 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/complexClassReturn.dart @@ -0,0 +1,1696 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/parameter_types.dart' as _i5; +import 'package:celest_backend/src/functions/return_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class ComplexClassReturnTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'complexClassReturn'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.complexClassReturn(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.ComplexClass>(response), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.ComplexClass, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i5.ComplexClass.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': ComplexClassReturnTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/return_types/complexClassReturnNullable.dart b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/complexClassReturnNullable.dart new file mode 100644 index 000000000..bf43442ba --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/complexClassReturnNullable.dart @@ -0,0 +1,1697 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/parameter_types.dart' as _i5; +import 'package:celest_backend/src/functions/return_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class ComplexClassReturnNullableTarget + extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'complexClassReturnNullable'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.complexClassReturnNullable(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.ComplexClass?>(response), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.ComplexClass, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i5.ComplexClass.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': ComplexClassReturnNullableTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/return_types/complexReturn.dart b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/complexReturn.dart new file mode 100644 index 000000000..23162679a --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/complexReturn.dart @@ -0,0 +1,2139 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; +import 'dart:typed_data' as _i12; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/parameter_types.dart' as _i5; +import 'package:celest_backend/src/functions/return_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i13; +import 'package:shelf/shelf.dart' as _i2; + +final class ComplexReturnTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'complexReturn'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.complexReturn(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.ComplexStruct>(response), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.ComplexStruct, Map>( + serialize: + ($value) => { + r'aBigInt': _i4.Serializers.instance.serialize( + $value.aBigInt, + ), + r'aBool': $value.aBool, + r'aDateTime': _i4.Serializers.instance.serialize( + $value.aDateTime, + ), + r'aDouble': $value.aDouble, + r'aDuration': _i4.Serializers.instance.serialize( + $value.aDuration, + ), + r'aListOfBigInt': + $value.aListOfBigInt + .map( + (el) => _i4.Serializers.instance.serialize(el), + ) + .toList(), + r'aListOfBool': $value.aListOfBool, + r'aListOfDateTime': + $value.aListOfDateTime + .map( + (el) => + _i4.Serializers.instance.serialize(el), + ) + .toList(), + r'aListOfDouble': $value.aListOfDouble, + r'aListOfDuration': + $value.aListOfDuration + .map( + (el) => + _i4.Serializers.instance.serialize(el), + ) + .toList(), + r'aListOfEnum': + $value.aListOfEnum + .map( + (el) => + _i4.Serializers.instance.serialize<_i5.MyEnum>(el), + ) + .toList(), + r'aListOfInt': $value.aListOfInt, + r'aListOfNull': $value.aListOfNull, + r'aListOfRegExp': + $value.aListOfRegExp + .map( + (el) => _i4.Serializers.instance.serialize(el), + ) + .toList(), + r'aListOfSimpleClass': + $value.aListOfSimpleClass + .map( + (el) => _i4.Serializers.instance + .serialize<_i5.SimpleClass>(el), + ) + .toList(), + r'aListOfSimpleStruct': + $value.aListOfSimpleStruct + .map( + (el) => _i4.Serializers.instance + .serialize<_i5.SimpleStruct>(el), + ) + .toList(), + r'aListOfStackTrace': + $value.aListOfStackTrace + .map( + (el) => + _i4.Serializers.instance.serialize(el), + ) + .toList(), + r'aListOfString': $value.aListOfString, + r'aListOfUint8List': + $value.aListOfUint8List + .map( + (el) => _i4.Serializers.instance + .serialize<_i12.Uint8List>(el), + ) + .toList(), + r'aListOfUri': + $value.aListOfUri + .map((el) => _i4.Serializers.instance.serialize(el)) + .toList(), + r'aListOfUriData': + $value.aListOfUriData + .map( + (el) => _i4.Serializers.instance.serialize(el), + ) + .toList(), + r'aMapOfBigInt': $value.aMapOfBigInt.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.serialize(value), + ), + ), + r'aMapOfBool': $value.aMapOfBool, + r'aMapOfDateTime': $value.aMapOfDateTime.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.serialize(value), + ), + ), + r'aMapOfDouble': $value.aMapOfDouble, + r'aMapOfDuration': $value.aMapOfDuration.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.serialize(value), + ), + ), + r'aMapOfEnum': $value.aMapOfEnum.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.serialize<_i5.MyEnum>(value), + ), + ), + r'aMapOfInt': $value.aMapOfInt, + r'aMapOfNull': $value.aMapOfNull, + r'aMapOfRegExp': $value.aMapOfRegExp.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.serialize(value), + ), + ), + r'aMapOfSimpleClass': $value.aMapOfSimpleClass.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.serialize<_i5.SimpleClass>(value), + ), + ), + r'aMapOfSimpleStruct': $value.aMapOfSimpleStruct.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.serialize<_i5.SimpleStruct>(value), + ), + ), + r'aMapOfStackTrace': $value.aMapOfStackTrace.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.serialize(value), + ), + ), + r'aMapOfString': $value.aMapOfString, + r'aMapOfUint8List': $value.aMapOfUint8List.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.serialize<_i12.Uint8List>(value), + ), + ), + r'aMapOfUri': $value.aMapOfUri.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.serialize(value), + ), + ), + r'aMapOfUriData': $value.aMapOfUriData.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.serialize(value), + ), + ), + r'aNull': $value.aNull, + r'aRegExp': _i4.Serializers.instance.serialize( + $value.aRegExp, + ), + r'aSimpleClass': _i4.Serializers.instance + .serialize<_i5.SimpleClass>($value.aSimpleClass), + r'aSimpleStruct': _i4.Serializers.instance + .serialize<_i5.SimpleStruct>($value.aSimpleStruct), + r'aStackTrace': _i4.Serializers.instance.serialize( + $value.aStackTrace, + ), + r'aString': $value.aString, + r'aUint8List': _i4.Serializers.instance.serialize<_i12.Uint8List>( + $value.aUint8List, + ), + r'aUri': _i4.Serializers.instance.serialize($value.aUri), + r'aUriData': _i4.Serializers.instance.serialize( + $value.aUriData, + ), + r'anEnum': _i4.Serializers.instance.serialize<_i5.MyEnum>( + $value.anEnum, + ), + r'anInt': $value.anInt, + r'anIterableOfSimpleClass': + $value.anIterableOfSimpleClass + .map( + (el) => _i4.Serializers.instance + .serialize<_i5.SimpleClass>(el), + ) + .toList(), + }, + deserialize: ($serialized) { + return ( + aBigInt: _i4.Serializers.instance.deserialize( + $serialized[r'aBigInt'], + ), + aBool: ($serialized[r'aBool'] as bool), + aDateTime: _i4.Serializers.instance.deserialize( + $serialized[r'aDateTime'], + ), + aDouble: ($serialized[r'aDouble'] as num).toDouble(), + aDuration: _i4.Serializers.instance.deserialize( + $serialized[r'aDuration'], + ), + aListOfBigInt: + ($serialized[r'aListOfBigInt'] as Iterable) + .map( + (el) => _i4.Serializers.instance.deserialize(el), + ) + .toList(), + aListOfBool: + ($serialized[r'aListOfBool'] as Iterable) + .map((el) => (el as bool)) + .toList(), + aListOfDateTime: + ($serialized[r'aListOfDateTime'] as Iterable) + .map( + (el) => + _i4.Serializers.instance.deserialize(el), + ) + .toList(), + aListOfDouble: + ($serialized[r'aListOfDouble'] as Iterable) + .map((el) => (el as num).toDouble()) + .toList(), + aListOfDuration: + ($serialized[r'aListOfDuration'] as Iterable) + .map( + (el) => + _i4.Serializers.instance.deserialize(el), + ) + .toList(), + aListOfEnum: + ($serialized[r'aListOfEnum'] as Iterable) + .map( + (el) => + _i4.Serializers.instance.deserialize<_i5.MyEnum>(el), + ) + .toList(), + aListOfInt: + ($serialized[r'aListOfInt'] as Iterable) + .map((el) => (el as num).toInt()) + .toList(), + aListOfNull: + ($serialized[r'aListOfNull'] as Iterable) + .map((el) => (el as Null)) + .toList(), + aListOfRegExp: + ($serialized[r'aListOfRegExp'] as Iterable) + .map( + (el) => _i4.Serializers.instance.deserialize(el), + ) + .toList(), + aListOfSimpleClass: + ($serialized[r'aListOfSimpleClass'] as Iterable) + .map( + (el) => _i4.Serializers.instance + .deserialize<_i5.SimpleClass>(el), + ) + .toList(), + aListOfSimpleStruct: + ($serialized[r'aListOfSimpleStruct'] as Iterable) + .map( + (el) => _i4.Serializers.instance + .deserialize<_i5.SimpleStruct>(el), + ) + .toList(), + aListOfStackTrace: + ($serialized[r'aListOfStackTrace'] as Iterable) + .map( + (el) => + _i4.Serializers.instance.deserialize(el), + ) + .toList(), + aListOfString: + ($serialized[r'aListOfString'] as Iterable) + .map((el) => (el as String)) + .toList(), + aListOfUint8List: + ($serialized[r'aListOfUint8List'] as Iterable) + .map( + (el) => _i4.Serializers.instance + .deserialize<_i12.Uint8List>(el), + ) + .toList(), + aListOfUri: + ($serialized[r'aListOfUri'] as Iterable) + .map((el) => _i4.Serializers.instance.deserialize(el)) + .toList(), + aListOfUriData: + ($serialized[r'aListOfUriData'] as Iterable) + .map( + (el) => _i4.Serializers.instance.deserialize(el), + ) + .toList(), + aMapOfBigInt: ($serialized[r'aMapOfBigInt'] as Map) + .map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize(value), + ), + ), + aMapOfBool: ($serialized[r'aMapOfBool'] as Map) + .map((key, value) => MapEntry(key, (value as bool))), + aMapOfDateTime: + ($serialized[r'aMapOfDateTime'] as Map).map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize(value), + ), + ), + aMapOfDouble: ($serialized[r'aMapOfDouble'] as Map) + .map((key, value) => MapEntry(key, (value as num).toDouble())), + aMapOfDuration: + ($serialized[r'aMapOfDuration'] as Map).map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize(value), + ), + ), + aMapOfEnum: ($serialized[r'aMapOfEnum'] as Map) + .map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize<_i5.MyEnum>(value), + ), + ), + aMapOfInt: ($serialized[r'aMapOfInt'] as Map).map( + (key, value) => MapEntry(key, (value as num).toInt()), + ), + aMapOfNull: ($serialized[r'aMapOfNull'] as Map) + .map((key, value) => MapEntry(key, (value as Null))), + aMapOfRegExp: ($serialized[r'aMapOfRegExp'] as Map) + .map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize(value), + ), + ), + aMapOfSimpleClass: + ($serialized[r'aMapOfSimpleClass'] as Map).map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize<_i5.SimpleClass>( + value, + ), + ), + ), + aMapOfSimpleStruct: ($serialized[r'aMapOfSimpleStruct'] + as Map) + .map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize<_i5.SimpleStruct>( + value, + ), + ), + ), + aMapOfStackTrace: + ($serialized[r'aMapOfStackTrace'] as Map).map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize(value), + ), + ), + aMapOfString: ($serialized[r'aMapOfString'] as Map) + .map((key, value) => MapEntry(key, (value as String))), + aMapOfUint8List: + ($serialized[r'aMapOfUint8List'] as Map).map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize<_i12.Uint8List>(value), + ), + ), + aMapOfUri: ($serialized[r'aMapOfUri'] as Map).map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize(value), + ), + ), + aMapOfUriData: + ($serialized[r'aMapOfUriData'] as Map).map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize(value), + ), + ), + aNull: ($serialized[r'aNull'] as Null), + aRegExp: _i4.Serializers.instance.deserialize( + $serialized[r'aRegExp'], + ), + aSimpleClass: _i4.Serializers.instance.deserialize<_i5.SimpleClass>( + $serialized[r'aSimpleClass'], + ), + aSimpleStruct: _i4.Serializers.instance + .deserialize<_i5.SimpleStruct>($serialized[r'aSimpleStruct']), + aStackTrace: _i4.Serializers.instance.deserialize( + $serialized[r'aStackTrace'], + ), + aString: ($serialized[r'aString'] as String), + aUint8List: _i4.Serializers.instance.deserialize<_i12.Uint8List>( + $serialized[r'aUint8List'], + ), + aUri: _i4.Serializers.instance.deserialize( + $serialized[r'aUri'], + ), + aUriData: _i4.Serializers.instance.deserialize( + $serialized[r'aUriData'], + ), + anEnum: _i4.Serializers.instance.deserialize<_i5.MyEnum>( + $serialized[r'anEnum'], + ), + anInt: ($serialized[r'anInt'] as num).toInt(), + anIterableOfSimpleClass: + ($serialized[r'anIterableOfSimpleClass'] as Iterable) + .map( + (el) => _i4.Serializers.instance + .deserialize<_i5.SimpleClass>(el), + ) + .toList(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.MyEnum, String>( + serialize: ($value) => $value.name, + deserialize: ($serialized) { + return _i5.MyEnum.values.byName($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.SimpleClass, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i5.SimpleClass.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.SimpleStruct, Map?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return (); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i13.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': ComplexReturnTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/return_types/complexReturnNullable.dart b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/complexReturnNullable.dart new file mode 100644 index 000000000..fee10f794 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/complexReturnNullable.dart @@ -0,0 +1,2139 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; +import 'dart:typed_data' as _i12; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/parameter_types.dart' as _i5; +import 'package:celest_backend/src/functions/return_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i13; +import 'package:shelf/shelf.dart' as _i2; + +final class ComplexReturnNullableTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'complexReturnNullable'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.complexReturnNullable(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.ComplexStruct?>(response), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.ComplexStruct, Map>( + serialize: + ($value) => { + r'aBigInt': _i4.Serializers.instance.serialize( + $value.aBigInt, + ), + r'aBool': $value.aBool, + r'aDateTime': _i4.Serializers.instance.serialize( + $value.aDateTime, + ), + r'aDouble': $value.aDouble, + r'aDuration': _i4.Serializers.instance.serialize( + $value.aDuration, + ), + r'aListOfBigInt': + $value.aListOfBigInt + .map( + (el) => _i4.Serializers.instance.serialize(el), + ) + .toList(), + r'aListOfBool': $value.aListOfBool, + r'aListOfDateTime': + $value.aListOfDateTime + .map( + (el) => + _i4.Serializers.instance.serialize(el), + ) + .toList(), + r'aListOfDouble': $value.aListOfDouble, + r'aListOfDuration': + $value.aListOfDuration + .map( + (el) => + _i4.Serializers.instance.serialize(el), + ) + .toList(), + r'aListOfEnum': + $value.aListOfEnum + .map( + (el) => + _i4.Serializers.instance.serialize<_i5.MyEnum>(el), + ) + .toList(), + r'aListOfInt': $value.aListOfInt, + r'aListOfNull': $value.aListOfNull, + r'aListOfRegExp': + $value.aListOfRegExp + .map( + (el) => _i4.Serializers.instance.serialize(el), + ) + .toList(), + r'aListOfSimpleClass': + $value.aListOfSimpleClass + .map( + (el) => _i4.Serializers.instance + .serialize<_i5.SimpleClass>(el), + ) + .toList(), + r'aListOfSimpleStruct': + $value.aListOfSimpleStruct + .map( + (el) => _i4.Serializers.instance + .serialize<_i5.SimpleStruct>(el), + ) + .toList(), + r'aListOfStackTrace': + $value.aListOfStackTrace + .map( + (el) => + _i4.Serializers.instance.serialize(el), + ) + .toList(), + r'aListOfString': $value.aListOfString, + r'aListOfUint8List': + $value.aListOfUint8List + .map( + (el) => _i4.Serializers.instance + .serialize<_i12.Uint8List>(el), + ) + .toList(), + r'aListOfUri': + $value.aListOfUri + .map((el) => _i4.Serializers.instance.serialize(el)) + .toList(), + r'aListOfUriData': + $value.aListOfUriData + .map( + (el) => _i4.Serializers.instance.serialize(el), + ) + .toList(), + r'aMapOfBigInt': $value.aMapOfBigInt.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.serialize(value), + ), + ), + r'aMapOfBool': $value.aMapOfBool, + r'aMapOfDateTime': $value.aMapOfDateTime.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.serialize(value), + ), + ), + r'aMapOfDouble': $value.aMapOfDouble, + r'aMapOfDuration': $value.aMapOfDuration.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.serialize(value), + ), + ), + r'aMapOfEnum': $value.aMapOfEnum.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.serialize<_i5.MyEnum>(value), + ), + ), + r'aMapOfInt': $value.aMapOfInt, + r'aMapOfNull': $value.aMapOfNull, + r'aMapOfRegExp': $value.aMapOfRegExp.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.serialize(value), + ), + ), + r'aMapOfSimpleClass': $value.aMapOfSimpleClass.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.serialize<_i5.SimpleClass>(value), + ), + ), + r'aMapOfSimpleStruct': $value.aMapOfSimpleStruct.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.serialize<_i5.SimpleStruct>(value), + ), + ), + r'aMapOfStackTrace': $value.aMapOfStackTrace.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.serialize(value), + ), + ), + r'aMapOfString': $value.aMapOfString, + r'aMapOfUint8List': $value.aMapOfUint8List.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.serialize<_i12.Uint8List>(value), + ), + ), + r'aMapOfUri': $value.aMapOfUri.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.serialize(value), + ), + ), + r'aMapOfUriData': $value.aMapOfUriData.map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.serialize(value), + ), + ), + r'aNull': $value.aNull, + r'aRegExp': _i4.Serializers.instance.serialize( + $value.aRegExp, + ), + r'aSimpleClass': _i4.Serializers.instance + .serialize<_i5.SimpleClass>($value.aSimpleClass), + r'aSimpleStruct': _i4.Serializers.instance + .serialize<_i5.SimpleStruct>($value.aSimpleStruct), + r'aStackTrace': _i4.Serializers.instance.serialize( + $value.aStackTrace, + ), + r'aString': $value.aString, + r'aUint8List': _i4.Serializers.instance.serialize<_i12.Uint8List>( + $value.aUint8List, + ), + r'aUri': _i4.Serializers.instance.serialize($value.aUri), + r'aUriData': _i4.Serializers.instance.serialize( + $value.aUriData, + ), + r'anEnum': _i4.Serializers.instance.serialize<_i5.MyEnum>( + $value.anEnum, + ), + r'anInt': $value.anInt, + r'anIterableOfSimpleClass': + $value.anIterableOfSimpleClass + .map( + (el) => _i4.Serializers.instance + .serialize<_i5.SimpleClass>(el), + ) + .toList(), + }, + deserialize: ($serialized) { + return ( + aBigInt: _i4.Serializers.instance.deserialize( + $serialized[r'aBigInt'], + ), + aBool: ($serialized[r'aBool'] as bool), + aDateTime: _i4.Serializers.instance.deserialize( + $serialized[r'aDateTime'], + ), + aDouble: ($serialized[r'aDouble'] as num).toDouble(), + aDuration: _i4.Serializers.instance.deserialize( + $serialized[r'aDuration'], + ), + aListOfBigInt: + ($serialized[r'aListOfBigInt'] as Iterable) + .map( + (el) => _i4.Serializers.instance.deserialize(el), + ) + .toList(), + aListOfBool: + ($serialized[r'aListOfBool'] as Iterable) + .map((el) => (el as bool)) + .toList(), + aListOfDateTime: + ($serialized[r'aListOfDateTime'] as Iterable) + .map( + (el) => + _i4.Serializers.instance.deserialize(el), + ) + .toList(), + aListOfDouble: + ($serialized[r'aListOfDouble'] as Iterable) + .map((el) => (el as num).toDouble()) + .toList(), + aListOfDuration: + ($serialized[r'aListOfDuration'] as Iterable) + .map( + (el) => + _i4.Serializers.instance.deserialize(el), + ) + .toList(), + aListOfEnum: + ($serialized[r'aListOfEnum'] as Iterable) + .map( + (el) => + _i4.Serializers.instance.deserialize<_i5.MyEnum>(el), + ) + .toList(), + aListOfInt: + ($serialized[r'aListOfInt'] as Iterable) + .map((el) => (el as num).toInt()) + .toList(), + aListOfNull: + ($serialized[r'aListOfNull'] as Iterable) + .map((el) => (el as Null)) + .toList(), + aListOfRegExp: + ($serialized[r'aListOfRegExp'] as Iterable) + .map( + (el) => _i4.Serializers.instance.deserialize(el), + ) + .toList(), + aListOfSimpleClass: + ($serialized[r'aListOfSimpleClass'] as Iterable) + .map( + (el) => _i4.Serializers.instance + .deserialize<_i5.SimpleClass>(el), + ) + .toList(), + aListOfSimpleStruct: + ($serialized[r'aListOfSimpleStruct'] as Iterable) + .map( + (el) => _i4.Serializers.instance + .deserialize<_i5.SimpleStruct>(el), + ) + .toList(), + aListOfStackTrace: + ($serialized[r'aListOfStackTrace'] as Iterable) + .map( + (el) => + _i4.Serializers.instance.deserialize(el), + ) + .toList(), + aListOfString: + ($serialized[r'aListOfString'] as Iterable) + .map((el) => (el as String)) + .toList(), + aListOfUint8List: + ($serialized[r'aListOfUint8List'] as Iterable) + .map( + (el) => _i4.Serializers.instance + .deserialize<_i12.Uint8List>(el), + ) + .toList(), + aListOfUri: + ($serialized[r'aListOfUri'] as Iterable) + .map((el) => _i4.Serializers.instance.deserialize(el)) + .toList(), + aListOfUriData: + ($serialized[r'aListOfUriData'] as Iterable) + .map( + (el) => _i4.Serializers.instance.deserialize(el), + ) + .toList(), + aMapOfBigInt: ($serialized[r'aMapOfBigInt'] as Map) + .map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize(value), + ), + ), + aMapOfBool: ($serialized[r'aMapOfBool'] as Map) + .map((key, value) => MapEntry(key, (value as bool))), + aMapOfDateTime: + ($serialized[r'aMapOfDateTime'] as Map).map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize(value), + ), + ), + aMapOfDouble: ($serialized[r'aMapOfDouble'] as Map) + .map((key, value) => MapEntry(key, (value as num).toDouble())), + aMapOfDuration: + ($serialized[r'aMapOfDuration'] as Map).map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize(value), + ), + ), + aMapOfEnum: ($serialized[r'aMapOfEnum'] as Map) + .map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize<_i5.MyEnum>(value), + ), + ), + aMapOfInt: ($serialized[r'aMapOfInt'] as Map).map( + (key, value) => MapEntry(key, (value as num).toInt()), + ), + aMapOfNull: ($serialized[r'aMapOfNull'] as Map) + .map((key, value) => MapEntry(key, (value as Null))), + aMapOfRegExp: ($serialized[r'aMapOfRegExp'] as Map) + .map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize(value), + ), + ), + aMapOfSimpleClass: + ($serialized[r'aMapOfSimpleClass'] as Map).map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize<_i5.SimpleClass>( + value, + ), + ), + ), + aMapOfSimpleStruct: ($serialized[r'aMapOfSimpleStruct'] + as Map) + .map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize<_i5.SimpleStruct>( + value, + ), + ), + ), + aMapOfStackTrace: + ($serialized[r'aMapOfStackTrace'] as Map).map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize(value), + ), + ), + aMapOfString: ($serialized[r'aMapOfString'] as Map) + .map((key, value) => MapEntry(key, (value as String))), + aMapOfUint8List: + ($serialized[r'aMapOfUint8List'] as Map).map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize<_i12.Uint8List>(value), + ), + ), + aMapOfUri: ($serialized[r'aMapOfUri'] as Map).map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize(value), + ), + ), + aMapOfUriData: + ($serialized[r'aMapOfUriData'] as Map).map( + (key, value) => MapEntry( + key, + _i4.Serializers.instance.deserialize(value), + ), + ), + aNull: ($serialized[r'aNull'] as Null), + aRegExp: _i4.Serializers.instance.deserialize( + $serialized[r'aRegExp'], + ), + aSimpleClass: _i4.Serializers.instance.deserialize<_i5.SimpleClass>( + $serialized[r'aSimpleClass'], + ), + aSimpleStruct: _i4.Serializers.instance + .deserialize<_i5.SimpleStruct>($serialized[r'aSimpleStruct']), + aStackTrace: _i4.Serializers.instance.deserialize( + $serialized[r'aStackTrace'], + ), + aString: ($serialized[r'aString'] as String), + aUint8List: _i4.Serializers.instance.deserialize<_i12.Uint8List>( + $serialized[r'aUint8List'], + ), + aUri: _i4.Serializers.instance.deserialize( + $serialized[r'aUri'], + ), + aUriData: _i4.Serializers.instance.deserialize( + $serialized[r'aUriData'], + ), + anEnum: _i4.Serializers.instance.deserialize<_i5.MyEnum>( + $serialized[r'anEnum'], + ), + anInt: ($serialized[r'anInt'] as num).toInt(), + anIterableOfSimpleClass: + ($serialized[r'anIterableOfSimpleClass'] as Iterable) + .map( + (el) => _i4.Serializers.instance + .deserialize<_i5.SimpleClass>(el), + ) + .toList(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.MyEnum, String>( + serialize: ($value) => $value.name, + deserialize: ($serialized) { + return _i5.MyEnum.values.byName($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.SimpleClass, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i5.SimpleClass.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.SimpleStruct, Map?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return (); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i13.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': ComplexReturnNullableTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/return_types/doubleReturn.dart b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/doubleReturn.dart new file mode 100644 index 000000000..7cd34412d --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/doubleReturn.dart @@ -0,0 +1,1685 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i9; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/return_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i10; +import 'package:celest_core/src/serialization/json_value.dart' as _i11; +import 'package:shelf/shelf.dart' as _i2; + +final class DoubleReturnTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'doubleReturn'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.doubleReturn(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(response), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i9.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i10.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i9.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i10.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i11.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': DoubleReturnTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/return_types/doubleReturnNullable.dart b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/doubleReturnNullable.dart new file mode 100644 index 000000000..84f9fdf6d --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/doubleReturnNullable.dart @@ -0,0 +1,1685 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i9; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/return_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i10; +import 'package:celest_core/src/serialization/json_value.dart' as _i11; +import 'package:shelf/shelf.dart' as _i2; + +final class DoubleReturnNullableTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'doubleReturnNullable'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.doubleReturnNullable(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(response), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i9.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i10.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i9.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i10.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i11.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': DoubleReturnNullableTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/return_types/intReturn.dart b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/intReturn.dart new file mode 100644 index 000000000..e12a9eeb4 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/intReturn.dart @@ -0,0 +1,1685 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i9; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/return_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i10; +import 'package:celest_core/src/serialization/json_value.dart' as _i11; +import 'package:shelf/shelf.dart' as _i2; + +final class IntReturnTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'intReturn'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.intReturn(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(response), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i9.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i10.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i9.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i10.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i11.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': IntReturnTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/return_types/intReturnNullable.dart b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/intReturnNullable.dart new file mode 100644 index 000000000..a058f75f2 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/intReturnNullable.dart @@ -0,0 +1,1685 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i9; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/return_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i10; +import 'package:celest_core/src/serialization/json_value.dart' as _i11; +import 'package:shelf/shelf.dart' as _i2; + +final class IntReturnNullableTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'intReturnNullable'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.intReturnNullable(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(response), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i9.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i10.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i9.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i10.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i11.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': IntReturnNullableTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/return_types/iterableReturn.dart b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/iterableReturn.dart new file mode 100644 index 000000000..cbda0330d --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/iterableReturn.dart @@ -0,0 +1,1685 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i9; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/return_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i10; +import 'package:celest_core/src/serialization/json_value.dart' as _i11; +import 'package:shelf/shelf.dart' as _i2; + +final class IterableReturnTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'iterableReturn'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.iterableReturn(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(response), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i9.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i10.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i9.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i10.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i11.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': IterableReturnTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/return_types/iterableReturnNullable.dart b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/iterableReturnNullable.dart new file mode 100644 index 000000000..663046300 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/iterableReturnNullable.dart @@ -0,0 +1,1685 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i9; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/return_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i10; +import 'package:celest_core/src/serialization/json_value.dart' as _i11; +import 'package:shelf/shelf.dart' as _i2; + +final class IterableReturnNullableTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'iterableReturnNullable'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.iterableReturnNullable(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(response), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i9.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i10.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i9.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i10.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i11.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': IterableReturnNullableTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/return_types/listReturn.dart b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/listReturn.dart new file mode 100644 index 000000000..9eefa7f81 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/listReturn.dart @@ -0,0 +1,1685 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i9; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/return_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i10; +import 'package:celest_core/src/serialization/json_value.dart' as _i11; +import 'package:shelf/shelf.dart' as _i2; + +final class ListReturnTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'listReturn'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.listReturn(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(response), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i9.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i10.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i9.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i10.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i11.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': ListReturnTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/return_types/listReturnNullable.dart b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/listReturnNullable.dart new file mode 100644 index 000000000..d5a69a8fa --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/listReturnNullable.dart @@ -0,0 +1,1685 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i9; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/return_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i10; +import 'package:celest_core/src/serialization/json_value.dart' as _i11; +import 'package:shelf/shelf.dart' as _i2; + +final class ListReturnNullableTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'listReturnNullable'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.listReturnNullable(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(response), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i9.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i10.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i9.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i10.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i11.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': ListReturnNullableTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/return_types/mapReturn.dart b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/mapReturn.dart new file mode 100644 index 000000000..00977add4 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/mapReturn.dart @@ -0,0 +1,1685 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i9; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/return_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i10; +import 'package:celest_core/src/serialization/json_value.dart' as _i11; +import 'package:shelf/shelf.dart' as _i2; + +final class MapReturnTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'mapReturn'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.mapReturn(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(response), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i9.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i10.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i9.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i10.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i11.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': MapReturnTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/return_types/mapReturnNullable.dart b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/mapReturnNullable.dart new file mode 100644 index 000000000..5c05a27a9 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/mapReturnNullable.dart @@ -0,0 +1,1685 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i9; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/return_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i10; +import 'package:celest_core/src/serialization/json_value.dart' as _i11; +import 'package:shelf/shelf.dart' as _i2; + +final class MapReturnNullableTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'mapReturnNullable'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.mapReturnNullable(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(response), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i9.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i10.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i9.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i10.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i11.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': MapReturnNullableTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/return_types/simpleClassReturn.dart b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/simpleClassReturn.dart new file mode 100644 index 000000000..6ca686fe4 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/simpleClassReturn.dart @@ -0,0 +1,1696 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/parameter_types.dart' as _i5; +import 'package:celest_backend/src/functions/return_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class SimpleClassReturnTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'simpleClassReturn'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.simpleClassReturn(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.SimpleClass>(response), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.SimpleClass, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i5.SimpleClass.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': SimpleClassReturnTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/return_types/simpleClassReturnNullable.dart b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/simpleClassReturnNullable.dart new file mode 100644 index 000000000..3dbfd840e --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/simpleClassReturnNullable.dart @@ -0,0 +1,1697 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/parameter_types.dart' as _i5; +import 'package:celest_backend/src/functions/return_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class SimpleClassReturnNullableTarget + extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'simpleClassReturnNullable'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.simpleClassReturnNullable(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.SimpleClass?>(response), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.SimpleClass, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i5.SimpleClass.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': SimpleClassReturnNullableTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/return_types/stringReturn.dart b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/stringReturn.dart new file mode 100644 index 000000000..6067383d9 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/stringReturn.dart @@ -0,0 +1,1685 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i9; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/return_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i10; +import 'package:celest_core/src/serialization/json_value.dart' as _i11; +import 'package:shelf/shelf.dart' as _i2; + +final class StringReturnTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'stringReturn'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.stringReturn(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(response), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i9.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i10.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i9.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i10.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i11.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': StringReturnTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/return_types/stringReturnNullable.dart b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/stringReturnNullable.dart new file mode 100644 index 000000000..698fa7707 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/stringReturnNullable.dart @@ -0,0 +1,1685 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i9; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/return_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i10; +import 'package:celest_core/src/serialization/json_value.dart' as _i11; +import 'package:shelf/shelf.dart' as _i2; + +final class StringReturnNullableTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'stringReturnNullable'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.stringReturnNullable(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(response), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i9.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i10.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i9.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i10.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i11.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': StringReturnNullableTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/return_types/structReturn.dart b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/structReturn.dart new file mode 100644 index 000000000..c241b61aa --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/structReturn.dart @@ -0,0 +1,1696 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/parameter_types.dart' as _i5; +import 'package:celest_backend/src/functions/return_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class StructReturnTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'structReturn'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.structReturn(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.SimpleStruct>(response), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.SimpleStruct, Map?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return (); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': StructReturnTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/return_types/structReturnNullable.dart b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/structReturnNullable.dart new file mode 100644 index 000000000..06428b5d9 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/structReturnNullable.dart @@ -0,0 +1,1696 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/parameter_types.dart' as _i5; +import 'package:celest_backend/src/functions/return_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class StructReturnNullableTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'structReturnNullable'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.structReturnNullable(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.SimpleStruct?>(response), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.SimpleStruct, Map?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return (); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': StructReturnNullableTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/return_types/voidReturn.dart b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/voidReturn.dart new file mode 100644 index 000000000..83c66a415 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/return_types/voidReturn.dart @@ -0,0 +1,1685 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i9; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/return_types.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i10; +import 'package:celest_core/src/serialization/json_value.dart' as _i11; +import 'package:shelf/shelf.dart' as _i2; + +final class VoidReturnTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'voidReturn'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + _i3.voidReturn(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(null), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i9.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i10.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i9.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i10.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i11.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': VoidReturnTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/sealed_classes/aliasedErrShapeResults.dart b/apps/cli/fixtures/legacy/api/goldens/functions/sealed_classes/aliasedErrShapeResults.dart new file mode 100644 index 000000000..0f8accac7 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/sealed_classes/aliasedErrShapeResults.dart @@ -0,0 +1,2200 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i11; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/exceptions/exceptions.dart' as _i10; +import 'package:celest_backend/models/sealed_classes.dart' as _i5; +import 'package:celest_backend/src/functions/sealed_classes.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i12; +import 'package:celest_core/src/serialization/json_value.dart' as _i13; +import 'package:shelf/shelf.dart' as _i2; + +final class AliasedErrShapeResultsTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'aliasedErrShapeResults'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.aliasedErrShapeResults( + (request[r'shapes'] as Iterable) + .map((el) => _i4.Serializers.instance.deserialize<_i5.Shape>(el)) + .toList(), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + response + .map( + (el) => _i4.Serializers.instance + .serialize<_i5.Result<_i5.Shape, String>>(el), + ) + .toList(), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomErrorToFromJson catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'api.v1.CustomErrorToFromJson', + 'value': _i4.Serializers.instance + .serialize<_i10.CustomErrorToFromJson>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'api.v1.CustomError', + 'value': _i4.Serializers.instance.serialize<_i10.CustomError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomErrorWithStackTrace catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'api.v1.CustomErrorWithStackTrace', + 'value': _i4.Serializers.instance + .serialize<_i10.CustomErrorWithStackTrace>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomExceptionToFromJson catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'api.v1.CustomExceptionToFromJson', + 'value': _i4.Serializers.instance + .serialize<_i10.CustomExceptionToFromJson>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'api.v1.CustomException', + 'value': _i4.Serializers.instance.serialize<_i10.CustomException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i11.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i12.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i12.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i11.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i11.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.CustomError, Map?>( + serialize: + ($value) => { + r'message': $value.message, + r'additionalInfo': _i4.Serializers.instance + .serialize<_i13.JsonMap>( + $value.additionalInfo, + const _i4.TypeToken<_i13.JsonMap>('JsonMap'), + ), + }, + deserialize: ($serialized) { + return _i10.CustomError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.CustomErrorToFromJson, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i10.CustomErrorToFromJson.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.CustomErrorWithStackTrace, + Map? + >( + serialize: + ($value) => { + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + r'message': $value.message, + r'additionalInfo': $value.additionalInfo, + }, + deserialize: ($serialized) { + return _i10.CustomErrorWithStackTrace( + stackTrace: _i4.Serializers.instance.deserialize( + $serialized?[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.CustomException, Map?>( + serialize: + ($value) => { + r'message': $value.message, + r'additionalInfo': _i4.Serializers.instance + .serialize<_i13.JsonMap>( + $value.additionalInfo, + const _i4.TypeToken<_i13.JsonMap>('JsonMap'), + ), + }, + deserialize: ($serialized) { + return _i10.CustomException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.CustomExceptionToFromJson, + Map + >( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i10.CustomExceptionToFromJson.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.Circle, Map>( + serialize: + ($value) => { + r'radius': $value.radius, + r'area': $value.area, + }, + deserialize: ($serialized) { + return _i5.Circle(($serialized[r'radius'] as num).toDouble()); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.ErrResult, Map>( + serialize: ($value) => {r'error': $value.error}, + deserialize: ($serialized) { + return _i5.ErrResult(($serialized[r'error'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.ErrResult<_i5.Shape>, Map>( + serialize: + ($value) => { + r'error': _i4.Serializers.instance.serialize<_i5.Shape>( + $value.error, + ), + }, + deserialize: ($serialized) { + return _i5.ErrResult<_i5.Shape>( + _i4.Serializers.instance.deserialize<_i5.Shape>( + $serialized[r'error'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OkResult<_i5.Shape>, Map>( + serialize: + ($value) => { + r'data': _i4.Serializers.instance.serialize<_i5.Shape>( + $value.data, + ), + }, + deserialize: ($serialized) { + return _i5.OkResult<_i5.Shape>( + _i4.Serializers.instance.deserialize<_i5.Shape>( + $serialized[r'data'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OkResult, Map>( + serialize: ($value) => {r'data': $value.data}, + deserialize: ($serialized) { + return _i5.OkResult(($serialized[r'data'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.Rectangle, Map>( + serialize: + ($value) => { + r'width': $value.width, + r'height': $value.height, + r'area': $value.area, + }, + deserialize: ($serialized) { + return _i5.Rectangle( + ($serialized[r'width'] as num).toDouble(), + ($serialized[r'height'] as num).toDouble(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.Result<_i5.Shape, String>, + Map + >( + serialize: ($value) { + if ($value is _i5.SwappedResult) { + return { + ...(_i4.Serializers.instance + .serialize<_i5.SwappedResult>($value) + as Map), + r'$type': r'SwappedResult', + }; + } + if ($value is _i5.OkResult<_i5.Shape>) { + return { + ...(_i4.Serializers.instance.serialize<_i5.OkResult<_i5.Shape>>( + $value, + ) + as Map), + r'$type': r'OkResult', + }; + } + if ($value is _i5.ErrResult) { + return { + ...(_i4.Serializers.instance.serialize<_i5.ErrResult>( + $value, + ) + as Map), + r'$type': r'ErrResult', + }; + } + throw _i4.SerializationException( + (StringBuffer('Unknown subtype of ') + ..write(r'Result') + ..write(': ') + ..write($value.runtimeType)) + .toString(), + ); + }, + deserialize: ($serialized) { + if ($serialized[r'$type'] == r'SwappedResult') { + return _i4.Serializers.instance + .deserialize<_i5.SwappedResult>($serialized); + } + if ($serialized[r'$type'] == r'OkResult') { + return _i4.Serializers.instance + .deserialize<_i5.OkResult<_i5.Shape>>($serialized); + } + if ($serialized[r'$type'] == r'ErrResult') { + return _i4.Serializers.instance.deserialize<_i5.ErrResult>( + $serialized, + ); + } + throw _i4.SerializationException( + (StringBuffer('Unknown subtype of ') + ..write(r'Result') + ..write(': ') + ..write($serialized[r'$type'])) + .toString(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.Result, + Map + >( + serialize: ($value) { + if ($value is _i5.SwappedResult<_i5.Shape, String>) { + return { + ...(_i4.Serializers.instance + .serialize<_i5.SwappedResult<_i5.Shape, String>>($value) + as Map), + r'$type': r'SwappedResult', + }; + } + if ($value is _i5.OkResult) { + return { + ...(_i4.Serializers.instance.serialize<_i5.OkResult>( + $value, + ) + as Map), + r'$type': r'OkResult', + }; + } + if ($value is _i5.ErrResult<_i5.Shape>) { + return { + ...(_i4.Serializers.instance.serialize<_i5.ErrResult<_i5.Shape>>( + $value, + ) + as Map), + r'$type': r'ErrResult', + }; + } + throw _i4.SerializationException( + (StringBuffer('Unknown subtype of ') + ..write(r'Result') + ..write(': ') + ..write($value.runtimeType)) + .toString(), + ); + }, + deserialize: ($serialized) { + if ($serialized[r'$type'] == r'SwappedResult') { + return _i4.Serializers.instance + .deserialize<_i5.SwappedResult<_i5.Shape, String>>($serialized); + } + if ($serialized[r'$type'] == r'OkResult') { + return _i4.Serializers.instance.deserialize<_i5.OkResult>( + $serialized, + ); + } + if ($serialized[r'$type'] == r'ErrResult') { + return _i4.Serializers.instance + .deserialize<_i5.ErrResult<_i5.Shape>>($serialized); + } + throw _i4.SerializationException( + (StringBuffer('Unknown subtype of ') + ..write(r'Result') + ..write(': ') + ..write($serialized[r'$type'])) + .toString(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.Shape, Map>( + serialize: ($value) { + if ($value is _i5.Circle) { + return { + ...(_i4.Serializers.instance.serialize<_i5.Circle>($value) + as Map), + r'$type': r'Circle', + }; + } + if ($value is _i5.Rectangle) { + return { + ...(_i4.Serializers.instance.serialize<_i5.Rectangle>($value) + as Map), + r'$type': r'Rectangle', + }; + } + throw _i4.SerializationException( + (StringBuffer('Unknown subtype of ') + ..write(r'Shape') + ..write(': ') + ..write($value.runtimeType)) + .toString(), + ); + }, + deserialize: ($serialized) { + if ($serialized[r'$type'] == r'Circle') { + return _i4.Serializers.instance.deserialize<_i5.Circle>( + $serialized, + ); + } + if ($serialized[r'$type'] == r'Rectangle') { + return _i4.Serializers.instance.deserialize<_i5.Rectangle>( + $serialized, + ); + } + throw _i4.SerializationException( + (StringBuffer('Unknown subtype of ') + ..write(r'Shape') + ..write(': ') + ..write($serialized[r'$type'])) + .toString(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.SwappedResult<_i5.Shape, String>, + Map + >( + serialize: + ($value) => { + r'result': _i4.Serializers.instance + .serialize<_i5.Result<_i5.Shape, String>>($value.result), + }, + deserialize: ($serialized) { + return _i5.SwappedResult<_i5.Shape, String>( + _i4.Serializers.instance.deserialize<_i5.Result<_i5.Shape, String>>( + $serialized[r'result'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.SwappedResult, + Map + >( + serialize: + ($value) => { + r'result': _i4.Serializers.instance + .serialize<_i5.Result>($value.result), + }, + deserialize: ($serialized) { + return _i5.SwappedResult( + _i4.Serializers.instance.deserialize<_i5.Result>( + $serialized[r'result'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i12.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.JsonMap, Map>( + serialize: ($value) => $value, + deserialize: ($serialized) { + return _i13.JsonMap(($serialized as Map)); + }, + ), + const _i4.TypeToken<_i13.JsonMap>('JsonMap'), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i13.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': AliasedErrShapeResultsTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/sealed_classes/aliasedOkShapeResults.dart b/apps/cli/fixtures/legacy/api/goldens/functions/sealed_classes/aliasedOkShapeResults.dart new file mode 100644 index 000000000..8ed6b5056 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/sealed_classes/aliasedOkShapeResults.dart @@ -0,0 +1,2200 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i11; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/exceptions/exceptions.dart' as _i10; +import 'package:celest_backend/models/sealed_classes.dart' as _i5; +import 'package:celest_backend/src/functions/sealed_classes.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i12; +import 'package:celest_core/src/serialization/json_value.dart' as _i13; +import 'package:shelf/shelf.dart' as _i2; + +final class AliasedOkShapeResultsTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'aliasedOkShapeResults'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.aliasedOkShapeResults( + (request[r'shapes'] as Iterable) + .map((el) => _i4.Serializers.instance.deserialize<_i5.Shape>(el)) + .toList(), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + response + .map( + (el) => _i4.Serializers.instance + .serialize<_i5.Result<_i5.Shape, String>>(el), + ) + .toList(), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomErrorToFromJson catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'api.v1.CustomErrorToFromJson', + 'value': _i4.Serializers.instance + .serialize<_i10.CustomErrorToFromJson>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'api.v1.CustomError', + 'value': _i4.Serializers.instance.serialize<_i10.CustomError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomErrorWithStackTrace catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'api.v1.CustomErrorWithStackTrace', + 'value': _i4.Serializers.instance + .serialize<_i10.CustomErrorWithStackTrace>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomExceptionToFromJson catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'api.v1.CustomExceptionToFromJson', + 'value': _i4.Serializers.instance + .serialize<_i10.CustomExceptionToFromJson>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'api.v1.CustomException', + 'value': _i4.Serializers.instance.serialize<_i10.CustomException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i11.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i12.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i12.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i11.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i11.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.CustomError, Map?>( + serialize: + ($value) => { + r'message': $value.message, + r'additionalInfo': _i4.Serializers.instance + .serialize<_i13.JsonMap>( + $value.additionalInfo, + const _i4.TypeToken<_i13.JsonMap>('JsonMap'), + ), + }, + deserialize: ($serialized) { + return _i10.CustomError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.CustomErrorToFromJson, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i10.CustomErrorToFromJson.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.CustomErrorWithStackTrace, + Map? + >( + serialize: + ($value) => { + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + r'message': $value.message, + r'additionalInfo': $value.additionalInfo, + }, + deserialize: ($serialized) { + return _i10.CustomErrorWithStackTrace( + stackTrace: _i4.Serializers.instance.deserialize( + $serialized?[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.CustomException, Map?>( + serialize: + ($value) => { + r'message': $value.message, + r'additionalInfo': _i4.Serializers.instance + .serialize<_i13.JsonMap>( + $value.additionalInfo, + const _i4.TypeToken<_i13.JsonMap>('JsonMap'), + ), + }, + deserialize: ($serialized) { + return _i10.CustomException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.CustomExceptionToFromJson, + Map + >( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i10.CustomExceptionToFromJson.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.Circle, Map>( + serialize: + ($value) => { + r'radius': $value.radius, + r'area': $value.area, + }, + deserialize: ($serialized) { + return _i5.Circle(($serialized[r'radius'] as num).toDouble()); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.ErrResult, Map>( + serialize: ($value) => {r'error': $value.error}, + deserialize: ($serialized) { + return _i5.ErrResult(($serialized[r'error'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.ErrResult<_i5.Shape>, Map>( + serialize: + ($value) => { + r'error': _i4.Serializers.instance.serialize<_i5.Shape>( + $value.error, + ), + }, + deserialize: ($serialized) { + return _i5.ErrResult<_i5.Shape>( + _i4.Serializers.instance.deserialize<_i5.Shape>( + $serialized[r'error'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OkResult<_i5.Shape>, Map>( + serialize: + ($value) => { + r'data': _i4.Serializers.instance.serialize<_i5.Shape>( + $value.data, + ), + }, + deserialize: ($serialized) { + return _i5.OkResult<_i5.Shape>( + _i4.Serializers.instance.deserialize<_i5.Shape>( + $serialized[r'data'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OkResult, Map>( + serialize: ($value) => {r'data': $value.data}, + deserialize: ($serialized) { + return _i5.OkResult(($serialized[r'data'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.Rectangle, Map>( + serialize: + ($value) => { + r'width': $value.width, + r'height': $value.height, + r'area': $value.area, + }, + deserialize: ($serialized) { + return _i5.Rectangle( + ($serialized[r'width'] as num).toDouble(), + ($serialized[r'height'] as num).toDouble(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.Result<_i5.Shape, String>, + Map + >( + serialize: ($value) { + if ($value is _i5.SwappedResult) { + return { + ...(_i4.Serializers.instance + .serialize<_i5.SwappedResult>($value) + as Map), + r'$type': r'SwappedResult', + }; + } + if ($value is _i5.OkResult<_i5.Shape>) { + return { + ...(_i4.Serializers.instance.serialize<_i5.OkResult<_i5.Shape>>( + $value, + ) + as Map), + r'$type': r'OkResult', + }; + } + if ($value is _i5.ErrResult) { + return { + ...(_i4.Serializers.instance.serialize<_i5.ErrResult>( + $value, + ) + as Map), + r'$type': r'ErrResult', + }; + } + throw _i4.SerializationException( + (StringBuffer('Unknown subtype of ') + ..write(r'Result') + ..write(': ') + ..write($value.runtimeType)) + .toString(), + ); + }, + deserialize: ($serialized) { + if ($serialized[r'$type'] == r'SwappedResult') { + return _i4.Serializers.instance + .deserialize<_i5.SwappedResult>($serialized); + } + if ($serialized[r'$type'] == r'OkResult') { + return _i4.Serializers.instance + .deserialize<_i5.OkResult<_i5.Shape>>($serialized); + } + if ($serialized[r'$type'] == r'ErrResult') { + return _i4.Serializers.instance.deserialize<_i5.ErrResult>( + $serialized, + ); + } + throw _i4.SerializationException( + (StringBuffer('Unknown subtype of ') + ..write(r'Result') + ..write(': ') + ..write($serialized[r'$type'])) + .toString(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.Result, + Map + >( + serialize: ($value) { + if ($value is _i5.SwappedResult<_i5.Shape, String>) { + return { + ...(_i4.Serializers.instance + .serialize<_i5.SwappedResult<_i5.Shape, String>>($value) + as Map), + r'$type': r'SwappedResult', + }; + } + if ($value is _i5.OkResult) { + return { + ...(_i4.Serializers.instance.serialize<_i5.OkResult>( + $value, + ) + as Map), + r'$type': r'OkResult', + }; + } + if ($value is _i5.ErrResult<_i5.Shape>) { + return { + ...(_i4.Serializers.instance.serialize<_i5.ErrResult<_i5.Shape>>( + $value, + ) + as Map), + r'$type': r'ErrResult', + }; + } + throw _i4.SerializationException( + (StringBuffer('Unknown subtype of ') + ..write(r'Result') + ..write(': ') + ..write($value.runtimeType)) + .toString(), + ); + }, + deserialize: ($serialized) { + if ($serialized[r'$type'] == r'SwappedResult') { + return _i4.Serializers.instance + .deserialize<_i5.SwappedResult<_i5.Shape, String>>($serialized); + } + if ($serialized[r'$type'] == r'OkResult') { + return _i4.Serializers.instance.deserialize<_i5.OkResult>( + $serialized, + ); + } + if ($serialized[r'$type'] == r'ErrResult') { + return _i4.Serializers.instance + .deserialize<_i5.ErrResult<_i5.Shape>>($serialized); + } + throw _i4.SerializationException( + (StringBuffer('Unknown subtype of ') + ..write(r'Result') + ..write(': ') + ..write($serialized[r'$type'])) + .toString(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.Shape, Map>( + serialize: ($value) { + if ($value is _i5.Circle) { + return { + ...(_i4.Serializers.instance.serialize<_i5.Circle>($value) + as Map), + r'$type': r'Circle', + }; + } + if ($value is _i5.Rectangle) { + return { + ...(_i4.Serializers.instance.serialize<_i5.Rectangle>($value) + as Map), + r'$type': r'Rectangle', + }; + } + throw _i4.SerializationException( + (StringBuffer('Unknown subtype of ') + ..write(r'Shape') + ..write(': ') + ..write($value.runtimeType)) + .toString(), + ); + }, + deserialize: ($serialized) { + if ($serialized[r'$type'] == r'Circle') { + return _i4.Serializers.instance.deserialize<_i5.Circle>( + $serialized, + ); + } + if ($serialized[r'$type'] == r'Rectangle') { + return _i4.Serializers.instance.deserialize<_i5.Rectangle>( + $serialized, + ); + } + throw _i4.SerializationException( + (StringBuffer('Unknown subtype of ') + ..write(r'Shape') + ..write(': ') + ..write($serialized[r'$type'])) + .toString(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.SwappedResult<_i5.Shape, String>, + Map + >( + serialize: + ($value) => { + r'result': _i4.Serializers.instance + .serialize<_i5.Result<_i5.Shape, String>>($value.result), + }, + deserialize: ($serialized) { + return _i5.SwappedResult<_i5.Shape, String>( + _i4.Serializers.instance.deserialize<_i5.Result<_i5.Shape, String>>( + $serialized[r'result'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.SwappedResult, + Map + >( + serialize: + ($value) => { + r'result': _i4.Serializers.instance + .serialize<_i5.Result>($value.result), + }, + deserialize: ($serialized) { + return _i5.SwappedResult( + _i4.Serializers.instance.deserialize<_i5.Result>( + $serialized[r'result'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i12.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.JsonMap, Map>( + serialize: ($value) => $value, + deserialize: ($serialized) { + return _i13.JsonMap(($serialized as Map)); + }, + ), + const _i4.TypeToken<_i13.JsonMap>('JsonMap'), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i13.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': AliasedOkShapeResultsTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/sealed_classes/aliasedShapeResults.dart b/apps/cli/fixtures/legacy/api/goldens/functions/sealed_classes/aliasedShapeResults.dart new file mode 100644 index 000000000..a06ab2855 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/sealed_classes/aliasedShapeResults.dart @@ -0,0 +1,2200 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i11; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/exceptions/exceptions.dart' as _i10; +import 'package:celest_backend/models/sealed_classes.dart' as _i5; +import 'package:celest_backend/src/functions/sealed_classes.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i12; +import 'package:celest_core/src/serialization/json_value.dart' as _i13; +import 'package:shelf/shelf.dart' as _i2; + +final class AliasedShapeResultsTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'aliasedShapeResults'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.aliasedShapeResults( + (request[r'shapes'] as Iterable) + .map((el) => _i4.Serializers.instance.deserialize<_i5.Shape>(el)) + .toList(), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + response + .map( + (el) => _i4.Serializers.instance + .serialize<_i5.Result<_i5.Shape, String>>(el), + ) + .toList(), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomErrorToFromJson catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'api.v1.CustomErrorToFromJson', + 'value': _i4.Serializers.instance + .serialize<_i10.CustomErrorToFromJson>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'api.v1.CustomError', + 'value': _i4.Serializers.instance.serialize<_i10.CustomError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomErrorWithStackTrace catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'api.v1.CustomErrorWithStackTrace', + 'value': _i4.Serializers.instance + .serialize<_i10.CustomErrorWithStackTrace>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomExceptionToFromJson catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'api.v1.CustomExceptionToFromJson', + 'value': _i4.Serializers.instance + .serialize<_i10.CustomExceptionToFromJson>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'api.v1.CustomException', + 'value': _i4.Serializers.instance.serialize<_i10.CustomException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i11.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i12.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i12.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i11.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i11.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.CustomError, Map?>( + serialize: + ($value) => { + r'message': $value.message, + r'additionalInfo': _i4.Serializers.instance + .serialize<_i13.JsonMap>( + $value.additionalInfo, + const _i4.TypeToken<_i13.JsonMap>('JsonMap'), + ), + }, + deserialize: ($serialized) { + return _i10.CustomError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.CustomErrorToFromJson, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i10.CustomErrorToFromJson.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.CustomErrorWithStackTrace, + Map? + >( + serialize: + ($value) => { + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + r'message': $value.message, + r'additionalInfo': $value.additionalInfo, + }, + deserialize: ($serialized) { + return _i10.CustomErrorWithStackTrace( + stackTrace: _i4.Serializers.instance.deserialize( + $serialized?[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.CustomException, Map?>( + serialize: + ($value) => { + r'message': $value.message, + r'additionalInfo': _i4.Serializers.instance + .serialize<_i13.JsonMap>( + $value.additionalInfo, + const _i4.TypeToken<_i13.JsonMap>('JsonMap'), + ), + }, + deserialize: ($serialized) { + return _i10.CustomException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.CustomExceptionToFromJson, + Map + >( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i10.CustomExceptionToFromJson.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.Circle, Map>( + serialize: + ($value) => { + r'radius': $value.radius, + r'area': $value.area, + }, + deserialize: ($serialized) { + return _i5.Circle(($serialized[r'radius'] as num).toDouble()); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.ErrResult, Map>( + serialize: ($value) => {r'error': $value.error}, + deserialize: ($serialized) { + return _i5.ErrResult(($serialized[r'error'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.ErrResult<_i5.Shape>, Map>( + serialize: + ($value) => { + r'error': _i4.Serializers.instance.serialize<_i5.Shape>( + $value.error, + ), + }, + deserialize: ($serialized) { + return _i5.ErrResult<_i5.Shape>( + _i4.Serializers.instance.deserialize<_i5.Shape>( + $serialized[r'error'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OkResult<_i5.Shape>, Map>( + serialize: + ($value) => { + r'data': _i4.Serializers.instance.serialize<_i5.Shape>( + $value.data, + ), + }, + deserialize: ($serialized) { + return _i5.OkResult<_i5.Shape>( + _i4.Serializers.instance.deserialize<_i5.Shape>( + $serialized[r'data'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OkResult, Map>( + serialize: ($value) => {r'data': $value.data}, + deserialize: ($serialized) { + return _i5.OkResult(($serialized[r'data'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.Rectangle, Map>( + serialize: + ($value) => { + r'width': $value.width, + r'height': $value.height, + r'area': $value.area, + }, + deserialize: ($serialized) { + return _i5.Rectangle( + ($serialized[r'width'] as num).toDouble(), + ($serialized[r'height'] as num).toDouble(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.Result<_i5.Shape, String>, + Map + >( + serialize: ($value) { + if ($value is _i5.SwappedResult) { + return { + ...(_i4.Serializers.instance + .serialize<_i5.SwappedResult>($value) + as Map), + r'$type': r'SwappedResult', + }; + } + if ($value is _i5.OkResult<_i5.Shape>) { + return { + ...(_i4.Serializers.instance.serialize<_i5.OkResult<_i5.Shape>>( + $value, + ) + as Map), + r'$type': r'OkResult', + }; + } + if ($value is _i5.ErrResult) { + return { + ...(_i4.Serializers.instance.serialize<_i5.ErrResult>( + $value, + ) + as Map), + r'$type': r'ErrResult', + }; + } + throw _i4.SerializationException( + (StringBuffer('Unknown subtype of ') + ..write(r'Result') + ..write(': ') + ..write($value.runtimeType)) + .toString(), + ); + }, + deserialize: ($serialized) { + if ($serialized[r'$type'] == r'SwappedResult') { + return _i4.Serializers.instance + .deserialize<_i5.SwappedResult>($serialized); + } + if ($serialized[r'$type'] == r'OkResult') { + return _i4.Serializers.instance + .deserialize<_i5.OkResult<_i5.Shape>>($serialized); + } + if ($serialized[r'$type'] == r'ErrResult') { + return _i4.Serializers.instance.deserialize<_i5.ErrResult>( + $serialized, + ); + } + throw _i4.SerializationException( + (StringBuffer('Unknown subtype of ') + ..write(r'Result') + ..write(': ') + ..write($serialized[r'$type'])) + .toString(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.Result, + Map + >( + serialize: ($value) { + if ($value is _i5.SwappedResult<_i5.Shape, String>) { + return { + ...(_i4.Serializers.instance + .serialize<_i5.SwappedResult<_i5.Shape, String>>($value) + as Map), + r'$type': r'SwappedResult', + }; + } + if ($value is _i5.OkResult) { + return { + ...(_i4.Serializers.instance.serialize<_i5.OkResult>( + $value, + ) + as Map), + r'$type': r'OkResult', + }; + } + if ($value is _i5.ErrResult<_i5.Shape>) { + return { + ...(_i4.Serializers.instance.serialize<_i5.ErrResult<_i5.Shape>>( + $value, + ) + as Map), + r'$type': r'ErrResult', + }; + } + throw _i4.SerializationException( + (StringBuffer('Unknown subtype of ') + ..write(r'Result') + ..write(': ') + ..write($value.runtimeType)) + .toString(), + ); + }, + deserialize: ($serialized) { + if ($serialized[r'$type'] == r'SwappedResult') { + return _i4.Serializers.instance + .deserialize<_i5.SwappedResult<_i5.Shape, String>>($serialized); + } + if ($serialized[r'$type'] == r'OkResult') { + return _i4.Serializers.instance.deserialize<_i5.OkResult>( + $serialized, + ); + } + if ($serialized[r'$type'] == r'ErrResult') { + return _i4.Serializers.instance + .deserialize<_i5.ErrResult<_i5.Shape>>($serialized); + } + throw _i4.SerializationException( + (StringBuffer('Unknown subtype of ') + ..write(r'Result') + ..write(': ') + ..write($serialized[r'$type'])) + .toString(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.Shape, Map>( + serialize: ($value) { + if ($value is _i5.Circle) { + return { + ...(_i4.Serializers.instance.serialize<_i5.Circle>($value) + as Map), + r'$type': r'Circle', + }; + } + if ($value is _i5.Rectangle) { + return { + ...(_i4.Serializers.instance.serialize<_i5.Rectangle>($value) + as Map), + r'$type': r'Rectangle', + }; + } + throw _i4.SerializationException( + (StringBuffer('Unknown subtype of ') + ..write(r'Shape') + ..write(': ') + ..write($value.runtimeType)) + .toString(), + ); + }, + deserialize: ($serialized) { + if ($serialized[r'$type'] == r'Circle') { + return _i4.Serializers.instance.deserialize<_i5.Circle>( + $serialized, + ); + } + if ($serialized[r'$type'] == r'Rectangle') { + return _i4.Serializers.instance.deserialize<_i5.Rectangle>( + $serialized, + ); + } + throw _i4.SerializationException( + (StringBuffer('Unknown subtype of ') + ..write(r'Shape') + ..write(': ') + ..write($serialized[r'$type'])) + .toString(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.SwappedResult<_i5.Shape, String>, + Map + >( + serialize: + ($value) => { + r'result': _i4.Serializers.instance + .serialize<_i5.Result<_i5.Shape, String>>($value.result), + }, + deserialize: ($serialized) { + return _i5.SwappedResult<_i5.Shape, String>( + _i4.Serializers.instance.deserialize<_i5.Result<_i5.Shape, String>>( + $serialized[r'result'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.SwappedResult, + Map + >( + serialize: + ($value) => { + r'result': _i4.Serializers.instance + .serialize<_i5.Result>($value.result), + }, + deserialize: ($serialized) { + return _i5.SwappedResult( + _i4.Serializers.instance.deserialize<_i5.Result>( + $serialized[r'result'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i12.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.JsonMap, Map>( + serialize: ($value) => $value, + deserialize: ($serialized) { + return _i13.JsonMap(($serialized as Map)); + }, + ), + const _i4.TypeToken<_i13.JsonMap>('JsonMap'), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i13.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': AliasedShapeResultsTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/sealed_classes/area.dart b/apps/cli/fixtures/legacy/api/goldens/functions/sealed_classes/area.dart new file mode 100644 index 000000000..b60bc2292 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/sealed_classes/area.dart @@ -0,0 +1,1975 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i11; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/exceptions/exceptions.dart' as _i10; +import 'package:celest_backend/models/sealed_classes.dart' as _i5; +import 'package:celest_backend/src/functions/sealed_classes.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i12; +import 'package:celest_core/src/serialization/json_value.dart' as _i13; +import 'package:shelf/shelf.dart' as _i2; + +final class AreaTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'area'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.area( + _i4.Serializers.instance.deserialize<_i5.Shape>(request[r'shape']), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(response), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomErrorToFromJson catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'api.v1.CustomErrorToFromJson', + 'value': _i4.Serializers.instance + .serialize<_i10.CustomErrorToFromJson>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'api.v1.CustomError', + 'value': _i4.Serializers.instance.serialize<_i10.CustomError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomErrorWithStackTrace catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'api.v1.CustomErrorWithStackTrace', + 'value': _i4.Serializers.instance + .serialize<_i10.CustomErrorWithStackTrace>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomExceptionToFromJson catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'api.v1.CustomExceptionToFromJson', + 'value': _i4.Serializers.instance + .serialize<_i10.CustomExceptionToFromJson>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'api.v1.CustomException', + 'value': _i4.Serializers.instance.serialize<_i10.CustomException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i11.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i12.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i12.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i11.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i11.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.CustomError, Map?>( + serialize: + ($value) => { + r'message': $value.message, + r'additionalInfo': _i4.Serializers.instance + .serialize<_i13.JsonMap>( + $value.additionalInfo, + const _i4.TypeToken<_i13.JsonMap>('JsonMap'), + ), + }, + deserialize: ($serialized) { + return _i10.CustomError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.CustomErrorToFromJson, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i10.CustomErrorToFromJson.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.CustomErrorWithStackTrace, + Map? + >( + serialize: + ($value) => { + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + r'message': $value.message, + r'additionalInfo': $value.additionalInfo, + }, + deserialize: ($serialized) { + return _i10.CustomErrorWithStackTrace( + stackTrace: _i4.Serializers.instance.deserialize( + $serialized?[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.CustomException, Map?>( + serialize: + ($value) => { + r'message': $value.message, + r'additionalInfo': _i4.Serializers.instance + .serialize<_i13.JsonMap>( + $value.additionalInfo, + const _i4.TypeToken<_i13.JsonMap>('JsonMap'), + ), + }, + deserialize: ($serialized) { + return _i10.CustomException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.CustomExceptionToFromJson, + Map + >( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i10.CustomExceptionToFromJson.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.Circle, Map>( + serialize: + ($value) => { + r'radius': $value.radius, + r'area': $value.area, + }, + deserialize: ($serialized) { + return _i5.Circle(($serialized[r'radius'] as num).toDouble()); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.Rectangle, Map>( + serialize: + ($value) => { + r'width': $value.width, + r'height': $value.height, + r'area': $value.area, + }, + deserialize: ($serialized) { + return _i5.Rectangle( + ($serialized[r'width'] as num).toDouble(), + ($serialized[r'height'] as num).toDouble(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.Shape, Map>( + serialize: ($value) { + if ($value is _i5.Circle) { + return { + ...(_i4.Serializers.instance.serialize<_i5.Circle>($value) + as Map), + r'$type': r'Circle', + }; + } + if ($value is _i5.Rectangle) { + return { + ...(_i4.Serializers.instance.serialize<_i5.Rectangle>($value) + as Map), + r'$type': r'Rectangle', + }; + } + throw _i4.SerializationException( + (StringBuffer('Unknown subtype of ') + ..write(r'Shape') + ..write(': ') + ..write($value.runtimeType)) + .toString(), + ); + }, + deserialize: ($serialized) { + if ($serialized[r'$type'] == r'Circle') { + return _i4.Serializers.instance.deserialize<_i5.Circle>( + $serialized, + ); + } + if ($serialized[r'$type'] == r'Rectangle') { + return _i4.Serializers.instance.deserialize<_i5.Rectangle>( + $serialized, + ); + } + throw _i4.SerializationException( + (StringBuffer('Unknown subtype of ') + ..write(r'Shape') + ..write(': ') + ..write($serialized[r'$type'])) + .toString(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i12.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.JsonMap, Map>( + serialize: ($value) => $value, + deserialize: ($serialized) { + return _i13.JsonMap(($serialized as Map)); + }, + ), + const _i4.TypeToken<_i13.JsonMap>('JsonMap'), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i13.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': AreaTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/sealed_classes/circle.dart b/apps/cli/fixtures/legacy/api/goldens/functions/sealed_classes/circle.dart new file mode 100644 index 000000000..aa1a1a499 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/sealed_classes/circle.dart @@ -0,0 +1,1915 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i11; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/exceptions/exceptions.dart' as _i10; +import 'package:celest_backend/models/sealed_classes.dart' as _i5; +import 'package:celest_backend/src/functions/sealed_classes.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i12; +import 'package:celest_core/src/serialization/json_value.dart' as _i13; +import 'package:shelf/shelf.dart' as _i2; + +final class CircleTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'circle'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.circle( + _i4.Serializers.instance.deserialize<_i5.Circle>(request[r'circle']), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.Circle>(response), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomErrorToFromJson catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'api.v1.CustomErrorToFromJson', + 'value': _i4.Serializers.instance + .serialize<_i10.CustomErrorToFromJson>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'api.v1.CustomError', + 'value': _i4.Serializers.instance.serialize<_i10.CustomError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomErrorWithStackTrace catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'api.v1.CustomErrorWithStackTrace', + 'value': _i4.Serializers.instance + .serialize<_i10.CustomErrorWithStackTrace>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomExceptionToFromJson catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'api.v1.CustomExceptionToFromJson', + 'value': _i4.Serializers.instance + .serialize<_i10.CustomExceptionToFromJson>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'api.v1.CustomException', + 'value': _i4.Serializers.instance.serialize<_i10.CustomException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i11.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i12.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i12.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i11.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i11.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.CustomError, Map?>( + serialize: + ($value) => { + r'message': $value.message, + r'additionalInfo': _i4.Serializers.instance + .serialize<_i13.JsonMap>( + $value.additionalInfo, + const _i4.TypeToken<_i13.JsonMap>('JsonMap'), + ), + }, + deserialize: ($serialized) { + return _i10.CustomError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.CustomErrorToFromJson, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i10.CustomErrorToFromJson.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.CustomErrorWithStackTrace, + Map? + >( + serialize: + ($value) => { + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + r'message': $value.message, + r'additionalInfo': $value.additionalInfo, + }, + deserialize: ($serialized) { + return _i10.CustomErrorWithStackTrace( + stackTrace: _i4.Serializers.instance.deserialize( + $serialized?[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.CustomException, Map?>( + serialize: + ($value) => { + r'message': $value.message, + r'additionalInfo': _i4.Serializers.instance + .serialize<_i13.JsonMap>( + $value.additionalInfo, + const _i4.TypeToken<_i13.JsonMap>('JsonMap'), + ), + }, + deserialize: ($serialized) { + return _i10.CustomException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.CustomExceptionToFromJson, + Map + >( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i10.CustomExceptionToFromJson.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.Circle, Map>( + serialize: + ($value) => { + r'radius': $value.radius, + r'area': $value.area, + }, + deserialize: ($serialized) { + return _i5.Circle(($serialized[r'radius'] as num).toDouble()); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i12.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.JsonMap, Map>( + serialize: ($value) => $value, + deserialize: ($serialized) { + return _i13.JsonMap(($serialized as Map)); + }, + ), + const _i4.TypeToken<_i13.JsonMap>('JsonMap'), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i13.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': CircleTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/sealed_classes/circleWithOverriddenCustomJson.dart b/apps/cli/fixtures/legacy/api/goldens/functions/sealed_classes/circleWithOverriddenCustomJson.dart new file mode 100644 index 000000000..f9e0f2039 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/sealed_classes/circleWithOverriddenCustomJson.dart @@ -0,0 +1,1953 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i11; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/exceptions/exceptions.dart' as _i10; +import 'package:celest_backend/models/sealed_classes.dart' as _i5; +import 'package:celest_backend/src/functions/sealed_classes.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i12; +import 'package:celest_core/src/serialization/json_value.dart' as _i13; +import 'package:shelf/shelf.dart' as _i2; + +final class CircleWithOverriddenCustomJsonTarget + extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'circleWithOverriddenCustomJson'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.circleWithOverriddenCustomJson( + _i4.Serializers.instance.deserialize<_i5.ShapeWithOverriddenCustomJson>( + request[r'circle'], + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance + .serialize<_i5.CircleWithOverriddenCustomJson>(response), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomErrorToFromJson catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'api.v1.CustomErrorToFromJson', + 'value': _i4.Serializers.instance + .serialize<_i10.CustomErrorToFromJson>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'api.v1.CustomError', + 'value': _i4.Serializers.instance.serialize<_i10.CustomError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomErrorWithStackTrace catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'api.v1.CustomErrorWithStackTrace', + 'value': _i4.Serializers.instance + .serialize<_i10.CustomErrorWithStackTrace>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomExceptionToFromJson catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'api.v1.CustomExceptionToFromJson', + 'value': _i4.Serializers.instance + .serialize<_i10.CustomExceptionToFromJson>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'api.v1.CustomException', + 'value': _i4.Serializers.instance.serialize<_i10.CustomException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i11.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i12.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i12.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i11.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i11.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.CustomError, Map?>( + serialize: + ($value) => { + r'message': $value.message, + r'additionalInfo': _i4.Serializers.instance + .serialize<_i13.JsonMap>( + $value.additionalInfo, + const _i4.TypeToken<_i13.JsonMap>('JsonMap'), + ), + }, + deserialize: ($serialized) { + return _i10.CustomError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.CustomErrorToFromJson, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i10.CustomErrorToFromJson.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.CustomErrorWithStackTrace, + Map? + >( + serialize: + ($value) => { + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + r'message': $value.message, + r'additionalInfo': $value.additionalInfo, + }, + deserialize: ($serialized) { + return _i10.CustomErrorWithStackTrace( + stackTrace: _i4.Serializers.instance.deserialize( + $serialized?[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.CustomException, Map?>( + serialize: + ($value) => { + r'message': $value.message, + r'additionalInfo': _i4.Serializers.instance + .serialize<_i13.JsonMap>( + $value.additionalInfo, + const _i4.TypeToken<_i13.JsonMap>('JsonMap'), + ), + }, + deserialize: ($serialized) { + return _i10.CustomException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.CustomExceptionToFromJson, + Map + >( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i10.CustomExceptionToFromJson.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.CircleWithOverriddenCustomJson, + Map + >( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i5.CircleWithOverriddenCustomJson.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.RectangleWithOverriddenCustomJson, + Map + >( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return (_i5.ShapeWithOverriddenCustomJson.fromJson({ + r'$type': r'RectangleWithOverriddenCustomJson', + ...$serialized, + }) + as _i5.RectangleWithOverriddenCustomJson); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ShapeWithOverriddenCustomJson, + Map + >( + serialize: + ($value) => { + ...$value.toJson(), + r'$type': switch ($value) { + _i5.CircleWithOverriddenCustomJson() => + r'CircleWithOverriddenCustomJson', + _i5.RectangleWithOverriddenCustomJson() => + r'RectangleWithOverriddenCustomJson', + }, + }, + deserialize: ($serialized) { + return _i5.ShapeWithOverriddenCustomJson.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i12.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.JsonMap, Map>( + serialize: ($value) => $value, + deserialize: ($serialized) { + return _i13.JsonMap(($serialized as Map)); + }, + ), + const _i4.TypeToken<_i13.JsonMap>('JsonMap'), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i13.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': CircleWithOverriddenCustomJsonTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/sealed_classes/errShapeResults.dart b/apps/cli/fixtures/legacy/api/goldens/functions/sealed_classes/errShapeResults.dart new file mode 100644 index 000000000..5eea7e702 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/sealed_classes/errShapeResults.dart @@ -0,0 +1,1992 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i11; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/exceptions/exceptions.dart' as _i10; +import 'package:celest_backend/models/sealed_classes.dart' as _i5; +import 'package:celest_backend/src/functions/sealed_classes.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i12; +import 'package:celest_core/src/serialization/json_value.dart' as _i13; +import 'package:shelf/shelf.dart' as _i2; + +final class ErrShapeResultsTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'errShapeResults'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.errShapeResults( + (request[r'shapes'] as Iterable) + .map((el) => _i4.Serializers.instance.deserialize<_i5.Shape>(el)) + .toList(), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + response + .map( + (el) => _i4.Serializers.instance + .serialize<_i5.ErrResult>(el), + ) + .toList(), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomErrorToFromJson catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'api.v1.CustomErrorToFromJson', + 'value': _i4.Serializers.instance + .serialize<_i10.CustomErrorToFromJson>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'api.v1.CustomError', + 'value': _i4.Serializers.instance.serialize<_i10.CustomError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomErrorWithStackTrace catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'api.v1.CustomErrorWithStackTrace', + 'value': _i4.Serializers.instance + .serialize<_i10.CustomErrorWithStackTrace>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomExceptionToFromJson catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'api.v1.CustomExceptionToFromJson', + 'value': _i4.Serializers.instance + .serialize<_i10.CustomExceptionToFromJson>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'api.v1.CustomException', + 'value': _i4.Serializers.instance.serialize<_i10.CustomException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i11.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i12.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i12.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i11.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i11.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.CustomError, Map?>( + serialize: + ($value) => { + r'message': $value.message, + r'additionalInfo': _i4.Serializers.instance + .serialize<_i13.JsonMap>( + $value.additionalInfo, + const _i4.TypeToken<_i13.JsonMap>('JsonMap'), + ), + }, + deserialize: ($serialized) { + return _i10.CustomError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.CustomErrorToFromJson, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i10.CustomErrorToFromJson.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.CustomErrorWithStackTrace, + Map? + >( + serialize: + ($value) => { + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + r'message': $value.message, + r'additionalInfo': $value.additionalInfo, + }, + deserialize: ($serialized) { + return _i10.CustomErrorWithStackTrace( + stackTrace: _i4.Serializers.instance.deserialize( + $serialized?[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.CustomException, Map?>( + serialize: + ($value) => { + r'message': $value.message, + r'additionalInfo': _i4.Serializers.instance + .serialize<_i13.JsonMap>( + $value.additionalInfo, + const _i4.TypeToken<_i13.JsonMap>('JsonMap'), + ), + }, + deserialize: ($serialized) { + return _i10.CustomException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.CustomExceptionToFromJson, + Map + >( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i10.CustomExceptionToFromJson.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.Circle, Map>( + serialize: + ($value) => { + r'radius': $value.radius, + r'area': $value.area, + }, + deserialize: ($serialized) { + return _i5.Circle(($serialized[r'radius'] as num).toDouble()); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.ErrResult, Map>( + serialize: ($value) => {r'error': $value.error}, + deserialize: ($serialized) { + return _i5.ErrResult(($serialized[r'error'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.Rectangle, Map>( + serialize: + ($value) => { + r'width': $value.width, + r'height': $value.height, + r'area': $value.area, + }, + deserialize: ($serialized) { + return _i5.Rectangle( + ($serialized[r'width'] as num).toDouble(), + ($serialized[r'height'] as num).toDouble(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.Shape, Map>( + serialize: ($value) { + if ($value is _i5.Circle) { + return { + ...(_i4.Serializers.instance.serialize<_i5.Circle>($value) + as Map), + r'$type': r'Circle', + }; + } + if ($value is _i5.Rectangle) { + return { + ...(_i4.Serializers.instance.serialize<_i5.Rectangle>($value) + as Map), + r'$type': r'Rectangle', + }; + } + throw _i4.SerializationException( + (StringBuffer('Unknown subtype of ') + ..write(r'Shape') + ..write(': ') + ..write($value.runtimeType)) + .toString(), + ); + }, + deserialize: ($serialized) { + if ($serialized[r'$type'] == r'Circle') { + return _i4.Serializers.instance.deserialize<_i5.Circle>( + $serialized, + ); + } + if ($serialized[r'$type'] == r'Rectangle') { + return _i4.Serializers.instance.deserialize<_i5.Rectangle>( + $serialized, + ); + } + throw _i4.SerializationException( + (StringBuffer('Unknown subtype of ') + ..write(r'Shape') + ..write(': ') + ..write($serialized[r'$type'])) + .toString(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i12.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.JsonMap, Map>( + serialize: ($value) => $value, + deserialize: ($serialized) { + return _i13.JsonMap(($serialized as Map)); + }, + ), + const _i4.TypeToken<_i13.JsonMap>('JsonMap'), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i13.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': ErrShapeResultsTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/sealed_classes/genericResult.dart b/apps/cli/fixtures/legacy/api/goldens/functions/sealed_classes/genericResult.dart new file mode 100644 index 000000000..532c3036e --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/sealed_classes/genericResult.dart @@ -0,0 +1,2031 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i11; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/exceptions/exceptions.dart' as _i10; +import 'package:celest_backend/models/sealed_classes.dart' as _i3; +import 'package:celest_backend/src/functions/sealed_classes.dart' as _i5; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i12; +import 'package:celest_core/src/serialization/json_value.dart' as _i13; +import 'package:shelf/shelf.dart' as _i2; + +final class GenericResultTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'genericResult'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) { + final $T = (request[r'$T'] as String?); + final $types = ($T,); + return switch ($types) { + (r'Shape' || null,) => innerHandle<_i3.Shape>( + request, + headers: headers, + queryParameters: queryParameters, + ), + (r'Circle',) => innerHandle<_i3.Circle>( + request, + headers: headers, + queryParameters: queryParameters, + ), + (r'Rectangle',) => innerHandle<_i3.Rectangle>( + request, + headers: headers, + queryParameters: queryParameters, + ), + _ => + throw _i4.SerializationException('Invalid type parameters: ${$types}'), + }; + } + + Future<_i2.Response> innerHandle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i5.genericResult( + _i4.Serializers.instance.deserialize(request[r'data']), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i3.OkResult>(response), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomErrorToFromJson catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'api.v1.CustomErrorToFromJson', + 'value': _i4.Serializers.instance + .serialize<_i10.CustomErrorToFromJson>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'api.v1.CustomError', + 'value': _i4.Serializers.instance.serialize<_i10.CustomError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomErrorWithStackTrace catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'api.v1.CustomErrorWithStackTrace', + 'value': _i4.Serializers.instance + .serialize<_i10.CustomErrorWithStackTrace>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomExceptionToFromJson catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'api.v1.CustomExceptionToFromJson', + 'value': _i4.Serializers.instance + .serialize<_i10.CustomExceptionToFromJson>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'api.v1.CustomException', + 'value': _i4.Serializers.instance.serialize<_i10.CustomException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i11.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i12.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i12.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i11.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i11.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.CustomError, Map?>( + serialize: + ($value) => { + r'message': $value.message, + r'additionalInfo': _i4.Serializers.instance + .serialize<_i13.JsonMap>( + $value.additionalInfo, + const _i4.TypeToken<_i13.JsonMap>('JsonMap'), + ), + }, + deserialize: ($serialized) { + return _i10.CustomError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.CustomErrorToFromJson, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i10.CustomErrorToFromJson.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.CustomErrorWithStackTrace, + Map? + >( + serialize: + ($value) => { + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + r'message': $value.message, + r'additionalInfo': $value.additionalInfo, + }, + deserialize: ($serialized) { + return _i10.CustomErrorWithStackTrace( + stackTrace: _i4.Serializers.instance.deserialize( + $serialized?[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.CustomException, Map?>( + serialize: + ($value) => { + r'message': $value.message, + r'additionalInfo': _i4.Serializers.instance + .serialize<_i13.JsonMap>( + $value.additionalInfo, + const _i4.TypeToken<_i13.JsonMap>('JsonMap'), + ), + }, + deserialize: ($serialized) { + return _i10.CustomException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.CustomExceptionToFromJson, + Map + >( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i10.CustomExceptionToFromJson.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i3.Circle, Map>( + serialize: + ($value) => { + r'radius': $value.radius, + r'area': $value.area, + }, + deserialize: ($serialized) { + return _i3.Circle(($serialized[r'radius'] as num).toDouble()); + }, + ), + ); + _i4.Serializers.instance.put(const OkResult_T_ShapeSerializer()); + _i4.Serializers.instance.put(const OkResult_T_ShapeSerializer<_i3.Shape>()); + _i4.Serializers.instance.put( + const OkResult_T_ShapeSerializer<_i3.Circle>(), + ); + _i4.Serializers.instance.put( + const OkResult_T_ShapeSerializer<_i3.Rectangle>(), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i3.Rectangle, Map>( + serialize: + ($value) => { + r'width': $value.width, + r'height': $value.height, + r'area': $value.area, + }, + deserialize: ($serialized) { + return _i3.Rectangle( + ($serialized[r'width'] as num).toDouble(), + ($serialized[r'height'] as num).toDouble(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i3.Shape, Map>( + serialize: ($value) { + if ($value is _i3.Circle) { + return { + ...(_i4.Serializers.instance.serialize<_i3.Circle>($value) + as Map), + r'$type': r'Circle', + }; + } + if ($value is _i3.Rectangle) { + return { + ...(_i4.Serializers.instance.serialize<_i3.Rectangle>($value) + as Map), + r'$type': r'Rectangle', + }; + } + throw _i4.SerializationException( + (StringBuffer('Unknown subtype of ') + ..write(r'Shape') + ..write(': ') + ..write($value.runtimeType)) + .toString(), + ); + }, + deserialize: ($serialized) { + if ($serialized[r'$type'] == r'Circle') { + return _i4.Serializers.instance.deserialize<_i3.Circle>( + $serialized, + ); + } + if ($serialized[r'$type'] == r'Rectangle') { + return _i4.Serializers.instance.deserialize<_i3.Rectangle>( + $serialized, + ); + } + throw _i4.SerializationException( + (StringBuffer('Unknown subtype of ') + ..write(r'Shape') + ..write(': ') + ..write($serialized[r'$type'])) + .toString(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i12.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.JsonMap, Map>( + serialize: ($value) => $value, + deserialize: ($serialized) { + return _i13.JsonMap(($serialized as Map)); + }, + ), + const _i4.TypeToken<_i13.JsonMap>('JsonMap'), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i13.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': GenericResultTarget()}, + setup: (_i7.Context context) async {}, + ); +} + +final class OkResult_T_ShapeSerializer + extends _i4.Serializer<_i3.OkResult> { + const OkResult_T_ShapeSerializer(); + + @override + _i3.OkResult deserialize(Object? $value) { + final $serialized = assertWireType>($value); + return _i3.OkResult( + _i4.Serializers.instance.deserialize($serialized[r'data']), + ); + } + + @override + Object? serialize(_i3.OkResult $value) => { + r'data': _i4.Serializers.instance.serialize($value.data), + }; +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/sealed_classes/multipleGenericResult.dart b/apps/cli/fixtures/legacy/api/goldens/functions/sealed_classes/multipleGenericResult.dart new file mode 100644 index 000000000..33a23ff9b --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/sealed_classes/multipleGenericResult.dart @@ -0,0 +1,2526 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i10; +import 'dart:convert' as _i11; + +import 'package:celest/celest.dart' as _i9; +import 'package:celest/src/core/context.dart' as _i8; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/exceptions/exceptions.dart' as _i4; +import 'package:celest_backend/models/sealed_classes.dart' as _i3; +import 'package:celest_backend/src/functions/sealed_classes.dart' as _i6; +import 'package:celest_core/celest_core.dart' as _i5; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i7; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i12; +import 'package:celest_core/src/serialization/json_value.dart' as _i13; +import 'package:shelf/shelf.dart' as _i2; + +final class MultipleGenericResultTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'multipleGenericResult'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) { + final $T = (request[r'$T'] as String?); + final $E = (request[r'$E'] as String?); + final $types = ($T, $E); + return switch ($types) { + (r'Shape' || null, r'ShapeException' || null) => + innerHandle<_i3.Shape, _i4.ShapeException>( + request, + headers: headers, + queryParameters: queryParameters, + ), + (r'Shape' || null, r'BadShapeException') => + innerHandle<_i3.Shape, _i4.BadShapeException>( + request, + headers: headers, + queryParameters: queryParameters, + ), + (r'Circle', r'ShapeException' || null) => + innerHandle<_i3.Circle, _i4.ShapeException>( + request, + headers: headers, + queryParameters: queryParameters, + ), + (r'Circle', r'BadShapeException') => + innerHandle<_i3.Circle, _i4.BadShapeException>( + request, + headers: headers, + queryParameters: queryParameters, + ), + (r'Rectangle', r'ShapeException' || null) => + innerHandle<_i3.Rectangle, _i4.ShapeException>( + request, + headers: headers, + queryParameters: queryParameters, + ), + (r'Rectangle', r'BadShapeException') => + innerHandle<_i3.Rectangle, _i4.BadShapeException>( + request, + headers: headers, + queryParameters: queryParameters, + ), + _ => + throw _i5.SerializationException('Invalid type parameters: ${$types}'), + }; + } + + Future<_i2.Response> + innerHandle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i6.multipleGenericResult( + _i5.Serializers.instance.deserialize(request[r'data']), + _i5.Serializers.instance.deserialize(request[r'error']), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i5.JsonUtf8.encode( + response + .map( + (el) => + _i5.Serializers.instance.serialize<_i3.Result>(el), + ) + .toList(), + ), + ); + } on _i7.AbortedException catch (e, st) { + const statusCode = 409; + _i8.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i5.Serializers.instance.serialize<_i7.AbortedException>( + e, + ), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i5.JsonUtf8.encode(status), + ); + } on _i7.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i8.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i5.Serializers.instance + .serialize<_i7.AlreadyExistsException>(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i5.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i8.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i5.Serializers.instance.serialize(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i5.JsonUtf8.encode(status), + ); + } on _i10.AsyncError catch (e, st) { + const statusCode = 500; + _i8.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i5.Serializers.instance.serialize<_i10.AsyncError>(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i5.JsonUtf8.encode(status), + ); + } on _i7.CancelledException catch (e, st) { + const statusCode = 499; + _i8.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i5.Serializers.instance + .serialize<_i7.CancelledException>(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i5.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i8.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i5.Serializers.instance + .serialize(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i5.JsonUtf8.encode(status), + ); + } on _i4.CustomErrorToFromJson catch (e, st) { + const statusCode = 500; + _i8.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'api.v1.CustomErrorToFromJson', + 'value': _i5.Serializers.instance + .serialize<_i4.CustomErrorToFromJson>(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i5.JsonUtf8.encode(status), + ); + } on _i4.CustomError catch (e, st) { + const statusCode = 500; + _i8.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'api.v1.CustomError', + 'value': _i5.Serializers.instance.serialize<_i4.CustomError>(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i5.JsonUtf8.encode(status), + ); + } on _i4.CustomErrorWithStackTrace catch (e, st) { + const statusCode = 500; + _i8.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'api.v1.CustomErrorWithStackTrace', + 'value': _i5.Serializers.instance + .serialize<_i4.CustomErrorWithStackTrace>(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i5.JsonUtf8.encode(status), + ); + } on _i4.CustomExceptionToFromJson catch (e, st) { + const statusCode = 400; + _i8.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'api.v1.CustomExceptionToFromJson', + 'value': _i5.Serializers.instance + .serialize<_i4.CustomExceptionToFromJson>(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i5.JsonUtf8.encode(status), + ); + } on _i4.CustomException catch (e, st) { + const statusCode = 400; + _i8.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'api.v1.CustomException', + 'value': _i5.Serializers.instance.serialize<_i4.CustomException>( + e, + ), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i5.JsonUtf8.encode(status), + ); + } on _i7.DataLossError catch (e, st) { + const statusCode = 500; + _i8.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i5.Serializers.instance.serialize<_i7.DataLossError>(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i5.JsonUtf8.encode(status), + ); + } on _i7.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i8.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i5.Serializers.instance + .serialize<_i7.DeadlineExceededError>(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i5.JsonUtf8.encode(status), + ); + } on _i7.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i8.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i5.Serializers.instance + .serialize<_i7.FailedPreconditionException>(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i5.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i8.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i5.Serializers.instance.serialize(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i5.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i8.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i5.Serializers.instance + .serialize(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i5.JsonUtf8.encode(status), + ); + } on _i7.InternalServerError catch (e, st) { + const statusCode = 500; + _i8.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i5.Serializers.instance + .serialize<_i7.InternalServerError>(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i5.JsonUtf8.encode(status), + ); + } on _i11.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i8.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i5.Serializers.instance + .serialize<_i11.JsonUnsupportedObjectError>(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i5.JsonUtf8.encode(status), + ); + } on _i7.NotFoundException catch (e, st) { + const statusCode = 404; + _i8.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i5.Serializers.instance + .serialize<_i7.NotFoundException>(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i5.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i8.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i5.Serializers.instance.serialize(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i5.JsonUtf8.encode(status), + ); + } on _i7.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i8.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i5.Serializers.instance + .serialize<_i7.OutOfRangeException>(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i5.JsonUtf8.encode(status), + ); + } on _i7.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i8.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i5.Serializers.instance + .serialize<_i7.PermissionDeniedException>(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i5.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i8.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i5.Serializers.instance.serialize(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i5.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i8.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i5.Serializers.instance.serialize(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i5.JsonUtf8.encode(status), + ); + } on _i7.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i8.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i5.Serializers.instance + .serialize<_i7.ResourceExhaustedException>(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i5.JsonUtf8.encode(status), + ); + } on _i12.SerializationException catch (e, st) { + const statusCode = 400; + _i8.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i5.Serializers.instance + .serialize<_i12.SerializationException>(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i5.JsonUtf8.encode(status), + ); + } on _i7.BadRequestException catch (e, st) { + const statusCode = 400; + _i8.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i5.Serializers.instance + .serialize<_i7.BadRequestException>(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i5.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i8.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i5.Serializers.instance.serialize(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i5.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i8.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i5.Serializers.instance.serialize( + e, + ), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i5.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i8.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i5.Serializers.instance.serialize(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i5.JsonUtf8.encode(status), + ); + } on _i10.TimeoutException catch (e, st) { + const statusCode = 400; + _i8.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i5.Serializers.instance + .serialize<_i10.TimeoutException>(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i5.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i8.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i5.Serializers.instance.serialize(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i5.JsonUtf8.encode(status), + ); + } on _i7.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i8.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i5.Serializers.instance + .serialize<_i7.UnauthorizedException>(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i5.JsonUtf8.encode(status), + ); + } on _i7.UnavailableError catch (e, st) { + const statusCode = 503; + _i8.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i5.Serializers.instance.serialize<_i7.UnavailableError>( + e, + ), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i5.JsonUtf8.encode(status), + ); + } on _i7.UnimplementedError catch (e, st) { + const statusCode = 501; + _i8.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i5.Serializers.instance + .serialize<_i7.UnimplementedError>(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i5.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i8.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i5.Serializers.instance.serialize( + e, + ), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i5.JsonUtf8.encode(status), + ); + } on _i7.UnknownError catch (e, st) { + const statusCode = 500; + _i8.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i5.Serializers.instance.serialize<_i7.UnknownError>(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i5.JsonUtf8.encode(status), + ); + } on _i7.CloudException catch (e, st) { + const statusCode = 400; + _i8.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i5.Serializers.instance.serialize<_i7.CloudException>( + e, + ), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i5.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i8.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i5.Serializers.instance.serialize(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i5.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i8.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i5.Serializers.instance.serialize(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i5.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i8.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i5.Serializers.instance.serialize(e), + }, + if (_i8.context.environment != _i9.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i5.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i5.Serializers.instance.put( + _i5.Serializer.define<_i10.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i5.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i10.AsyncError( + $serialized[r'error']!, + _i5.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define<_i10.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i5.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i10.TimeoutException( + ($serialized[r'message'] as String?), + _i5.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define< + _i11.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i11.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define?>( + serialize: + ($value) => { + if (_i5.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define<_i4.BadShapeException, Map>( + serialize: + ($value) => { + r'shape': _i5.Serializers.instance.serialize<_i3.Shape>( + $value.shape, + ), + }, + deserialize: ($serialized) { + return _i4.BadShapeException( + _i5.Serializers.instance.deserialize<_i3.Shape>( + $serialized[r'shape'], + ), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define<_i4.CustomError, Map?>( + serialize: + ($value) => { + r'message': $value.message, + r'additionalInfo': _i5.Serializers.instance + .serialize<_i13.JsonMap>( + $value.additionalInfo, + const _i5.TypeToken<_i13.JsonMap>('JsonMap'), + ), + }, + deserialize: ($serialized) { + return _i4.CustomError(); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define<_i4.CustomErrorToFromJson, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i4.CustomErrorToFromJson.fromJson($serialized); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define< + _i4.CustomErrorWithStackTrace, + Map? + >( + serialize: + ($value) => { + r'stackTrace': _i5.Serializers.instance.serialize( + $value.stackTrace, + ), + r'message': $value.message, + r'additionalInfo': $value.additionalInfo, + }, + deserialize: ($serialized) { + return _i4.CustomErrorWithStackTrace( + stackTrace: _i5.Serializers.instance.deserialize( + $serialized?[r'stackTrace'], + ), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define<_i4.CustomException, Map?>( + serialize: + ($value) => { + r'message': $value.message, + r'additionalInfo': _i5.Serializers.instance + .serialize<_i13.JsonMap>( + $value.additionalInfo, + const _i5.TypeToken<_i13.JsonMap>('JsonMap'), + ), + }, + deserialize: ($serialized) { + return _i4.CustomException(); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define< + _i4.CustomExceptionToFromJson, + Map + >( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i4.CustomExceptionToFromJson.fromJson($serialized); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define<_i4.ShapeException, Map>( + serialize: ($value) { + if ($value is _i4.BadShapeException) { + return { + ...(_i5.Serializers.instance.serialize<_i4.BadShapeException>( + $value, + ) + as Map), + r'$type': r'BadShapeException', + }; + } + throw _i5.SerializationException( + (StringBuffer('Unknown subtype of ') + ..write(r'ShapeException') + ..write(': ') + ..write($value.runtimeType)) + .toString(), + ); + }, + deserialize: ($serialized) { + if ($serialized[r'$type'] == r'BadShapeException') { + return _i5.Serializers.instance.deserialize<_i4.BadShapeException>( + $serialized, + ); + } + throw _i5.SerializationException( + (StringBuffer('Unknown subtype of ') + ..write(r'ShapeException') + ..write(': ') + ..write($serialized[r'$type'])) + .toString(), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define<_i3.Circle, Map>( + serialize: + ($value) => { + r'radius': $value.radius, + r'area': $value.area, + }, + deserialize: ($serialized) { + return _i3.Circle(($serialized[r'radius'] as num).toDouble()); + }, + ), + ); + _i5.Serializers.instance.put(const ErrResult_E_ShapeExceptionSerializer()); + _i5.Serializers.instance.put( + const ErrResult_E_ShapeExceptionSerializer<_i4.ShapeException>(), + ); + _i5.Serializers.instance.put( + const ErrResult_E_ShapeExceptionSerializer<_i4.BadShapeException>(), + ); + _i5.Serializers.instance.put(const ErrResult_T_ShapeSerializer()); + _i5.Serializers.instance.put( + const ErrResult_T_ShapeSerializer<_i3.Shape>(), + ); + _i5.Serializers.instance.put( + const ErrResult_T_ShapeSerializer<_i3.Circle>(), + ); + _i5.Serializers.instance.put( + const ErrResult_T_ShapeSerializer<_i3.Rectangle>(), + ); + _i5.Serializers.instance.put(const OkResult_T_ShapeSerializer()); + _i5.Serializers.instance.put(const OkResult_T_ShapeSerializer<_i3.Shape>()); + _i5.Serializers.instance.put( + const OkResult_T_ShapeSerializer<_i3.Circle>(), + ); + _i5.Serializers.instance.put( + const OkResult_T_ShapeSerializer<_i3.Rectangle>(), + ); + _i5.Serializers.instance.put(const OkResult_E_ShapeExceptionSerializer()); + _i5.Serializers.instance.put( + const OkResult_E_ShapeExceptionSerializer<_i4.ShapeException>(), + ); + _i5.Serializers.instance.put( + const OkResult_E_ShapeExceptionSerializer<_i4.BadShapeException>(), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define<_i3.Rectangle, Map>( + serialize: + ($value) => { + r'width': $value.width, + r'height': $value.height, + r'area': $value.area, + }, + deserialize: ($serialized) { + return _i3.Rectangle( + ($serialized[r'width'] as num).toDouble(), + ($serialized[r'height'] as num).toDouble(), + ); + }, + ), + ); + _i5.Serializers.instance.put( + const Result_T_Shape_E_ShapeExceptionSerializer(), + ); + _i5.Serializers.instance.put( + const Result_T_Shape_E_ShapeExceptionSerializer< + _i3.Shape, + _i4.ShapeException + >(), + ); + _i5.Serializers.instance.put( + const Result_T_Shape_E_ShapeExceptionSerializer< + _i3.Shape, + _i4.BadShapeException + >(), + ); + _i5.Serializers.instance.put( + const Result_T_Shape_E_ShapeExceptionSerializer< + _i3.Circle, + _i4.ShapeException + >(), + ); + _i5.Serializers.instance.put( + const Result_T_Shape_E_ShapeExceptionSerializer< + _i3.Circle, + _i4.BadShapeException + >(), + ); + _i5.Serializers.instance.put( + const Result_T_Shape_E_ShapeExceptionSerializer< + _i3.Rectangle, + _i4.ShapeException + >(), + ); + _i5.Serializers.instance.put( + const Result_T_Shape_E_ShapeExceptionSerializer< + _i3.Rectangle, + _i4.BadShapeException + >(), + ); + _i5.Serializers.instance.put( + const Result_E_ShapeException_T_ShapeSerializer(), + ); + _i5.Serializers.instance.put( + const Result_E_ShapeException_T_ShapeSerializer< + _i4.ShapeException, + _i3.Shape + >(), + ); + _i5.Serializers.instance.put( + const Result_E_ShapeException_T_ShapeSerializer< + _i4.ShapeException, + _i3.Circle + >(), + ); + _i5.Serializers.instance.put( + const Result_E_ShapeException_T_ShapeSerializer< + _i4.ShapeException, + _i3.Rectangle + >(), + ); + _i5.Serializers.instance.put( + const Result_E_ShapeException_T_ShapeSerializer< + _i4.BadShapeException, + _i3.Shape + >(), + ); + _i5.Serializers.instance.put( + const Result_E_ShapeException_T_ShapeSerializer< + _i4.BadShapeException, + _i3.Circle + >(), + ); + _i5.Serializers.instance.put( + const Result_E_ShapeException_T_ShapeSerializer< + _i4.BadShapeException, + _i3.Rectangle + >(), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define<_i3.Shape, Map>( + serialize: ($value) { + if ($value is _i3.Circle) { + return { + ...(_i5.Serializers.instance.serialize<_i3.Circle>($value) + as Map), + r'$type': r'Circle', + }; + } + if ($value is _i3.Rectangle) { + return { + ...(_i5.Serializers.instance.serialize<_i3.Rectangle>($value) + as Map), + r'$type': r'Rectangle', + }; + } + throw _i5.SerializationException( + (StringBuffer('Unknown subtype of ') + ..write(r'Shape') + ..write(': ') + ..write($value.runtimeType)) + .toString(), + ); + }, + deserialize: ($serialized) { + if ($serialized[r'$type'] == r'Circle') { + return _i5.Serializers.instance.deserialize<_i3.Circle>( + $serialized, + ); + } + if ($serialized[r'$type'] == r'Rectangle') { + return _i5.Serializers.instance.deserialize<_i3.Rectangle>( + $serialized, + ); + } + throw _i5.SerializationException( + (StringBuffer('Unknown subtype of ') + ..write(r'Shape') + ..write(': ') + ..write($serialized[r'$type'])) + .toString(), + ); + }, + ), + ); + _i5.Serializers.instance.put( + const SwappedResult_E_ShapeException_T_ShapeSerializer(), + ); + _i5.Serializers.instance.put( + const SwappedResult_E_ShapeException_T_ShapeSerializer< + _i4.ShapeException, + _i3.Shape + >(), + ); + _i5.Serializers.instance.put( + const SwappedResult_E_ShapeException_T_ShapeSerializer< + _i4.ShapeException, + _i3.Circle + >(), + ); + _i5.Serializers.instance.put( + const SwappedResult_E_ShapeException_T_ShapeSerializer< + _i4.ShapeException, + _i3.Rectangle + >(), + ); + _i5.Serializers.instance.put( + const SwappedResult_E_ShapeException_T_ShapeSerializer< + _i4.BadShapeException, + _i3.Shape + >(), + ); + _i5.Serializers.instance.put( + const SwappedResult_E_ShapeException_T_ShapeSerializer< + _i4.BadShapeException, + _i3.Circle + >(), + ); + _i5.Serializers.instance.put( + const SwappedResult_E_ShapeException_T_ShapeSerializer< + _i4.BadShapeException, + _i3.Rectangle + >(), + ); + _i5.Serializers.instance.put( + const SwappedResult_T_Shape_E_ShapeExceptionSerializer(), + ); + _i5.Serializers.instance.put( + const SwappedResult_T_Shape_E_ShapeExceptionSerializer< + _i3.Shape, + _i4.ShapeException + >(), + ); + _i5.Serializers.instance.put( + const SwappedResult_T_Shape_E_ShapeExceptionSerializer< + _i3.Shape, + _i4.BadShapeException + >(), + ); + _i5.Serializers.instance.put( + const SwappedResult_T_Shape_E_ShapeExceptionSerializer< + _i3.Circle, + _i4.ShapeException + >(), + ); + _i5.Serializers.instance.put( + const SwappedResult_T_Shape_E_ShapeExceptionSerializer< + _i3.Circle, + _i4.BadShapeException + >(), + ); + _i5.Serializers.instance.put( + const SwappedResult_T_Shape_E_ShapeExceptionSerializer< + _i3.Rectangle, + _i4.ShapeException + >(), + ); + _i5.Serializers.instance.put( + const SwappedResult_T_Shape_E_ShapeExceptionSerializer< + _i3.Rectangle, + _i4.BadShapeException + >(), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define<_i7.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i5.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i5.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.AbortedException( + ($serialized?[r'message'] as String?), + _i5.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i5.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define<_i7.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i5.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i5.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i5.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i5.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define<_i7.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i5.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i5.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.BadRequestException( + ($serialized?[r'message'] as String?), + _i5.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i5.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define<_i7.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i5.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i5.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.CancelledException( + ($serialized?[r'message'] as String?), + _i5.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i5.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define<_i7.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i5.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i5.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.CloudException.fromJson($serialized); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define<_i7.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i5.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i5.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.DataLossError( + ($serialized?[r'message'] as String?), + _i5.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i5.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define<_i7.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i5.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i5.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i5.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i5.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define< + _i7.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i5.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i5.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i5.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i5.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define<_i7.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i5.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i5.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.InternalServerError( + ($serialized?[r'message'] as String?), + _i5.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i5.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define<_i7.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i5.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i5.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.NotFoundException( + ($serialized?[r'message'] as String?), + _i5.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i5.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define<_i7.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i5.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i5.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i5.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i5.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define< + _i7.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i5.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i5.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i5.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i5.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define< + _i7.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i5.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i5.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i5.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i5.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define<_i7.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i5.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i5.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i5.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i5.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define<_i7.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i5.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i5.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.UnavailableError( + ($serialized?[r'message'] as String?), + _i5.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i5.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define<_i7.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i5.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i5.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.UnimplementedError( + ($serialized?[r'message'] as String?), + _i5.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i5.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define<_i7.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i5.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i5.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.UnknownError( + ($serialized?[r'message'] as String?), + _i5.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i5.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define<_i12.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i5.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i5.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i12.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define<_i13.JsonMap, Map>( + serialize: ($value) => $value, + deserialize: ($serialized) { + return _i13.JsonMap(($serialized as Map)); + }, + ), + const _i5.TypeToken<_i13.JsonMap>('JsonMap'), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define<_i13.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i13.JsonValue($serialized); + }, + ), + const _i5.TypeToken<_i13.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': MultipleGenericResultTarget()}, + setup: (_i8.Context context) async {}, + ); +} + +final class ErrResult_E_ShapeExceptionSerializer + extends _i5.Serializer<_i3.ErrResult> { + const ErrResult_E_ShapeExceptionSerializer(); + + @override + _i3.ErrResult deserialize(Object? $value) { + final $serialized = assertWireType>($value); + return _i3.ErrResult( + _i5.Serializers.instance.deserialize($serialized[r'error']), + ); + } + + @override + Object? serialize(_i3.ErrResult $value) => { + r'error': _i5.Serializers.instance.serialize($value.error), + }; +} + +final class ErrResult_T_ShapeSerializer + extends _i5.Serializer<_i3.ErrResult> { + const ErrResult_T_ShapeSerializer(); + + @override + _i3.ErrResult deserialize(Object? $value) { + final $serialized = assertWireType>($value); + return _i3.ErrResult( + _i5.Serializers.instance.deserialize($serialized[r'error']), + ); + } + + @override + Object? serialize(_i3.ErrResult $value) => { + r'error': _i5.Serializers.instance.serialize($value.error), + }; +} + +final class OkResult_E_ShapeExceptionSerializer + extends _i5.Serializer<_i3.OkResult> { + const OkResult_E_ShapeExceptionSerializer(); + + @override + _i3.OkResult deserialize(Object? $value) { + final $serialized = assertWireType>($value); + return _i3.OkResult( + _i5.Serializers.instance.deserialize($serialized[r'data']), + ); + } + + @override + Object? serialize(_i3.OkResult $value) => { + r'data': _i5.Serializers.instance.serialize($value.data), + }; +} + +final class OkResult_T_ShapeSerializer + extends _i5.Serializer<_i3.OkResult> { + const OkResult_T_ShapeSerializer(); + + @override + _i3.OkResult deserialize(Object? $value) { + final $serialized = assertWireType>($value); + return _i3.OkResult( + _i5.Serializers.instance.deserialize($serialized[r'data']), + ); + } + + @override + Object? serialize(_i3.OkResult $value) => { + r'data': _i5.Serializers.instance.serialize($value.data), + }; +} + +final class Result_E_ShapeException_T_ShapeSerializer< + E extends _i4.ShapeException, + T extends _i3.Shape +> + extends _i5.Serializer<_i3.Result> { + const Result_E_ShapeException_T_ShapeSerializer(); + + @override + _i3.Result deserialize(Object? $value) { + final $serialized = assertWireType>($value); + if ($serialized[r'$type'] == r'SwappedResult') { + return _i5.Serializers.instance.deserialize<_i3.SwappedResult>( + $serialized, + ); + } + if ($serialized[r'$type'] == r'OkResult') { + return _i5.Serializers.instance.deserialize<_i3.OkResult>($serialized); + } + if ($serialized[r'$type'] == r'ErrResult') { + return _i5.Serializers.instance.deserialize<_i3.ErrResult>( + $serialized, + ); + } + throw _i5.SerializationException( + (StringBuffer('Unknown subtype of ') + ..write(r'Result') + ..write(': ') + ..write($serialized[r'$type'])) + .toString(), + ); + } + + @override + Object? serialize(_i3.Result $value) { + if ($value is _i3.SwappedResult) { + return { + ...(_i5.Serializers.instance.serialize<_i3.SwappedResult>($value) + as Map), + r'$type': r'SwappedResult', + }; + } + if ($value is _i3.OkResult) { + return { + ...(_i5.Serializers.instance.serialize<_i3.OkResult>($value) + as Map), + r'$type': r'OkResult', + }; + } + if ($value is _i3.ErrResult) { + return { + ...(_i5.Serializers.instance.serialize<_i3.ErrResult>($value) + as Map), + r'$type': r'ErrResult', + }; + } + throw _i5.SerializationException( + (StringBuffer('Unknown subtype of ') + ..write(r'Result') + ..write(': ') + ..write($value.runtimeType)) + .toString(), + ); + } +} + +final class Result_T_Shape_E_ShapeExceptionSerializer< + T extends _i3.Shape, + E extends _i4.ShapeException +> + extends _i5.Serializer<_i3.Result> { + const Result_T_Shape_E_ShapeExceptionSerializer(); + + @override + _i3.Result deserialize(Object? $value) { + final $serialized = assertWireType>($value); + if ($serialized[r'$type'] == r'SwappedResult') { + return _i5.Serializers.instance.deserialize<_i3.SwappedResult>( + $serialized, + ); + } + if ($serialized[r'$type'] == r'OkResult') { + return _i5.Serializers.instance.deserialize<_i3.OkResult>($serialized); + } + if ($serialized[r'$type'] == r'ErrResult') { + return _i5.Serializers.instance.deserialize<_i3.ErrResult>( + $serialized, + ); + } + throw _i5.SerializationException( + (StringBuffer('Unknown subtype of ') + ..write(r'Result') + ..write(': ') + ..write($serialized[r'$type'])) + .toString(), + ); + } + + @override + Object? serialize(_i3.Result $value) { + if ($value is _i3.SwappedResult) { + return { + ...(_i5.Serializers.instance.serialize<_i3.SwappedResult>($value) + as Map), + r'$type': r'SwappedResult', + }; + } + if ($value is _i3.OkResult) { + return { + ...(_i5.Serializers.instance.serialize<_i3.OkResult>($value) + as Map), + r'$type': r'OkResult', + }; + } + if ($value is _i3.ErrResult) { + return { + ...(_i5.Serializers.instance.serialize<_i3.ErrResult>($value) + as Map), + r'$type': r'ErrResult', + }; + } + throw _i5.SerializationException( + (StringBuffer('Unknown subtype of ') + ..write(r'Result') + ..write(': ') + ..write($value.runtimeType)) + .toString(), + ); + } +} + +final class SwappedResult_E_ShapeException_T_ShapeSerializer< + E extends _i4.ShapeException, + T extends _i3.Shape +> + extends _i5.Serializer<_i3.SwappedResult> { + const SwappedResult_E_ShapeException_T_ShapeSerializer(); + + @override + _i3.SwappedResult deserialize(Object? $value) { + final $serialized = assertWireType>($value); + return _i3.SwappedResult( + _i5.Serializers.instance.deserialize<_i3.Result>( + $serialized[r'result'], + ), + ); + } + + @override + Object? serialize(_i3.SwappedResult $value) => { + r'result': _i5.Serializers.instance.serialize<_i3.Result>( + $value.result, + ), + }; +} + +final class SwappedResult_T_Shape_E_ShapeExceptionSerializer< + T extends _i3.Shape, + E extends _i4.ShapeException +> + extends _i5.Serializer<_i3.SwappedResult> { + const SwappedResult_T_Shape_E_ShapeExceptionSerializer(); + + @override + _i3.SwappedResult deserialize(Object? $value) { + final $serialized = assertWireType>($value); + return _i3.SwappedResult( + _i5.Serializers.instance.deserialize<_i3.Result>( + $serialized[r'result'], + ), + ); + } + + @override + Object? serialize(_i3.SwappedResult $value) => { + r'result': _i5.Serializers.instance.serialize<_i3.Result>( + $value.result, + ), + }; +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/sealed_classes/okShapeResult.dart b/apps/cli/fixtures/legacy/api/goldens/functions/sealed_classes/okShapeResult.dart new file mode 100644 index 000000000..4f47a2b64 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/sealed_classes/okShapeResult.dart @@ -0,0 +1,1994 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i11; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/exceptions/exceptions.dart' as _i10; +import 'package:celest_backend/models/sealed_classes.dart' as _i5; +import 'package:celest_backend/src/functions/sealed_classes.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i12; +import 'package:celest_core/src/serialization/json_value.dart' as _i13; +import 'package:shelf/shelf.dart' as _i2; + +final class OkShapeResultTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'okShapeResult'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.okShapeResult( + _i4.Serializers.instance.deserialize<_i5.Shape>(request[r'shape']), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.OkShapeResult>(response), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomErrorToFromJson catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'api.v1.CustomErrorToFromJson', + 'value': _i4.Serializers.instance + .serialize<_i10.CustomErrorToFromJson>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'api.v1.CustomError', + 'value': _i4.Serializers.instance.serialize<_i10.CustomError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomErrorWithStackTrace catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'api.v1.CustomErrorWithStackTrace', + 'value': _i4.Serializers.instance + .serialize<_i10.CustomErrorWithStackTrace>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomExceptionToFromJson catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'api.v1.CustomExceptionToFromJson', + 'value': _i4.Serializers.instance + .serialize<_i10.CustomExceptionToFromJson>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'api.v1.CustomException', + 'value': _i4.Serializers.instance.serialize<_i10.CustomException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i11.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i12.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i12.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i11.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i11.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.CustomError, Map?>( + serialize: + ($value) => { + r'message': $value.message, + r'additionalInfo': _i4.Serializers.instance + .serialize<_i13.JsonMap>( + $value.additionalInfo, + const _i4.TypeToken<_i13.JsonMap>('JsonMap'), + ), + }, + deserialize: ($serialized) { + return _i10.CustomError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.CustomErrorToFromJson, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i10.CustomErrorToFromJson.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.CustomErrorWithStackTrace, + Map? + >( + serialize: + ($value) => { + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + r'message': $value.message, + r'additionalInfo': $value.additionalInfo, + }, + deserialize: ($serialized) { + return _i10.CustomErrorWithStackTrace( + stackTrace: _i4.Serializers.instance.deserialize( + $serialized?[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.CustomException, Map?>( + serialize: + ($value) => { + r'message': $value.message, + r'additionalInfo': _i4.Serializers.instance + .serialize<_i13.JsonMap>( + $value.additionalInfo, + const _i4.TypeToken<_i13.JsonMap>('JsonMap'), + ), + }, + deserialize: ($serialized) { + return _i10.CustomException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.CustomExceptionToFromJson, + Map + >( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i10.CustomExceptionToFromJson.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.Circle, Map>( + serialize: + ($value) => { + r'radius': $value.radius, + r'area': $value.area, + }, + deserialize: ($serialized) { + return _i5.Circle(($serialized[r'radius'] as num).toDouble()); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OkShapeResult, Map>( + serialize: + ($value) => { + r'data': _i4.Serializers.instance.serialize<_i5.Shape>( + $value.data, + ), + }, + deserialize: ($serialized) { + return _i5.OkShapeResult( + _i4.Serializers.instance.deserialize<_i5.Shape>( + $serialized[r'data'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.Rectangle, Map>( + serialize: + ($value) => { + r'width': $value.width, + r'height': $value.height, + r'area': $value.area, + }, + deserialize: ($serialized) { + return _i5.Rectangle( + ($serialized[r'width'] as num).toDouble(), + ($serialized[r'height'] as num).toDouble(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.Shape, Map>( + serialize: ($value) { + if ($value is _i5.Circle) { + return { + ...(_i4.Serializers.instance.serialize<_i5.Circle>($value) + as Map), + r'$type': r'Circle', + }; + } + if ($value is _i5.Rectangle) { + return { + ...(_i4.Serializers.instance.serialize<_i5.Rectangle>($value) + as Map), + r'$type': r'Rectangle', + }; + } + throw _i4.SerializationException( + (StringBuffer('Unknown subtype of ') + ..write(r'Shape') + ..write(': ') + ..write($value.runtimeType)) + .toString(), + ); + }, + deserialize: ($serialized) { + if ($serialized[r'$type'] == r'Circle') { + return _i4.Serializers.instance.deserialize<_i5.Circle>( + $serialized, + ); + } + if ($serialized[r'$type'] == r'Rectangle') { + return _i4.Serializers.instance.deserialize<_i5.Rectangle>( + $serialized, + ); + } + throw _i4.SerializationException( + (StringBuffer('Unknown subtype of ') + ..write(r'Shape') + ..write(': ') + ..write($serialized[r'$type'])) + .toString(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i12.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.JsonMap, Map>( + serialize: ($value) => $value, + deserialize: ($serialized) { + return _i13.JsonMap(($serialized as Map)); + }, + ), + const _i4.TypeToken<_i13.JsonMap>('JsonMap'), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i13.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': OkShapeResultTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/sealed_classes/okShapeResults.dart b/apps/cli/fixtures/legacy/api/goldens/functions/sealed_classes/okShapeResults.dart new file mode 100644 index 000000000..d4fc32ed1 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/sealed_classes/okShapeResults.dart @@ -0,0 +1,2001 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i11; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/exceptions/exceptions.dart' as _i10; +import 'package:celest_backend/models/sealed_classes.dart' as _i5; +import 'package:celest_backend/src/functions/sealed_classes.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i12; +import 'package:celest_core/src/serialization/json_value.dart' as _i13; +import 'package:shelf/shelf.dart' as _i2; + +final class OkShapeResultsTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'okShapeResults'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.okShapeResults( + (request[r'shapes'] as Iterable) + .map((el) => _i4.Serializers.instance.deserialize<_i5.Shape>(el)) + .toList(), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + response + .map( + (el) => _i4.Serializers.instance + .serialize<_i5.OkResult<_i5.Shape>>(el), + ) + .toList(), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomErrorToFromJson catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'api.v1.CustomErrorToFromJson', + 'value': _i4.Serializers.instance + .serialize<_i10.CustomErrorToFromJson>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'api.v1.CustomError', + 'value': _i4.Serializers.instance.serialize<_i10.CustomError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomErrorWithStackTrace catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'api.v1.CustomErrorWithStackTrace', + 'value': _i4.Serializers.instance + .serialize<_i10.CustomErrorWithStackTrace>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomExceptionToFromJson catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'api.v1.CustomExceptionToFromJson', + 'value': _i4.Serializers.instance + .serialize<_i10.CustomExceptionToFromJson>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'api.v1.CustomException', + 'value': _i4.Serializers.instance.serialize<_i10.CustomException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i11.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i12.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i12.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i11.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i11.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.CustomError, Map?>( + serialize: + ($value) => { + r'message': $value.message, + r'additionalInfo': _i4.Serializers.instance + .serialize<_i13.JsonMap>( + $value.additionalInfo, + const _i4.TypeToken<_i13.JsonMap>('JsonMap'), + ), + }, + deserialize: ($serialized) { + return _i10.CustomError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.CustomErrorToFromJson, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i10.CustomErrorToFromJson.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.CustomErrorWithStackTrace, + Map? + >( + serialize: + ($value) => { + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + r'message': $value.message, + r'additionalInfo': $value.additionalInfo, + }, + deserialize: ($serialized) { + return _i10.CustomErrorWithStackTrace( + stackTrace: _i4.Serializers.instance.deserialize( + $serialized?[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.CustomException, Map?>( + serialize: + ($value) => { + r'message': $value.message, + r'additionalInfo': _i4.Serializers.instance + .serialize<_i13.JsonMap>( + $value.additionalInfo, + const _i4.TypeToken<_i13.JsonMap>('JsonMap'), + ), + }, + deserialize: ($serialized) { + return _i10.CustomException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.CustomExceptionToFromJson, + Map + >( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i10.CustomExceptionToFromJson.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.Circle, Map>( + serialize: + ($value) => { + r'radius': $value.radius, + r'area': $value.area, + }, + deserialize: ($serialized) { + return _i5.Circle(($serialized[r'radius'] as num).toDouble()); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OkResult<_i5.Shape>, Map>( + serialize: + ($value) => { + r'data': _i4.Serializers.instance.serialize<_i5.Shape>( + $value.data, + ), + }, + deserialize: ($serialized) { + return _i5.OkResult<_i5.Shape>( + _i4.Serializers.instance.deserialize<_i5.Shape>( + $serialized[r'data'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.Rectangle, Map>( + serialize: + ($value) => { + r'width': $value.width, + r'height': $value.height, + r'area': $value.area, + }, + deserialize: ($serialized) { + return _i5.Rectangle( + ($serialized[r'width'] as num).toDouble(), + ($serialized[r'height'] as num).toDouble(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.Shape, Map>( + serialize: ($value) { + if ($value is _i5.Circle) { + return { + ...(_i4.Serializers.instance.serialize<_i5.Circle>($value) + as Map), + r'$type': r'Circle', + }; + } + if ($value is _i5.Rectangle) { + return { + ...(_i4.Serializers.instance.serialize<_i5.Rectangle>($value) + as Map), + r'$type': r'Rectangle', + }; + } + throw _i4.SerializationException( + (StringBuffer('Unknown subtype of ') + ..write(r'Shape') + ..write(': ') + ..write($value.runtimeType)) + .toString(), + ); + }, + deserialize: ($serialized) { + if ($serialized[r'$type'] == r'Circle') { + return _i4.Serializers.instance.deserialize<_i5.Circle>( + $serialized, + ); + } + if ($serialized[r'$type'] == r'Rectangle') { + return _i4.Serializers.instance.deserialize<_i5.Rectangle>( + $serialized, + ); + } + throw _i4.SerializationException( + (StringBuffer('Unknown subtype of ') + ..write(r'Shape') + ..write(': ') + ..write($serialized[r'$type'])) + .toString(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i12.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.JsonMap, Map>( + serialize: ($value) => $value, + deserialize: ($serialized) { + return _i13.JsonMap(($serialized as Map)); + }, + ), + const _i4.TypeToken<_i13.JsonMap>('JsonMap'), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i13.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': OkShapeResultsTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/sealed_classes/rectangle.dart b/apps/cli/fixtures/legacy/api/goldens/functions/sealed_classes/rectangle.dart new file mode 100644 index 000000000..7bcb32c4f --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/sealed_classes/rectangle.dart @@ -0,0 +1,1921 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i11; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/exceptions/exceptions.dart' as _i10; +import 'package:celest_backend/models/sealed_classes.dart' as _i5; +import 'package:celest_backend/src/functions/sealed_classes.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i12; +import 'package:celest_core/src/serialization/json_value.dart' as _i13; +import 'package:shelf/shelf.dart' as _i2; + +final class RectangleTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'rectangle'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.rectangle( + _i4.Serializers.instance.deserialize<_i5.Rectangle>( + request[r'rectangle'], + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.Rectangle>(response), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomErrorToFromJson catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'api.v1.CustomErrorToFromJson', + 'value': _i4.Serializers.instance + .serialize<_i10.CustomErrorToFromJson>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'api.v1.CustomError', + 'value': _i4.Serializers.instance.serialize<_i10.CustomError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomErrorWithStackTrace catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'api.v1.CustomErrorWithStackTrace', + 'value': _i4.Serializers.instance + .serialize<_i10.CustomErrorWithStackTrace>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomExceptionToFromJson catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'api.v1.CustomExceptionToFromJson', + 'value': _i4.Serializers.instance + .serialize<_i10.CustomExceptionToFromJson>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'api.v1.CustomException', + 'value': _i4.Serializers.instance.serialize<_i10.CustomException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i11.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i12.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i12.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i11.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i11.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.CustomError, Map?>( + serialize: + ($value) => { + r'message': $value.message, + r'additionalInfo': _i4.Serializers.instance + .serialize<_i13.JsonMap>( + $value.additionalInfo, + const _i4.TypeToken<_i13.JsonMap>('JsonMap'), + ), + }, + deserialize: ($serialized) { + return _i10.CustomError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.CustomErrorToFromJson, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i10.CustomErrorToFromJson.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.CustomErrorWithStackTrace, + Map? + >( + serialize: + ($value) => { + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + r'message': $value.message, + r'additionalInfo': $value.additionalInfo, + }, + deserialize: ($serialized) { + return _i10.CustomErrorWithStackTrace( + stackTrace: _i4.Serializers.instance.deserialize( + $serialized?[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.CustomException, Map?>( + serialize: + ($value) => { + r'message': $value.message, + r'additionalInfo': _i4.Serializers.instance + .serialize<_i13.JsonMap>( + $value.additionalInfo, + const _i4.TypeToken<_i13.JsonMap>('JsonMap'), + ), + }, + deserialize: ($serialized) { + return _i10.CustomException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.CustomExceptionToFromJson, + Map + >( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i10.CustomExceptionToFromJson.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.Rectangle, Map>( + serialize: + ($value) => { + r'width': $value.width, + r'height': $value.height, + r'area': $value.area, + }, + deserialize: ($serialized) { + return _i5.Rectangle( + ($serialized[r'width'] as num).toDouble(), + ($serialized[r'height'] as num).toDouble(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i12.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.JsonMap, Map>( + serialize: ($value) => $value, + deserialize: ($serialized) { + return _i13.JsonMap(($serialized as Map)); + }, + ), + const _i4.TypeToken<_i13.JsonMap>('JsonMap'), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i13.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': RectangleTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/sealed_classes/rectangleWithOverriddenCustomJson.dart b/apps/cli/fixtures/legacy/api/goldens/functions/sealed_classes/rectangleWithOverriddenCustomJson.dart new file mode 100644 index 000000000..320e9bd6f --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/sealed_classes/rectangleWithOverriddenCustomJson.dart @@ -0,0 +1,1955 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i11; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/exceptions/exceptions.dart' as _i10; +import 'package:celest_backend/models/sealed_classes.dart' as _i5; +import 'package:celest_backend/src/functions/sealed_classes.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i12; +import 'package:celest_core/src/serialization/json_value.dart' as _i13; +import 'package:shelf/shelf.dart' as _i2; + +final class RectangleWithOverriddenCustomJsonTarget + extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'rectangleWithOverriddenCustomJson'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.rectangleWithOverriddenCustomJson( + _i4.Serializers.instance + .deserialize<_i5.RectangleWithOverriddenCustomJson>( + request[r'rectangle'], + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.ShapeWithOverriddenCustomJson>( + response, + ), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomErrorToFromJson catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'api.v1.CustomErrorToFromJson', + 'value': _i4.Serializers.instance + .serialize<_i10.CustomErrorToFromJson>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'api.v1.CustomError', + 'value': _i4.Serializers.instance.serialize<_i10.CustomError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomErrorWithStackTrace catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'api.v1.CustomErrorWithStackTrace', + 'value': _i4.Serializers.instance + .serialize<_i10.CustomErrorWithStackTrace>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomExceptionToFromJson catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'api.v1.CustomExceptionToFromJson', + 'value': _i4.Serializers.instance + .serialize<_i10.CustomExceptionToFromJson>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'api.v1.CustomException', + 'value': _i4.Serializers.instance.serialize<_i10.CustomException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i11.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i12.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i12.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i11.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i11.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.CustomError, Map?>( + serialize: + ($value) => { + r'message': $value.message, + r'additionalInfo': _i4.Serializers.instance + .serialize<_i13.JsonMap>( + $value.additionalInfo, + const _i4.TypeToken<_i13.JsonMap>('JsonMap'), + ), + }, + deserialize: ($serialized) { + return _i10.CustomError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.CustomErrorToFromJson, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i10.CustomErrorToFromJson.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.CustomErrorWithStackTrace, + Map? + >( + serialize: + ($value) => { + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + r'message': $value.message, + r'additionalInfo': $value.additionalInfo, + }, + deserialize: ($serialized) { + return _i10.CustomErrorWithStackTrace( + stackTrace: _i4.Serializers.instance.deserialize( + $serialized?[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.CustomException, Map?>( + serialize: + ($value) => { + r'message': $value.message, + r'additionalInfo': _i4.Serializers.instance + .serialize<_i13.JsonMap>( + $value.additionalInfo, + const _i4.TypeToken<_i13.JsonMap>('JsonMap'), + ), + }, + deserialize: ($serialized) { + return _i10.CustomException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.CustomExceptionToFromJson, + Map + >( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i10.CustomExceptionToFromJson.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.CircleWithOverriddenCustomJson, + Map + >( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i5.CircleWithOverriddenCustomJson.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.RectangleWithOverriddenCustomJson, + Map + >( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return (_i5.ShapeWithOverriddenCustomJson.fromJson({ + r'$type': r'RectangleWithOverriddenCustomJson', + ...$serialized, + }) + as _i5.RectangleWithOverriddenCustomJson); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ShapeWithOverriddenCustomJson, + Map + >( + serialize: + ($value) => { + ...$value.toJson(), + r'$type': switch ($value) { + _i5.CircleWithOverriddenCustomJson() => + r'CircleWithOverriddenCustomJson', + _i5.RectangleWithOverriddenCustomJson() => + r'RectangleWithOverriddenCustomJson', + }, + }, + deserialize: ($serialized) { + return _i5.ShapeWithOverriddenCustomJson.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i12.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.JsonMap, Map>( + serialize: ($value) => $value, + deserialize: ($serialized) { + return _i13.JsonMap(($serialized as Map)); + }, + ), + const _i4.TypeToken<_i13.JsonMap>('JsonMap'), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i13.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': RectangleWithOverriddenCustomJsonTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/sealed_classes/sealedClass.dart b/apps/cli/fixtures/legacy/api/goldens/functions/sealed_classes/sealedClass.dart new file mode 100644 index 000000000..b597cf029 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/sealed_classes/sealedClass.dart @@ -0,0 +1,1984 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i11; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/exceptions/exceptions.dart' as _i10; +import 'package:celest_backend/models/sealed_classes.dart' as _i5; +import 'package:celest_backend/src/functions/sealed_classes.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i12; +import 'package:celest_core/src/serialization/json_value.dart' as _i13; +import 'package:shelf/shelf.dart' as _i2; + +final class SealedClassTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'sealedClass'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.sealedClass( + shapes: + (request[r'shapes'] as Iterable) + .map( + (el) => _i4.Serializers.instance.deserialize<_i5.Shape>(el), + ) + .toList(), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + response + .map((el) => _i4.Serializers.instance.serialize<_i5.Shape>(el)) + .toList(), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomErrorToFromJson catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'api.v1.CustomErrorToFromJson', + 'value': _i4.Serializers.instance + .serialize<_i10.CustomErrorToFromJson>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'api.v1.CustomError', + 'value': _i4.Serializers.instance.serialize<_i10.CustomError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomErrorWithStackTrace catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'api.v1.CustomErrorWithStackTrace', + 'value': _i4.Serializers.instance + .serialize<_i10.CustomErrorWithStackTrace>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomExceptionToFromJson catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'api.v1.CustomExceptionToFromJson', + 'value': _i4.Serializers.instance + .serialize<_i10.CustomExceptionToFromJson>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'api.v1.CustomException', + 'value': _i4.Serializers.instance.serialize<_i10.CustomException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i11.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i12.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i12.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i11.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i11.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.CustomError, Map?>( + serialize: + ($value) => { + r'message': $value.message, + r'additionalInfo': _i4.Serializers.instance + .serialize<_i13.JsonMap>( + $value.additionalInfo, + const _i4.TypeToken<_i13.JsonMap>('JsonMap'), + ), + }, + deserialize: ($serialized) { + return _i10.CustomError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.CustomErrorToFromJson, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i10.CustomErrorToFromJson.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.CustomErrorWithStackTrace, + Map? + >( + serialize: + ($value) => { + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + r'message': $value.message, + r'additionalInfo': $value.additionalInfo, + }, + deserialize: ($serialized) { + return _i10.CustomErrorWithStackTrace( + stackTrace: _i4.Serializers.instance.deserialize( + $serialized?[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.CustomException, Map?>( + serialize: + ($value) => { + r'message': $value.message, + r'additionalInfo': _i4.Serializers.instance + .serialize<_i13.JsonMap>( + $value.additionalInfo, + const _i4.TypeToken<_i13.JsonMap>('JsonMap'), + ), + }, + deserialize: ($serialized) { + return _i10.CustomException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.CustomExceptionToFromJson, + Map + >( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i10.CustomExceptionToFromJson.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.Circle, Map>( + serialize: + ($value) => { + r'radius': $value.radius, + r'area': $value.area, + }, + deserialize: ($serialized) { + return _i5.Circle(($serialized[r'radius'] as num).toDouble()); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.Rectangle, Map>( + serialize: + ($value) => { + r'width': $value.width, + r'height': $value.height, + r'area': $value.area, + }, + deserialize: ($serialized) { + return _i5.Rectangle( + ($serialized[r'width'] as num).toDouble(), + ($serialized[r'height'] as num).toDouble(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.Shape, Map>( + serialize: ($value) { + if ($value is _i5.Circle) { + return { + ...(_i4.Serializers.instance.serialize<_i5.Circle>($value) + as Map), + r'$type': r'Circle', + }; + } + if ($value is _i5.Rectangle) { + return { + ...(_i4.Serializers.instance.serialize<_i5.Rectangle>($value) + as Map), + r'$type': r'Rectangle', + }; + } + throw _i4.SerializationException( + (StringBuffer('Unknown subtype of ') + ..write(r'Shape') + ..write(': ') + ..write($value.runtimeType)) + .toString(), + ); + }, + deserialize: ($serialized) { + if ($serialized[r'$type'] == r'Circle') { + return _i4.Serializers.instance.deserialize<_i5.Circle>( + $serialized, + ); + } + if ($serialized[r'$type'] == r'Rectangle') { + return _i4.Serializers.instance.deserialize<_i5.Rectangle>( + $serialized, + ); + } + throw _i4.SerializationException( + (StringBuffer('Unknown subtype of ') + ..write(r'Shape') + ..write(': ') + ..write($serialized[r'$type'])) + .toString(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i12.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.JsonMap, Map>( + serialize: ($value) => $value, + deserialize: ($serialized) { + return _i13.JsonMap(($serialized as Map)); + }, + ), + const _i4.TypeToken<_i13.JsonMap>('JsonMap'), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i13.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': SealedClassTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/sealed_classes/sealedClassWithCustomJson.dart b/apps/cli/fixtures/legacy/api/goldens/functions/sealed_classes/sealedClassWithCustomJson.dart new file mode 100644 index 000000000..939e9ed31 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/sealed_classes/sealedClassWithCustomJson.dart @@ -0,0 +1,1978 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i11; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/exceptions/exceptions.dart' as _i10; +import 'package:celest_backend/models/sealed_classes.dart' as _i5; +import 'package:celest_backend/src/functions/sealed_classes.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i12; +import 'package:celest_core/src/serialization/json_value.dart' as _i13; +import 'package:shelf/shelf.dart' as _i2; + +final class SealedClassWithCustomJsonTarget + extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'sealedClassWithCustomJson'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.sealedClassWithCustomJson( + shapes: + (request[r'shapes'] as Iterable) + .map( + (el) => _i4.Serializers.instance + .deserialize<_i5.ShapeWithCustomJson>(el), + ) + .toList(), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + response + .map( + (el) => _i4.Serializers.instance + .serialize<_i5.ShapeWithCustomJson>(el), + ) + .toList(), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomErrorToFromJson catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'api.v1.CustomErrorToFromJson', + 'value': _i4.Serializers.instance + .serialize<_i10.CustomErrorToFromJson>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'api.v1.CustomError', + 'value': _i4.Serializers.instance.serialize<_i10.CustomError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomErrorWithStackTrace catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'api.v1.CustomErrorWithStackTrace', + 'value': _i4.Serializers.instance + .serialize<_i10.CustomErrorWithStackTrace>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomExceptionToFromJson catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'api.v1.CustomExceptionToFromJson', + 'value': _i4.Serializers.instance + .serialize<_i10.CustomExceptionToFromJson>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'api.v1.CustomException', + 'value': _i4.Serializers.instance.serialize<_i10.CustomException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i11.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i12.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i12.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i11.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i11.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.CustomError, Map?>( + serialize: + ($value) => { + r'message': $value.message, + r'additionalInfo': _i4.Serializers.instance + .serialize<_i13.JsonMap>( + $value.additionalInfo, + const _i4.TypeToken<_i13.JsonMap>('JsonMap'), + ), + }, + deserialize: ($serialized) { + return _i10.CustomError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.CustomErrorToFromJson, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i10.CustomErrorToFromJson.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.CustomErrorWithStackTrace, + Map? + >( + serialize: + ($value) => { + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + r'message': $value.message, + r'additionalInfo': $value.additionalInfo, + }, + deserialize: ($serialized) { + return _i10.CustomErrorWithStackTrace( + stackTrace: _i4.Serializers.instance.deserialize( + $serialized?[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.CustomException, Map?>( + serialize: + ($value) => { + r'message': $value.message, + r'additionalInfo': _i4.Serializers.instance + .serialize<_i13.JsonMap>( + $value.additionalInfo, + const _i4.TypeToken<_i13.JsonMap>('JsonMap'), + ), + }, + deserialize: ($serialized) { + return _i10.CustomException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.CustomExceptionToFromJson, + Map + >( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i10.CustomExceptionToFromJson.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CircleWithCustomJson, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i5.CircleWithCustomJson.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.RectangleWithCustomJson, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i5.RectangleWithCustomJson.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.ShapeWithCustomJson, Map>( + serialize: ($value) { + if ($value is _i5.CircleWithCustomJson) { + return { + ...(_i4.Serializers.instance.serialize<_i5.CircleWithCustomJson>( + $value, + ) + as Map), + r'$type': r'CircleWithCustomJson', + }; + } + if ($value is _i5.RectangleWithCustomJson) { + return { + ...(_i4.Serializers.instance + .serialize<_i5.RectangleWithCustomJson>($value) + as Map), + r'$type': r'RectangleWithCustomJson', + }; + } + throw _i4.SerializationException( + (StringBuffer('Unknown subtype of ') + ..write(r'ShapeWithCustomJson') + ..write(': ') + ..write($value.runtimeType)) + .toString(), + ); + }, + deserialize: ($serialized) { + if ($serialized[r'$type'] == r'CircleWithCustomJson') { + return _i4.Serializers.instance + .deserialize<_i5.CircleWithCustomJson>($serialized); + } + if ($serialized[r'$type'] == r'RectangleWithCustomJson') { + return _i4.Serializers.instance + .deserialize<_i5.RectangleWithCustomJson>($serialized); + } + throw _i4.SerializationException( + (StringBuffer('Unknown subtype of ') + ..write(r'ShapeWithCustomJson') + ..write(': ') + ..write($serialized[r'$type'])) + .toString(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i12.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.JsonMap, Map>( + serialize: ($value) => $value, + deserialize: ($serialized) { + return _i13.JsonMap(($serialized as Map)); + }, + ), + const _i4.TypeToken<_i13.JsonMap>('JsonMap'), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i13.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': SealedClassWithCustomJsonTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/sealed_classes/sealedClassWithInheritedCustomJson.dart b/apps/cli/fixtures/legacy/api/goldens/functions/sealed_classes/sealedClassWithInheritedCustomJson.dart new file mode 100644 index 000000000..51e273191 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/sealed_classes/sealedClassWithInheritedCustomJson.dart @@ -0,0 +1,1965 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i11; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/exceptions/exceptions.dart' as _i10; +import 'package:celest_backend/models/sealed_classes.dart' as _i5; +import 'package:celest_backend/src/functions/sealed_classes.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i12; +import 'package:celest_core/src/serialization/json_value.dart' as _i13; +import 'package:shelf/shelf.dart' as _i2; + +final class SealedClassWithInheritedCustomJsonTarget + extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'sealedClassWithInheritedCustomJson'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.sealedClassWithInheritedCustomJson( + shapes: + (request[r'shapes'] as Iterable) + .map( + (el) => _i4.Serializers.instance + .deserialize<_i5.ShapeWithInheritedCustomJson>(el), + ) + .toList(), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + response + .map( + (el) => _i4.Serializers.instance + .serialize<_i5.ShapeWithInheritedCustomJson>(el), + ) + .toList(), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomErrorToFromJson catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'api.v1.CustomErrorToFromJson', + 'value': _i4.Serializers.instance + .serialize<_i10.CustomErrorToFromJson>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'api.v1.CustomError', + 'value': _i4.Serializers.instance.serialize<_i10.CustomError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomErrorWithStackTrace catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'api.v1.CustomErrorWithStackTrace', + 'value': _i4.Serializers.instance + .serialize<_i10.CustomErrorWithStackTrace>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomExceptionToFromJson catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'api.v1.CustomExceptionToFromJson', + 'value': _i4.Serializers.instance + .serialize<_i10.CustomExceptionToFromJson>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'api.v1.CustomException', + 'value': _i4.Serializers.instance.serialize<_i10.CustomException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i11.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i12.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i12.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i11.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i11.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.CustomError, Map?>( + serialize: + ($value) => { + r'message': $value.message, + r'additionalInfo': _i4.Serializers.instance + .serialize<_i13.JsonMap>( + $value.additionalInfo, + const _i4.TypeToken<_i13.JsonMap>('JsonMap'), + ), + }, + deserialize: ($serialized) { + return _i10.CustomError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.CustomErrorToFromJson, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i10.CustomErrorToFromJson.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.CustomErrorWithStackTrace, + Map? + >( + serialize: + ($value) => { + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + r'message': $value.message, + r'additionalInfo': $value.additionalInfo, + }, + deserialize: ($serialized) { + return _i10.CustomErrorWithStackTrace( + stackTrace: _i4.Serializers.instance.deserialize( + $serialized?[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.CustomException, Map?>( + serialize: + ($value) => { + r'message': $value.message, + r'additionalInfo': _i4.Serializers.instance + .serialize<_i13.JsonMap>( + $value.additionalInfo, + const _i4.TypeToken<_i13.JsonMap>('JsonMap'), + ), + }, + deserialize: ($serialized) { + return _i10.CustomException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.CustomExceptionToFromJson, + Map + >( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i10.CustomExceptionToFromJson.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.CircleWithInheritedCustomJson, + Map + >( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return (_i5.ShapeWithInheritedCustomJson.fromJson({ + r'$type': r'CircleWithInheritedCustomJson', + ...$serialized, + }) + as _i5.CircleWithInheritedCustomJson); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.RectangleWithInheritedCustomJson, + Map + >( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return (_i5.ShapeWithInheritedCustomJson.fromJson({ + r'$type': r'RectangleWithInheritedCustomJson', + ...$serialized, + }) + as _i5.RectangleWithInheritedCustomJson); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ShapeWithInheritedCustomJson, + Map + >( + serialize: + ($value) => { + ...$value.toJson(), + r'$type': switch ($value) { + _i5.CircleWithInheritedCustomJson() => + r'CircleWithInheritedCustomJson', + _i5.RectangleWithInheritedCustomJson() => + r'RectangleWithInheritedCustomJson', + }, + }, + deserialize: ($serialized) { + return _i5.ShapeWithInheritedCustomJson.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i12.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.JsonMap, Map>( + serialize: ($value) => $value, + deserialize: ($serialized) { + return _i13.JsonMap(($serialized as Map)); + }, + ), + const _i4.TypeToken<_i13.JsonMap>('JsonMap'), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i13.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': SealedClassWithInheritedCustomJsonTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/sealed_classes/sealedClassWithOverriddenCustomJson.dart b/apps/cli/fixtures/legacy/api/goldens/functions/sealed_classes/sealedClassWithOverriddenCustomJson.dart new file mode 100644 index 000000000..66fdf9388 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/sealed_classes/sealedClassWithOverriddenCustomJson.dart @@ -0,0 +1,1969 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i11; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/exceptions/exceptions.dart' as _i10; +import 'package:celest_backend/models/sealed_classes.dart' as _i5; +import 'package:celest_backend/src/functions/sealed_classes.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i12; +import 'package:celest_core/src/serialization/json_value.dart' as _i13; +import 'package:shelf/shelf.dart' as _i2; + +final class SealedClassWithOverriddenCustomJsonTarget + extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'sealedClassWithOverriddenCustomJson'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.sealedClassWithOverriddenCustomJson( + circle: _i4.Serializers.instance + .deserialize<_i5.CircleWithOverriddenCustomJson>( + request[r'circle'], + ), + rectangle: _i4.Serializers.instance + .deserialize<_i5.RectangleWithOverriddenCustomJson>( + request[r'rectangle'], + ), + other: + (request[r'other'] as Iterable) + .map( + (el) => _i4.Serializers.instance + .deserialize<_i5.ShapeWithOverriddenCustomJson>(el), + ) + .toList(), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + response + .map( + (el) => _i4.Serializers.instance + .serialize<_i5.ShapeWithOverriddenCustomJson>(el), + ) + .toList(), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomErrorToFromJson catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'api.v1.CustomErrorToFromJson', + 'value': _i4.Serializers.instance + .serialize<_i10.CustomErrorToFromJson>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'api.v1.CustomError', + 'value': _i4.Serializers.instance.serialize<_i10.CustomError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomErrorWithStackTrace catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'api.v1.CustomErrorWithStackTrace', + 'value': _i4.Serializers.instance + .serialize<_i10.CustomErrorWithStackTrace>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomExceptionToFromJson catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'api.v1.CustomExceptionToFromJson', + 'value': _i4.Serializers.instance + .serialize<_i10.CustomExceptionToFromJson>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'api.v1.CustomException', + 'value': _i4.Serializers.instance.serialize<_i10.CustomException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i11.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i12.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i12.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i11.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i11.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.CustomError, Map?>( + serialize: + ($value) => { + r'message': $value.message, + r'additionalInfo': _i4.Serializers.instance + .serialize<_i13.JsonMap>( + $value.additionalInfo, + const _i4.TypeToken<_i13.JsonMap>('JsonMap'), + ), + }, + deserialize: ($serialized) { + return _i10.CustomError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.CustomErrorToFromJson, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i10.CustomErrorToFromJson.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.CustomErrorWithStackTrace, + Map? + >( + serialize: + ($value) => { + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + r'message': $value.message, + r'additionalInfo': $value.additionalInfo, + }, + deserialize: ($serialized) { + return _i10.CustomErrorWithStackTrace( + stackTrace: _i4.Serializers.instance.deserialize( + $serialized?[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.CustomException, Map?>( + serialize: + ($value) => { + r'message': $value.message, + r'additionalInfo': _i4.Serializers.instance + .serialize<_i13.JsonMap>( + $value.additionalInfo, + const _i4.TypeToken<_i13.JsonMap>('JsonMap'), + ), + }, + deserialize: ($serialized) { + return _i10.CustomException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.CustomExceptionToFromJson, + Map + >( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i10.CustomExceptionToFromJson.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.CircleWithOverriddenCustomJson, + Map + >( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i5.CircleWithOverriddenCustomJson.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.RectangleWithOverriddenCustomJson, + Map + >( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return (_i5.ShapeWithOverriddenCustomJson.fromJson({ + r'$type': r'RectangleWithOverriddenCustomJson', + ...$serialized, + }) + as _i5.RectangleWithOverriddenCustomJson); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ShapeWithOverriddenCustomJson, + Map + >( + serialize: + ($value) => { + ...$value.toJson(), + r'$type': switch ($value) { + _i5.CircleWithOverriddenCustomJson() => + r'CircleWithOverriddenCustomJson', + _i5.RectangleWithOverriddenCustomJson() => + r'RectangleWithOverriddenCustomJson', + }, + }, + deserialize: ($serialized) { + return _i5.ShapeWithOverriddenCustomJson.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i12.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.JsonMap, Map>( + serialize: ($value) => $value, + deserialize: ($serialized) { + return _i13.JsonMap(($serialized as Map)); + }, + ), + const _i4.TypeToken<_i13.JsonMap>('JsonMap'), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i13.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': SealedClassWithOverriddenCustomJsonTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/sealed_classes/shapeResults.dart b/apps/cli/fixtures/legacy/api/goldens/functions/sealed_classes/shapeResults.dart new file mode 100644 index 000000000..7b32412b3 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/sealed_classes/shapeResults.dart @@ -0,0 +1,2200 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i11; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/exceptions/exceptions.dart' as _i10; +import 'package:celest_backend/models/sealed_classes.dart' as _i5; +import 'package:celest_backend/src/functions/sealed_classes.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i12; +import 'package:celest_core/src/serialization/json_value.dart' as _i13; +import 'package:shelf/shelf.dart' as _i2; + +final class ShapeResultsTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'shapeResults'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.shapeResults( + (request[r'shapes'] as Iterable) + .map((el) => _i4.Serializers.instance.deserialize<_i5.Shape>(el)) + .toList(), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + response + .map( + (el) => _i4.Serializers.instance + .serialize<_i5.Result<_i5.Shape, String>>(el), + ) + .toList(), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomErrorToFromJson catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'api.v1.CustomErrorToFromJson', + 'value': _i4.Serializers.instance + .serialize<_i10.CustomErrorToFromJson>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'api.v1.CustomError', + 'value': _i4.Serializers.instance.serialize<_i10.CustomError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomErrorWithStackTrace catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'api.v1.CustomErrorWithStackTrace', + 'value': _i4.Serializers.instance + .serialize<_i10.CustomErrorWithStackTrace>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomExceptionToFromJson catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'api.v1.CustomExceptionToFromJson', + 'value': _i4.Serializers.instance + .serialize<_i10.CustomExceptionToFromJson>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'api.v1.CustomException', + 'value': _i4.Serializers.instance.serialize<_i10.CustomException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i11.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i12.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i12.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i11.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i11.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.CustomError, Map?>( + serialize: + ($value) => { + r'message': $value.message, + r'additionalInfo': _i4.Serializers.instance + .serialize<_i13.JsonMap>( + $value.additionalInfo, + const _i4.TypeToken<_i13.JsonMap>('JsonMap'), + ), + }, + deserialize: ($serialized) { + return _i10.CustomError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.CustomErrorToFromJson, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i10.CustomErrorToFromJson.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.CustomErrorWithStackTrace, + Map? + >( + serialize: + ($value) => { + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + r'message': $value.message, + r'additionalInfo': $value.additionalInfo, + }, + deserialize: ($serialized) { + return _i10.CustomErrorWithStackTrace( + stackTrace: _i4.Serializers.instance.deserialize( + $serialized?[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.CustomException, Map?>( + serialize: + ($value) => { + r'message': $value.message, + r'additionalInfo': _i4.Serializers.instance + .serialize<_i13.JsonMap>( + $value.additionalInfo, + const _i4.TypeToken<_i13.JsonMap>('JsonMap'), + ), + }, + deserialize: ($serialized) { + return _i10.CustomException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.CustomExceptionToFromJson, + Map + >( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i10.CustomExceptionToFromJson.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.Circle, Map>( + serialize: + ($value) => { + r'radius': $value.radius, + r'area': $value.area, + }, + deserialize: ($serialized) { + return _i5.Circle(($serialized[r'radius'] as num).toDouble()); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.ErrResult, Map>( + serialize: ($value) => {r'error': $value.error}, + deserialize: ($serialized) { + return _i5.ErrResult(($serialized[r'error'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.ErrResult<_i5.Shape>, Map>( + serialize: + ($value) => { + r'error': _i4.Serializers.instance.serialize<_i5.Shape>( + $value.error, + ), + }, + deserialize: ($serialized) { + return _i5.ErrResult<_i5.Shape>( + _i4.Serializers.instance.deserialize<_i5.Shape>( + $serialized[r'error'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OkResult<_i5.Shape>, Map>( + serialize: + ($value) => { + r'data': _i4.Serializers.instance.serialize<_i5.Shape>( + $value.data, + ), + }, + deserialize: ($serialized) { + return _i5.OkResult<_i5.Shape>( + _i4.Serializers.instance.deserialize<_i5.Shape>( + $serialized[r'data'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OkResult, Map>( + serialize: ($value) => {r'data': $value.data}, + deserialize: ($serialized) { + return _i5.OkResult(($serialized[r'data'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.Rectangle, Map>( + serialize: + ($value) => { + r'width': $value.width, + r'height': $value.height, + r'area': $value.area, + }, + deserialize: ($serialized) { + return _i5.Rectangle( + ($serialized[r'width'] as num).toDouble(), + ($serialized[r'height'] as num).toDouble(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.Result<_i5.Shape, String>, + Map + >( + serialize: ($value) { + if ($value is _i5.SwappedResult) { + return { + ...(_i4.Serializers.instance + .serialize<_i5.SwappedResult>($value) + as Map), + r'$type': r'SwappedResult', + }; + } + if ($value is _i5.OkResult<_i5.Shape>) { + return { + ...(_i4.Serializers.instance.serialize<_i5.OkResult<_i5.Shape>>( + $value, + ) + as Map), + r'$type': r'OkResult', + }; + } + if ($value is _i5.ErrResult) { + return { + ...(_i4.Serializers.instance.serialize<_i5.ErrResult>( + $value, + ) + as Map), + r'$type': r'ErrResult', + }; + } + throw _i4.SerializationException( + (StringBuffer('Unknown subtype of ') + ..write(r'Result') + ..write(': ') + ..write($value.runtimeType)) + .toString(), + ); + }, + deserialize: ($serialized) { + if ($serialized[r'$type'] == r'SwappedResult') { + return _i4.Serializers.instance + .deserialize<_i5.SwappedResult>($serialized); + } + if ($serialized[r'$type'] == r'OkResult') { + return _i4.Serializers.instance + .deserialize<_i5.OkResult<_i5.Shape>>($serialized); + } + if ($serialized[r'$type'] == r'ErrResult') { + return _i4.Serializers.instance.deserialize<_i5.ErrResult>( + $serialized, + ); + } + throw _i4.SerializationException( + (StringBuffer('Unknown subtype of ') + ..write(r'Result') + ..write(': ') + ..write($serialized[r'$type'])) + .toString(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.Result, + Map + >( + serialize: ($value) { + if ($value is _i5.SwappedResult<_i5.Shape, String>) { + return { + ...(_i4.Serializers.instance + .serialize<_i5.SwappedResult<_i5.Shape, String>>($value) + as Map), + r'$type': r'SwappedResult', + }; + } + if ($value is _i5.OkResult) { + return { + ...(_i4.Serializers.instance.serialize<_i5.OkResult>( + $value, + ) + as Map), + r'$type': r'OkResult', + }; + } + if ($value is _i5.ErrResult<_i5.Shape>) { + return { + ...(_i4.Serializers.instance.serialize<_i5.ErrResult<_i5.Shape>>( + $value, + ) + as Map), + r'$type': r'ErrResult', + }; + } + throw _i4.SerializationException( + (StringBuffer('Unknown subtype of ') + ..write(r'Result') + ..write(': ') + ..write($value.runtimeType)) + .toString(), + ); + }, + deserialize: ($serialized) { + if ($serialized[r'$type'] == r'SwappedResult') { + return _i4.Serializers.instance + .deserialize<_i5.SwappedResult<_i5.Shape, String>>($serialized); + } + if ($serialized[r'$type'] == r'OkResult') { + return _i4.Serializers.instance.deserialize<_i5.OkResult>( + $serialized, + ); + } + if ($serialized[r'$type'] == r'ErrResult') { + return _i4.Serializers.instance + .deserialize<_i5.ErrResult<_i5.Shape>>($serialized); + } + throw _i4.SerializationException( + (StringBuffer('Unknown subtype of ') + ..write(r'Result') + ..write(': ') + ..write($serialized[r'$type'])) + .toString(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.Shape, Map>( + serialize: ($value) { + if ($value is _i5.Circle) { + return { + ...(_i4.Serializers.instance.serialize<_i5.Circle>($value) + as Map), + r'$type': r'Circle', + }; + } + if ($value is _i5.Rectangle) { + return { + ...(_i4.Serializers.instance.serialize<_i5.Rectangle>($value) + as Map), + r'$type': r'Rectangle', + }; + } + throw _i4.SerializationException( + (StringBuffer('Unknown subtype of ') + ..write(r'Shape') + ..write(': ') + ..write($value.runtimeType)) + .toString(), + ); + }, + deserialize: ($serialized) { + if ($serialized[r'$type'] == r'Circle') { + return _i4.Serializers.instance.deserialize<_i5.Circle>( + $serialized, + ); + } + if ($serialized[r'$type'] == r'Rectangle') { + return _i4.Serializers.instance.deserialize<_i5.Rectangle>( + $serialized, + ); + } + throw _i4.SerializationException( + (StringBuffer('Unknown subtype of ') + ..write(r'Shape') + ..write(': ') + ..write($serialized[r'$type'])) + .toString(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.SwappedResult<_i5.Shape, String>, + Map + >( + serialize: + ($value) => { + r'result': _i4.Serializers.instance + .serialize<_i5.Result<_i5.Shape, String>>($value.result), + }, + deserialize: ($serialized) { + return _i5.SwappedResult<_i5.Shape, String>( + _i4.Serializers.instance.deserialize<_i5.Result<_i5.Shape, String>>( + $serialized[r'result'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.SwappedResult, + Map + >( + serialize: + ($value) => { + r'result': _i4.Serializers.instance + .serialize<_i5.Result>($value.result), + }, + deserialize: ($serialized) { + return _i5.SwappedResult( + _i4.Serializers.instance.deserialize<_i5.Result>( + $serialized[r'result'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i12.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.JsonMap, Map>( + serialize: ($value) => $value, + deserialize: ($serialized) { + return _i13.JsonMap(($serialized as Map)); + }, + ), + const _i4.TypeToken<_i13.JsonMap>('JsonMap'), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i13.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': ShapeResultsTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/sealed_classes/swappedResult.dart b/apps/cli/fixtures/legacy/api/goldens/functions/sealed_classes/swappedResult.dart new file mode 100644 index 000000000..ad508e3ab --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/sealed_classes/swappedResult.dart @@ -0,0 +1,2196 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i11; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/exceptions/exceptions.dart' as _i10; +import 'package:celest_backend/models/sealed_classes.dart' as _i5; +import 'package:celest_backend/src/functions/sealed_classes.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i12; +import 'package:celest_core/src/serialization/json_value.dart' as _i13; +import 'package:shelf/shelf.dart' as _i2; + +final class SwappedResultTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'swappedResult'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.swappedResult( + _i4.Serializers.instance.deserialize<_i5.Result<_i5.Shape, String>>( + request[r'result'], + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance + .serialize<_i5.SwappedResult<_i5.Shape, String>>(response), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomErrorToFromJson catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'api.v1.CustomErrorToFromJson', + 'value': _i4.Serializers.instance + .serialize<_i10.CustomErrorToFromJson>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'api.v1.CustomError', + 'value': _i4.Serializers.instance.serialize<_i10.CustomError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomErrorWithStackTrace catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'api.v1.CustomErrorWithStackTrace', + 'value': _i4.Serializers.instance + .serialize<_i10.CustomErrorWithStackTrace>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomExceptionToFromJson catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'api.v1.CustomExceptionToFromJson', + 'value': _i4.Serializers.instance + .serialize<_i10.CustomExceptionToFromJson>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CustomException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'api.v1.CustomException', + 'value': _i4.Serializers.instance.serialize<_i10.CustomException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i11.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i12.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i12.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i11.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i11.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.CustomError, Map?>( + serialize: + ($value) => { + r'message': $value.message, + r'additionalInfo': _i4.Serializers.instance + .serialize<_i13.JsonMap>( + $value.additionalInfo, + const _i4.TypeToken<_i13.JsonMap>('JsonMap'), + ), + }, + deserialize: ($serialized) { + return _i10.CustomError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.CustomErrorToFromJson, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i10.CustomErrorToFromJson.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.CustomErrorWithStackTrace, + Map? + >( + serialize: + ($value) => { + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + r'message': $value.message, + r'additionalInfo': $value.additionalInfo, + }, + deserialize: ($serialized) { + return _i10.CustomErrorWithStackTrace( + stackTrace: _i4.Serializers.instance.deserialize( + $serialized?[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.CustomException, Map?>( + serialize: + ($value) => { + r'message': $value.message, + r'additionalInfo': _i4.Serializers.instance + .serialize<_i13.JsonMap>( + $value.additionalInfo, + const _i4.TypeToken<_i13.JsonMap>('JsonMap'), + ), + }, + deserialize: ($serialized) { + return _i10.CustomException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.CustomExceptionToFromJson, + Map + >( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i10.CustomExceptionToFromJson.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.Circle, Map>( + serialize: + ($value) => { + r'radius': $value.radius, + r'area': $value.area, + }, + deserialize: ($serialized) { + return _i5.Circle(($serialized[r'radius'] as num).toDouble()); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.ErrResult, Map>( + serialize: ($value) => {r'error': $value.error}, + deserialize: ($serialized) { + return _i5.ErrResult(($serialized[r'error'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.ErrResult<_i5.Shape>, Map>( + serialize: + ($value) => { + r'error': _i4.Serializers.instance.serialize<_i5.Shape>( + $value.error, + ), + }, + deserialize: ($serialized) { + return _i5.ErrResult<_i5.Shape>( + _i4.Serializers.instance.deserialize<_i5.Shape>( + $serialized[r'error'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OkResult, Map>( + serialize: ($value) => {r'data': $value.data}, + deserialize: ($serialized) { + return _i5.OkResult(($serialized[r'data'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OkResult<_i5.Shape>, Map>( + serialize: + ($value) => { + r'data': _i4.Serializers.instance.serialize<_i5.Shape>( + $value.data, + ), + }, + deserialize: ($serialized) { + return _i5.OkResult<_i5.Shape>( + _i4.Serializers.instance.deserialize<_i5.Shape>( + $serialized[r'data'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.Rectangle, Map>( + serialize: + ($value) => { + r'width': $value.width, + r'height': $value.height, + r'area': $value.area, + }, + deserialize: ($serialized) { + return _i5.Rectangle( + ($serialized[r'width'] as num).toDouble(), + ($serialized[r'height'] as num).toDouble(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.Result<_i5.Shape, String>, + Map + >( + serialize: ($value) { + if ($value is _i5.SwappedResult) { + return { + ...(_i4.Serializers.instance + .serialize<_i5.SwappedResult>($value) + as Map), + r'$type': r'SwappedResult', + }; + } + if ($value is _i5.OkResult<_i5.Shape>) { + return { + ...(_i4.Serializers.instance.serialize<_i5.OkResult<_i5.Shape>>( + $value, + ) + as Map), + r'$type': r'OkResult', + }; + } + if ($value is _i5.ErrResult) { + return { + ...(_i4.Serializers.instance.serialize<_i5.ErrResult>( + $value, + ) + as Map), + r'$type': r'ErrResult', + }; + } + throw _i4.SerializationException( + (StringBuffer('Unknown subtype of ') + ..write(r'Result') + ..write(': ') + ..write($value.runtimeType)) + .toString(), + ); + }, + deserialize: ($serialized) { + if ($serialized[r'$type'] == r'SwappedResult') { + return _i4.Serializers.instance + .deserialize<_i5.SwappedResult>($serialized); + } + if ($serialized[r'$type'] == r'OkResult') { + return _i4.Serializers.instance + .deserialize<_i5.OkResult<_i5.Shape>>($serialized); + } + if ($serialized[r'$type'] == r'ErrResult') { + return _i4.Serializers.instance.deserialize<_i5.ErrResult>( + $serialized, + ); + } + throw _i4.SerializationException( + (StringBuffer('Unknown subtype of ') + ..write(r'Result') + ..write(': ') + ..write($serialized[r'$type'])) + .toString(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.Result, + Map + >( + serialize: ($value) { + if ($value is _i5.SwappedResult<_i5.Shape, String>) { + return { + ...(_i4.Serializers.instance + .serialize<_i5.SwappedResult<_i5.Shape, String>>($value) + as Map), + r'$type': r'SwappedResult', + }; + } + if ($value is _i5.OkResult) { + return { + ...(_i4.Serializers.instance.serialize<_i5.OkResult>( + $value, + ) + as Map), + r'$type': r'OkResult', + }; + } + if ($value is _i5.ErrResult<_i5.Shape>) { + return { + ...(_i4.Serializers.instance.serialize<_i5.ErrResult<_i5.Shape>>( + $value, + ) + as Map), + r'$type': r'ErrResult', + }; + } + throw _i4.SerializationException( + (StringBuffer('Unknown subtype of ') + ..write(r'Result') + ..write(': ') + ..write($value.runtimeType)) + .toString(), + ); + }, + deserialize: ($serialized) { + if ($serialized[r'$type'] == r'SwappedResult') { + return _i4.Serializers.instance + .deserialize<_i5.SwappedResult<_i5.Shape, String>>($serialized); + } + if ($serialized[r'$type'] == r'OkResult') { + return _i4.Serializers.instance.deserialize<_i5.OkResult>( + $serialized, + ); + } + if ($serialized[r'$type'] == r'ErrResult') { + return _i4.Serializers.instance + .deserialize<_i5.ErrResult<_i5.Shape>>($serialized); + } + throw _i4.SerializationException( + (StringBuffer('Unknown subtype of ') + ..write(r'Result') + ..write(': ') + ..write($serialized[r'$type'])) + .toString(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.Shape, Map>( + serialize: ($value) { + if ($value is _i5.Circle) { + return { + ...(_i4.Serializers.instance.serialize<_i5.Circle>($value) + as Map), + r'$type': r'Circle', + }; + } + if ($value is _i5.Rectangle) { + return { + ...(_i4.Serializers.instance.serialize<_i5.Rectangle>($value) + as Map), + r'$type': r'Rectangle', + }; + } + throw _i4.SerializationException( + (StringBuffer('Unknown subtype of ') + ..write(r'Shape') + ..write(': ') + ..write($value.runtimeType)) + .toString(), + ); + }, + deserialize: ($serialized) { + if ($serialized[r'$type'] == r'Circle') { + return _i4.Serializers.instance.deserialize<_i5.Circle>( + $serialized, + ); + } + if ($serialized[r'$type'] == r'Rectangle') { + return _i4.Serializers.instance.deserialize<_i5.Rectangle>( + $serialized, + ); + } + throw _i4.SerializationException( + (StringBuffer('Unknown subtype of ') + ..write(r'Shape') + ..write(': ') + ..write($serialized[r'$type'])) + .toString(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.SwappedResult<_i5.Shape, String>, + Map + >( + serialize: + ($value) => { + r'result': _i4.Serializers.instance + .serialize<_i5.Result<_i5.Shape, String>>($value.result), + }, + deserialize: ($serialized) { + return _i5.SwappedResult<_i5.Shape, String>( + _i4.Serializers.instance.deserialize<_i5.Result<_i5.Shape, String>>( + $serialized[r'result'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.SwappedResult, + Map + >( + serialize: + ($value) => { + r'result': _i4.Serializers.instance + .serialize<_i5.Result>($value.result), + }, + deserialize: ($serialized) { + return _i5.SwappedResult( + _i4.Serializers.instance.deserialize<_i5.Result>( + $serialized[r'result'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i12.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.JsonMap, Map>( + serialize: ($value) => $value, + deserialize: ($serialized) { + return _i13.JsonMap(($serialized as Map)); + }, + ), + const _i4.TypeToken<_i13.JsonMap>('JsonMap'), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i13.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': SwappedResultTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/typedefs/json.dart b/apps/cli/fixtures/legacy/api/goldens/functions/typedefs/json.dart new file mode 100644 index 000000000..6fa1cdb0d --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/typedefs/json.dart @@ -0,0 +1,1687 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i9; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/typedefs.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i10; +import 'package:celest_core/src/serialization/json_value.dart' as _i11; +import 'package:shelf/shelf.dart' as _i2; + +final class JsonTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'json'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = await _i3.json( + (request[r'json'] as Map), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(response), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i9.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i10.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i9.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i10.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i11.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': JsonTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/typedefs/mixedJson.dart b/apps/cli/fixtures/legacy/api/goldens/functions/typedefs/mixedJson.dart new file mode 100644 index 000000000..60e772367 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/typedefs/mixedJson.dart @@ -0,0 +1,1687 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i9; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/typedefs.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i10; +import 'package:celest_core/src/serialization/json_value.dart' as _i11; +import 'package:shelf/shelf.dart' as _i2; + +final class MixedJsonTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'mixedJson'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = await _i3.mixedJson( + (request[r'json'] as Map), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(response), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i9.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i10.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i9.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i10.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i11.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': MixedJsonTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/typedefs/nullableJson.dart b/apps/cli/fixtures/legacy/api/goldens/functions/typedefs/nullableJson.dart new file mode 100644 index 000000000..6d2ffa192 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/typedefs/nullableJson.dart @@ -0,0 +1,1687 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i9; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/typedefs.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i10; +import 'package:celest_core/src/serialization/json_value.dart' as _i11; +import 'package:shelf/shelf.dart' as _i2; + +final class NullableJsonTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'nullableJson'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = await _i3.nullableJson( + (request[r'json'] as Map?), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(response), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i9.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i10.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i9.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i10.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i11.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': NullableJsonTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/goldens/functions/typedefs/portfolio.dart b/apps/cli/fixtures/legacy/api/goldens/functions/typedefs/portfolio.dart new file mode 100644 index 000000000..60a207168 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/goldens/functions/typedefs/portfolio.dart @@ -0,0 +1,1700 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/typedefs.dart' as _i5; +import 'package:celest_backend/src/functions/typedefs.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class PortfolioTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'portfolio'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = await _i3.portfolio( + _i4.Serializers.instance.deserialize<_i5.Portfolio>( + request[r'portfolio'], + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.Portfolio>(response), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.Portfolio, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i5.Portfolio.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': PortfolioTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/api/lib/exceptions/demo.dart b/apps/cli/fixtures/legacy/api/lib/exceptions/demo.dart new file mode 100644 index 000000000..1fbccce65 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/lib/exceptions/demo.dart @@ -0,0 +1,8 @@ +class BadNameException implements Exception { + const BadNameException(this.message); + + final String message; + + @override + String toString() => 'BadNameException: $message'; +} diff --git a/apps/cli/fixtures/legacy/api/lib/exceptions/exceptions.dart b/apps/cli/fixtures/legacy/api/lib/exceptions/exceptions.dart new file mode 100644 index 000000000..0c0a3715f --- /dev/null +++ b/apps/cli/fixtures/legacy/api/lib/exceptions/exceptions.dart @@ -0,0 +1,82 @@ +import 'package:celest_backend/models/sealed_classes.dart'; +import 'package:celest_core/celest_core.dart'; + +final class CustomException implements Exception { + final String message = 'This is a custom exception'; + final JsonMap additionalInfo = JsonMap({ + 'hello': 'world', + }); + + @override + String toString() => 'CustomException: $message'; +} + +final class CustomExceptionToFromJson extends CustomException { + CustomExceptionToFromJson(); + + CustomExceptionToFromJson.fromJson(Map json) { + json.remove('message'); + this.additionalInfo.addAll(json); + } + + Map toJson() => { + 'message': message, + ...additionalInfo, + 'another': 'value', + }; +} + +final class CustomError extends Error { + final String message = 'This is a custom error'; + final JsonMap additionalInfo = JsonMap({ + 'hello': 'world', + }); + + @override + String toString() => 'CustomError: $message'; +} + +final class CustomErrorToFromJson extends CustomError { + CustomErrorToFromJson(); + + CustomErrorToFromJson.fromJson(Map json) { + json.remove('message'); + this.additionalInfo.addAll(json); + } + + Map toJson() => { + 'message': message, + ...additionalInfo, + 'another': 'value', + }; +} + +final class CustomErrorWithStackTrace extends Error { + CustomErrorWithStackTrace({ + StackTrace? stackTrace, + }) : stackTrace = stackTrace ?? StackTrace.empty; + + @override + final StackTrace stackTrace; + + final String message = 'This is a custom error'; + final Map additionalInfo = { + 'hello': 'world', + }; + + @override + String toString() => 'CustomError: $message'; +} + +sealed class ShapeException { + const ShapeException(); +} + +final class BadShapeException extends ShapeException { + final Shape shape; + + BadShapeException(this.shape); + + @override + String toString() => 'Bad shape: ($shape)'; +} diff --git a/apps/cli/fixtures/legacy/api/lib/exceptions/overrides.dart b/apps/cli/fixtures/legacy/api/lib/exceptions/overrides.dart new file mode 100644 index 000000000..1370f05a0 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/lib/exceptions/overrides.dart @@ -0,0 +1,6 @@ +import 'package:celest/celest.dart'; +import 'package:_common/_common.dart' as common; + +@customOverride +extension type const OverriddenException(common.OverriddenException _) + implements common.OverriddenException {} diff --git a/apps/cli/fixtures/legacy/api/lib/fix_data/v1_migration.yaml b/apps/cli/fixtures/legacy/api/lib/fix_data/v1_migration.yaml new file mode 100644 index 000000000..84cb5da56 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/lib/fix_data/v1_migration.yaml @@ -0,0 +1,13 @@ +# Generated by Celest. Do not modify. +version: 1 +transforms: + - title: "Updates the import of the Celest client" + date: 2024-10-06 + element: + uris: ["client.dart"] + variable: celest + changes: + - kind: replacedBy + newElement: + uris: ["package:api_client/api_client.dart"] + variable: celest diff --git a/apps/cli/fixtures/legacy/api/lib/models/classes.dart b/apps/cli/fixtures/legacy/api/lib/models/classes.dart new file mode 100644 index 000000000..0e2469745 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/lib/models/classes.dart @@ -0,0 +1,130 @@ +class EmptySuper {} + +class Empty extends EmptySuper {} + +class SuperFields { + SuperFields(this.superField); + + final String superField; +} + +class Fields extends SuperFields { + Fields(super.superField, this.field); + + final String field; +} + +class NamedFields extends SuperFields { + NamedFields({ + required String superField, + required this.field, + }) : super(superField); + + final String field; +} + +class MixedFields extends SuperFields { + MixedFields( + super.superField, { + required this.field, + }); + + final String field; +} + +class DefaultValues { + DefaultValues({ + this.field = 'default', + this.nullableField, + this.nullableFieldWithDefault = 'default', + }); + + final String field; + final String? nullableField; + final String? nullableFieldWithDefault; + final String fieldWithoutInitializer = 'default'; +} + +class NestedClass { + NestedClass( + this.fields, + this.nullableFields, + ); + + final Fields fields; + final Fields? nullableFields; +} + +class OnlyFromJson { + OnlyFromJson.fromJson(Map json) + : field = json['field'] as String; + + final String field; +} + +class OnlyToJson { + OnlyToJson(this.field); + + final String field; + + Map toJson() => { + 'field': field, + }; +} + +class OnlyToJsonWithDefaults { + OnlyToJsonWithDefaults([this.field = 'default']); + + final String field; + final String anotherField = 'default'; + + Map toJson() => { + 'field': field, + }; +} + +class FromJsonAndToJson { + FromJsonAndToJson.fromJson(Map json) + : field = json['field'] as String; + + final String field; + + Map toJson() => { + 'field': field, + }; +} + +class NonMapToJson { + NonMapToJson(this.field); + + final String field; + + String toJson() => field; +} + +class NonMapToJsonWithDefaults { + NonMapToJsonWithDefaults([this.field = 'default']); + + final String field; + final String anotherField = 'default'; + + String toJson() => field; +} + +class NonMapFromAndToJson { + NonMapFromAndToJson.fromJson(this.field); + + final String field; + + String toJson() => field; +} + +class FromJsonStatic { + const FromJsonStatic(this.field); + + static FromJsonStatic fromJson(String field) => FromJsonStatic(field); + + final String field; + + String toJson() => field; +} diff --git a/apps/cli/fixtures/legacy/api/lib/models/cycles.dart b/apps/cli/fixtures/legacy/api/lib/models/cycles.dart new file mode 100644 index 000000000..c646c375f --- /dev/null +++ b/apps/cli/fixtures/legacy/api/lib/models/cycles.dart @@ -0,0 +1,39 @@ +sealed class Node { + const Node(this.name); + + final String name; + List get children; +} + +class Parent extends Node { + const Parent(super.name, this.children); + + final List children; +} + +class Child extends Node { + const Child(super.name); + + @override + List get children => const []; +} + +class SelfReferencing { + const SelfReferencing({ + this.value, + this.wrapper, + required this.list, + }); + + final SelfReferencing? value; + final SelfReferencingWrapper? wrapper; + final List list; +} + +class SelfReferencingWrapper { + const SelfReferencingWrapper({ + required this.value, + }); + + final SelfReferencing value; +} diff --git a/apps/cli/fixtures/legacy/api/lib/models/demo.dart b/apps/cli/fixtures/legacy/api/lib/models/demo.dart new file mode 100644 index 000000000..c22ad3180 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/lib/models/demo.dart @@ -0,0 +1,5 @@ +class Person { + const Person({required this.name}); + + final String name; +} diff --git a/apps/cli/fixtures/legacy/api/lib/models/exceptions.dart b/apps/cli/fixtures/legacy/api/lib/models/exceptions.dart new file mode 100644 index 000000000..eeed3774a --- /dev/null +++ b/apps/cli/fixtures/legacy/api/lib/models/exceptions.dart @@ -0,0 +1,9 @@ +enum SupportedExceptionType { + Exception, + FormatException, +} + +enum SupportedErrorType { + Error, + ArgumentError, +} diff --git a/apps/cli/fixtures/legacy/api/lib/models/extension_types.dart b/apps/cli/fixtures/legacy/api/lib/models/extension_types.dart new file mode 100644 index 000000000..dae241818 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/lib/models/extension_types.dart @@ -0,0 +1,133 @@ +extension type StringX(String s) {} +extension type StringXImpl(String s) implements String {} +extension type StringXToFromJson(String s) { + StringXToFromJson.fromJson(this.s); + + String toJson() => String.fromCharCodes(s.codeUnits.reversed); +} +extension type StringXToJson(String s) { + String toJson() => String.fromCharCodes(s.codeUnits.reversed); +} +extension type StringXToJsonImpl(String s) implements String { + String toJson() => String.fromCharCodes(s.codeUnits.reversed); +} +extension type StringXFromJson(String s) { + StringXFromJson.fromJson(String s) + : s = String.fromCharCodes(s.codeUnits.reversed); +} +extension type StringXFromJsonImpl(String s) implements String { + StringXFromJsonImpl.fromJson(String s) + : s = String.fromCharCodes(s.codeUnits.reversed); +} +extension type StringXFromJsonStatic(String s) { + static StringXFromJsonStatic fromJson(String s) => + StringXFromJsonStatic(String.fromCharCodes(s.codeUnits.reversed)); +} +extension type StringXPrivateField(String _) {} +extension type StringXPrivateFieldImpl(String _) implements String {} +extension type StringXPrivateCtor._(String s) {} +extension type StringXPrivateCtorImpl._(String s) implements String {} + +class Value { + const Value(this.value); + + factory Value.fromJson(String value) => Value(value); + + final String value; + + String toJson() => value; +} + +extension type const ValueX(Value v) {} +extension type const ValueXImpl(Value v) implements Value {} +extension type const ValueXToFromJson(Value v) { + ValueXToFromJson.fromJson(String value) : v = Value('${value}FromJson'); + + String toJson() => '${v.value}ToJson'; +} +extension type const ValueXToJson(Value v) { + Map toJson() => {'value': '${v.value}ToJson'}; +} +extension type const ValueXToJsonImpl(Value v) implements Value { + String toJson() => '${v.value}ToJson'; +} +extension type const ValueXFromJson(Value v) { + ValueXFromJson.fromJson(Map json) + : v = Value('${json['value']}FromJson'); +} +extension type const ValueXFromJsonImpl(Value v) implements Value { + ValueXFromJsonImpl.fromJson(String value) : v = Value('${value}FromJson'); + + String toJson() => v.toJson(); +} +extension type const ValueXFromJsonStatic(Value v) { + static ValueXFromJsonStatic fromJson(Map json) => + ValueXFromJsonStatic(Value('${json['value']}FromJson')); +} + +enum Color { + red, + green, + blue; + + factory Color.fromJson(String value) => switch (value) { + 'r' => red, + 'g' => green, + 'b' => blue, + _ => throw ArgumentError.value(value, 'value', 'Invalid color'), + }; + + String toJson() => switch (this) { + red => 'r', + green => 'g', + blue => 'b', + }; +} + +extension type const ColorX(Color c) {} +extension type const ColorXImpl(Color c) implements Color {} +extension type const ColorXToFromJson(Color c) { + ColorXToFromJson.fromJson(String value) + : c = switch (value) { + 'RED' => Color.red, + 'GREEN' => Color.green, + 'BLUE' => Color.blue, + _ => throw ArgumentError.value(value, 'value', 'Invalid color'), + }; + + String toJson() => c.name.toUpperCase(); +} +extension type const ColorXToJson(Color c) { + String toJson() => c.name.toUpperCase(); +} +extension type const ColorXToJsonImpl(Color c) implements Color { + String toJson() => c.name.toUpperCase(); +} +extension type const ColorXFromJson(Color c) { + ColorXFromJson.fromJson(String value) + : c = switch (value) { + 'RED' => Color.red, + 'GREEN' => Color.green, + 'BLUE' => Color.blue, + _ => throw ArgumentError.value(value, 'value', 'Invalid color'), + }; +} +extension type const ColorXFromJsonImpl(Color c) implements Color { + ColorXFromJsonImpl.fromJson(String value) + : c = switch (value) { + 'RED' => Color.red, + 'GREEN' => Color.green, + 'BLUE' => Color.blue, + _ => throw ArgumentError.value(value, 'value', 'Invalid color'), + }; + + String toJson() => c.toJson(); +} +extension type const ColorXFromJsonStatic(Color c) { + static ColorXFromJsonStatic fromJson(String value) => switch (value) { + 'RED' => Color.red, + 'GREEN' => Color.green, + 'BLUE' => Color.blue, + _ => throw ArgumentError.value(value, 'value', 'Invalid color'), + } as ColorXFromJsonStatic; +} diff --git a/apps/cli/fixtures/legacy/api/lib/models/generic_wrappers.dart b/apps/cli/fixtures/legacy/api/lib/models/generic_wrappers.dart new file mode 100644 index 000000000..de84e1e63 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/lib/models/generic_wrappers.dart @@ -0,0 +1,38 @@ +import 'package:celest_backend/models/parameter_types.dart'; +import 'package:fast_immutable_collections/fast_immutable_collections.dart'; + +class GenericWrappers { + GenericWrappers({ + required this.listOfString, + required this.listOfUri, + required this.listOfSimpleClass, + required this.listOfListOfString, + required this.listOfListOfUri, + required this.listOfListOfSimpleClass, + required this.mapOfString, + required this.mapOfUri, + required this.mapOfSimpleClass, + required this.mapOfListOfString, + required this.mapOfListOfUri, + required this.mapOfListOfSimpleClass, + required this.mapOfMapOfString, + required this.mapOfMapOfUri, + required this.mapOfMapOfSimpleClass, + }); + + final IList listOfString; + final IList listOfUri; + final IList listOfSimpleClass; + final IList> listOfListOfString; + final IList> listOfListOfUri; + final IList> listOfListOfSimpleClass; + final IMap mapOfString; + final IMap mapOfUri; + final IMap mapOfSimpleClass; + final IMap> mapOfListOfString; + final IMap> mapOfListOfUri; + final IMap> mapOfListOfSimpleClass; + final IMap> mapOfMapOfString; + final IMap> mapOfMapOfUri; + final IMap> mapOfMapOfSimpleClass; +} diff --git a/apps/cli/fixtures/legacy/api/lib/models/metadata.dart b/apps/cli/fixtures/legacy/api/lib/models/metadata.dart new file mode 100644 index 000000000..db52b6021 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/lib/models/metadata.dart @@ -0,0 +1,52 @@ +class MyAnnotation { + const MyAnnotation.create(this.positional, {required this.named}); + + final String positional; + final String named; +} + +enum LiteralEnum { a, b, c } + +class Literals { + const Literals({ + required this.string, + required this.intValue, + required this.doubleValue, + required this.boolValue, + required this.list, + required this.map, + required this.enumValue, + required this.recordValue, + }); + + final String string; + final int intValue; + final double doubleValue; + final bool boolValue; + final List list; + final Map map; + final LiteralEnum enumValue; + final ({String a, String b, String c}) recordValue; +} + +class _NotExportable { + const _NotExportable(); +} + +class Exportable { + const Exportable(); + + static const instance = Exportable(); +} + +const exportable = Exportable(); +const notExportable = _NotExportable(); + +class Serializable { + const Serializable([this.type]); + const Serializable.forType(String this.type); + + static const string = Serializable.forType('String'); + + final String? type; +} diff --git a/apps/cli/fixtures/legacy/api/lib/models/overrides.dart b/apps/cli/fixtures/legacy/api/lib/models/overrides.dart new file mode 100644 index 000000000..691cd69a2 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/lib/models/overrides.dart @@ -0,0 +1,21 @@ +import 'package:celest/celest.dart'; +import 'package:_common/_common.dart' as common; + +@customOverride +extension type const NestedParent(common.NestedParent _) + implements common.NestedParent {} + +@customOverride +extension type const NestedChild(common.NestedChild _child) + implements common.NestedChild { + NestedChild.fromJson(Map json) + : this(common.NestedChild(json['name'] as String)); + + Map toJson() => {'name': _child.value}; +} + +final class NestedGrandparent { + const NestedGrandparent(this.parent); + + final common.NestedParent parent; +} diff --git a/apps/cli/fixtures/legacy/api/lib/models/parameter_types.dart b/apps/cli/fixtures/legacy/api/lib/models/parameter_types.dart new file mode 100644 index 000000000..7fdcdcc65 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/lib/models/parameter_types.dart @@ -0,0 +1,358 @@ +import 'dart:typed_data'; + +import 'package:celest_core/celest_core.dart'; + +enum MyEnum { a, b, c } + +typedef SimpleStruct = (); + +class SimpleClass { + const SimpleClass(); + factory SimpleClass.fromJson(Map json) => SimpleClass(); + Map toJson() => {}; +} + +typedef ComplexStruct = ({ + String aString, + int anInt, + double aDouble, + bool aBool, + MyEnum anEnum, + Null aNull, + BigInt aBigInt, + DateTime aDateTime, + Duration aDuration, + RegExp aRegExp, + StackTrace aStackTrace, + Uri aUri, + UriData aUriData, + Uint8List aUint8List, + SimpleStruct aSimpleStruct, + SimpleClass aSimpleClass, + Iterable anIterableOfSimpleClass, + List aListOfString, + List aListOfInt, + List aListOfDouble, + List aListOfBool, + List aListOfEnum, + List aListOfNull, + List aListOfBigInt, + List aListOfDateTime, + List aListOfDuration, + List aListOfRegExp, + List aListOfStackTrace, + List aListOfUri, + List aListOfUriData, + List aListOfUint8List, + List aListOfSimpleStruct, + List aListOfSimpleClass, + Map aMapOfString, + Map aMapOfInt, + Map aMapOfDouble, + Map aMapOfBool, + Map aMapOfEnum, + Map aMapOfNull, + Map aMapOfBigInt, + Map aMapOfDateTime, + Map aMapOfDuration, + Map aMapOfRegExp, + Map aMapOfStackTrace, + Map aMapOfUri, + Map aMapOfUriData, + Map aMapOfUint8List, + Map aMapOfSimpleStruct, + Map aMapOfSimpleClass, +}); + +class ComplexClass { + final String aString; + final int anInt; + final double aDouble; + final bool aBool; + final MyEnum anEnum; + final Null aNull; + final BigInt aBigInt; + final DateTime aDateTime; + final Duration aDuration; + final RegExp aRegExp; + final StackTrace aStackTrace; + final Uri aUri; + final UriData aUriData; + final Uint8List aUint8List; + final SimpleStruct aSimpleStruct; + final SimpleClass aSimpleClass; + final Iterable anIterableOfSimpleClass; + final List aListOfString; + final List aListOfInt; + final List aListOfDouble; + final List aListOfBool; + final List aListOfEnum; + final List aListOfNull; + final List aListOfBigInt; + final List aListOfDateTime; + final List aListOfDuration; + final List aListOfRegExp; + final List aListOfStackTrace; + final List aListOfUri; + final List aListOfUriData; + final List aListOfUint8List; + final List aListOfSimpleStruct; + final List aListOfSimpleClass; + final Map aMapOfString; + final Map aMapOfInt; + final Map aMapOfDouble; + final Map aMapOfBool; + final Map aMapOfEnum; + final Map aMapOfNull; + final Map aMapOfBigInt; + final Map aMapOfDateTime; + final Map aMapOfDuration; + final Map aMapOfRegExp; + final Map aMapOfStackTrace; + final Map aMapOfUri; + final Map aMapOfUriData; + final Map aMapOfUint8List; + final Map aMapOfSimpleStruct; + final Map aMapOfSimpleClass; + + const ComplexClass({ + required this.aString, + required this.anInt, + required this.aDouble, + required this.aBool, + required this.anEnum, + required this.aNull, + required this.aBigInt, + required this.aDateTime, + required this.aDuration, + required this.aRegExp, + required this.aStackTrace, + required this.aUri, + required this.aUriData, + required this.aUint8List, + required this.aSimpleStruct, + required this.aSimpleClass, + required this.anIterableOfSimpleClass, + required this.aListOfString, + required this.aListOfInt, + required this.aListOfDouble, + required this.aListOfBool, + required this.aListOfEnum, + required this.aListOfNull, + required this.aListOfBigInt, + required this.aListOfDateTime, + required this.aListOfDuration, + required this.aListOfRegExp, + required this.aListOfStackTrace, + required this.aListOfUri, + required this.aListOfUriData, + required this.aListOfUint8List, + required this.aListOfSimpleStruct, + required this.aListOfSimpleClass, + required this.aMapOfString, + required this.aMapOfInt, + required this.aMapOfDouble, + required this.aMapOfBool, + required this.aMapOfEnum, + required this.aMapOfNull, + required this.aMapOfBigInt, + required this.aMapOfDateTime, + required this.aMapOfDuration, + required this.aMapOfRegExp, + required this.aMapOfStackTrace, + required this.aMapOfUri, + required this.aMapOfUriData, + required this.aMapOfUint8List, + required this.aMapOfSimpleStruct, + required this.aMapOfSimpleClass, + }); + + factory ComplexClass.fromJson(Map json) => ComplexClass( + aString: json['aString'] as String, + anInt: json['anInt'] as int, + aDouble: json['aDouble'] as double, + aBool: json['aBool'] as bool, + anEnum: MyEnum.values.byName(json['anEnum'] as String), + aNull: json['aNull'] as Null, + aBigInt: Serializers.instance.deserialize(json['aBigInt']), + aDateTime: + Serializers.instance.deserialize(json['aDateTime']), + aDuration: + Serializers.instance.deserialize(json['aDuration']), + aRegExp: Serializers.instance.deserialize(json['aRegExp']), + aStackTrace: + Serializers.instance.deserialize(json['aStackTrace']), + aUri: Serializers.instance.deserialize(json['aUri']), + aUriData: Serializers.instance.deserialize(json['aUriData']), + aUint8List: + Serializers.instance.deserialize(json['aUint8List']), + aSimpleStruct: (), + aSimpleClass: SimpleClass.fromJson(json['aSimpleStruct']), + anIterableOfSimpleClass: + (json['anIterableOfSimpleClass'] as List) + .map((e) => SimpleClass.fromJson(e)) + .toList(), + aListOfString: (json['aListOfString'] as List) + .map((e) => e as String) + .toList(), + aListOfInt: + (json['aListOfInt'] as List).map((e) => e as int).toList(), + aListOfDouble: (json['aListOfDouble'] as List) + .map((e) => e as double) + .toList(), + aListOfBool: (json['aListOfBool'] as List) + .map((e) => e as bool) + .toList(), + aListOfEnum: (json['aListOfEnum'] as List) + .map((e) => MyEnum.values.byName(e as String)) + .toList(), + aListOfNull: (json['aListOfNull'] as List) + .map((e) => e as Null) + .toList(), + aListOfBigInt: (json['aListOfBigInt'] as List) + .map((e) => Serializers.instance.deserialize(e)) + .toList(), + aListOfDateTime: (json['aListOfDateTime'] as List) + .map((e) => Serializers.instance.deserialize(e)) + .toList(), + aListOfDuration: (json['aListOfDuration'] as List) + .map((e) => Serializers.instance.deserialize(e)) + .toList(), + aListOfRegExp: (json['aListOfRegExp'] as List) + .map((e) => Serializers.instance.deserialize(e)) + .toList(), + aListOfStackTrace: (json['aListOfStackTrace'] as List) + .map((e) => Serializers.instance.deserialize(e)) + .toList(), + aListOfUri: (json['aListOfUri'] as List) + .map((e) => Serializers.instance.deserialize(e)) + .toList(), + aListOfUriData: (json['aListOfUriData'] as List) + .map((e) => Serializers.instance.deserialize(e)) + .toList(), + aListOfUint8List: (json['aListOfUint8List'] as List) + .map((e) => Serializers.instance.deserialize(e)) + .toList(), + aListOfSimpleStruct: (json['aListOfSimpleStruct'] as List) + .map((e) => ()) + .toList(), + aListOfSimpleClass: (json['aListOfSimpleClass'] as List) + .map((e) => SimpleClass.fromJson(e)) + .toList(), + aMapOfString: (json['aMapOfString'] as Map) + .map((k, e) => MapEntry(k, e as String)), + aMapOfInt: (json['aMapOfInt'] as Map) + .map((k, e) => MapEntry(k, e as int)), + aMapOfDouble: (json['aMapOfDouble'] as Map) + .map((k, e) => MapEntry(k, e as double)), + aMapOfBool: (json['aMapOfBool'] as Map) + .map((k, e) => MapEntry(k, e as bool)), + aMapOfEnum: (json['aMapOfEnum'] as Map) + .map((k, e) => MapEntry(k, MyEnum.values.byName(e as String))), + aMapOfNull: (json['aMapOfNull'] as Map) + .map((k, e) => MapEntry(k, e as Null)), + aMapOfBigInt: (json['aMapOfBigInt'] as Map).map( + (k, e) => MapEntry(k, Serializers.instance.deserialize(e))), + aMapOfDateTime: (json['aMapOfDateTime'] as Map).map( + (k, e) => + MapEntry(k, Serializers.instance.deserialize(e))), + aMapOfDuration: (json['aMapOfDuration'] as Map).map( + (k, e) => + MapEntry(k, Serializers.instance.deserialize(e))), + aMapOfRegExp: (json['aMapOfRegExp'] as Map).map( + (k, e) => MapEntry(k, Serializers.instance.deserialize(e))), + aMapOfStackTrace: (json['aMapOfStackTrace'] as Map) + .map((k, e) => + MapEntry(k, Serializers.instance.deserialize(e))), + aMapOfUri: (json['aMapOfUri'] as Map).map( + (k, e) => MapEntry(k, Serializers.instance.deserialize(e))), + aMapOfUriData: (json['aMapOfUriData'] as Map).map( + (k, e) => + MapEntry(k, Serializers.instance.deserialize(e))), + aMapOfUint8List: (json['aMapOfUint8List'] as Map).map( + (k, e) => + MapEntry(k, Serializers.instance.deserialize(e))), + aMapOfSimpleStruct: (json['aMapOfSimpleStruct'] as Map) + .map((k, e) => MapEntry(k, ())), + aMapOfSimpleClass: (json['aMapOfSimpleClass'] as Map) + .map((k, e) => MapEntry(k, SimpleClass.fromJson(e))), + ); + + Map toJson() => { + 'aString': aString, + 'anInt': anInt, + 'aDouble': aDouble, + 'aBool': aBool, + 'anEnum': anEnum.name, + 'aNull': aNull, + 'aBigInt': Serializers.instance.serialize(aBigInt), + 'aDateTime': Serializers.instance.serialize(aDateTime), + 'aDuration': Serializers.instance.serialize(aDuration), + 'aRegExp': Serializers.instance.serialize(aRegExp), + 'aStackTrace': Serializers.instance.serialize(aStackTrace), + 'aUri': Serializers.instance.serialize(aUri), + 'aUriData': Serializers.instance.serialize(aUriData), + 'aUint8List': Serializers.instance.serialize(aUint8List), + 'aSimpleStruct': (), + 'aSimpleClass': aSimpleClass.toJson(), + 'anIterableOfSimpleClass': + anIterableOfSimpleClass.map((e) => e.toJson()).toList(), + 'aListOfString': aListOfString, + 'aListOfInt': aListOfInt, + 'aListOfDouble': aListOfDouble, + 'aListOfBool': aListOfBool, + 'aListOfEnum': aListOfEnum.map((e) => e.name).toList(), + 'aListOfNull': aListOfNull, + 'aListOfBigInt': aListOfBigInt + .map((e) => Serializers.instance.serialize(e)) + .toList(), + 'aListOfDateTime': aListOfDateTime + .map((e) => Serializers.instance.serialize(e)) + .toList(), + 'aListOfDuration': aListOfDuration + .map((e) => Serializers.instance.serialize(e)) + .toList(), + 'aListOfRegExp': aListOfRegExp + .map((e) => Serializers.instance.serialize(e)) + .toList(), + 'aListOfStackTrace': aListOfStackTrace + .map((e) => Serializers.instance.serialize(e)) + .toList(), + 'aListOfUri': + aListOfUri.map((e) => Serializers.instance.serialize(e)).toList(), + 'aListOfUriData': aListOfUriData + .map((e) => Serializers.instance.serialize(e)) + .toList(), + 'aListOfUint8List': aListOfUint8List + .map((e) => Serializers.instance.serialize(e)) + .toList(), + 'aListOfSimpleStruct': aListOfSimpleStruct.map((e) => ()).toList(), + 'aListOfSimpleClass': + aListOfSimpleClass.map((e) => e.toJson()).toList(), + 'aMapOfString': aMapOfString, + 'aMapOfInt': aMapOfInt, + 'aMapOfDouble': aMapOfDouble, + 'aMapOfBool': aMapOfBool, + 'aMapOfEnum': aMapOfEnum.map((k, e) => MapEntry(k, e.name)), + 'aMapOfNull': aMapOfNull, + 'aMapOfBigInt': aMapOfBigInt + .map((k, e) => MapEntry(k, Serializers.instance.serialize(e))), + 'aMapOfDateTime': aMapOfDateTime + .map((k, e) => MapEntry(k, Serializers.instance.serialize(e))), + 'aMapOfDuration': aMapOfDuration + .map((k, e) => MapEntry(k, Serializers.instance.serialize(e))), + 'aMapOfRegExp': aMapOfRegExp + .map((k, e) => MapEntry(k, Serializers.instance.serialize(e))), + 'aMapOfStackTrace': aMapOfStackTrace + .map((k, e) => MapEntry(k, Serializers.instance.serialize(e))), + 'aMapOfUri': aMapOfUri + .map((k, e) => MapEntry(k, Serializers.instance.serialize(e))), + 'aMapOfUriData': aMapOfUriData + .map((k, e) => MapEntry(k, Serializers.instance.serialize(e))), + 'aMapOfUint8List': aMapOfUint8List + .map((k, e) => MapEntry(k, Serializers.instance.serialize(e))), + 'aMapOfSimpleStruct': aMapOfSimpleStruct.map((k, e) => MapEntry(k, ())), + 'aMapOfSimpleClass': + aMapOfSimpleClass.map((k, e) => MapEntry(k, e.toJson())), + }; +} diff --git a/apps/cli/fixtures/legacy/api/lib/models/records.dart b/apps/cli/fixtures/legacy/api/lib/models/records.dart new file mode 100644 index 000000000..124275383 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/lib/models/records.dart @@ -0,0 +1,8 @@ +typedef NamedFieldsRecord = ({ + String field, + String anotherField, +}); + +typedef Nested = ({NamedFieldsRecord namedFields}); + +typedef NullableNested = ({NamedFieldsRecord? namedFields}); diff --git a/apps/cli/fixtures/legacy/api/lib/models/sealed_classes.dart b/apps/cli/fixtures/legacy/api/lib/models/sealed_classes.dart new file mode 100644 index 000000000..0c666554f --- /dev/null +++ b/apps/cli/fixtures/legacy/api/lib/models/sealed_classes.dart @@ -0,0 +1,220 @@ +import 'dart:math'; + +sealed class Shape { + double get area; +} + +class Rectangle extends Shape { + Rectangle(this.width, this.height); + + final double width; + final double height; + + @override + double get area => width * height; + + @override + String toString() => 'Rectangle: $width x $height'; +} + +class Circle extends Shape { + Circle(this.radius); + + final double radius; + + @override + double get area => pi * radius * radius; + + @override + String toString() => 'Circle: $radius'; +} + +sealed class ShapeWithInheritedCustomJson { + const ShapeWithInheritedCustomJson(); + + factory ShapeWithInheritedCustomJson.fromJson(Map json) { + final type = json[r'$type'] as String; + final size = json['size'] as Map; + if (type == 'RectangleWithInheritedCustomJson') { + return RectangleWithInheritedCustomJson( + (size['width'] as num).toDouble(), + (size['height'] as num).toDouble(), + ); + } else if (type == 'CircleWithInheritedCustomJson') { + return CircleWithInheritedCustomJson( + (size['radius'] as num).toDouble(), + ); + } else { + throw ArgumentError.value( + json, + 'json', + 'Unknown type: $type', + ); + } + } + + Map toJson() => switch (this) { + RectangleWithInheritedCustomJson(:final width, :final height) => { + 'size': { + 'width': width, + 'height': height, + }, + }, + CircleWithInheritedCustomJson(:final radius) => { + 'size': { + 'radius': radius, + }, + }, + }; +} + +class RectangleWithInheritedCustomJson extends ShapeWithInheritedCustomJson { + RectangleWithInheritedCustomJson(this.width, this.height); + + final double width; + final double height; +} + +class CircleWithInheritedCustomJson extends ShapeWithInheritedCustomJson { + CircleWithInheritedCustomJson(this.radius); + + final double radius; +} + +sealed class ShapeWithCustomJson {} + +class RectangleWithCustomJson extends ShapeWithCustomJson { + RectangleWithCustomJson(this.width, this.height); + + factory RectangleWithCustomJson.fromJson(Map json) { + final size = json['size'] as Map; + return RectangleWithCustomJson( + (size['width'] as num).toDouble(), + (size['height'] as num).toDouble(), + ); + } + + final double width; + final double height; + + Map toJson() => { + 'size': { + 'width': width, + 'height': height, + }, + }; +} + +class CircleWithCustomJson extends ShapeWithCustomJson { + CircleWithCustomJson(this.radius); + + factory CircleWithCustomJson.fromJson(Map json) { + final size = json['size'] as Map; + return CircleWithCustomJson( + (size['radius'] as num).toDouble(), + ); + } + + final double radius; + + Map toJson() => { + 'size': { + 'radius': radius, + }, + }; +} + +sealed class ShapeWithOverriddenCustomJson { + const ShapeWithOverriddenCustomJson(); + + factory ShapeWithOverriddenCustomJson.fromJson(Map json) { + final type = json[r'$type'] as String; + if (type == 'RectangleWithOverriddenCustomJson') { + final size = json['size'] as Map; + return RectangleWithOverriddenCustomJson( + (size['width'] as num).toDouble(), + (size['height'] as num).toDouble(), + ); + } else if (type == 'CircleWithOverriddenCustomJson') { + return CircleWithOverriddenCustomJson.fromJson(json); + } else { + throw ArgumentError.value( + json, + 'json', + 'Unknown type: $type', + ); + } + } + + Map toJson() => switch (this) { + RectangleWithOverriddenCustomJson(:final width, :final height) => { + 'size': { + 'width': width, + 'height': height, + }, + }, + _ => throw StateError('Unknown type: $this'), + }; +} + +class RectangleWithOverriddenCustomJson extends ShapeWithOverriddenCustomJson { + RectangleWithOverriddenCustomJson(this.width, this.height); + + final double width; + final double height; +} + +class CircleWithOverriddenCustomJson extends ShapeWithOverriddenCustomJson { + CircleWithOverriddenCustomJson(this.radius); + + factory CircleWithOverriddenCustomJson.fromJson(Map json) { + final size = json['size'] as Map; + return CircleWithOverriddenCustomJson( + (size['radius'] as num).toDouble(), + ); + } + + final double radius; + + @override + Map toJson() => { + 'size': { + 'radius': radius, + }, + }; +} + +sealed class Result { + const Result(); + + const factory Result.ok(T data) = OkResult; + const factory Result.err(E error) = ErrResult; +} + +// Tests `extends` +final class OkResult extends Result { + const OkResult(this.data); + + final T data; +} + +// Tests `implements` +final class ErrResult implements Result { + const ErrResult(this.error); + + final E error; +} + +// Tests `typedef` (aliased sealed class) +typedef ShapeResult = Result; + +// Tests type parameters are matched up correctly +final class SwappedResult extends Result { + const SwappedResult(this.result); + + final Result result; +} + +final class OkShapeResult extends OkResult { + const OkShapeResult(Shape data) : super(data); +} diff --git a/apps/cli/fixtures/legacy/api/lib/models/typedefs.dart b/apps/cli/fixtures/legacy/api/lib/models/typedefs.dart new file mode 100644 index 000000000..e2d63ea61 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/lib/models/typedefs.dart @@ -0,0 +1,12 @@ +// Repro of https://github.com/celest-dev/celest/issues/53 +typedef Json = Map; + +class Portfolio { + factory Portfolio.fromJson(Json? json) { + return const Portfolio._(); + } + + const Portfolio._(); + + Map toJson() => {}; +} diff --git a/apps/cli/fixtures/legacy/api/lib/src/functions/asserts.dart b/apps/cli/fixtures/legacy/api/lib/src/functions/asserts.dart new file mode 100644 index 000000000..bd0f54028 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/lib/src/functions/asserts.dart @@ -0,0 +1,12 @@ +import 'package:celest/celest.dart'; + +/// Tests that asserts are enabled when running the local API. +@cloud +bool assertsEnabled() { + var assertsEnabled = false; + assert(() { + assertsEnabled = true; + return true; + }()); + return assertsEnabled; +} diff --git a/apps/cli/fixtures/legacy/api/lib/src/functions/classes.dart b/apps/cli/fixtures/legacy/api/lib/src/functions/classes.dart new file mode 100644 index 000000000..b02b0d8f7 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/lib/src/functions/classes.dart @@ -0,0 +1,100 @@ +/// Tests that classes with and without explicit fromJson/toJson methods are +/// serializable and deserializable. +library; + +import 'package:celest/celest.dart'; +import 'package:celest_backend/models/classes.dart'; + +@cloud +Empty empty(Empty value) => value; +@cloud +Future asyncEmpty(Empty value) async => value; + +@cloud +Fields fields(Fields value) => value; +@cloud +Future asyncFields(Fields value) async => value; + +@cloud +Fields? nullableFields(Fields? value) => value; +@cloud +Future asyncNullableFields(Fields? value) async => value; + +@cloud +NamedFields namedFields(NamedFields value) => value; +@cloud +Future asyncNamedFields(NamedFields value) async => value; + +@cloud +MixedFields mixedFields(MixedFields value) => value; +@cloud +Future asyncMixedFields(MixedFields value) async => value; + +@cloud +DefaultValues defaultValues(DefaultValues value) => value; +@cloud +Future asyncDefaultValues(DefaultValues value) async => value; + +@cloud +NestedClass nestedClass(NestedClass value) => value; +@cloud +Future asyncNestedClass(NestedClass value) async => value; + +@cloud +OnlyFromJson onlyFromJson(OnlyFromJson value) => value; +@cloud +Future asyncOnlyFromJson(OnlyFromJson value) async => value; + +@cloud +OnlyToJson onlyToJson(OnlyToJson value) => value; +@cloud +Future asyncOnlyToJson(OnlyToJson value) async => value; + +@cloud +OnlyToJsonWithDefaults onlyToJsonWithDefaults( + OnlyToJsonWithDefaults value, +) => + value; +@cloud +Future asyncOnlyToJsonWithDefaults( + OnlyToJsonWithDefaults value, +) async => + value; + +@cloud +FromJsonAndToJson fromAndToJson(FromJsonAndToJson value) => value; +@cloud +Future asyncFromAndToJson( + FromJsonAndToJson value, +) async => + value; + +@cloud +NonMapToJson nonMapToJson(NonMapToJson value) => value; +@cloud +Future asyncNonMapToJson(NonMapToJson value) async => value; + +@cloud +NonMapToJsonWithDefaults nonMapToJsonWithDefaults( + NonMapToJsonWithDefaults value, +) => + value; +@cloud +Future asyncNonMapToJsonWithDefaults( + NonMapToJsonWithDefaults value, +) async => + value; + +@cloud +NonMapFromAndToJson nonMapFromAndToJson( + NonMapFromAndToJson value, +) => + value; +@cloud +Future asyncNonMapFromAndToJson( + NonMapFromAndToJson value, +) async => + value; + +@cloud +FromJsonStatic fromJsonStatic(FromJsonStatic value) => value; diff --git a/apps/cli/fixtures/legacy/api/lib/src/functions/collections.dart b/apps/cli/fixtures/legacy/api/lib/src/functions/collections.dart new file mode 100644 index 000000000..142bc0328 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/lib/src/functions/collections.dart @@ -0,0 +1,28 @@ +/// Tests that collections (e.g. Lists/Maps) can be used as parameter and +/// return types. +library; + +import 'package:celest/celest.dart'; +import 'package:celest_backend/models/parameter_types.dart'; + +@cloud +Future> simpleList(List list) async => list; +@cloud +Future> complexList(List list) async => list; + +@cloud +Future> simpleMap(Map map) async => map; +@cloud +Future> dynamicMap(Map map) async => map; +@cloud +Future> objectMap(Map map) async => map; +@cloud +Future> objectNullableMap( + Map map, +) async => + map; +@cloud +Future> complexMap( + Map map, +) async => + map; diff --git a/apps/cli/fixtures/legacy/api/lib/src/functions/cycles.dart b/apps/cli/fixtures/legacy/api/lib/src/functions/cycles.dart new file mode 100644 index 000000000..5e568d288 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/lib/src/functions/cycles.dart @@ -0,0 +1,67 @@ +/// Tests that some cycles are allowed, e.g. when there is at least one level +/// of indirection. +library; + +import 'package:celest/celest.dart'; +import 'package:celest_backend/models/cycles.dart'; + +@cloud +Node createTree() { + return const Parent( + 'root', + [ + Parent( + 'parentA', + [ + Child('childA'), + Child('childB'), + ], + ), + Parent( + 'parentB', + [ + Child('childC'), + Child('childD'), + ], + ), + ], + ); +} + +@cloud +void printTree(Node node) { + _printTree(node); +} + +void _printTree(Node node, {int indent = 0}) { + print('${' ' * indent}${node.name}'); + for (final child in node.children) { + _printTree(child, indent: indent + 1); + } +} + +// Test different combinations of nullability and cycles. +@cloud +Node combineTrees( + Node tree1, [ + Parent? tree2, + Node? tree3, + List additionalChildren = const [], +]) { + return Parent( + 'root', + [ + tree1, + if (tree2 != null) tree2, + if (tree3 != null) tree3, + ...additionalChildren.nonNulls, + ], + ); +} + +/// Tests that self-referencing is allowed when there is a level +/// of indirection, e.g. nullability, generics, or a wrapper. +@cloud +SelfReferencing selfReferencing(SelfReferencing selfReferencing) { + return selfReferencing; +} diff --git a/apps/cli/fixtures/legacy/api/lib/src/functions/demo.dart b/apps/cli/fixtures/legacy/api/lib/src/functions/demo.dart new file mode 100644 index 000000000..5e9e79657 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/lib/src/functions/demo.dart @@ -0,0 +1,15 @@ +// Cloud functions are top-level Dart functions defined in the `functions/` +// folder of your Celest project. + +import 'package:celest/celest.dart'; +import 'package:celest_backend/exceptions/demo.dart'; +import 'package:celest_backend/models/demo.dart'; + +/// Says hello to a [person]. +@cloud +Future sayHello({required Person person}) async { + if (person.name.isEmpty) { + throw BadNameException('Name cannot be empty'); + } + return 'Hello, ${person.name}!'; +} diff --git a/apps/cli/fixtures/legacy/api/lib/src/functions/exceptions.dart b/apps/cli/fixtures/legacy/api/lib/src/functions/exceptions.dart new file mode 100644 index 000000000..b2cdfa328 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/lib/src/functions/exceptions.dart @@ -0,0 +1,52 @@ +import 'package:celest/celest.dart'; +import 'package:celest_backend/exceptions/exceptions.dart'; +import 'package:celest_backend/models/exceptions.dart'; + +@cloud +void throwsException({ + required SupportedExceptionType type, +}) { + switch (type) { + case SupportedExceptionType.Exception: + throw Exception('Something bad happened'); + case SupportedExceptionType.FormatException: + throw FormatException('Bad format'); + } +} + +@cloud +void throwsError({ + required SupportedErrorType type, +}) { + switch (type) { + case SupportedErrorType.Error: + throw Error(); + case SupportedErrorType.ArgumentError: + throw ArgumentError('Bad argument', 'someArg'); + } +} + +@cloud +void throwsCustomException() { + throw CustomException(); +} + +@cloud +void throwsCustomExceptionToFromJson() { + throw CustomExceptionToFromJson(); +} + +@cloud +void throwsCustomError() { + throw CustomError(); +} + +@cloud +void throwsCustomErrorToFromJson() { + throw CustomErrorToFromJson(); +} + +@cloud +void throwsCustomErrorWithStackTrace() { + throw CustomErrorWithStackTrace(); +} diff --git a/apps/cli/fixtures/legacy/api/lib/src/functions/extension_types.dart b/apps/cli/fixtures/legacy/api/lib/src/functions/extension_types.dart new file mode 100644 index 000000000..72cea3024 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/lib/src/functions/extension_types.dart @@ -0,0 +1,97 @@ +/// Tests that extension types are correctly handled by the analyzer. +library; + +import 'dart:async'; + +import 'package:celest/celest.dart'; +import 'package:celest_backend/models/extension_types.dart'; + +// Basic extension types +@cloud +StringX string(StringX s) => s; +@cloud +FutureOr asyncOrString(StringX s) => s; +@cloud +Future asyncString(StringX s) async => s; + +// Extension type over primitive +@cloud +StringXImpl stringImpl(StringXImpl s) => s; +@cloud +StringXToFromJson stringToFromJson(StringXToFromJson s) => s; +@cloud +StringXToJson stringToJson(StringXToJson s) => s; +@cloud +StringXToJsonImpl stringToJsonImpl(StringXToJsonImpl s) => s; +@cloud +StringXFromJson stringFromJson(StringXFromJson s) => s; +@cloud +StringXFromJsonImpl stringFromJsonImpl(StringXFromJsonImpl s) => s; +@cloud +StringXFromJsonStatic stringFromJsonStatic(StringXFromJsonStatic s) => s; +@cloud +StringXPrivateField stringPrivateField(StringXPrivateField s) => s; +@cloud +StringXPrivateFieldImpl stringPrivateFieldImpl(StringXPrivateFieldImpl s) => s; +@cloud +StringXPrivateCtor stringPrivateCtor(StringXPrivateCtor s) => s; +@cloud +StringXPrivateCtorImpl stringPrivateCtorImpl(StringXPrivateCtorImpl s) => s; + +// Extension type over custom model +@cloud +Value value(Value v) => v; +@cloud +ValueX valueX(ValueX v) => v; +@cloud +ValueXImpl valueXImpl(ValueXImpl v) => v; +@cloud +ValueXToFromJson valueXToFromJson(ValueXToFromJson v) => v; +@cloud +ValueXToJson valueXToJson(ValueXToJson v) => v; +@cloud +ValueXToJsonImpl valueXToJsonImpl(ValueXToJsonImpl v) => v; +@cloud +ValueXFromJson valueXFromJson(ValueXFromJson v) => v; +@cloud +ValueXFromJsonImpl valueXFromJsonImpl(ValueXFromJsonImpl v) => v; +@cloud +ValueXFromJsonStatic valueXFromJsonStatic(ValueXFromJsonStatic v) => v; + +// Enum tests +@cloud +Color color(Color color) => color; +@cloud +ColorX colorX(ColorX color) => color; +@cloud +ColorXImpl colorXImpl(ColorXImpl color) => color; +@cloud +ColorXToFromJson colorXToFromJson(ColorXToFromJson color) => color; +@cloud +ColorXToJson colorXToJson(ColorXToJson color) => color; +@cloud +ColorXToJsonImpl colorXToJsonImpl(ColorXToJsonImpl color) => color; +@cloud +ColorXFromJson colorXFromJson(ColorXFromJson color) => color; +@cloud +ColorXFromJsonImpl colorXFromJsonImpl(ColorXFromJsonImpl color) => color; +@cloud +ColorXFromJsonStatic colorXFromJsonStatic(ColorXFromJsonStatic color) => color; + +// JsonValue tests +@cloud +JsonValue jsonValue(JsonValue value) => value; +@cloud +JsonString jsonString(JsonString value) => value; +@cloud +JsonNum jsonNum(JsonNum value) => value; +@cloud +JsonInt jsonInt(JsonInt value) => value; +@cloud +JsonDouble jsonDouble(JsonDouble value) => value; +@cloud +JsonBool jsonBool(JsonBool value) => value; +@cloud +JsonList jsonList(JsonList value) => value; +@cloud +JsonMap jsonMap(JsonMap value) => value; diff --git a/apps/cli/fixtures/legacy/api/lib/src/functions/generic_wrappers.dart b/apps/cli/fixtures/legacy/api/lib/src/functions/generic_wrappers.dart new file mode 100644 index 000000000..a5a7168e6 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/lib/src/functions/generic_wrappers.dart @@ -0,0 +1,52 @@ +/// Tests that classes which wrap generic types are generated correctly when +/// those generic types follow the specifications of `json_serializable`, e.g. +/// having a `toJson` method with function parameters for mapping the +/// underlying types to JSON (Object Function(T) toJsonT). +library; + +import 'package:celest/celest.dart'; +import 'package:celest_backend/models/generic_wrappers.dart'; +import 'package:celest_backend/models/parameter_types.dart'; +import 'package:fast_immutable_collections/fast_immutable_collections.dart'; + +@cloud +GenericWrappers genericWrappers(GenericWrappers value) => value; +@cloud +Future genericWrappersAsync(GenericWrappers value) async => + value; +@cloud +GenericWrappers genericWrapperParameters({ + required IList listOfString, + required IList listOfUri, + required IList listOfSimpleClass, + required IList> listOfListOfString, + required IList> listOfListOfUri, + required IList> listOfListOfSimpleClass, + required IMap mapOfString, + required IMap mapOfUri, + required IMap mapOfSimpleClass, + required IMap> mapOfListOfString, + required IMap> mapOfListOfUri, + required IMap> mapOfListOfSimpleClass, + required IMap> mapOfMapOfString, + required IMap> mapOfMapOfUri, + required IMap> mapOfMapOfSimpleClass, +}) { + return GenericWrappers( + listOfString: listOfString, + listOfUri: listOfUri, + listOfSimpleClass: listOfSimpleClass, + listOfListOfString: listOfListOfString, + listOfListOfUri: listOfListOfUri, + listOfListOfSimpleClass: listOfListOfSimpleClass, + mapOfString: mapOfString, + mapOfUri: mapOfUri, + mapOfSimpleClass: mapOfSimpleClass, + mapOfListOfString: mapOfListOfString, + mapOfListOfUri: mapOfListOfUri, + mapOfListOfSimpleClass: mapOfListOfSimpleClass, + mapOfMapOfString: mapOfMapOfString, + mapOfMapOfUri: mapOfMapOfUri, + mapOfMapOfSimpleClass: mapOfMapOfSimpleClass, + ); +} diff --git a/apps/cli/fixtures/legacy/api/lib/src/functions/metadata.dart b/apps/cli/fixtures/legacy/api/lib/src/functions/metadata.dart new file mode 100644 index 000000000..38bc8eec2 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/lib/src/functions/metadata.dart @@ -0,0 +1,298 @@ +/// Tests that metadata associated with functions and parameters are correctly +/// parsed and transferred to the generated client. +library; + +import 'package:celest/celest.dart'; +import 'package:celest_backend/models/metadata.dart'; + +/// A function that has doc comments. +/// +/// This is a doc comment. +/// +/// # This is an H1 +/// ## This is an H2 +/// ### This is an H3 +/// * This is a list item +/// +/// This is an example: +/// +/// ```dart +/// void hasDocComments() {} +/// ``` +// This should not be copied over. +@cloud +void hasDocComments() {} + +@cloud +@deprecated +void hasDeprecatedAnnotation() {} + +@cloud +@Deprecated('Do not use this function.') +void hasConstructedDeprecatedAnnotation() {} + +@cloud +@MyAnnotation.create('positional', named: 'named') +void hasNamedConstructedAnnotation() {} + +@cloud +@Literals( + string: 'string', + intValue: 1, + doubleValue: 1.0, + boolValue: true, + list: ['list'], + map: {'map': 'map'}, + enumValue: LiteralEnum.a, + recordValue: (a: 'a', b: 'b', c: 'c'), +) +void hasLiteralsAnnotation( + @Literals( + string: 'string', + intValue: 1, + doubleValue: 1.0, + boolValue: true, + list: ['list'], + map: {'map': 'map'}, + enumValue: LiteralEnum.a, + recordValue: (a: 'a', b: 'b', c: 'c'), + ) + String value, { + @Literals( + string: 'string', + intValue: 1, + doubleValue: 1.0, + boolValue: true, + list: ['list'], + map: {'map': 'map'}, + enumValue: LiteralEnum.a, + recordValue: (a: 'a', b: 'b', c: 'c'), + ) + required String named, +}) {} + +@cloud +@exportable +void hasExportableAnnotation( + @exportable String value, { + @exportable String named = 'named', +}) {} + +@cloud +@Exportable() +void hasExportableConstructedAnnotation( + @Exportable() String value, { + @Exportable() String named = 'named', +}) {} + +@cloud +@notExportable +void hasNotExportableAnnotation( + @notExportable String value, { + @notExportable String named = 'named', +}) {} + +// -- Default values -- + +@cloud +void positionalDefaultValues([ + String value = 'value', + int intValue = 1, + double doubleValue = 1.0, + bool boolValue = true, + List list = const ['list'], + Map map = const {'map': 'map'}, + Exportable exportable = const Exportable(), + Serializable serializable = const Serializable.forType('String'), + LiteralEnum enumValue = LiteralEnum.a, + ({String a, String b, String c}) recordValue = (a: 'a', b: 'b', c: 'c'), +]) {} + +@cloud +void nullablePositionalDefaultValues([ + String? value = 'value', + int? intValue = 1, + double? doubleValue = 1.0, + bool? boolValue = true, + List? list = const ['list'], + Map? map = const {'map': 'map'}, + Exportable? exportable = const Exportable(), + Serializable? serializable = const Serializable.forType('String'), + LiteralEnum? enumValue = LiteralEnum.a, + ({String a, String b, String c})? recordValue = (a: 'a', b: 'b', c: 'c'), +]) {} + +@cloud +void namedDefaultValues({ + String value = 'value', + int intValue = 1, + double doubleValue = 1.0, + bool boolValue = true, + List list = const ['list'], + Map map = const {'map': 'map'}, + Exportable exportable = const Exportable(), + Serializable serializable = const Serializable.forType('String'), + LiteralEnum enumValue = LiteralEnum.a, + ({String a, String b, String c}) recordValue = (a: 'a', b: 'b', c: 'c'), +}) {} + +@cloud +void nullableNamedDefaultValues({ + String? value = 'value', + int? intValue = 1, + double? doubleValue = 1.0, + bool? boolValue = true, + List? list = const ['list'], + Map? map = const {'map': 'map'}, + Exportable? exportable = const Exportable(), + Serializable? serializable = const Serializable.forType('String'), + LiteralEnum? enumValue = LiteralEnum.a, + ({String a, String b, String c})? recordValue = (a: 'a', b: 'b', c: 'c'), +}) {} + +// Tests that default values of function parameters can refer +// to top-level variables and static field variables. + +const defaultInt = 42; +const defaultDouble = 42.0; +const defaultBool = true; +const defaultString = 'default'; +const defaultList = ['default']; +const defaultMap = {'default': 'default'}; +const defaultEnum = LiteralEnum.a; +const defaultRecord = (a: 'a', b: 'b', c: 'c'); +const defaultExportable = Exportable.instance; +const defaultSerializable = Serializable.string; + +@cloud +void positionalDefaultValueVars([ + int value = defaultInt, + double doubleValue = defaultDouble, + bool boolValue = defaultBool, + String stringValue = defaultString, + List listValue = defaultList, + Map mapValue = defaultMap, + LiteralEnum enumValue = defaultEnum, + ({String a, String b, String c}) recordValue = defaultRecord, + Exportable exportable = defaultExportable, + Serializable serializable = defaultSerializable, +]) {} + +@cloud +void nullablePositionalDefaultValueVars([ + int? value = defaultInt, + double? doubleValue = defaultDouble, + bool? boolValue = defaultBool, + String? stringValue = defaultString, + List? listValue = defaultList, + Map? mapValue = defaultMap, + LiteralEnum? enumValue = defaultEnum, + ({String a, String b, String c})? recordValue = defaultRecord, + Exportable? exportable = defaultExportable, + Serializable? serializable = defaultSerializable, +]) {} + +@cloud +void namedDefaultValueVars({ + int value = defaultInt, + double doubleValue = defaultDouble, + bool boolValue = defaultBool, + String stringValue = defaultString, + List listValue = defaultList, + Map mapValue = defaultMap, + LiteralEnum enumValue = defaultEnum, + ({String a, String b, String c}) recordValue = defaultRecord, + Exportable exportable = defaultExportable, + Serializable serializable = defaultSerializable, +}) {} + +@cloud +void nullableNamedDefaultValueVars({ + int? value = defaultInt, + double? doubleValue = defaultDouble, + bool? boolValue = defaultBool, + String? stringValue = defaultString, + List? listValue = defaultList, + Map? mapValue = defaultMap, + LiteralEnum? enumValue = defaultEnum, + ({String a, String b, String c})? recordValue = defaultRecord, + Exportable? exportable = defaultExportable, + Serializable? serializable = defaultSerializable, +}) {} + +// Tests that default values which are private variable references +// are copied by value and not by trying to reference the private +// variable. +// +// Since function signatures would become invalid if we did not +// copy over the default value, this is a way to ensure that client +// signatures look the same as the server signatures when variables +// are public, but still function correctly when variables are +// private. + +const _defaultInt = 42; +const _defaultDouble = 42.0; +const _defaultBool = true; +const _defaultString = 'default'; +const _defaultList = ['default']; +const _defaultMap = {'default': 'default'}; +const _defaultEnum = LiteralEnum.a; +const _defaultRecord = (a: 'a', b: 'b', c: 'c'); +const _defaultExportable = Exportable.instance; +const _defaultSerializable = Serializable.string; + +@cloud +void positionalDefaultValueVarsPrivate([ + int value = _defaultInt, + double doubleValue = _defaultDouble, + bool boolValue = _defaultBool, + String stringValue = _defaultString, + List listValue = _defaultList, + Map mapValue = _defaultMap, + LiteralEnum enumValue = _defaultEnum, + ({String a, String b, String c}) recordValue = _defaultRecord, + Exportable exportable = _defaultExportable, + Serializable serializable = _defaultSerializable, +]) {} + +@cloud +void nullablePositionalDefaultValueVarsPrivate([ + int? value = _defaultInt, + double? doubleValue = _defaultDouble, + bool? boolValue = _defaultBool, + String? stringValue = _defaultString, + List? listValue = _defaultList, + Map? mapValue = _defaultMap, + LiteralEnum? enumValue = _defaultEnum, + ({String a, String b, String c})? recordValue = _defaultRecord, + Exportable? exportable = _defaultExportable, + Serializable? serializable = _defaultSerializable, +]) {} + +@cloud +void namedDefaultValueVarsPrivate({ + int value = _defaultInt, + double doubleValue = _defaultDouble, + bool boolValue = _defaultBool, + String stringValue = _defaultString, + List listValue = _defaultList, + Map mapValue = _defaultMap, + LiteralEnum enumValue = _defaultEnum, + ({String a, String b, String c}) recordValue = _defaultRecord, + Exportable exportable = _defaultExportable, + Serializable serializable = _defaultSerializable, +}) {} + +@cloud +void nullableNamedDefaultValueVarsPrivate({ + int? value = _defaultInt, + double? doubleValue = _defaultDouble, + bool? boolValue = _defaultBool, + String? stringValue = _defaultString, + List? listValue = _defaultList, + Map? mapValue = _defaultMap, + LiteralEnum? enumValue = _defaultEnum, + ({String a, String b, String c})? recordValue = _defaultRecord, + Exportable? exportable = _defaultExportable, + Serializable? serializable = _defaultSerializable, +}) {} diff --git a/apps/cli/fixtures/legacy/api/lib/src/functions/overrides.dart b/apps/cli/fixtures/legacy/api/lib/src/functions/overrides.dart new file mode 100644 index 000000000..4d854834c --- /dev/null +++ b/apps/cli/fixtures/legacy/api/lib/src/functions/overrides.dart @@ -0,0 +1,43 @@ +/// Tests that types can be recursively overriden in the serialization protocol +/// using extension types. +library; + +import 'package:celest/celest.dart'; +import 'package:_common/_common.dart' as common; +import 'package:celest_backend/exceptions/overrides.dart'; +import 'package:celest_backend/models/overrides.dart'; + +// These should all work the same way because the override is recursive and +// does not have to be used directly to apply. + +@cloud +common.NestedParent commonNestedParent(common.NestedParent parent) => parent; +@cloud +common.NestedChild commonNestedChild(common.NestedChild child) => child; +@cloud +NestedGrandparent nestedGrandparent(NestedGrandparent grandparent) => + grandparent; +@cloud +NestedParent nestedParent(NestedParent parent) => parent; +@cloud +NestedChild nestedChild(NestedChild child) => child; + +@cloud +void callsThrowsCommonOverriddenException() { + common.throwsOverriddenException(); +} + +@cloud +void throwsCommonOverriddenException() { + throw common.OverriddenException('message'); +} + +@cloud +void throwsOverriddenException() { + throw OverriddenException(common.OverriddenException('message')); +} + +@cloud +void callsThrowsOverriddenException() { + throwsOverriddenException(); +} diff --git a/apps/cli/fixtures/legacy/api/lib/src/functions/parameter_types.dart b/apps/cli/fixtures/legacy/api/lib/src/functions/parameter_types.dart new file mode 100644 index 000000000..6f6226776 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/lib/src/functions/parameter_types.dart @@ -0,0 +1,153 @@ +import 'package:celest/celest.dart'; +import 'dart:typed_data'; + +import 'package:celest_backend/models/parameter_types.dart'; + +@cloud +Future simple( + String aString, + int anInt, + double aDouble, + bool aBool, + MyEnum anEnum, + Null aNull, + BigInt aBigInt, + DateTime aDateTime, + Duration aDuration, + RegExp aRegExp, + StackTrace aStackTrace, + Uri aUri, + UriData aUriData, + Uint8List aUint8List, + Iterable anIterableOfString, + Iterable anIterableOfUint8List, + List aListOfString, + List aListOfInt, + List aListOfDouble, + List aListOfBool, + List aListOfEnum, + List aListOfNull, + List aListOfBigInt, + List aListOfDateTime, + List aListOfDuration, + List aListOfRegExp, + List aListOfStackTrace, + List aListOfUri, + List aListOfUriData, + List aListOfUint8List, + Map aMapOfString, + Map aMapOfInt, + Map aMapOfDouble, + Map aMapOfBool, + Map aMapOfEnum, + Map aMapOfNull, + Map aMapOfBigInt, + Map aMapOfDateTime, + Map aMapOfDuration, + Map aMapOfRegExp, + Map aMapOfStackTrace, + Map aMapOfUri, + Map aMapOfUriData, + Map aMapOfUint8List, + // TODO: Map / Map +) async {} + +@cloud +Future simpleOptional( + String? aString, + int? anInt, + double? aDouble, + bool? aBool, + MyEnum? anEnum, + Null aNull, + BigInt? aBigInt, + DateTime? aDateTime, + Duration? aDuration, + RegExp? aRegExp, + StackTrace? aStackTrace, + Uri? aUri, + UriData? aUriData, + Uint8List? aUint8List, + Iterable? anIterableOfString, + Iterable? anIterableOfUint8List, + List? aListOfString, + List? aListOfInt, + List? aListOfDouble, + List? aListOfBool, + List? aListOfEnum, + List? aListOfNull, + List? aListOfBigInt, + List? aListOfDateTime, + List? aListOfDuration, + List? aListOfRegExp, + List? aListOfStackTrace, + List? aListOfUri, + List? aListOfUriData, + List? aListOfUint8List, + Map? aMapOfString, + Map? aMapOfInt, + Map? aMapOfDouble, + Map? aMapOfBool, + Map? aMapOfEnum, + Map? aMapOfNull, + Map? aMapOfBigInt, + Map? aMapOfDateTime, + Map? aMapOfDuration, + Map? aMapOfRegExp, + Map? aMapOfStackTrace, + Map? aMapOfUri, + Map? aMapOfUriData, + Map? aMapOfUint8List, +) async {} + +@cloud +Future complex( + SimpleStruct aSimpleStruct, + ComplexStruct aComplexStruct, + SimpleClass aSimpleClass, + ComplexClass aComplexClass, + SimpleStruct? aNullableSimpleStruct, + ComplexStruct? aNullableComplexStruct, + SimpleClass? aNullableSimpleClass, + ComplexClass? aNullableComplexClass, + Iterable anIterableOfSimpleStruct, + Iterable anIterableOfComplexStruct, + Iterable anIterableOfSimpleClass, + Iterable anIterableOfComplexClass, + Iterable? aNullableIterableOfSimpleStruct, + Iterable? aNullableIterableOfComplexStruct, + Iterable? aNullableIterableOfSimpleClass, + Iterable? aNullableIterableOfComplexClass, + Iterable anIterableOfNullableSimpleStruct, + Iterable anIterableOfNullableComplexStruct, + Iterable anIterableOfNullableSimpleClass, + Iterable anIterableOfNullableComplexClass, + List aListOfSimpleStruct, + List aListOfComplexStruct, + List aListOfSimpleClass, + List aListOfComplexClass, + List? aNullableListOfSimpleStruct, + List? aNullableListOfComplexStruct, + List? aNullableListOfSimpleClass, + List? aNullableListOfComplexClass, + List aListOfNullableSimpleStruct, + List aListOfNullableComplexStruct, + List aListOfNullableSimpleClass, + List aListOfNullableComplexClass, + Map aMapOfSimpleStruct, + Map aMapOfComplexStruct, + Map aMapOfSimpleClass, + Map aMapOfComplexClass, + Map? aNullableMapOfSimpleStruct, + Map? aNullableMapOfComplexStruct, + Map? aNullableMapOfSimpleClass, + Map? aNullableMapOfComplexClass, + Map aMapOfNullableSimpleStruct, + Map aMapOfNullableComplexStruct, + Map aMapOfNullableSimpleClass, + Map aMapOfNullableComplexClass, + Map? aNullableMapOfNullableSimpleStruct, + Map? aNullableMapOfNullableComplexStruct, + Map? aNullableMapOfNullableSimpleClass, + Map? aNullableMapOfNullableComplexClass, +) async {} diff --git a/apps/cli/fixtures/legacy/api/lib/src/functions/parameters.dart b/apps/cli/fixtures/legacy/api/lib/src/functions/parameters.dart new file mode 100644 index 000000000..e2c35de19 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/lib/src/functions/parameters.dart @@ -0,0 +1,25 @@ +import 'package:celest/celest.dart'; + +@cloud +Future optionalPositional([ + String? optionalString, + int? optionalInt, +]) async {} + +@cloud +Future optionalNamed({ + String? namedString, + int? namedInt, +}) async {} + +@cloud +Future requiredPositional( + String requiredString, + int requiredInt, +) async {} + +@cloud +Future requiredNamed({ + required String requiredString, + required int requiredInt, +}) async {} diff --git a/apps/cli/fixtures/legacy/api/lib/src/functions/records.dart b/apps/cli/fixtures/legacy/api/lib/src/functions/records.dart new file mode 100644 index 000000000..f45fefd11 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/lib/src/functions/records.dart @@ -0,0 +1,136 @@ +/// Tests that records with and without aliases are serializable and +/// deserializable. +library; + +import 'package:celest/celest.dart'; +import 'package:celest_backend/models/records.dart'; + +@cloud +({ + String field, + String anotherField, +}) nonAliasedNamedFields({ + required ({ + String field, + String anotherField, + }) value, +}) => + value; +@cloud +Future< + ({ + String field, + String anotherField, + })> asyncNonAliasedNamedFields({ + required ({ + String field, + String anotherField, + }) value, +}) async => + value; + +@cloud +NamedFieldsRecord aliasedNamedFields({ + required NamedFieldsRecord value, +}) => + value; +@cloud +Future asyncAliasedNamedFields({ + required NamedFieldsRecord value, +}) async => + value; + +@cloud +({ + ({ + String field, + String anotherField, + }) nonAliased, + NamedFieldsRecord aliased, +}) namedFields({ + required ({ + String field, + String anotherField, + }) nonAliased, + required NamedFieldsRecord aliased, +}) => + ( + nonAliased: nonAliased, + aliased: aliased, + ); +@cloud +Future< + ({ + ({ + String field, + String anotherField, + }) nonAliased, + NamedFieldsRecord aliased, + })> asyncNamedFields({ + required ({ + String field, + String anotherField, + }) nonAliased, + required NamedFieldsRecord aliased, +}) async => + ( + nonAliased: nonAliased, + aliased: aliased, + ); + +@cloud +Nested nested(Nested value) => value; +@cloud +Future asyncNested(Nested value) async => value; + +@cloud +NullableNested? nullableNested(NullableNested? value) => value; +@cloud +Future asyncNullableNested(NullableNested? value) async => + value; + +// TODO(dnys1): https://github.com/dart-lang/sdk/issues/54346 + +// typedef AliasedNullable = ( +// String field, +// String? nullableField, { +// String anotherField, +// String? anotherNullableField, +// })?; + +// AliasedNullable aliasedNullable(AliasedNullable value) => value; +// Future asyncAliasedNullable(AliasedNullable value) async => +// value; + +// ( +// String field, +// String? nullableField, { +// String anotherField, +// String? anotherNullableField, +// })? nonAliasedNullable( +// ( +// String field, +// String? nullableField, { +// String anotherField, +// String? anotherNullableField, +// })? value, +// ) => +// value; +// Future< +// ( +// String field, +// String? nullableField, { +// String anotherField, +// String? anotherNullableField, +// })?> asyncNonAliasedNullable( +// ( +// String field, +// String? nullableField, { +// String anotherField, +// String? anotherNullableField, +// })? value, +// ) async => +// value; + +// TODO(dnys1): Generics +void _generics() {} diff --git a/apps/cli/fixtures/legacy/api/lib/src/functions/return_types.dart b/apps/cli/fixtures/legacy/api/lib/src/functions/return_types.dart new file mode 100644 index 000000000..9e38d0c3a --- /dev/null +++ b/apps/cli/fixtures/legacy/api/lib/src/functions/return_types.dart @@ -0,0 +1,592 @@ +/// Validates all permutations of return types. +library; + +import 'package:celest/celest.dart'; +import 'dart:async'; +import 'dart:convert'; + +import 'package:celest_backend/models/parameter_types.dart'; + +@cloud +Future asyncVoidReturn() async {} + +@cloud +Future asyncStringReturn() async { + return 'Hello, world!'; +} + +@cloud +Future asyncIntReturn() async { + return 42; +} + +@cloud +Future asyncDoubleReturn() async { + return 3.14; +} + +@cloud +Future asyncBoolReturn() async { + return true; +} + +@cloud +Future> asyncIterableReturn() async { + return ['Hello', 'world']; +} + +@cloud +Future> asyncListReturn() async { + return ['Hello', 'world']; +} + +@cloud +Future> asyncMapReturn() async { + return {'Hello': 'world'}; +} + +@cloud +Future asyncStructReturn() async { + return (); +} + +@cloud +Future asyncStructReturnNullable() async { + return null; +} + +@cloud +Future asyncComplexStructReturn() async { + return ( + aString: 'Hello', + anInt: 42, + aDouble: 3.14, + aBool: true, + anEnum: MyEnum.a, + aNull: null, + aBigInt: BigInt.from(42), + aDateTime: DateTime.now(), + aDuration: Duration(seconds: 42), + aRegExp: RegExp(r'Hello, world!'), + aStackTrace: StackTrace.current, + aUri: Uri.parse('https://example.com'), + aUriData: UriData.fromString('Hello, world!'), + aUint8List: utf8.encode('Hello, world!'), + aSimpleStruct: (), + aSimpleClass: SimpleClass(), + anIterableOfSimpleClass: [SimpleClass(), SimpleClass()], + aListOfString: ['Hello', 'world'], + aListOfInt: [1, 2, 3], + aListOfDouble: [1.1, 2.2, 3.3], + aListOfBool: [true, false], + aListOfEnum: [MyEnum.a, MyEnum.b], + aListOfNull: [null], + aListOfBigInt: [BigInt.from(42), BigInt.from(43)], + aListOfDateTime: [DateTime.now(), DateTime.now()], + aListOfDuration: [Duration(seconds: 42), Duration(seconds: 43)], + aListOfRegExp: [RegExp(r'Hello, world!'), RegExp(r'Hello, world!')], + aListOfStackTrace: [StackTrace.current, StackTrace.current], + aListOfUri: [ + Uri.parse('https://example.com'), + Uri.parse('https://example.com') + ], + aListOfUriData: [ + UriData.fromString('Hello, world!'), + UriData.fromString('Hello, world!') + ], + aListOfUint8List: [ + utf8.encode('Hello, world!'), + utf8.encode('Hello, world!') + ], + aListOfSimpleStruct: [(), ()], + aListOfSimpleClass: [SimpleClass(), SimpleClass()], + aMapOfString: {'Hello': 'world'}, + aMapOfInt: {'Hello': 42}, + aMapOfDouble: {'Hello': 3.14}, + aMapOfBool: {'Hello': true}, + aMapOfEnum: {'Hello': MyEnum.a}, + aMapOfNull: {'Hello': null}, + aMapOfBigInt: {'Hello': BigInt.from(42)}, + aMapOfDateTime: {'Hello': DateTime.now()}, + aMapOfDuration: {'Hello': Duration(seconds: 42)}, + aMapOfRegExp: {'Hello': RegExp(r'Hello, world!')}, + aMapOfStackTrace: {'Hello': StackTrace.current}, + aMapOfUri: {'Hello': Uri.parse('https://example.com')}, + aMapOfUriData: {'Hello': UriData.fromString('Hello, world!')}, + aMapOfUint8List: {'Hello': utf8.encode('Hello, world!')}, + aMapOfSimpleStruct: {'Hello': (), 'World': ()}, + aMapOfSimpleClass: {'Hello': SimpleClass(), 'World': SimpleClass()}, + ); +} + +@cloud +Future asyncComplexStructReturnNullable() async { + return null; +} + +@cloud +Future asyncComplexClassReturn() async { + return ComplexClass( + aString: 'Hello', + anInt: 42, + aDouble: 3.14, + aBool: true, + anEnum: MyEnum.a, + aNull: null, + aBigInt: BigInt.from(42), + aDateTime: DateTime.now(), + aDuration: Duration(seconds: 42), + aRegExp: RegExp(r'Hello, world!'), + aStackTrace: StackTrace.current, + aUri: Uri.parse('https://example.com'), + aUriData: UriData.fromString('Hello, world!'), + aUint8List: utf8.encode('Hello, world!'), + aSimpleStruct: (), + aSimpleClass: SimpleClass(), + anIterableOfSimpleClass: [SimpleClass(), SimpleClass()], + aListOfString: ['Hello', 'world'], + aListOfInt: [1, 2, 3], + aListOfDouble: [1.1, 2.2, 3.3], + aListOfBool: [true, false], + aListOfEnum: [MyEnum.a, MyEnum.b], + aListOfNull: [null], + aListOfBigInt: [BigInt.from(42), BigInt.from(43)], + aListOfDateTime: [DateTime.now(), DateTime.now()], + aListOfDuration: [Duration(seconds: 42), Duration(seconds: 43)], + aListOfRegExp: [RegExp(r'Hello, world!'), RegExp(r'Hello, world!')], + aListOfStackTrace: [StackTrace.current, StackTrace.current], + aListOfUri: [ + Uri.parse('https://example.com'), + Uri.parse('https://example.com') + ], + aListOfUriData: [ + UriData.fromString('Hello, world!'), + UriData.fromString('Hello, world!') + ], + aListOfUint8List: [ + utf8.encode('Hello, world!'), + utf8.encode('Hello, world!') + ], + aListOfSimpleStruct: [(), ()], + aListOfSimpleClass: [SimpleClass(), SimpleClass()], + aMapOfString: {'Hello': 'world'}, + aMapOfInt: {'Hello': 42}, + aMapOfDouble: {'Hello': 3.14}, + aMapOfBool: {'Hello': true}, + aMapOfEnum: {'Hello': MyEnum.a}, + aMapOfNull: {'Hello': null}, + aMapOfBigInt: {'Hello': BigInt.from(42)}, + aMapOfDateTime: {'Hello': DateTime.now()}, + aMapOfDuration: {'Hello': Duration(seconds: 42)}, + aMapOfRegExp: {'Hello': RegExp(r'Hello, world!')}, + aMapOfStackTrace: {'Hello': StackTrace.current}, + aMapOfUri: {'Hello': Uri.parse('https://example.com')}, + aMapOfUriData: {'Hello': UriData.fromString('Hello, world!')}, + aMapOfUint8List: {'Hello': utf8.encode('Hello, world!')}, + aMapOfSimpleStruct: {'Hello': (), 'World': ()}, + aMapOfSimpleClass: {'Hello': SimpleClass(), 'World': SimpleClass()}, + ); +} + +@cloud +Future asyncClassReturnNullable() async { + return null; +} + +@cloud +FutureOr asyncOrVoidReturn() async {} + +@cloud +FutureOr asyncOrStringReturn() async { + return 'Hello, world!'; +} + +@cloud +FutureOr asyncOrIntReturn() async { + return 42; +} + +@cloud +FutureOr asyncOrDoubleReturn() async { + return 3.14; +} + +@cloud +FutureOr asyncOrBoolReturn() async { + return true; +} + +@cloud +FutureOr> asyncOrIterableReturn() async { + return ['Hello', 'world']; +} + +@cloud +FutureOr> asyncOrListReturn() async { + return ['Hello', 'world']; +} + +@cloud +FutureOr> asyncOrMapReturn() async { + return {'Hello': 'world'}; +} + +@cloud +FutureOr asyncOrStructReturn() async { + return (); +} + +@cloud +FutureOr asyncOrComplexStructReturn() async { + return ( + aString: 'Hello', + anInt: 42, + aDouble: 3.14, + aBool: true, + anEnum: MyEnum.a, + aNull: null, + aBigInt: BigInt.from(42), + aDateTime: DateTime.now(), + aDuration: Duration(seconds: 42), + aRegExp: RegExp(r'Hello, world!'), + aStackTrace: StackTrace.current, + aUri: Uri.parse('https://example.com'), + aUriData: UriData.fromString('Hello, world!'), + aUint8List: utf8.encode('Hello, world!'), + aSimpleStruct: (), + aSimpleClass: SimpleClass(), + anIterableOfSimpleClass: [SimpleClass(), SimpleClass()], + aListOfString: ['Hello', 'world'], + aListOfInt: [1, 2, 3], + aListOfDouble: [1.1, 2.2, 3.3], + aListOfBool: [true, false], + aListOfEnum: [MyEnum.a, MyEnum.b], + aListOfNull: [null], + aListOfBigInt: [BigInt.from(42), BigInt.from(43)], + aListOfDateTime: [DateTime.now(), DateTime.now()], + aListOfDuration: [Duration(seconds: 42), Duration(seconds: 43)], + aListOfRegExp: [RegExp(r'Hello, world!'), RegExp(r'Hello, world!')], + aListOfStackTrace: [StackTrace.current, StackTrace.current], + aListOfUri: [ + Uri.parse('https://example.com'), + Uri.parse('https://example.com') + ], + aListOfUriData: [ + UriData.fromString('Hello, world!'), + UriData.fromString('Hello, world!') + ], + aListOfUint8List: [ + utf8.encode('Hello, world!'), + utf8.encode('Hello, world!') + ], + aListOfSimpleStruct: [(), ()], + aListOfSimpleClass: [SimpleClass(), SimpleClass()], + aMapOfString: {'Hello': 'world'}, + aMapOfInt: {'Hello': 42}, + aMapOfDouble: {'Hello': 3.14}, + aMapOfBool: {'Hello': true}, + aMapOfEnum: {'Hello': MyEnum.a}, + aMapOfNull: {'Hello': null}, + aMapOfBigInt: {'Hello': BigInt.from(42)}, + aMapOfDateTime: {'Hello': DateTime.now()}, + aMapOfDuration: {'Hello': Duration(seconds: 42)}, + aMapOfRegExp: {'Hello': RegExp(r'Hello, world!')}, + aMapOfStackTrace: {'Hello': StackTrace.current}, + aMapOfUri: {'Hello': Uri.parse('https://example.com')}, + aMapOfUriData: {'Hello': UriData.fromString('Hello, world!')}, + aMapOfUint8List: {'Hello': utf8.encode('Hello, world!')}, + aMapOfSimpleStruct: {'Hello': (), 'World': ()}, + aMapOfSimpleClass: {'Hello': SimpleClass(), 'World': SimpleClass()}, + ); +} + +@cloud +FutureOr? asyncOrVoidReturnNullable() { + return null; +} + +@cloud +FutureOr? asyncOrStringReturnNullable() { + return null; +} + +@cloud +FutureOr? asyncOrIntReturnNullable() { + return null; +} + +@cloud +FutureOr? asyncOrDoubleReturnNullable() { + return null; +} + +@cloud +FutureOr? asyncOrBoolReturnNullable() { + return null; +} + +@cloud +FutureOr>? asyncOrIterableReturnNullable() { + return null; +} + +@cloud +FutureOr>? asyncOrListReturnNullable() { + return null; +} + +@cloud +FutureOr>? asyncOrMapReturnNullable() { + return null; +} + +@cloud +FutureOr? asyncOrStructReturnNullable() { + return null; +} + +@cloud +FutureOr? asyncOrComplexStructReturnNullable() { + return null; +} + +@cloud +FutureOr? asyncOrSimpleClassReturnNullable() { + return null; +} + +@cloud +FutureOr? asyncOrComplexClassReturnNullable() { + return null; +} + +@cloud +void voidReturn() {} + +@cloud +String stringReturn() { + return 'Hello, world!'; +} + +@cloud +int intReturn() { + return 42; +} + +@cloud +double doubleReturn() { + return 3.14; +} + +@cloud +bool boolReturn() { + return true; +} + +@cloud +Iterable iterableReturn() { + return ['Hello', 'world']; +} + +@cloud +List listReturn() { + return ['Hello', 'world']; +} + +@cloud +Map mapReturn() { + return {'Hello': 'world'}; +} + +@cloud +SimpleStruct structReturn() { + return (); +} + +@cloud +ComplexStruct complexReturn() { + return ( + aString: 'Hello', + anInt: 42, + aDouble: 3.14, + aBool: true, + anEnum: MyEnum.a, + aNull: null, + aBigInt: BigInt.from(42), + aDateTime: DateTime.now(), + aDuration: Duration(seconds: 42), + aRegExp: RegExp(r'Hello, world!'), + aStackTrace: StackTrace.current, + aUri: Uri.parse('https://example.com'), + aUriData: UriData.fromString('Hello, world!'), + aUint8List: utf8.encode('Hello, world!'), + aSimpleStruct: (), + aSimpleClass: SimpleClass(), + anIterableOfSimpleClass: [SimpleClass(), SimpleClass()], + aListOfString: ['Hello', 'world'], + aListOfInt: [1, 2, 3], + aListOfDouble: [1.1, 2.2, 3.3], + aListOfBool: [true, false], + aListOfEnum: [MyEnum.a, MyEnum.b], + aListOfNull: [null], + aListOfBigInt: [BigInt.from(42), BigInt.from(43)], + aListOfDateTime: [DateTime.now(), DateTime.now()], + aListOfDuration: [Duration(seconds: 42), Duration(seconds: 43)], + aListOfRegExp: [RegExp(r'Hello, world!'), RegExp(r'Hello, world!')], + aListOfStackTrace: [StackTrace.current, StackTrace.current], + aListOfUri: [ + Uri.parse('https://example.com'), + Uri.parse('https://example.com') + ], + aListOfUriData: [ + UriData.fromString('Hello, world!'), + UriData.fromString('Hello, world!') + ], + aListOfUint8List: [ + utf8.encode('Hello, world!'), + utf8.encode('Hello, world!') + ], + aListOfSimpleStruct: [(), ()], + aListOfSimpleClass: [SimpleClass(), SimpleClass()], + aMapOfString: {'Hello': 'world'}, + aMapOfInt: {'Hello': 42}, + aMapOfDouble: {'Hello': 3.14}, + aMapOfBool: {'Hello': true}, + aMapOfEnum: {'Hello': MyEnum.a}, + aMapOfNull: {'Hello': null}, + aMapOfBigInt: {'Hello': BigInt.from(42)}, + aMapOfDateTime: {'Hello': DateTime.now()}, + aMapOfDuration: {'Hello': Duration(seconds: 42)}, + aMapOfRegExp: {'Hello': RegExp(r'Hello, world!')}, + aMapOfStackTrace: {'Hello': StackTrace.current}, + aMapOfUri: {'Hello': Uri.parse('https://example.com')}, + aMapOfUriData: {'Hello': UriData.fromString('Hello, world!')}, + aMapOfUint8List: {'Hello': utf8.encode('Hello, world!')}, + aMapOfSimpleStruct: {'Hello': (), 'World': ()}, + aMapOfSimpleClass: {'Hello': SimpleClass(), 'World': SimpleClass()}, + ); +} + +@cloud +SimpleClass simpleClassReturn() { + return SimpleClass(); +} + +@cloud +ComplexClass complexClassReturn() { + return ComplexClass( + aString: 'Hello', + anInt: 42, + aDouble: 3.14, + aBool: true, + anEnum: MyEnum.a, + aNull: null, + aBigInt: BigInt.from(42), + aDateTime: DateTime.now(), + aDuration: Duration(seconds: 42), + aRegExp: RegExp(r'Hello, world!'), + aStackTrace: StackTrace.current, + aUri: Uri.parse('https://example.com'), + aUriData: UriData.fromString('Hello, world!'), + aUint8List: utf8.encode('Hello, world!'), + aSimpleStruct: (), + aSimpleClass: SimpleClass(), + anIterableOfSimpleClass: [SimpleClass(), SimpleClass()], + aListOfString: ['Hello', 'world'], + aListOfInt: [1, 2, 3], + aListOfDouble: [1.1, 2.2, 3.3], + aListOfBool: [true, false], + aListOfEnum: [MyEnum.a, MyEnum.b], + aListOfNull: [null], + aListOfBigInt: [BigInt.from(42), BigInt.from(43)], + aListOfDateTime: [DateTime.now(), DateTime.now()], + aListOfDuration: [Duration(seconds: 42), Duration(seconds: 43)], + aListOfRegExp: [RegExp(r'Hello, world!'), RegExp(r'Hello, world!')], + aListOfStackTrace: [StackTrace.current, StackTrace.current], + aListOfUri: [ + Uri.parse('https://example.com'), + Uri.parse('https://example.com') + ], + aListOfUriData: [ + UriData.fromString('Hello, world!'), + UriData.fromString('Hello, world!') + ], + aListOfUint8List: [ + utf8.encode('Hello, world!'), + utf8.encode('Hello, world!') + ], + aListOfSimpleStruct: [(), ()], + aListOfSimpleClass: [SimpleClass(), SimpleClass()], + aMapOfString: {'Hello': 'world'}, + aMapOfInt: {'Hello': 42}, + aMapOfDouble: {'Hello': 3.14}, + aMapOfBool: {'Hello': true}, + aMapOfEnum: {'Hello': MyEnum.a}, + aMapOfNull: {'Hello': null}, + aMapOfBigInt: {'Hello': BigInt.from(42)}, + aMapOfDateTime: {'Hello': DateTime.now()}, + aMapOfDuration: {'Hello': Duration(seconds: 42)}, + aMapOfRegExp: {'Hello': RegExp(r'Hello, world!')}, + aMapOfStackTrace: {'Hello': StackTrace.current}, + aMapOfUri: {'Hello': Uri.parse('https://example.com')}, + aMapOfUriData: {'Hello': UriData.fromString('Hello, world!')}, + aMapOfUint8List: {'Hello': utf8.encode('Hello, world!')}, + aMapOfSimpleStruct: {'Hello': (), 'World': ()}, + aMapOfSimpleClass: {'Hello': SimpleClass(), 'World': SimpleClass()}, + ); +} + +@cloud +String? stringReturnNullable() { + return null; +} + +@cloud +int? intReturnNullable() { + return null; +} + +@cloud +double? doubleReturnNullable() { + return null; +} + +@cloud +bool? boolReturnNullable() { + return null; +} + +@cloud +Iterable? iterableReturnNullable() { + return null; +} + +@cloud +List? listReturnNullable() { + return null; +} + +@cloud +Map? mapReturnNullable() { + return null; +} + +@cloud +SimpleStruct? structReturnNullable() { + return null; +} + +@cloud +ComplexStruct? complexReturnNullable() { + return null; +} + +@cloud +SimpleClass? simpleClassReturnNullable() { + return null; +} + +@cloud +ComplexClass? complexClassReturnNullable() { + return null; +} diff --git a/apps/cli/fixtures/legacy/api/lib/src/functions/sealed_classes.dart b/apps/cli/fixtures/legacy/api/lib/src/functions/sealed_classes.dart new file mode 100644 index 000000000..5465e85cb --- /dev/null +++ b/apps/cli/fixtures/legacy/api/lib/src/functions/sealed_classes.dart @@ -0,0 +1,110 @@ +// Should be able to use the base type. +import 'package:celest/celest.dart'; +import 'package:celest_backend/exceptions/exceptions.dart'; +import 'package:celest_backend/models/sealed_classes.dart'; + +@cloud +double area(Shape shape) => shape.area; + +// Should be able to use the base type in a collection. +@cloud +List sealedClass({ + required List shapes, +}) { + return shapes; +} + +// Should be able to use leaf types directly. +@cloud +Rectangle rectangle(Rectangle rectangle) => rectangle; +@cloud +Circle circle(Circle circle) => circle; + +// Should be able to define custom toJson/fromJson methods. +@cloud +List sealedClassWithInheritedCustomJson({ + required List shapes, +}) { + return shapes; +} + +// Should be able to define toJson/fromJson on just the leaf classes. +@cloud +List sealedClassWithCustomJson({ + required List shapes, +}) { + return shapes; +} + +// Should be able to override toJson/fromJson in the leaf classes. +@cloud +List sealedClassWithOverriddenCustomJson({ + required CircleWithOverriddenCustomJson circle, + required RectangleWithOverriddenCustomJson rectangle, + required List other, +}) { + return [ + circle, + rectangle, + ...other, + ]; +} + +@cloud +ShapeWithOverriddenCustomJson rectangleWithOverriddenCustomJson( + RectangleWithOverriddenCustomJson rectangle, +) { + return rectangle; +} + +@cloud +CircleWithOverriddenCustomJson circleWithOverriddenCustomJson( + ShapeWithOverriddenCustomJson circle, +) { + return circle as CircleWithOverriddenCustomJson; +} + +@cloud +List> okShapeResults(List shapes) => + [for (final shape in shapes) OkResult(shape)]; +@cloud +List> errShapeResults(List shapes) => + [for (final shape in shapes) ErrResult('Bad shape: ($shape)')]; +@cloud +List> shapeResults(List shapes) => [ + ...okShapeResults(shapes), + ...errShapeResults(shapes), + ]; + +// TODO(dnys1): Test ShapeResult not allowed. +@cloud +List> aliasedOkShapeResults(List shapes) => + [for (final shape in shapes) OkResult(shape)]; +@cloud +List> aliasedErrShapeResults(List shapes) => + [for (final shape in shapes) ErrResult('Bad shape: ($shape)')]; +@cloud +List> aliasedShapeResults(List shapes) => [ + ...okShapeResults(shapes), + ...errShapeResults(shapes), + ]; + +@cloud +SwappedResult swappedResult(Result result) => + SwappedResult(result); + +@cloud +OkResult genericResult(T data) => OkResult(data); +@cloud +List> + multipleGenericResult( + T data, + E error, +) => + [OkResult(data), ErrResult(error)]; + +// TODO(dnys1): rework subtype checks with finals so that OkShapeResult is not +// a subtype of Result. Currently, OkShapeResult is a subtype of +// Result because it extends OkResult. +@cloud +OkShapeResult okShapeResult(Shape shape) => OkShapeResult(shape); diff --git a/apps/cli/fixtures/legacy/api/lib/src/functions/typedefs.dart b/apps/cli/fixtures/legacy/api/lib/src/functions/typedefs.dart new file mode 100644 index 000000000..9c5192678 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/lib/src/functions/typedefs.dart @@ -0,0 +1,15 @@ +/// Checks that typedefs work as expected. +library; + +import 'package:celest/celest.dart'; +import 'package:celest_backend/models/typedefs.dart'; + +// Repro of https://github.com/celest-dev/celest/issues/53 +@cloud +Future portfolio(Portfolio portfolio) async => portfolio; +@cloud +Future json(Json json) async => json; +@cloud +Future nullableJson(Json? json) async => json; +@cloud +Future mixedJson(Json json) async => json; diff --git a/apps/cli/fixtures/legacy/api/lib/src/generated/cloud.celest.dart b/apps/cli/fixtures/legacy/api/lib/src/generated/cloud.celest.dart new file mode 100644 index 000000000..f1a89c399 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/lib/src/generated/cloud.celest.dart @@ -0,0 +1,45 @@ +// Generated by Celest. This file should not be modified manually, but +// it can be checked into version control. +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +library; + +import 'package:celest/src/core/context.dart'; +import 'package:celest_backend/src/generated/config.celest.dart'; + +/// The interface to your Celest backend. +/// +/// Similar to the `celest` global in the frontend, this +/// provides access to the backend environment and services +/// configured for your project. +const CelestCloud celest = CelestCloud._(); + +/// A per-request context object which propogates request information and common +/// accessors to the Celest server environment. +CelestContext get context => CelestContext._(context); + +/// The interface to your Celest backend. +/// +/// Similar to the `Celest` class in the frontend, this class +/// provides access to the backend environment and services +/// configured for your project. +class CelestCloud { + const CelestCloud._(); + + /// The current environment of the Celest service. + /// + /// This is determined by the `CELEST_ENVIRONMENT` variable + /// which is set for you by the deployment environment. + CelestEnvironment get currentEnvironment => + (variables.currentEnvironment as CelestEnvironment); + + /// The variables of the Celest service. + /// + /// This class provides access to the values configured for the + /// [currentEnvironment]. + CelestVariables get variables => const CelestVariables(); +} + +/// A per-request context object which propogates request information and common +/// accessors to the Celest server environment. +extension type CelestContext._(Context _context) implements Context {} diff --git a/apps/cli/fixtures/legacy/api/lib/src/generated/config.celest.dart b/apps/cli/fixtures/legacy/api/lib/src/generated/config.celest.dart new file mode 100644 index 000000000..687b9f186 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/lib/src/generated/config.celest.dart @@ -0,0 +1,45 @@ +// Generated by Celest. This file should not be modified manually, but +// it can be checked into version control. +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +library; + +import 'package:celest/celest.dart'; +import 'package:celest/src/core/context.dart'; + +/// An environment of a deployed Celest service. +/// +/// Celest services can have multiple isolated branches, for example +/// a `development` and `production` environment. +extension type const CelestEnvironment._(String _env) + implements Environment, String { + /// The local Celest environment, used to delineate when a + /// Celest service is running on a developer machine as opposed + /// to the cloud. + static const CelestEnvironment local = CelestEnvironment._('local'); + + /// The production Celest environment which is common to all + /// Celest projects and labels the environment which is considered + /// live and served to end-users. + static const CelestEnvironment production = CelestEnvironment._('production'); + + /// Whether `this` represents the [local] environment. + bool get isLocal => this == local; + + /// Whether `this` represents the [production] environment. + bool get isProduction => this == production; +} + +/// The environment variables for the Celest service. +/// +/// This class provides access to the environment variable values +/// that are configured for the current [CelestEnvironment]. +class CelestVariables { + const CelestVariables(); + + /// The environment variable that determines the current environment. + /// + /// This is set by the deployment environment and is used to + /// determine the current environment of the Celest service. + String get currentEnvironment => context.expect(env.environment); +} diff --git a/apps/cli/fixtures/legacy/api/lib/src/project.dart b/apps/cli/fixtures/legacy/api/lib/src/project.dart new file mode 100644 index 000000000..c436b9732 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/lib/src/project.dart @@ -0,0 +1,3 @@ +import 'package:celest/celest.dart'; + +const project = Project(name: 'api'); diff --git a/apps/cli/fixtures/legacy/api/pubspec.yaml b/apps/cli/fixtures/legacy/api/pubspec.yaml new file mode 100644 index 000000000..15f3f9f47 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/pubspec.yaml @@ -0,0 +1,35 @@ +name: celest_backend +publish_to: none + +environment: + sdk: ^3.4.0 + +dependencies: + _common: + path: ../_common + celest: ^1.0.0 + celest_core: ^1.0.0 + fast_immutable_collections: ^10.1.1 + http: ^1.0.0 + meta: ^1.12.0 + shelf: ^1.4.1 + +dependency_overrides: + cedar: + path: ../../../../../cedar/packages/cedar + celest: + path: ../../../../../celest/packages/celest + celest_ast: + path: ../../../../../celest/packages/celest_ast + celest_auth: + path: ../../../../../celest/packages/celest_auth + celest_cloud: + path: ../../../../../celest/packages/celest_cloud + celest_cloud_auth: + path: ../../../../../celest/services/celest_cloud_auth + celest_core: + path: ../../../../../celest/packages/celest_core + +dev_dependencies: + lints: ^4.0.0 + test: ^1.25.0 diff --git a/apps/cli/fixtures/legacy/api/test/client_test_todo.dart b/apps/cli/fixtures/legacy/api/test/client_test_todo.dart new file mode 100644 index 000000000..8f00e8ff8 --- /dev/null +++ b/apps/cli/fixtures/legacy/api/test/client_test_todo.dart @@ -0,0 +1,175 @@ +import 'package:test/test.dart'; + +import '../client/lib/api_client.dart'; + +void main() { + group('Client', () { + // late final Process celestProcess; + + setUpAll(() async { + // celestProcess = await Process.start( + // Platform.resolvedExecutable, + // [Platform.script.resolve('../../../../bin/celest.dart').toFilePath()], + // workingDirectory: Platform.script.resolve('..').toFilePath(), + // ); + celest.init(); + }); + + group('apis', () { + test('classes', () async { + await expectLater( + celest.functions.classes.empty(Empty()), + completion(isA()), + ); + + await expectLater( + celest.functions.classes.asyncEmpty(Empty()), + completion(isA()), + ); + + await expectLater( + celest.functions.classes.fields( + Fields('superField', 'field'), + ), + completion( + isA() + .having((f) => f.superField, 'superField', 'superField') + .having((f) => f.field, 'field', 'field'), + ), + ); + + await expectLater( + celest.functions.classes.asyncFields( + Fields('superField', 'field'), + ), + completion( + isA() + .having((f) => f.superField, 'superField', 'superField') + .having((f) => f.field, 'field', 'field'), + ), + ); + + await expectLater( + celest.functions.classes.nullableFields( + Fields('superField', 'field'), + ), + completion( + isA() + .having((f) => f.superField, 'superField', 'superField') + .having((f) => f.field, 'field', 'field'), + ), + ); + await expectLater( + celest.functions.classes.nullableFields(null), + completion(isNull), + ); + + await expectLater( + celest.functions.classes.asyncNullableFields( + Fields('superField', 'field'), + ), + completion( + isA() + .having((f) => f.superField, 'superField', 'superField') + .having((f) => f.field, 'field', 'field'), + ), + ); + await expectLater( + celest.functions.classes.asyncNullableFields(null), + completion(isNull), + ); + + await expectLater( + celest.functions.classes.namedFields( + NamedFields(superField: 'superField', field: 'field'), + ), + completion( + isA() + .having((f) => f.superField, 'superField', 'superField') + .having((f) => f.field, 'field', 'field'), + ), + ); + await expectLater( + celest.functions.classes.asyncNamedFields( + NamedFields(superField: 'superField', field: 'field'), + ), + completion( + isA() + .having((f) => f.superField, 'superField', 'superField') + .having((f) => f.field, 'field', 'field'), + ), + ); + + await expectLater( + celest.functions.classes.mixedFields( + MixedFields('superField', field: 'field'), + ), + completion( + isA() + .having((f) => f.superField, 'superField', 'superField') + .having((f) => f.field, 'field', 'field'), + ), + ); + await expectLater( + celest.functions.classes.asyncMixedFields( + MixedFields('superField', field: 'field'), + ), + completion( + isA() + .having((f) => f.superField, 'superField', 'superField') + .having((f) => f.field, 'field', 'field'), + ), + ); + + await expectLater( + celest.functions.classes.defaultValues( + DefaultValues(), + ), + completion( + isA() + .having((f) => f.field, 'field', 'default') + .having((f) => f.nullableField, 'nullableField', isNull) + .having( + (f) => f.nullableFieldWithDefault, + 'nullableFieldWithDefault', + 'default', + ) + .having( + (f) => f.fieldWithoutInitializer, + 'fieldWithoutInitializer', + 'default', + ), + ), + ); + await expectLater( + celest.functions.classes.asyncDefaultValues( + DefaultValues( + field: 'field', + nullableField: 'nullableField', + nullableFieldWithDefault: 'nullableFieldWithDefault', + ), + ), + completion( + isA() + .having((f) => f.field, 'field', 'field') + .having( + (f) => f.nullableField, + 'nullableField', + 'nullableField', + ) + .having( + (f) => f.nullableFieldWithDefault, + 'nullableFieldWithDefault', + 'nullableFieldWithDefault', + ) + .having( + (f) => f.fieldWithoutInitializer, + 'fieldWithoutInitializer', + 'default', + ), + ), + ); + }); + }); + }); +} diff --git a/apps/cli/fixtures/legacy/auth/.env.local b/apps/cli/fixtures/legacy/auth/.env.local new file mode 100644 index 000000000..c1c6d3b85 --- /dev/null +++ b/apps/cli/fixtures/legacy/auth/.env.local @@ -0,0 +1 @@ +SUPABASE_URL=https://vduqtbtlcxxozghvhdqu.supabase.co \ No newline at end of file diff --git a/apps/cli/fixtures/legacy/auth/.firebaserc b/apps/cli/fixtures/legacy/auth/.firebaserc new file mode 100644 index 000000000..426b5bc10 --- /dev/null +++ b/apps/cli/fixtures/legacy/auth/.firebaserc @@ -0,0 +1,7 @@ +{ + "projects": { + "local": "prj-d-firebase-test" + }, + "targets": {}, + "etags": {} +} \ No newline at end of file diff --git a/apps/cli/fixtures/legacy/auth/client/lib/auth_client.dart b/apps/cli/fixtures/legacy/auth/client/lib/auth_client.dart new file mode 100644 index 000000000..3caac0841 --- /dev/null +++ b/apps/cli/fixtures/legacy/auth/client/lib/auth_client.dart @@ -0,0 +1,91 @@ +// Generated by Celest. This file should not be modified manually, but +// it can be checked into version control. +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +library; // ignore_for_file: no_leading_underscores_for_library_prefixes + +import 'dart:async'; +import 'dart:io'; + +import 'package:auth_client/src/auth.dart'; +import 'package:auth_client/src/functions.dart'; +import 'package:auth_client/src/serializers.dart'; +import 'package:celest_core/_internal.dart' as _$celest; +import 'package:celest_core/celest_core.dart' as _$celest; +import 'package:celest_core/src/util/globals.dart' as _$celest; +import 'package:http/http.dart' as _$http_http; +import 'package:native_storage/native_storage.dart' + as _$native_storage_native_storage; + +export 'package:celest_auth/celest_auth.dart'; +export 'src/auth.dart'; + +final Celest celest = Celest(); + +enum CelestEnvironment { + local, + production; + + Uri get baseUri => switch (this) { + local => + _$celest.kIsWeb || !Platform.isAndroid + ? Uri.parse('http://localhost:7777') + : Uri.parse('http://10.0.2.2:7777'), + production => Uri.parse('https://example.celest.run'), + }; +} + +class Celest with _$celest.CelestBase { + var _initialized = false; + + late CelestEnvironment _currentEnvironment; + + late final _$native_storage_native_storage.NativeStorage nativeStorage = + _$native_storage_native_storage.NativeStorage(scope: 'celest'); + + @override + late _$http_http.Client httpClient = _$celest.CelestHttpClient( + secureStorage: nativeStorage.secure, + ); + + late Uri _baseUri; + + final _functions = CelestFunctions(); + + late final CelestAuth _auth = CelestAuth(this, storage: nativeStorage); + + T _checkInitialized(T Function() value) { + if (!_initialized) { + throw StateError( + 'Celest has not been initialized. Make sure to call `celest.init()` at the start of your `main` method.', + ); + } + return value(); + } + + CelestEnvironment get currentEnvironment => + _checkInitialized(() => _currentEnvironment); + + @override + Uri get baseUri => _checkInitialized(() => _baseUri); + + CelestFunctions get functions => _checkInitialized(() => _functions); + + CelestAuth get auth => _checkInitialized(() => _auth); + + void init({ + CelestEnvironment environment = CelestEnvironment.local, + _$celest.Serializers? serializers, + }) { + if (_initialized && environment != _currentEnvironment) { + _auth.signOut(); + } + _currentEnvironment = environment; + _baseUri = environment.baseUri; + scheduleMicrotask(_auth.init); + if (!_initialized) { + initSerializers(serializers: serializers); + } + _initialized = true; + } +} diff --git a/apps/cli/fixtures/legacy/auth/client/lib/src/auth.dart b/apps/cli/fixtures/legacy/auth/client/lib/src/auth.dart new file mode 100644 index 000000000..265d7a4c0 --- /dev/null +++ b/apps/cli/fixtures/legacy/auth/client/lib/src/auth.dart @@ -0,0 +1,20 @@ +// Generated by Celest. This file should not be modified manually, but +// it can be checked into version control. +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +library; // ignore_for_file: no_leading_underscores_for_library_prefixes + +import 'package:celest_auth/celest_auth.dart' as _$celest; +import 'package:celest_auth/src/auth_impl.dart' as _$celest; +import 'package:celest_core/_internal.dart' as _$celest; +import 'package:native_storage/native_storage.dart' + as _$native_storage_native_storage; + +extension type CelestAuth._(_$celest.AuthImpl _hub) implements _$celest.Auth { + CelestAuth( + _$celest.CelestBase celest, { + required _$native_storage_native_storage.NativeStorage storage, + }) : _hub = _$celest.AuthImpl(celest, storage: storage); + + _$celest.Email get email => _$celest.Email(_hub); +} diff --git a/apps/cli/fixtures/legacy/auth/client/lib/src/functions.dart b/apps/cli/fixtures/legacy/auth/client/lib/src/functions.dart new file mode 100644 index 000000000..2ce0da156 --- /dev/null +++ b/apps/cli/fixtures/legacy/auth/client/lib/src/functions.dart @@ -0,0 +1,966 @@ +// Generated by Celest. This file should not be modified manually, but +// it can be checked into version control. +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +library; // ignore_for_file: no_leading_underscores_for_library_prefixes + +import 'dart:async'; +import 'dart:convert'; + +import 'package:auth_client/auth_client.dart'; +import 'package:celest/celest.dart' as _$celest; +import 'package:celest_core/celest_core.dart' as _$celest; +import 'package:celest_core/src/exception/cloud_exception.dart' as _$celest; +import 'package:celest_core/src/exception/serialization_exception.dart' + as _$celest; + +class CelestFunctions { + final authenticatedLib = CelestFunctionsAuthenticatedLib(); + + final lib = CelestFunctionsLib(); + + final publicLib = CelestFunctionsPublicLib(); +} + +class CelestFunctionsAuthenticatedLib { + Never _throwError({int? code, required Map body}) { + final status = body['@status'] as Map?; + final message = status?['message'] as String?; + final details = status?['details'] as _$celest.JsonList?; + final (errorType, errorValue, stackTrace) = switch (details) { + null || [] => const (null, null, StackTrace.empty), + [ + final errorDetails as Map, + { + '@type': 'dart.core.StackTrace', + 'value': final stackTraceValue as String, + }, + ..., + ] => + ( + errorDetails['@type'], + errorDetails['value'], + StackTrace.fromString(stackTraceValue), + ), + [final errorDetails as Map, ...] => ( + errorDetails['@type'], + errorDetails['value'], + StackTrace.empty, + ), + }; + + switch (errorType) { + case 'celest.core.v1.CloudException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.CloudException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.CancelledException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.CancelledException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnknownError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.UnknownError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.BadRequestException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.BadRequestException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnauthorizedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.UnauthorizedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.NotFoundException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.NotFoundException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.AlreadyExistsException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.AlreadyExistsException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.PermissionDeniedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.PermissionDeniedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.ResourceExhaustedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.ResourceExhaustedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.FailedPreconditionException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.FailedPreconditionException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.AbortedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.AbortedException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.OutOfRangeException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.OutOfRangeException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnimplementedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.UnimplementedError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.InternalServerError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.InternalServerError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnavailableError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.UnavailableError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.DataLossError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.DataLossError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.DeadlineExceededError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.DeadlineExceededError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.SerializationException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.SerializationException>(errorValue), + stackTrace, + ); + case 'dart.core.Error': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.AssertionError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.TypeError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.ArgumentError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.RangeError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.IndexError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.UnsupportedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.UnimplementedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.StateError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.ConcurrentModificationError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.core.OutOfMemoryError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.StackOverflowError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.Exception': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.FormatException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.IntegerDivisionByZeroException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.async.AsyncError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.async.TimeoutException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.convert.JsonUnsupportedObjectError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + default: + Error.throwWithStackTrace( + _$celest.CloudException.http( + code: code, + message: message, + details: ((details ?? body) as _$celest.JsonValue), + ), + StackTrace.empty, + ); + } + } + + @_$celest.CloudFunction(api: 'authenticated_lib', function: 'sayHello') + Future sayHello() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/authenticated-lib/say-hello'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return ($body as String); + } + + @_$celest.CloudFunction(api: 'authenticated_lib', function: 'streamHello') + Stream streamHello() { + final $channel = celest.eventClient.connect( + celest.baseUri.resolve('/authenticated-lib/stream-hello'), + ); + return $channel.stream.map(($event) { + if ($event is Map && $event.containsKey('@error')) { + _throwError(body: $event); + } + return ($event as String); + }); + } +} + +class CelestFunctionsLib { + Never _throwError({int? code, required Map body}) { + final status = body['@status'] as Map?; + final message = status?['message'] as String?; + final details = status?['details'] as _$celest.JsonList?; + final (errorType, errorValue, stackTrace) = switch (details) { + null || [] => const (null, null, StackTrace.empty), + [ + final errorDetails as Map, + { + '@type': 'dart.core.StackTrace', + 'value': final stackTraceValue as String, + }, + ..., + ] => + ( + errorDetails['@type'], + errorDetails['value'], + StackTrace.fromString(stackTraceValue), + ), + [final errorDetails as Map, ...] => ( + errorDetails['@type'], + errorDetails['value'], + StackTrace.empty, + ), + }; + + switch (errorType) { + case 'celest.core.v1.CloudException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.CloudException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.CancelledException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.CancelledException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnknownError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.UnknownError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.BadRequestException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.BadRequestException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnauthorizedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.UnauthorizedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.NotFoundException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.NotFoundException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.AlreadyExistsException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.AlreadyExistsException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.PermissionDeniedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.PermissionDeniedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.ResourceExhaustedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.ResourceExhaustedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.FailedPreconditionException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.FailedPreconditionException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.AbortedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.AbortedException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.OutOfRangeException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.OutOfRangeException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnimplementedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.UnimplementedError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.InternalServerError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.InternalServerError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnavailableError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.UnavailableError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.DataLossError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.DataLossError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.DeadlineExceededError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.DeadlineExceededError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.SerializationException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.SerializationException>(errorValue), + stackTrace, + ); + case 'dart.core.Error': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.AssertionError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.TypeError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.ArgumentError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.RangeError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.IndexError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.UnsupportedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.UnimplementedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.StateError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.ConcurrentModificationError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.core.OutOfMemoryError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.StackOverflowError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.Exception': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.FormatException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.IntegerDivisionByZeroException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.async.AsyncError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.async.TimeoutException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.convert.JsonUnsupportedObjectError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + default: + Error.throwWithStackTrace( + _$celest.CloudException.http( + code: code, + message: message, + details: ((details ?? body) as _$celest.JsonValue), + ), + StackTrace.empty, + ); + } + } + + @_$celest.CloudFunction(api: 'lib', function: 'sayHelloAuthenticated') + Future sayHelloAuthenticated() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/lib/say-hello-authenticated'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return ($body as String); + } + + @_$celest.CloudFunction(api: 'lib', function: 'streamHelloAuthenticated') + Stream streamHelloAuthenticated() { + final $channel = celest.eventClient.connect( + celest.baseUri.resolve('/lib/stream-hello-authenticated'), + ); + return $channel.stream.map(($event) { + if ($event is Map && $event.containsKey('@error')) { + _throwError(body: $event); + } + return ($event as String); + }); + } + + @_$celest.CloudFunction(api: 'lib', function: 'sayHelloPublic') + Future sayHelloPublic() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/lib/say-hello-public'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return ($body as String); + } + + @_$celest.CloudFunction(api: 'lib', function: 'streamHelloPublic') + Stream streamHelloPublic() { + final $channel = celest.eventClient.connect( + celest.baseUri.resolve('/lib/stream-hello-public'), + ); + return $channel.stream.map(($event) { + if ($event is Map && $event.containsKey('@error')) { + _throwError(body: $event); + } + return ($event as String); + }); + } + + @_$celest.CloudFunction(api: 'lib', function: 'sayHello') + Future sayHello() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/lib/say-hello'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return ($body as String); + } + + @_$celest.CloudFunction(api: 'lib', function: 'streamHello') + Stream streamHello() { + final $channel = celest.eventClient.connect( + celest.baseUri.resolve('/lib/stream-hello'), + ); + return $channel.stream.map(($event) { + if ($event is Map && $event.containsKey('@error')) { + _throwError(body: $event); + } + return ($event as String); + }); + } +} + +class CelestFunctionsPublicLib { + Never _throwError({int? code, required Map body}) { + final status = body['@status'] as Map?; + final message = status?['message'] as String?; + final details = status?['details'] as _$celest.JsonList?; + final (errorType, errorValue, stackTrace) = switch (details) { + null || [] => const (null, null, StackTrace.empty), + [ + final errorDetails as Map, + { + '@type': 'dart.core.StackTrace', + 'value': final stackTraceValue as String, + }, + ..., + ] => + ( + errorDetails['@type'], + errorDetails['value'], + StackTrace.fromString(stackTraceValue), + ), + [final errorDetails as Map, ...] => ( + errorDetails['@type'], + errorDetails['value'], + StackTrace.empty, + ), + }; + + switch (errorType) { + case 'celest.core.v1.CloudException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.CloudException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.CancelledException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.CancelledException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnknownError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.UnknownError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.BadRequestException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.BadRequestException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnauthorizedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.UnauthorizedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.NotFoundException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.NotFoundException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.AlreadyExistsException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.AlreadyExistsException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.PermissionDeniedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.PermissionDeniedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.ResourceExhaustedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.ResourceExhaustedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.FailedPreconditionException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.FailedPreconditionException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.AbortedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.AbortedException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.OutOfRangeException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.OutOfRangeException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnimplementedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.UnimplementedError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.InternalServerError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.InternalServerError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnavailableError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.UnavailableError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.DataLossError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.DataLossError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.DeadlineExceededError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.DeadlineExceededError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.SerializationException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.SerializationException>(errorValue), + stackTrace, + ); + case 'dart.core.Error': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.AssertionError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.TypeError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.ArgumentError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.RangeError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.IndexError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.UnsupportedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.UnimplementedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.StateError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.ConcurrentModificationError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.core.OutOfMemoryError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.StackOverflowError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.Exception': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.FormatException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.IntegerDivisionByZeroException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.async.AsyncError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.async.TimeoutException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.convert.JsonUnsupportedObjectError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + default: + Error.throwWithStackTrace( + _$celest.CloudException.http( + code: code, + message: message, + details: ((details ?? body) as _$celest.JsonValue), + ), + StackTrace.empty, + ); + } + } + + @_$celest.CloudFunction(api: 'public_lib', function: 'sayHello') + Future sayHello() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/public-lib/say-hello'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return ($body as String); + } + + @_$celest.CloudFunction(api: 'public_lib', function: 'streamHello') + Stream streamHello() { + final $channel = celest.eventClient.connect( + celest.baseUri.resolve('/public-lib/stream-hello'), + ); + return $channel.stream.map(($event) { + if ($event is Map && $event.containsKey('@error')) { + _throwError(body: $event); + } + return ($event as String); + }); + } +} diff --git a/apps/cli/fixtures/legacy/auth/client/lib/src/serializers.dart b/apps/cli/fixtures/legacy/auth/client/lib/src/serializers.dart new file mode 100644 index 000000000..892541e56 --- /dev/null +++ b/apps/cli/fixtures/legacy/auth/client/lib/src/serializers.dart @@ -0,0 +1,751 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async'; +import 'dart:convert'; + +import 'package:celest_core/celest_core.dart' as _$celest; +import 'package:celest_core/src/exception/cloud_exception.dart' as _$celest; +import 'package:celest_core/src/exception/serialization_exception.dart' + as _$celest; +import 'package:celest_core/src/serialization/json_value.dart' as _$celest; + +void initSerializers({_$celest.Serializers? serializers}) { + return runZoned(() { + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _$celest.Serializers.instance + .serialize($value.stackTrace), + }, + deserialize: ($serialized) { + return AsyncError( + $serialized[r'error']!, + _$celest.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_$celest.Serializers.instance.serialize( + $value.duration, + ) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return TimeoutException( + ($serialized[r'message'] as String?), + _$celest.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest + .Serializer.define>( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + ConcurrentModificationError, + Map? + >( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: + ($value) => { + if (_$celest.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest + .Serializer.define<_$celest.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.AbortedException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.AlreadyExistsException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.BadRequestException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.BadRequestException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.CancelledException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.CancelledException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define<_$celest.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.CloudException.fromJson($serialized); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define<_$celest.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.DataLossError( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.DeadlineExceededError, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.InternalServerError, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.InternalServerError( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest + .Serializer.define<_$celest.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.NotFoundException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.OutOfRangeException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.OutOfRangeException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.UnauthorizedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.UnauthorizedException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest + .Serializer.define<_$celest.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.UnavailableError( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.UnimplementedError, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.UnimplementedError( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define<_$celest.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.UnknownError( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.SerializationException, + Map + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define<_$celest.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _$celest.JsonValue($serialized); + }, + ), + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ); + }, zoneValues: {_$celest.Serializers: serializers}); +} diff --git a/apps/cli/fixtures/legacy/auth/client/pubspec.yaml b/apps/cli/fixtures/legacy/auth/client/pubspec.yaml new file mode 100644 index 000000000..cf90bf9fd --- /dev/null +++ b/apps/cli/fixtures/legacy/auth/client/pubspec.yaml @@ -0,0 +1,29 @@ +name: auth_client +description: The Celest client for auth. +publish_to: none + +environment: + sdk: ^3.4.0 + +dependencies: + celest: ^1.0.0 + celest_backend: + path: .. + celest_core: ^1.0.0 + http: ^1.0.0 + native_storage: ^0.2.2 + +dependency_overrides: + celest: + path: ../../../../../../celest/packages/celest + celest_ast: + path: ../../../../../../celest/packages/celest_ast + celest_auth: + path: ../../../../../../celest/packages/celest_auth + celest_cloud: + path: ../../../../../../celest/packages/celest_cloud + celest_cloud_auth: + path: ../../../../../../celest/services/celest_cloud_auth + celest_core: + path: ../../../../../../celest/packages/celest_core +dev_dependencies: {} diff --git a/apps/cli/fixtures/legacy/auth/goldens/api.local.dart b/apps/cli/fixtures/legacy/auth/goldens/api.local.dart new file mode 100644 index 000000000..b61572eb2 --- /dev/null +++ b/apps/cli/fixtures/legacy/auth/goldens/api.local.dart @@ -0,0 +1,41 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'package:celest/src/core/context.dart' as _i12; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/generated/auth.celest.dart' as _i13; + +import 'functions/authenticated_lib/sayHello.dart' as _i2; +import 'functions/authenticated_lib/streamHello.dart' as _i3; +import 'functions/lib/sayHello.dart' as _i4; +import 'functions/lib/sayHelloAuthenticated.dart' as _i5; +import 'functions/lib/sayHelloPublic.dart' as _i6; +import 'functions/lib/streamHello.dart' as _i7; +import 'functions/lib/streamHelloAuthenticated.dart' as _i8; +import 'functions/lib/streamHelloPublic.dart' as _i9; +import 'functions/public_lib/sayHello.dart' as _i10; +import 'functions/public_lib/streamHello.dart' as _i11; + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: { + '/authenticated-lib/say-hello': _i2.SayHelloTarget(), + '/authenticated-lib/stream-hello': _i3.StreamHelloTarget(), + '/lib/say-hello': _i4.SayHelloTarget(), + '/lib/say-hello-authenticated': _i5.SayHelloAuthenticatedTarget(), + '/lib/say-hello-public': _i6.SayHelloPublicTarget(), + '/lib/stream-hello': _i7.StreamHelloTarget(), + '/lib/stream-hello-authenticated': _i8.StreamHelloAuthenticatedTarget(), + '/lib/stream-hello-public': _i9.StreamHelloPublicTarget(), + '/public-lib/say-hello': _i10.SayHelloTarget(), + '/public-lib/stream-hello': _i11.StreamHelloTarget(), + }, + setup: (_i12.Context context) async { + await _i13.CelestAuth.init(context); + }, + ); +} diff --git a/apps/cli/fixtures/legacy/auth/goldens/ast.json b/apps/cli/fixtures/legacy/auth/goldens/ast.json new file mode 100644 index 000000000..35befb6ca --- /dev/null +++ b/apps/cli/fixtures/legacy/auth/goldens/ast.json @@ -0,0 +1,2131 @@ +{ + "name": "auth", + "environment": "local", + "reference": { + "$": "Reference", + "symbol": "project", + "url": "package:celest_backend/src/project.dart" + }, + "apis": { + "lib": { + "name": "lib", + "metadata": [], + "functions": { + "sayHelloAuthenticated": { + "name": "sayHelloAuthenticated", + "apiName": "lib", + "typeParameters": [], + "parameters": [ + { + "name": "user", + "type": { + "$": "TypeReference", + "symbol": "User", + "url": "package:celest_core/src/auth/user.dart", + "isNullable": false + }, + "required": true, + "named": true, + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_PrincipalContextKey", + "url": "package:celest/src/core/context.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_PrincipalContextKey", + "url": "package:celest/src/core/context.dart", + "isNullable": false + } + } + ], + "location": { + "start": { + "offset": 126, + "uri": "package:celest_backend/src/functions/lib.dart", + "line": 5, + "column": 27 + }, + "end": { + "offset": 130, + "uri": "package:celest_backend/src/functions/lib.dart", + "line": 5, + "column": 31 + }, + "text": "user" + }, + "references": { + "name": "$user", + "type": "userContext" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "Future", + "url": "dart:async", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + "metadata": [ + { + "$": "ApiAuthenticated", + "location": { + "start": { + "offset": 45, + "uri": "package:celest_backend/src/functions/lib.dart", + "line": 3, + "column": 0 + }, + "end": { + "offset": 59, + "uri": "package:celest_backend/src/functions/lib.dart", + "line": 3, + "column": 14 + }, + "text": "@authenticated" + } + } + ], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + }, + { + "$": "DartInstance", + "classRef": { + "symbol": "_Authenticated", + "url": "package:celest/src/grants/grants.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Authenticated", + "url": "package:celest/src/grants/grants.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 75, + "uri": "package:celest_backend/src/functions/lib.dart", + "line": 4, + "column": 15 + }, + "end": { + "offset": 96, + "uri": "package:celest_backend/src/functions/lib.dart", + "line": 4, + "column": 36 + }, + "text": "sayHelloAuthenticated" + } + }, + "streamHelloAuthenticated": { + "name": "streamHelloAuthenticated", + "apiName": "lib", + "typeParameters": [], + "parameters": [ + { + "name": "user", + "type": { + "$": "TypeReference", + "symbol": "User", + "url": "package:celest_core/src/auth/user.dart", + "isNullable": false + }, + "required": true, + "named": true, + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_PrincipalContextKey", + "url": "package:celest/src/core/context.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_PrincipalContextKey", + "url": "package:celest/src/core/context.dart", + "isNullable": false + } + } + ], + "location": { + "start": { + "offset": 262, + "uri": "package:celest_backend/src/functions/lib.dart", + "line": 13, + "column": 27 + }, + "end": { + "offset": 266, + "uri": "package:celest_backend/src/functions/lib.dart", + "line": 13, + "column": 31 + }, + "text": "user" + }, + "references": { + "name": "$user", + "type": "userContext" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "Stream", + "url": "dart:async", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + "metadata": [ + { + "$": "ApiAuthenticated", + "location": { + "start": { + "offset": 178, + "uri": "package:celest_backend/src/functions/lib.dart", + "line": 11, + "column": 0 + }, + "end": { + "offset": 192, + "uri": "package:celest_backend/src/functions/lib.dart", + "line": 11, + "column": 14 + }, + "text": "@authenticated" + } + } + ], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + }, + { + "$": "DartInstance", + "classRef": { + "symbol": "_Authenticated", + "url": "package:celest/src/grants/grants.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Authenticated", + "url": "package:celest/src/grants/grants.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 208, + "uri": "package:celest_backend/src/functions/lib.dart", + "line": 12, + "column": 15 + }, + "end": { + "offset": 232, + "uri": "package:celest_backend/src/functions/lib.dart", + "line": 12, + "column": 39 + }, + "text": "streamHelloAuthenticated" + }, + "streamType": "unidirectionalServer" + }, + "sayHelloPublic": { + "name": "sayHelloPublic", + "apiName": "lib", + "typeParameters": [], + "parameters": [ + { + "name": "user", + "type": { + "$": "TypeReference", + "symbol": "User", + "url": "package:celest_core/src/auth/user.dart", + "isNullable": true + }, + "required": false, + "named": true, + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_PrincipalContextKey", + "url": "package:celest/src/core/context.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_PrincipalContextKey", + "url": "package:celest/src/core/context.dart", + "isNullable": false + } + } + ], + "location": { + "start": { + "offset": 373, + "uri": "package:celest_backend/src/functions/lib.dart", + "line": 21, + "column": 19 + }, + "end": { + "offset": 377, + "uri": "package:celest_backend/src/functions/lib.dart", + "line": 21, + "column": 23 + }, + "text": "user" + }, + "references": { + "name": "$user", + "type": "userContext" + }, + "defaultTo": { + "$": "DartNull", + "staticType": { + "symbol": "Null", + "url": "dart:core" + } + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "Future", + "url": "dart:async", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + "metadata": [ + { + "$": "ApiPublic", + "location": { + "start": { + "offset": 314, + "uri": "package:celest_backend/src/functions/lib.dart", + "line": 19, + "column": 0 + }, + "end": { + "offset": 321, + "uri": "package:celest_backend/src/functions/lib.dart", + "line": 19, + "column": 7 + }, + "text": "@public" + } + } + ], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + }, + { + "$": "DartInstance", + "classRef": { + "symbol": "_Public", + "url": "package:celest/src/grants/grants.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Public", + "url": "package:celest/src/grants/grants.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 337, + "uri": "package:celest_backend/src/functions/lib.dart", + "line": 20, + "column": 15 + }, + "end": { + "offset": 351, + "uri": "package:celest_backend/src/functions/lib.dart", + "line": 20, + "column": 29 + }, + "text": "sayHelloPublic" + } + }, + "streamHelloPublic": { + "name": "streamHelloPublic", + "apiName": "lib", + "typeParameters": [], + "parameters": [ + { + "name": "user", + "type": { + "$": "TypeReference", + "symbol": "User", + "url": "package:celest_core/src/auth/user.dart", + "isNullable": true + }, + "required": false, + "named": true, + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_PrincipalContextKey", + "url": "package:celest/src/core/context.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_PrincipalContextKey", + "url": "package:celest/src/core/context.dart", + "isNullable": false + } + } + ], + "location": { + "start": { + "offset": 540, + "uri": "package:celest_backend/src/functions/lib.dart", + "line": 30, + "column": 19 + }, + "end": { + "offset": 544, + "uri": "package:celest_backend/src/functions/lib.dart", + "line": 30, + "column": 23 + }, + "text": "user" + }, + "references": { + "name": "$user", + "type": "userContext" + }, + "defaultTo": { + "$": "DartNull", + "staticType": { + "symbol": "Null", + "url": "dart:core" + } + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "Stream", + "url": "dart:async", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + "metadata": [ + { + "$": "ApiPublic", + "location": { + "start": { + "offset": 478, + "uri": "package:celest_backend/src/functions/lib.dart", + "line": 28, + "column": 0 + }, + "end": { + "offset": 485, + "uri": "package:celest_backend/src/functions/lib.dart", + "line": 28, + "column": 7 + }, + "text": "@public" + } + } + ], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + }, + { + "$": "DartInstance", + "classRef": { + "symbol": "_Public", + "url": "package:celest/src/grants/grants.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Public", + "url": "package:celest/src/grants/grants.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 501, + "uri": "package:celest_backend/src/functions/lib.dart", + "line": 29, + "column": 15 + }, + "end": { + "offset": 518, + "uri": "package:celest_backend/src/functions/lib.dart", + "line": 29, + "column": 32 + }, + "text": "streamHelloPublic" + }, + "streamType": "unidirectionalServer" + }, + "sayHello": { + "name": "sayHello", + "apiName": "lib", + "typeParameters": [], + "parameters": [ + { + "name": "user", + "type": { + "$": "TypeReference", + "symbol": "User", + "url": "package:celest_core/src/auth/user.dart", + "isNullable": true + }, + "required": false, + "named": true, + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_PrincipalContextKey", + "url": "package:celest/src/core/context.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_PrincipalContextKey", + "url": "package:celest/src/core/context.dart", + "isNullable": false + } + } + ], + "location": { + "start": { + "offset": 690, + "uri": "package:celest_backend/src/functions/lib.dart", + "line": 38, + "column": 19 + }, + "end": { + "offset": 694, + "uri": "package:celest_backend/src/functions/lib.dart", + "line": 38, + "column": 23 + }, + "text": "user" + }, + "references": { + "name": "$user", + "type": "userContext" + }, + "defaultTo": { + "$": "DartNull", + "staticType": { + "symbol": "Null", + "url": "dart:core" + } + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "Future", + "url": "dart:async", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 660, + "uri": "package:celest_backend/src/functions/lib.dart", + "line": 37, + "column": 15 + }, + "end": { + "offset": 668, + "uri": "package:celest_backend/src/functions/lib.dart", + "line": 37, + "column": 23 + }, + "text": "sayHello" + } + }, + "streamHello": { + "name": "streamHello", + "apiName": "lib", + "typeParameters": [], + "parameters": [ + { + "name": "user", + "type": { + "$": "TypeReference", + "symbol": "User", + "url": "package:celest_core/src/auth/user.dart", + "isNullable": true + }, + "required": false, + "named": true, + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_PrincipalContextKey", + "url": "package:celest/src/core/context.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_PrincipalContextKey", + "url": "package:celest/src/core/context.dart", + "isNullable": false + } + } + ], + "location": { + "start": { + "offset": 843, + "uri": "package:celest_backend/src/functions/lib.dart", + "line": 46, + "column": 19 + }, + "end": { + "offset": 847, + "uri": "package:celest_backend/src/functions/lib.dart", + "line": 46, + "column": 23 + }, + "text": "user" + }, + "references": { + "name": "$user", + "type": "userContext" + }, + "defaultTo": { + "$": "DartNull", + "staticType": { + "symbol": "Null", + "url": "dart:core" + } + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "Stream", + "url": "dart:async", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 810, + "uri": "package:celest_backend/src/functions/lib.dart", + "line": 45, + "column": 15 + }, + "end": { + "offset": 821, + "uri": "package:celest_backend/src/functions/lib.dart", + "line": 45, + "column": 26 + }, + "text": "streamHello" + }, + "streamType": "unidirectionalServer" + } + }, + "docs": [], + "exceptionTypes": [ + { + "$": "TypeReference", + "symbol": "CloudException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "CancelledException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnknownError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "BadRequestException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnauthorizedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "NotFoundException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AlreadyExistsException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "PermissionDeniedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ResourceExhaustedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "FailedPreconditionException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AbortedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "OutOfRangeException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnimplementedError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "InternalServerError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnavailableError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "DataLossError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "DeadlineExceededError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "SerializationException", + "url": "package:celest_core/src/exception/serialization_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "Error", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AssertionError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "TypeError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ArgumentError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "RangeError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "IndexError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnsupportedError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnimplementedError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "StateError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ConcurrentModificationError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "OutOfMemoryError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "StackOverflowError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "Exception", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "FormatException", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "IntegerDivisionByZeroException", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AsyncError", + "url": "dart:async", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "TimeoutException", + "url": "dart:async", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "JsonUnsupportedObjectError", + "url": "dart:convert", + "isNullable": false + } + ], + "location": { + "start": { + "offset": 0, + "uri": "package:celest_backend/src/functions/lib.dart", + "line": 0, + "column": 0 + }, + "end": { + "offset": 0, + "uri": "package:celest_backend/src/functions/lib.dart", + "line": 0, + "column": 0 + }, + "text": "" + } + }, + "authenticated_lib": { + "name": "authenticated_lib", + "metadata": [ + { + "$": "ApiAuthenticated", + "location": { + "start": { + "offset": 0, + "uri": "package:celest_backend/src/functions/authenticated_lib.dart", + "line": 0, + "column": 0 + }, + "end": { + "offset": 14, + "uri": "package:celest_backend/src/functions/authenticated_lib.dart", + "line": 0, + "column": 14 + }, + "text": "@authenticated" + } + } + ], + "functions": { + "sayHello": { + "name": "sayHello", + "apiName": "authenticated_lib", + "typeParameters": [], + "parameters": [ + { + "name": "user", + "type": { + "$": "TypeReference", + "symbol": "User", + "url": "package:celest_core/src/auth/user.dart", + "isNullable": false + }, + "required": true, + "named": true, + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_PrincipalContextKey", + "url": "package:celest/src/core/context.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_PrincipalContextKey", + "url": "package:celest/src/core/context.dart", + "isNullable": false + } + } + ], + "location": { + "start": { + "offset": 123, + "uri": "package:celest_backend/src/functions/authenticated_lib.dart", + "line": 7, + "column": 27 + }, + "end": { + "offset": 127, + "uri": "package:celest_backend/src/functions/authenticated_lib.dart", + "line": 7, + "column": 31 + }, + "text": "user" + }, + "references": { + "name": "$user", + "type": "userContext" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "Future", + "url": "dart:async", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 85, + "uri": "package:celest_backend/src/functions/authenticated_lib.dart", + "line": 6, + "column": 15 + }, + "end": { + "offset": 93, + "uri": "package:celest_backend/src/functions/authenticated_lib.dart", + "line": 6, + "column": 23 + }, + "text": "sayHello" + } + }, + "streamHello": { + "name": "streamHello", + "apiName": "authenticated_lib", + "typeParameters": [], + "parameters": [ + { + "name": "user", + "type": { + "$": "TypeReference", + "symbol": "User", + "url": "package:celest_core/src/auth/user.dart", + "isNullable": false + }, + "required": true, + "named": true, + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_PrincipalContextKey", + "url": "package:celest/src/core/context.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_PrincipalContextKey", + "url": "package:celest/src/core/context.dart", + "isNullable": false + } + } + ], + "location": { + "start": { + "offset": 231, + "uri": "package:celest_backend/src/functions/authenticated_lib.dart", + "line": 14, + "column": 27 + }, + "end": { + "offset": 235, + "uri": "package:celest_backend/src/functions/authenticated_lib.dart", + "line": 14, + "column": 31 + }, + "text": "user" + }, + "references": { + "name": "$user", + "type": "userContext" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "Stream", + "url": "dart:async", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 190, + "uri": "package:celest_backend/src/functions/authenticated_lib.dart", + "line": 13, + "column": 15 + }, + "end": { + "offset": 201, + "uri": "package:celest_backend/src/functions/authenticated_lib.dart", + "line": 13, + "column": 26 + }, + "text": "streamHello" + }, + "streamType": "unidirectionalServer" + } + }, + "docs": [], + "exceptionTypes": [ + { + "$": "TypeReference", + "symbol": "CloudException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "CancelledException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnknownError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "BadRequestException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnauthorizedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "NotFoundException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AlreadyExistsException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "PermissionDeniedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ResourceExhaustedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "FailedPreconditionException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AbortedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "OutOfRangeException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnimplementedError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "InternalServerError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnavailableError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "DataLossError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "DeadlineExceededError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "SerializationException", + "url": "package:celest_core/src/exception/serialization_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "Error", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AssertionError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "TypeError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ArgumentError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "RangeError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "IndexError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnsupportedError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnimplementedError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "StateError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ConcurrentModificationError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "OutOfMemoryError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "StackOverflowError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "Exception", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "FormatException", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "IntegerDivisionByZeroException", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AsyncError", + "url": "dart:async", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "TimeoutException", + "url": "dart:async", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "JsonUnsupportedObjectError", + "url": "dart:convert", + "isNullable": false + } + ], + "location": { + "start": { + "offset": 0, + "uri": "package:celest_backend/src/functions/authenticated_lib.dart", + "line": 0, + "column": 0 + }, + "end": { + "offset": 0, + "uri": "package:celest_backend/src/functions/authenticated_lib.dart", + "line": 0, + "column": 0 + }, + "text": "" + } + }, + "public_lib": { + "name": "public_lib", + "metadata": [ + { + "$": "ApiPublic", + "location": { + "start": { + "offset": 0, + "uri": "package:celest_backend/src/functions/public_lib.dart", + "line": 0, + "column": 0 + }, + "end": { + "offset": 7, + "uri": "package:celest_backend/src/functions/public_lib.dart", + "line": 0, + "column": 7 + }, + "text": "@public" + } + } + ], + "functions": { + "sayHello": { + "name": "sayHello", + "apiName": "public_lib", + "typeParameters": [], + "parameters": [ + { + "name": "user", + "type": { + "$": "TypeReference", + "symbol": "User", + "url": "package:celest_core/src/auth/user.dart", + "isNullable": true + }, + "required": false, + "named": true, + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_PrincipalContextKey", + "url": "package:celest/src/core/context.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_PrincipalContextKey", + "url": "package:celest/src/core/context.dart", + "isNullable": false + } + } + ], + "location": { + "start": { + "offset": 108, + "uri": "package:celest_backend/src/functions/public_lib.dart", + "line": 7, + "column": 19 + }, + "end": { + "offset": 112, + "uri": "package:celest_backend/src/functions/public_lib.dart", + "line": 7, + "column": 23 + }, + "text": "user" + }, + "references": { + "name": "$user", + "type": "userContext" + }, + "defaultTo": { + "$": "DartNull", + "staticType": { + "symbol": "Null", + "url": "dart:core" + } + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "Future", + "url": "dart:async", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 78, + "uri": "package:celest_backend/src/functions/public_lib.dart", + "line": 6, + "column": 15 + }, + "end": { + "offset": 86, + "uri": "package:celest_backend/src/functions/public_lib.dart", + "line": 6, + "column": 23 + }, + "text": "sayHello" + } + }, + "streamHello": { + "name": "streamHello", + "apiName": "public_lib", + "typeParameters": [], + "parameters": [ + { + "name": "user", + "type": { + "$": "TypeReference", + "symbol": "User", + "url": "package:celest_core/src/auth/user.dart", + "isNullable": true + }, + "required": false, + "named": true, + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_PrincipalContextKey", + "url": "package:celest/src/core/context.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_PrincipalContextKey", + "url": "package:celest/src/core/context.dart", + "isNullable": false + } + } + ], + "location": { + "start": { + "offset": 261, + "uri": "package:celest_backend/src/functions/public_lib.dart", + "line": 15, + "column": 19 + }, + "end": { + "offset": 265, + "uri": "package:celest_backend/src/functions/public_lib.dart", + "line": 15, + "column": 23 + }, + "text": "user" + }, + "references": { + "name": "$user", + "type": "userContext" + }, + "defaultTo": { + "$": "DartNull", + "staticType": { + "symbol": "Null", + "url": "dart:core" + } + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "Stream", + "url": "dart:async", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 228, + "uri": "package:celest_backend/src/functions/public_lib.dart", + "line": 14, + "column": 15 + }, + "end": { + "offset": 239, + "uri": "package:celest_backend/src/functions/public_lib.dart", + "line": 14, + "column": 26 + }, + "text": "streamHello" + }, + "streamType": "unidirectionalServer" + } + }, + "docs": [], + "exceptionTypes": [ + { + "$": "TypeReference", + "symbol": "CloudException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "CancelledException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnknownError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "BadRequestException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnauthorizedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "NotFoundException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AlreadyExistsException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "PermissionDeniedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ResourceExhaustedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "FailedPreconditionException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AbortedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "OutOfRangeException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnimplementedError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "InternalServerError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnavailableError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "DataLossError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "DeadlineExceededError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "SerializationException", + "url": "package:celest_core/src/exception/serialization_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "Error", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AssertionError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "TypeError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ArgumentError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "RangeError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "IndexError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnsupportedError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnimplementedError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "StateError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ConcurrentModificationError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "OutOfMemoryError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "StackOverflowError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "Exception", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "FormatException", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "IntegerDivisionByZeroException", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AsyncError", + "url": "dart:async", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "TimeoutException", + "url": "dart:async", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "JsonUnsupportedObjectError", + "url": "dart:convert", + "isNullable": false + } + ], + "location": { + "start": { + "offset": 0, + "uri": "package:celest_backend/src/functions/public_lib.dart", + "line": 0, + "column": 0 + }, + "end": { + "offset": 0, + "uri": "package:celest_backend/src/functions/public_lib.dart", + "line": 0, + "column": 0 + }, + "text": "" + } + } + }, + "variables": [], + "secrets": [], + "databases": {}, + "sdkConfig": { + "celest": "1.0.6+2", + "dart": { + "type": "dart", + "version": "3.29.0", + "enabledExperiments": [] + }, + "targetSdk": "flutter", + "featureFlags": [ + "streaming" + ], + "flutter": { + "type": "flutter", + "version": "3.29.0", + "enabledExperiments": [] + } + }, + "location": { + "start": { + "offset": 44, + "uri": "project.dart", + "line": 2, + "column": 6 + }, + "end": { + "offset": 75, + "uri": "project.dart", + "line": 2, + "column": 37 + }, + "text": "project = Project(name: 'auth')" + }, + "auth": { + "providers": [ + { + "$": "EmailAuthProvider", + "name": "emailOtp", + "type": "EMAIL_OTP", + "location": { + "start": { + "offset": 84, + "uri": "package:celest_backend/src/project.dart", + "line": 4, + "column": 6 + }, + "end": { + "offset": 88, + "uri": "package:celest_backend/src/project.dart", + "line": 4, + "column": 10 + }, + "text": "auth" + } + } + ], + "externalProviders": [], + "location": { + "start": { + "offset": 84, + "uri": "package:celest_backend/src/project.dart", + "line": 4, + "column": 6 + }, + "end": { + "offset": 88, + "uri": "package:celest_backend/src/project.dart", + "line": 4, + "column": 10 + }, + "text": "auth" + } + } +} \ No newline at end of file diff --git a/apps/cli/fixtures/legacy/auth/goldens/ast.resolved.json b/apps/cli/fixtures/legacy/auth/goldens/ast.resolved.json new file mode 100644 index 000000000..8864e3188 --- /dev/null +++ b/apps/cli/fixtures/legacy/auth/goldens/ast.resolved.json @@ -0,0 +1,431 @@ +{ + "projectId": "auth", + "environmentId": "local", + "apis": { + "lib": { + "apiId": "lib", + "functions": { + "sayHelloAuthenticated": { + "functionId": "sayHelloAuthenticated", + "apiId": "lib", + "httpConfig": { + "route": { + "method": "POST", + "path": "/lib/say-hello-authenticated" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {}, + "policySet": { + "policies": { + "lib/sayHelloAuthenticated.authenticated_restrict": { + "effect": "forbid", + "principal": { + "op": "All" + }, + "action": { + "op": "==", + "entity": { + "type": "Celest::Action", + "id": "invoke" + } + }, + "resource": { + "op": "==", + "entity": { + "type": "Celest::Function", + "id": "lib/sayHelloAuthenticated" + } + }, + "conditions": [ + { + "kind": "unless", + "body": { + "in": { + "left": { + "Var": "principal" + }, + "right": { + "Value": { + "__entity": { + "type": "Celest::Role", + "id": "authenticated" + } + } + } + } + } + } + ] + } + }, + "templates": {}, + "templateLinks": [ + { + "templateId": "cloud.functions.authenticated", + "newId": "lib/sayHelloAuthenticated.authenticated", + "values": { + "?resource": "Celest::Function::\"lib/sayHelloAuthenticated\"" + } + } + ] + } + }, + "streamHelloAuthenticated": { + "functionId": "streamHelloAuthenticated", + "apiId": "lib", + "httpConfig": { + "route": { + "method": "POST", + "path": "/lib/stream-hello-authenticated" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": { + "type": "unidirectionalServer" + }, + "policySet": { + "policies": { + "lib/streamHelloAuthenticated.authenticated_restrict": { + "effect": "forbid", + "principal": { + "op": "All" + }, + "action": { + "op": "==", + "entity": { + "type": "Celest::Action", + "id": "invoke" + } + }, + "resource": { + "op": "==", + "entity": { + "type": "Celest::Function", + "id": "lib/streamHelloAuthenticated" + } + }, + "conditions": [ + { + "kind": "unless", + "body": { + "in": { + "left": { + "Var": "principal" + }, + "right": { + "Value": { + "__entity": { + "type": "Celest::Role", + "id": "authenticated" + } + } + } + } + } + } + ] + } + }, + "templates": {}, + "templateLinks": [ + { + "templateId": "cloud.functions.authenticated", + "newId": "lib/streamHelloAuthenticated.authenticated", + "values": { + "?resource": "Celest::Function::\"lib/streamHelloAuthenticated\"" + } + } + ] + } + }, + "sayHelloPublic": { + "functionId": "sayHelloPublic", + "apiId": "lib", + "httpConfig": { + "route": { + "method": "POST", + "path": "/lib/say-hello-public" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {}, + "policySet": { + "policies": {}, + "templates": {}, + "templateLinks": [ + { + "templateId": "cloud.functions.public", + "newId": "lib/sayHelloPublic.public", + "values": { + "?resource": "Celest::Function::\"lib/sayHelloPublic\"" + } + } + ] + } + }, + "streamHelloPublic": { + "functionId": "streamHelloPublic", + "apiId": "lib", + "httpConfig": { + "route": { + "method": "POST", + "path": "/lib/stream-hello-public" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": { + "type": "unidirectionalServer" + }, + "policySet": { + "policies": {}, + "templates": {}, + "templateLinks": [ + { + "templateId": "cloud.functions.public", + "newId": "lib/streamHelloPublic.public", + "values": { + "?resource": "Celest::Function::\"lib/streamHelloPublic\"" + } + } + ] + } + }, + "sayHello": { + "functionId": "sayHello", + "apiId": "lib", + "httpConfig": { + "route": { + "method": "POST", + "path": "/lib/say-hello" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "streamHello": { + "functionId": "streamHello", + "apiId": "lib", + "httpConfig": { + "route": { + "method": "POST", + "path": "/lib/stream-hello" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": { + "type": "unidirectionalServer" + } + } + } + }, + "authenticated_lib": { + "apiId": "authenticated_lib", + "functions": { + "sayHello": { + "functionId": "sayHello", + "apiId": "authenticated_lib", + "httpConfig": { + "route": { + "method": "POST", + "path": "/authenticated-lib/say-hello" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "streamHello": { + "functionId": "streamHello", + "apiId": "authenticated_lib", + "httpConfig": { + "route": { + "method": "POST", + "path": "/authenticated-lib/stream-hello" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": { + "type": "unidirectionalServer" + } + } + }, + "policySet": { + "policies": { + "authenticated_lib.authenticated_restrict": { + "effect": "forbid", + "principal": { + "op": "All" + }, + "action": { + "op": "==", + "entity": { + "type": "Celest::Action", + "id": "invoke" + } + }, + "resource": { + "op": "in", + "entity": { + "type": "Celest::Api", + "id": "authenticated_lib" + } + }, + "conditions": [ + { + "kind": "unless", + "body": { + "in": { + "left": { + "Var": "principal" + }, + "right": { + "Value": { + "__entity": { + "type": "Celest::Role", + "id": "authenticated" + } + } + } + } + } + } + ] + } + }, + "templates": {}, + "templateLinks": [ + { + "templateId": "cloud.functions.authenticated", + "newId": "authenticated_lib.authenticated", + "values": { + "?resource": "Celest::Api::\"authenticated_lib\"" + } + } + ] + } + }, + "public_lib": { + "apiId": "public_lib", + "functions": { + "sayHello": { + "functionId": "sayHello", + "apiId": "public_lib", + "httpConfig": { + "route": { + "method": "POST", + "path": "/public-lib/say-hello" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "streamHello": { + "functionId": "streamHello", + "apiId": "public_lib", + "httpConfig": { + "route": { + "method": "POST", + "path": "/public-lib/stream-hello" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": { + "type": "unidirectionalServer" + } + } + }, + "policySet": { + "policies": {}, + "templates": {}, + "templateLinks": [ + { + "templateId": "cloud.functions.public", + "newId": "public_lib.public", + "values": { + "?resource": "Celest::Api::\"public_lib\"" + } + } + ] + } + } + }, + "variables": [ + { + "name": "SUPABASE_URL", + "value": "https://vduqtbtlcxxozghvhdqu.supabase.co" + }, + { + "name": "CELEST_ENVIRONMENT", + "value": "local" + } + ], + "secrets": [], + "databases": {}, + "sdkConfig": { + "celest": "1.0.6+2", + "dart": { + "type": "dart", + "version": "3.29.0", + "enabledExperiments": [] + }, + "targetSdk": "flutter", + "featureFlags": [ + "streaming" + ], + "flutter": { + "type": "flutter", + "version": "3.29.0", + "enabledExperiments": [] + } + }, + "auth": { + "providers": [ + { + "$": "ResolvedEmailAuthProvider", + "authProviderId": "emailOtp", + "type": "EMAIL_OTP" + } + ], + "externalProviders": [] + } +} \ No newline at end of file diff --git a/apps/cli/fixtures/legacy/auth/goldens/celest.json b/apps/cli/fixtures/legacy/auth/goldens/celest.json new file mode 100644 index 000000000..33a97779f --- /dev/null +++ b/apps/cli/fixtures/legacy/auth/goldens/celest.json @@ -0,0 +1,458 @@ +{ + "projectId": "auth", + "environmentId": "local", + "apis": { + "lib": { + "apiId": "lib", + "functions": { + "sayHelloAuthenticated": { + "functionId": "sayHelloAuthenticated", + "parentId": "lib", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/lib/say-hello-authenticated" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + }, + "policySet": { + "policies": { + "lib/sayHelloAuthenticated.authenticated_restrict": { + "effect": "EFFECT_FORBID", + "principal": { + "all": {} + }, + "action": { + "equals": { + "entity": { + "type": "Celest::Action", + "id": "invoke" + } + } + }, + "resource": { + "equals": { + "entity": { + "type": "Celest::Function", + "id": "lib/sayHelloAuthenticated" + } + } + }, + "conditions": [ + { + "kind": "CONDITION_KIND_UNLESS", + "body": { + "in": { + "left": { + "variable": { + "variable": "VARIABLE_PRINCIPAL" + } + }, + "right": { + "value": { + "value": { + "entity": { + "uid": { + "type": "Celest::Role", + "id": "authenticated" + } + } + } + } + } + } + } + } + ] + } + }, + "templateLinks": [ + { + "templateId": "cloud.functions.authenticated", + "newId": "lib/sayHelloAuthenticated.authenticated", + "values": { + "?resource": { + "type": "Celest::Function", + "id": "lib/sayHelloAuthenticated" + } + } + } + ] + } + }, + "streamHelloAuthenticated": { + "functionId": "streamHelloAuthenticated", + "parentId": "lib", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/lib/stream-hello-authenticated" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "UNIDIRECTIONAL_SERVER" + }, + "policySet": { + "policies": { + "lib/streamHelloAuthenticated.authenticated_restrict": { + "effect": "EFFECT_FORBID", + "principal": { + "all": {} + }, + "action": { + "equals": { + "entity": { + "type": "Celest::Action", + "id": "invoke" + } + } + }, + "resource": { + "equals": { + "entity": { + "type": "Celest::Function", + "id": "lib/streamHelloAuthenticated" + } + } + }, + "conditions": [ + { + "kind": "CONDITION_KIND_UNLESS", + "body": { + "in": { + "left": { + "variable": { + "variable": "VARIABLE_PRINCIPAL" + } + }, + "right": { + "value": { + "value": { + "entity": { + "uid": { + "type": "Celest::Role", + "id": "authenticated" + } + } + } + } + } + } + } + } + ] + } + }, + "templateLinks": [ + { + "templateId": "cloud.functions.authenticated", + "newId": "lib/streamHelloAuthenticated.authenticated", + "values": { + "?resource": { + "type": "Celest::Function", + "id": "lib/streamHelloAuthenticated" + } + } + } + ] + } + }, + "sayHelloPublic": { + "functionId": "sayHelloPublic", + "parentId": "lib", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/lib/say-hello-public" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + }, + "policySet": { + "templateLinks": [ + { + "templateId": "cloud.functions.public", + "newId": "lib/sayHelloPublic.public", + "values": { + "?resource": { + "type": "Celest::Function", + "id": "lib/sayHelloPublic" + } + } + } + ] + } + }, + "streamHelloPublic": { + "functionId": "streamHelloPublic", + "parentId": "lib", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/lib/stream-hello-public" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "UNIDIRECTIONAL_SERVER" + }, + "policySet": { + "templateLinks": [ + { + "templateId": "cloud.functions.public", + "newId": "lib/streamHelloPublic.public", + "values": { + "?resource": { + "type": "Celest::Function", + "id": "lib/streamHelloPublic" + } + } + } + ] + } + }, + "sayHello": { + "functionId": "sayHello", + "parentId": "lib", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/lib/say-hello" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "streamHello": { + "functionId": "streamHello", + "parentId": "lib", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/lib/stream-hello" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "UNIDIRECTIONAL_SERVER" + } + } + } + }, + "authenticated_lib": { + "apiId": "authenticated_lib", + "functions": { + "sayHello": { + "functionId": "sayHello", + "parentId": "authenticated_lib", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/authenticated-lib/say-hello" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "streamHello": { + "functionId": "streamHello", + "parentId": "authenticated_lib", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/authenticated-lib/stream-hello" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "UNIDIRECTIONAL_SERVER" + } + } + }, + "policySet": { + "policies": { + "authenticated_lib.authenticated_restrict": { + "effect": "EFFECT_FORBID", + "principal": { + "all": {} + }, + "action": { + "equals": { + "entity": { + "type": "Celest::Action", + "id": "invoke" + } + } + }, + "resource": { + "in": { + "entity": { + "type": "Celest::Api", + "id": "authenticated_lib" + } + } + }, + "conditions": [ + { + "kind": "CONDITION_KIND_UNLESS", + "body": { + "in": { + "left": { + "variable": { + "variable": "VARIABLE_PRINCIPAL" + } + }, + "right": { + "value": { + "value": { + "entity": { + "uid": { + "type": "Celest::Role", + "id": "authenticated" + } + } + } + } + } + } + } + } + ] + } + }, + "templateLinks": [ + { + "templateId": "cloud.functions.authenticated", + "newId": "authenticated_lib.authenticated", + "values": { + "?resource": { + "type": "Celest::Api", + "id": "authenticated_lib" + } + } + } + ] + } + }, + "public_lib": { + "apiId": "public_lib", + "functions": { + "sayHello": { + "functionId": "sayHello", + "parentId": "public_lib", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/public-lib/say-hello" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "streamHello": { + "functionId": "streamHello", + "parentId": "public_lib", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/public-lib/stream-hello" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "UNIDIRECTIONAL_SERVER" + } + } + }, + "policySet": { + "templateLinks": [ + { + "templateId": "cloud.functions.public", + "newId": "public_lib.public", + "values": { + "?resource": { + "type": "Celest::Api", + "id": "public_lib" + } + } + } + ] + } + } + }, + "variables": [ + { + "name": "SUPABASE_URL", + "value": "https://vduqtbtlcxxozghvhdqu.supabase.co" + }, + { + "name": "CELEST_ENVIRONMENT", + "value": "local" + } + ], + "auth": { + "providers": [ + { + "authProviderId": "emailOtp", + "type": "EMAIL_OTP", + "emailOtp": {} + } + ] + }, + "databases": {}, + "sdkConfig": { + "celest": { + "major": 1, + "minor": 0, + "patch": 6, + "build": [ + 2.0 + ], + "canonicalizedVersion": "1.0.6+2" + }, + "dart": { + "type": "DART", + "version": { + "major": 3, + "minor": 29, + "patch": 0, + "canonicalizedVersion": "3.29.0" + } + }, + "flutter": { + "type": "FLUTTER", + "version": { + "major": 3, + "minor": 29, + "patch": 0, + "canonicalizedVersion": "3.29.0" + } + }, + "targetSdk": "FLUTTER", + "featureFlags": [ + "STREAMING" + ] + } +} \ No newline at end of file diff --git a/apps/cli/fixtures/legacy/auth/goldens/functions/authenticated_lib/sayHello.dart b/apps/cli/fixtures/legacy/auth/goldens/functions/authenticated_lib/sayHello.dart new file mode 100644 index 000000000..ed2c578de --- /dev/null +++ b/apps/cli/fixtures/legacy/auth/goldens/functions/authenticated_lib/sayHello.dart @@ -0,0 +1,1705 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i3; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/authenticated_lib.dart' as _i5; +import 'package:celest_backend/src/generated/auth.celest.dart' as _i14; +import 'package:celest_cloud_auth/celest_cloud_auth.dart' as _i2; +import 'package:celest_core/celest_core.dart' as _i6; +import 'package:celest_core/src/auth/user.dart' as _i12; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i7; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i13; +import 'package:shelf/shelf.dart' as _i4; + +final class SayHelloTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'sayHello'; + + @override + List<_i1.Middleware> get middlewares => [ + _i1.Middleware.shelf(_i2.CelestCloudAuth.of(_i3.context).middleware.call), + ]; + + @override + String get method => 'POST'; + + @override + Future<_i4.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = await _i5.sayHello( + user: _i3.context.expect(_i3.ContextKey.principal), + ); + return _i4.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(response), + ); + } on _i7.AbortedException catch (e, st) { + const statusCode = 409; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i6.Serializers.instance.serialize<_i7.AbortedException>( + e, + ), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i7.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i6.Serializers.instance + .serialize<_i7.AlreadyExistsException>(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i6.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i7.CancelledException catch (e, st) { + const statusCode = 499; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i6.Serializers.instance + .serialize<_i7.CancelledException>(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i6.Serializers.instance + .serialize(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i7.DataLossError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i6.Serializers.instance.serialize<_i7.DataLossError>(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i7.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i6.Serializers.instance + .serialize<_i7.DeadlineExceededError>(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i7.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i6.Serializers.instance + .serialize<_i7.FailedPreconditionException>(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i6.Serializers.instance + .serialize(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i7.InternalServerError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i6.Serializers.instance + .serialize<_i7.InternalServerError>(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i6.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i7.NotFoundException catch (e, st) { + const statusCode = 404; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i6.Serializers.instance + .serialize<_i7.NotFoundException>(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i7.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i6.Serializers.instance + .serialize<_i7.OutOfRangeException>(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i7.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i6.Serializers.instance + .serialize<_i7.PermissionDeniedException>(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i7.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i6.Serializers.instance + .serialize<_i7.ResourceExhaustedException>(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i6.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i7.BadRequestException catch (e, st) { + const statusCode = 400; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i6.Serializers.instance + .serialize<_i7.BadRequestException>(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i6.Serializers.instance.serialize( + e, + ), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i6.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i7.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i6.Serializers.instance + .serialize<_i7.UnauthorizedException>(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i7.UnavailableError catch (e, st) { + const statusCode = 503; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i6.Serializers.instance.serialize<_i7.UnavailableError>( + e, + ), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i7.UnimplementedError catch (e, st) { + const statusCode = 501; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i6.Serializers.instance + .serialize<_i7.UnimplementedError>(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i6.Serializers.instance.serialize( + e, + ), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i7.UnknownError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i6.Serializers.instance.serialize<_i7.UnknownError>(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i7.CloudException catch (e, st) { + const statusCode = 400; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i6.Serializers.instance.serialize<_i7.CloudException>( + e, + ), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i6.Serializers.instance.put( + _i6.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i6.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i6.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i6.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i6.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: + ($value) => { + if (_i6.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i12.User, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i12.User.fromJson($serialized); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i7.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.AbortedException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i7.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i7.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.BadRequestException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i7.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.CancelledException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i7.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.CloudException.fromJson($serialized); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i7.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.DataLossError( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i7.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define< + _i7.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i7.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.InternalServerError( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i7.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.NotFoundException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i7.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define< + _i7.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define< + _i7.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i7.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i7.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.UnavailableError( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i7.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.UnimplementedError( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i7.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.UnknownError( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i13.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i13.JsonValue($serialized); + }, + ), + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': SayHelloTarget()}, + setup: (_i3.Context context) async { + await _i14.CelestAuth.init(context); + }, + ); +} diff --git a/apps/cli/fixtures/legacy/auth/goldens/functions/authenticated_lib/streamHello.dart b/apps/cli/fixtures/legacy/auth/goldens/functions/authenticated_lib/streamHello.dart new file mode 100644 index 000000000..64ffc0677 --- /dev/null +++ b/apps/cli/fixtures/legacy/auth/goldens/functions/authenticated_lib/streamHello.dart @@ -0,0 +1,1557 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i9; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i3; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/authenticated_lib.dart' as _i4; +import 'package:celest_backend/src/generated/auth.celest.dart' as _i13; +import 'package:celest_cloud_auth/celest_cloud_auth.dart' as _i2; +import 'package:celest_core/celest_core.dart' as _i6; +import 'package:celest_core/src/auth/user.dart' as _i11; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i10; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; + +final class StreamHelloTarget extends _i1.CloudEventSourceTarget { + @override + String get name => 'streamHello'; + + @override + List<_i1.Middleware> get middlewares => [ + _i1.Middleware.shelf(_i2.CelestCloudAuth.of(_i3.context).middleware.call), + ]; + + @override + bool get hasBody => false; + + @override + Stream handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async* { + try { + await for (final response in _i4.streamHello( + user: _i3.context.expect(_i3.ContextKey.principal), + )) { + yield response; + } + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i6.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i6.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on AssertionError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i6.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i6.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i6.Serializers.instance + .serialize(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i6.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i6.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i6.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on IndexError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i6.Serializers.instance + .serialize(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i6.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i9.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i6.Serializers.instance + .serialize<_i9.JsonUnsupportedObjectError>(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i6.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i6.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i6.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on RangeError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i6.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i10.SerializationException catch (e, st) { + const statusCode = 400; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i6.Serializers.instance + .serialize<_i10.SerializationException>(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i6.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on FormatException catch (e, st) { + const statusCode = 400; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i6.Serializers.instance.serialize( + e, + ), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on StateError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i6.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on TypeError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i6.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i6.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i6.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i6.Serializers.instance.serialize( + e, + ), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i6.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i6.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on Exception catch (e, st) { + const statusCode = 400; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on Error catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } + } + + @override + void init() { + _i6.Serializers.instance.put( + _i6.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i6.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i6.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i6.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i6.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define< + _i9.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i9.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: + ($value) => { + if (_i6.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i11.User, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i11.User.fromJson($serialized); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i10.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i10.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': StreamHelloTarget()}, + setup: (_i3.Context context) async { + await _i13.CelestAuth.init(context); + }, + ); +} diff --git a/apps/cli/fixtures/legacy/auth/goldens/functions/lib/sayHello.dart b/apps/cli/fixtures/legacy/auth/goldens/functions/lib/sayHello.dart new file mode 100644 index 000000000..756e32be5 --- /dev/null +++ b/apps/cli/fixtures/legacy/auth/goldens/functions/lib/sayHello.dart @@ -0,0 +1,1699 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i9; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i4; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/lib.dart' as _i3; +import 'package:celest_backend/src/generated/auth.celest.dart' as _i13; +import 'package:celest_core/celest_core.dart' as _i5; +import 'package:celest_core/src/auth/user.dart' as _i11; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i10; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class SayHelloTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'sayHello'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = await _i3.sayHello( + user: _i4.context.get(_i4.ContextKey.principal), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i5.JsonUtf8.encode(response), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i5.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i4.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i5.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i5.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i4.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i5.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i4.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i5.Serializers.instance.serialize(e), + }, + if (_i4.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i5.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i4.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i5.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i4.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i5.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i5.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i4.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i5.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i4.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i5.Serializers.instance + .serialize(e), + }, + if (_i4.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i5.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i5.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i4.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i5.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i5.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i4.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i5.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i5.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i4.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i5.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i4.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i5.Serializers.instance.serialize(e), + }, + if (_i4.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i5.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i5.Serializers.instance + .serialize(e), + }, + if (_i4.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i5.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i5.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i4.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i5.JsonUtf8.encode(status), + ); + } on _i9.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i4.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i5.Serializers.instance + .serialize<_i9.JsonUnsupportedObjectError>(e), + }, + if (_i4.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i5.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i5.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i4.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i5.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i4.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i5.Serializers.instance.serialize(e), + }, + if (_i4.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i5.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i5.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i4.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i5.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i5.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i4.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i5.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i4.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i5.Serializers.instance.serialize(e), + }, + if (_i4.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i5.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i4.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i5.Serializers.instance.serialize(e), + }, + if (_i4.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i5.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i5.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i4.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i5.JsonUtf8.encode(status), + ); + } on _i10.SerializationException catch (e, st) { + const statusCode = 400; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i5.Serializers.instance + .serialize<_i10.SerializationException>(e), + }, + if (_i4.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i5.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i5.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i4.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i5.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i5.Serializers.instance.serialize(e), + }, + if (_i4.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i5.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i4.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i5.Serializers.instance.serialize( + e, + ), + }, + if (_i4.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i5.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i5.Serializers.instance.serialize(e), + }, + if (_i4.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i5.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i5.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i4.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i5.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i4.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i5.Serializers.instance.serialize(e), + }, + if (_i4.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i5.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i5.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i4.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i5.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i5.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i4.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i5.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i5.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i4.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i5.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i5.Serializers.instance.serialize( + e, + ), + }, + if (_i4.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i5.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i5.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i4.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i5.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i5.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i4.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i5.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i4.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i5.Serializers.instance.serialize(e), + }, + if (_i4.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i5.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i5.Serializers.instance.serialize(e), + }, + if (_i4.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i5.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i4.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i5.Serializers.instance.serialize(e), + }, + if (_i4.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i5.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i5.Serializers.instance.put( + _i5.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i5.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i5.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i5.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i5.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define< + _i9.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i9.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define?>( + serialize: + ($value) => { + if (_i5.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define<_i11.User, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i11.User.fromJson($serialized); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i5.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i5.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i5.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i5.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i5.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i5.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i5.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i5.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i5.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i5.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i5.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i5.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i5.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i5.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i5.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i5.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i5.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i5.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i5.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i5.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i5.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i5.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i5.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i5.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i5.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i5.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i5.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i5.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i5.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i5.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i5.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i5.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i5.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i5.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i5.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i5.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i5.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i5.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i5.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i5.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i5.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i5.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i5.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i5.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i5.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i5.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i5.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i5.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i5.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i5.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i5.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i5.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i5.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i5.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i5.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i5.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i5.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i5.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i5.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i5.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i5.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i5.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i5.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i5.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i5.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i5.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define<_i10.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i5.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i5.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i10.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i5.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': SayHelloTarget()}, + setup: (_i4.Context context) async { + await _i13.CelestAuth.init(context); + }, + ); +} diff --git a/apps/cli/fixtures/legacy/auth/goldens/functions/lib/sayHelloAuthenticated.dart b/apps/cli/fixtures/legacy/auth/goldens/functions/lib/sayHelloAuthenticated.dart new file mode 100644 index 000000000..5cb81a2eb --- /dev/null +++ b/apps/cli/fixtures/legacy/auth/goldens/functions/lib/sayHelloAuthenticated.dart @@ -0,0 +1,1705 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i3; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/lib.dart' as _i5; +import 'package:celest_backend/src/generated/auth.celest.dart' as _i14; +import 'package:celest_cloud_auth/celest_cloud_auth.dart' as _i2; +import 'package:celest_core/celest_core.dart' as _i6; +import 'package:celest_core/src/auth/user.dart' as _i12; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i7; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i13; +import 'package:shelf/shelf.dart' as _i4; + +final class SayHelloAuthenticatedTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'sayHelloAuthenticated'; + + @override + List<_i1.Middleware> get middlewares => [ + _i1.Middleware.shelf(_i2.CelestCloudAuth.of(_i3.context).middleware.call), + ]; + + @override + String get method => 'POST'; + + @override + Future<_i4.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = await _i5.sayHelloAuthenticated( + user: _i3.context.expect(_i3.ContextKey.principal), + ); + return _i4.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(response), + ); + } on _i7.AbortedException catch (e, st) { + const statusCode = 409; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i6.Serializers.instance.serialize<_i7.AbortedException>( + e, + ), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i7.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i6.Serializers.instance + .serialize<_i7.AlreadyExistsException>(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i6.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i7.CancelledException catch (e, st) { + const statusCode = 499; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i6.Serializers.instance + .serialize<_i7.CancelledException>(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i6.Serializers.instance + .serialize(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i7.DataLossError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i6.Serializers.instance.serialize<_i7.DataLossError>(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i7.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i6.Serializers.instance + .serialize<_i7.DeadlineExceededError>(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i7.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i6.Serializers.instance + .serialize<_i7.FailedPreconditionException>(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i6.Serializers.instance + .serialize(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i7.InternalServerError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i6.Serializers.instance + .serialize<_i7.InternalServerError>(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i6.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i7.NotFoundException catch (e, st) { + const statusCode = 404; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i6.Serializers.instance + .serialize<_i7.NotFoundException>(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i7.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i6.Serializers.instance + .serialize<_i7.OutOfRangeException>(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i7.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i6.Serializers.instance + .serialize<_i7.PermissionDeniedException>(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i7.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i6.Serializers.instance + .serialize<_i7.ResourceExhaustedException>(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i6.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i7.BadRequestException catch (e, st) { + const statusCode = 400; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i6.Serializers.instance + .serialize<_i7.BadRequestException>(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i6.Serializers.instance.serialize( + e, + ), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i6.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i7.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i6.Serializers.instance + .serialize<_i7.UnauthorizedException>(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i7.UnavailableError catch (e, st) { + const statusCode = 503; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i6.Serializers.instance.serialize<_i7.UnavailableError>( + e, + ), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i7.UnimplementedError catch (e, st) { + const statusCode = 501; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i6.Serializers.instance + .serialize<_i7.UnimplementedError>(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i6.Serializers.instance.serialize( + e, + ), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i7.UnknownError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i6.Serializers.instance.serialize<_i7.UnknownError>(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i7.CloudException catch (e, st) { + const statusCode = 400; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i6.Serializers.instance.serialize<_i7.CloudException>( + e, + ), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i6.Serializers.instance.put( + _i6.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i6.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i6.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i6.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i6.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: + ($value) => { + if (_i6.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i12.User, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i12.User.fromJson($serialized); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i7.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.AbortedException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i7.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i7.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.BadRequestException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i7.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.CancelledException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i7.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.CloudException.fromJson($serialized); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i7.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.DataLossError( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i7.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define< + _i7.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i7.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.InternalServerError( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i7.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.NotFoundException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i7.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define< + _i7.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define< + _i7.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i7.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i7.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.UnavailableError( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i7.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.UnimplementedError( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i7.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.UnknownError( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i13.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i13.JsonValue($serialized); + }, + ), + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': SayHelloAuthenticatedTarget()}, + setup: (_i3.Context context) async { + await _i14.CelestAuth.init(context); + }, + ); +} diff --git a/apps/cli/fixtures/legacy/auth/goldens/functions/lib/sayHelloPublic.dart b/apps/cli/fixtures/legacy/auth/goldens/functions/lib/sayHelloPublic.dart new file mode 100644 index 000000000..4fbc15c06 --- /dev/null +++ b/apps/cli/fixtures/legacy/auth/goldens/functions/lib/sayHelloPublic.dart @@ -0,0 +1,1705 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i3; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/lib.dart' as _i5; +import 'package:celest_backend/src/generated/auth.celest.dart' as _i14; +import 'package:celest_cloud_auth/celest_cloud_auth.dart' as _i2; +import 'package:celest_core/celest_core.dart' as _i6; +import 'package:celest_core/src/auth/user.dart' as _i12; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i7; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i13; +import 'package:shelf/shelf.dart' as _i4; + +final class SayHelloPublicTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'sayHelloPublic'; + + @override + List<_i1.Middleware> get middlewares => [ + _i1.Middleware.shelf(_i2.CelestCloudAuth.of(_i3.context).middleware.call), + ]; + + @override + String get method => 'POST'; + + @override + Future<_i4.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = await _i5.sayHelloPublic( + user: _i3.context.get(_i3.ContextKey.principal), + ); + return _i4.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(response), + ); + } on _i7.AbortedException catch (e, st) { + const statusCode = 409; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i6.Serializers.instance.serialize<_i7.AbortedException>( + e, + ), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i7.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i6.Serializers.instance + .serialize<_i7.AlreadyExistsException>(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i6.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i7.CancelledException catch (e, st) { + const statusCode = 499; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i6.Serializers.instance + .serialize<_i7.CancelledException>(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i6.Serializers.instance + .serialize(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i7.DataLossError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i6.Serializers.instance.serialize<_i7.DataLossError>(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i7.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i6.Serializers.instance + .serialize<_i7.DeadlineExceededError>(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i7.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i6.Serializers.instance + .serialize<_i7.FailedPreconditionException>(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i6.Serializers.instance + .serialize(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i7.InternalServerError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i6.Serializers.instance + .serialize<_i7.InternalServerError>(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i6.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i7.NotFoundException catch (e, st) { + const statusCode = 404; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i6.Serializers.instance + .serialize<_i7.NotFoundException>(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i7.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i6.Serializers.instance + .serialize<_i7.OutOfRangeException>(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i7.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i6.Serializers.instance + .serialize<_i7.PermissionDeniedException>(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i7.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i6.Serializers.instance + .serialize<_i7.ResourceExhaustedException>(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i6.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i7.BadRequestException catch (e, st) { + const statusCode = 400; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i6.Serializers.instance + .serialize<_i7.BadRequestException>(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i6.Serializers.instance.serialize( + e, + ), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i6.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i7.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i6.Serializers.instance + .serialize<_i7.UnauthorizedException>(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i7.UnavailableError catch (e, st) { + const statusCode = 503; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i6.Serializers.instance.serialize<_i7.UnavailableError>( + e, + ), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i7.UnimplementedError catch (e, st) { + const statusCode = 501; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i6.Serializers.instance + .serialize<_i7.UnimplementedError>(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i6.Serializers.instance.serialize( + e, + ), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i7.UnknownError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i6.Serializers.instance.serialize<_i7.UnknownError>(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i7.CloudException catch (e, st) { + const statusCode = 400; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i6.Serializers.instance.serialize<_i7.CloudException>( + e, + ), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i6.Serializers.instance.put( + _i6.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i6.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i6.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i6.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i6.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: + ($value) => { + if (_i6.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i12.User, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i12.User.fromJson($serialized); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i7.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.AbortedException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i7.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i7.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.BadRequestException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i7.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.CancelledException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i7.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.CloudException.fromJson($serialized); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i7.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.DataLossError( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i7.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define< + _i7.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i7.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.InternalServerError( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i7.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.NotFoundException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i7.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define< + _i7.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define< + _i7.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i7.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i7.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.UnavailableError( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i7.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.UnimplementedError( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i7.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.UnknownError( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i13.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i13.JsonValue($serialized); + }, + ), + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': SayHelloPublicTarget()}, + setup: (_i3.Context context) async { + await _i14.CelestAuth.init(context); + }, + ); +} diff --git a/apps/cli/fixtures/legacy/auth/goldens/functions/lib/streamHello.dart b/apps/cli/fixtures/legacy/auth/goldens/functions/lib/streamHello.dart new file mode 100644 index 000000000..e15efcd79 --- /dev/null +++ b/apps/cli/fixtures/legacy/auth/goldens/functions/lib/streamHello.dart @@ -0,0 +1,1551 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i7; +import 'dart:convert' as _i8; + +import 'package:celest/celest.dart' as _i6; +import 'package:celest/src/core/context.dart' as _i3; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/lib.dart' as _i2; +import 'package:celest_backend/src/generated/auth.celest.dart' as _i12; +import 'package:celest_core/celest_core.dart' as _i5; +import 'package:celest_core/src/auth/user.dart' as _i10; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i4; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i9; +import 'package:celest_core/src/serialization/json_value.dart' as _i11; + +final class StreamHelloTarget extends _i1.CloudEventSourceTarget { + @override + String get name => 'streamHello'; + + @override + bool get hasBody => false; + + @override + Stream handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async* { + try { + await for (final response in _i2.streamHello( + user: _i3.context.get(_i3.ContextKey.principal), + )) { + yield response; + } + } on _i4.AbortedException catch (e, st) { + const statusCode = 409; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i5.Serializers.instance.serialize<_i4.AbortedException>( + e, + ), + }, + if (_i3.context.environment != _i6.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i4.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i5.Serializers.instance + .serialize<_i4.AlreadyExistsException>(e), + }, + if (_i3.context.environment != _i6.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on AssertionError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i5.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i6.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i7.AsyncError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i5.Serializers.instance.serialize<_i7.AsyncError>(e), + }, + if (_i3.context.environment != _i6.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i4.CancelledException catch (e, st) { + const statusCode = 499; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i5.Serializers.instance + .serialize<_i4.CancelledException>(e), + }, + if (_i3.context.environment != _i6.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i5.Serializers.instance + .serialize(e), + }, + if (_i3.context.environment != _i6.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i4.DataLossError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i5.Serializers.instance.serialize<_i4.DataLossError>(e), + }, + if (_i3.context.environment != _i6.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i4.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i5.Serializers.instance + .serialize<_i4.DeadlineExceededError>(e), + }, + if (_i3.context.environment != _i6.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i4.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i5.Serializers.instance + .serialize<_i4.FailedPreconditionException>(e), + }, + if (_i3.context.environment != _i6.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on IndexError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i5.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i6.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i5.Serializers.instance + .serialize(e), + }, + if (_i3.context.environment != _i6.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i4.InternalServerError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i5.Serializers.instance + .serialize<_i4.InternalServerError>(e), + }, + if (_i3.context.environment != _i6.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i8.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i5.Serializers.instance + .serialize<_i8.JsonUnsupportedObjectError>(e), + }, + if (_i3.context.environment != _i6.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i4.NotFoundException catch (e, st) { + const statusCode = 404; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i5.Serializers.instance + .serialize<_i4.NotFoundException>(e), + }, + if (_i3.context.environment != _i6.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i5.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i6.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i4.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i5.Serializers.instance + .serialize<_i4.OutOfRangeException>(e), + }, + if (_i3.context.environment != _i6.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i4.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i5.Serializers.instance + .serialize<_i4.PermissionDeniedException>(e), + }, + if (_i3.context.environment != _i6.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on RangeError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i5.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i6.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i5.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i6.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i4.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i5.Serializers.instance + .serialize<_i4.ResourceExhaustedException>(e), + }, + if (_i3.context.environment != _i6.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i9.SerializationException catch (e, st) { + const statusCode = 400; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i5.Serializers.instance + .serialize<_i9.SerializationException>(e), + }, + if (_i3.context.environment != _i6.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i4.BadRequestException catch (e, st) { + const statusCode = 400; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i5.Serializers.instance + .serialize<_i4.BadRequestException>(e), + }, + if (_i3.context.environment != _i6.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on FormatException catch (e, st) { + const statusCode = 400; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i5.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i6.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i5.Serializers.instance.serialize( + e, + ), + }, + if (_i3.context.environment != _i6.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on StateError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i5.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i6.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i7.TimeoutException catch (e, st) { + const statusCode = 400; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i5.Serializers.instance.serialize<_i7.TimeoutException>( + e, + ), + }, + if (_i3.context.environment != _i6.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on TypeError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i5.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i6.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i4.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i5.Serializers.instance + .serialize<_i4.UnauthorizedException>(e), + }, + if (_i3.context.environment != _i6.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i4.UnavailableError catch (e, st) { + const statusCode = 503; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i5.Serializers.instance.serialize<_i4.UnavailableError>( + e, + ), + }, + if (_i3.context.environment != _i6.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i4.UnimplementedError catch (e, st) { + const statusCode = 501; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i5.Serializers.instance + .serialize<_i4.UnimplementedError>(e), + }, + if (_i3.context.environment != _i6.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i5.Serializers.instance.serialize( + e, + ), + }, + if (_i3.context.environment != _i6.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i4.UnknownError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i5.Serializers.instance.serialize<_i4.UnknownError>(e), + }, + if (_i3.context.environment != _i6.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i4.CloudException catch (e, st) { + const statusCode = 400; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i5.Serializers.instance.serialize<_i4.CloudException>( + e, + ), + }, + if (_i3.context.environment != _i6.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on Exception catch (e, st) { + const statusCode = 400; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i5.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i6.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i5.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i6.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on Error catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i5.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i6.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } + } + + @override + void init() { + _i5.Serializers.instance.put( + _i5.Serializer.define<_i7.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i5.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i7.AsyncError( + $serialized[r'error']!, + _i5.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define<_i7.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i5.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i7.TimeoutException( + ($serialized[r'message'] as String?), + _i5.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define< + _i8.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i8.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define?>( + serialize: + ($value) => { + if (_i5.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define<_i10.User, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i10.User.fromJson($serialized); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define<_i4.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i5.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i5.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i4.AbortedException( + ($serialized?[r'message'] as String?), + _i5.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i5.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define<_i4.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i5.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i5.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i4.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i5.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i5.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define<_i4.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i5.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i5.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i4.BadRequestException( + ($serialized?[r'message'] as String?), + _i5.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i5.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define<_i4.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i5.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i5.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i4.CancelledException( + ($serialized?[r'message'] as String?), + _i5.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i5.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define<_i4.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i5.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i5.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i4.CloudException.fromJson($serialized); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define<_i4.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i5.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i5.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i4.DataLossError( + ($serialized?[r'message'] as String?), + _i5.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i5.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define<_i4.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i5.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i5.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i4.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i5.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i5.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define< + _i4.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i5.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i5.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i4.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i5.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i5.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define<_i4.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i5.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i5.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i4.InternalServerError( + ($serialized?[r'message'] as String?), + _i5.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i5.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define<_i4.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i5.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i5.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i4.NotFoundException( + ($serialized?[r'message'] as String?), + _i5.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i5.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define<_i4.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i5.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i5.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i4.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i5.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i5.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define< + _i4.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i5.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i5.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i4.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i5.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i5.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define< + _i4.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i5.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i5.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i4.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i5.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i5.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define<_i4.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i5.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i5.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i4.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i5.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i5.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define<_i4.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i5.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i5.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i4.UnavailableError( + ($serialized?[r'message'] as String?), + _i5.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i5.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define<_i4.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i5.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i5.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i4.UnimplementedError( + ($serialized?[r'message'] as String?), + _i5.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i5.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define<_i4.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i5.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i5.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i4.UnknownError( + ($serialized?[r'message'] as String?), + _i5.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i5.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define<_i9.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i5.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i5.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i9.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define<_i11.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i11.JsonValue($serialized); + }, + ), + const _i5.TypeToken<_i11.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': StreamHelloTarget()}, + setup: (_i3.Context context) async { + await _i12.CelestAuth.init(context); + }, + ); +} diff --git a/apps/cli/fixtures/legacy/auth/goldens/functions/lib/streamHelloAuthenticated.dart b/apps/cli/fixtures/legacy/auth/goldens/functions/lib/streamHelloAuthenticated.dart new file mode 100644 index 000000000..3690fc101 --- /dev/null +++ b/apps/cli/fixtures/legacy/auth/goldens/functions/lib/streamHelloAuthenticated.dart @@ -0,0 +1,1557 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i9; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i3; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/lib.dart' as _i4; +import 'package:celest_backend/src/generated/auth.celest.dart' as _i13; +import 'package:celest_cloud_auth/celest_cloud_auth.dart' as _i2; +import 'package:celest_core/celest_core.dart' as _i6; +import 'package:celest_core/src/auth/user.dart' as _i11; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i10; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; + +final class StreamHelloAuthenticatedTarget extends _i1.CloudEventSourceTarget { + @override + String get name => 'streamHelloAuthenticated'; + + @override + List<_i1.Middleware> get middlewares => [ + _i1.Middleware.shelf(_i2.CelestCloudAuth.of(_i3.context).middleware.call), + ]; + + @override + bool get hasBody => false; + + @override + Stream handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async* { + try { + await for (final response in _i4.streamHelloAuthenticated( + user: _i3.context.expect(_i3.ContextKey.principal), + )) { + yield response; + } + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i6.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i6.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on AssertionError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i6.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i6.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i6.Serializers.instance + .serialize(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i6.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i6.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i6.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on IndexError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i6.Serializers.instance + .serialize(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i6.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i9.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i6.Serializers.instance + .serialize<_i9.JsonUnsupportedObjectError>(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i6.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i6.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i6.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on RangeError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i6.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i10.SerializationException catch (e, st) { + const statusCode = 400; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i6.Serializers.instance + .serialize<_i10.SerializationException>(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i6.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on FormatException catch (e, st) { + const statusCode = 400; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i6.Serializers.instance.serialize( + e, + ), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on StateError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i6.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on TypeError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i6.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i6.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i6.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i6.Serializers.instance.serialize( + e, + ), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i6.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i6.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on Exception catch (e, st) { + const statusCode = 400; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on Error catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } + } + + @override + void init() { + _i6.Serializers.instance.put( + _i6.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i6.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i6.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i6.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i6.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define< + _i9.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i9.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: + ($value) => { + if (_i6.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i11.User, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i11.User.fromJson($serialized); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i10.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i10.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': StreamHelloAuthenticatedTarget()}, + setup: (_i3.Context context) async { + await _i13.CelestAuth.init(context); + }, + ); +} diff --git a/apps/cli/fixtures/legacy/auth/goldens/functions/lib/streamHelloPublic.dart b/apps/cli/fixtures/legacy/auth/goldens/functions/lib/streamHelloPublic.dart new file mode 100644 index 000000000..a61308f1e --- /dev/null +++ b/apps/cli/fixtures/legacy/auth/goldens/functions/lib/streamHelloPublic.dart @@ -0,0 +1,1557 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i9; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i3; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/lib.dart' as _i4; +import 'package:celest_backend/src/generated/auth.celest.dart' as _i13; +import 'package:celest_cloud_auth/celest_cloud_auth.dart' as _i2; +import 'package:celest_core/celest_core.dart' as _i6; +import 'package:celest_core/src/auth/user.dart' as _i11; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i10; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; + +final class StreamHelloPublicTarget extends _i1.CloudEventSourceTarget { + @override + String get name => 'streamHelloPublic'; + + @override + List<_i1.Middleware> get middlewares => [ + _i1.Middleware.shelf(_i2.CelestCloudAuth.of(_i3.context).middleware.call), + ]; + + @override + bool get hasBody => false; + + @override + Stream handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async* { + try { + await for (final response in _i4.streamHelloPublic( + user: _i3.context.get(_i3.ContextKey.principal), + )) { + yield response; + } + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i6.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i6.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on AssertionError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i6.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i6.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i6.Serializers.instance + .serialize(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i6.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i6.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i6.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on IndexError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i6.Serializers.instance + .serialize(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i6.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i9.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i6.Serializers.instance + .serialize<_i9.JsonUnsupportedObjectError>(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i6.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i6.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i6.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on RangeError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i6.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i10.SerializationException catch (e, st) { + const statusCode = 400; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i6.Serializers.instance + .serialize<_i10.SerializationException>(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i6.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on FormatException catch (e, st) { + const statusCode = 400; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i6.Serializers.instance.serialize( + e, + ), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on StateError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i6.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on TypeError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i6.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i6.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i6.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i6.Serializers.instance.serialize( + e, + ), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i6.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i6.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on Exception catch (e, st) { + const statusCode = 400; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on Error catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } + } + + @override + void init() { + _i6.Serializers.instance.put( + _i6.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i6.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i6.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i6.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i6.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define< + _i9.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i9.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: + ($value) => { + if (_i6.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i11.User, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i11.User.fromJson($serialized); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i10.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i10.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': StreamHelloPublicTarget()}, + setup: (_i3.Context context) async { + await _i13.CelestAuth.init(context); + }, + ); +} diff --git a/apps/cli/fixtures/legacy/auth/goldens/functions/public_lib/sayHello.dart b/apps/cli/fixtures/legacy/auth/goldens/functions/public_lib/sayHello.dart new file mode 100644 index 000000000..53671b65d --- /dev/null +++ b/apps/cli/fixtures/legacy/auth/goldens/functions/public_lib/sayHello.dart @@ -0,0 +1,1705 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i3; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/public_lib.dart' as _i5; +import 'package:celest_backend/src/generated/auth.celest.dart' as _i14; +import 'package:celest_cloud_auth/celest_cloud_auth.dart' as _i2; +import 'package:celest_core/celest_core.dart' as _i6; +import 'package:celest_core/src/auth/user.dart' as _i12; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i7; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i13; +import 'package:shelf/shelf.dart' as _i4; + +final class SayHelloTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'sayHello'; + + @override + List<_i1.Middleware> get middlewares => [ + _i1.Middleware.shelf(_i2.CelestCloudAuth.of(_i3.context).middleware.call), + ]; + + @override + String get method => 'POST'; + + @override + Future<_i4.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = await _i5.sayHello( + user: _i3.context.get(_i3.ContextKey.principal), + ); + return _i4.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(response), + ); + } on _i7.AbortedException catch (e, st) { + const statusCode = 409; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i6.Serializers.instance.serialize<_i7.AbortedException>( + e, + ), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i7.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i6.Serializers.instance + .serialize<_i7.AlreadyExistsException>(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i6.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i7.CancelledException catch (e, st) { + const statusCode = 499; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i6.Serializers.instance + .serialize<_i7.CancelledException>(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i6.Serializers.instance + .serialize(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i7.DataLossError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i6.Serializers.instance.serialize<_i7.DataLossError>(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i7.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i6.Serializers.instance + .serialize<_i7.DeadlineExceededError>(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i7.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i6.Serializers.instance + .serialize<_i7.FailedPreconditionException>(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i6.Serializers.instance + .serialize(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i7.InternalServerError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i6.Serializers.instance + .serialize<_i7.InternalServerError>(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i6.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i7.NotFoundException catch (e, st) { + const statusCode = 404; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i6.Serializers.instance + .serialize<_i7.NotFoundException>(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i7.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i6.Serializers.instance + .serialize<_i7.OutOfRangeException>(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i7.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i6.Serializers.instance + .serialize<_i7.PermissionDeniedException>(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i7.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i6.Serializers.instance + .serialize<_i7.ResourceExhaustedException>(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i6.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i7.BadRequestException catch (e, st) { + const statusCode = 400; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i6.Serializers.instance + .serialize<_i7.BadRequestException>(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i6.Serializers.instance.serialize( + e, + ), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i6.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i7.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i6.Serializers.instance + .serialize<_i7.UnauthorizedException>(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i7.UnavailableError catch (e, st) { + const statusCode = 503; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i6.Serializers.instance.serialize<_i7.UnavailableError>( + e, + ), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i7.UnimplementedError catch (e, st) { + const statusCode = 501; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i6.Serializers.instance + .serialize<_i7.UnimplementedError>(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i6.Serializers.instance.serialize( + e, + ), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i7.UnknownError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i6.Serializers.instance.serialize<_i7.UnknownError>(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i7.CloudException catch (e, st) { + const statusCode = 400; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i6.Serializers.instance.serialize<_i7.CloudException>( + e, + ), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i4.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i6.Serializers.instance.put( + _i6.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i6.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i6.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i6.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i6.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: + ($value) => { + if (_i6.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i12.User, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i12.User.fromJson($serialized); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i7.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.AbortedException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i7.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i7.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.BadRequestException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i7.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.CancelledException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i7.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.CloudException.fromJson($serialized); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i7.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.DataLossError( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i7.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define< + _i7.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i7.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.InternalServerError( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i7.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.NotFoundException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i7.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define< + _i7.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define< + _i7.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i7.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i7.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.UnavailableError( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i7.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.UnimplementedError( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i7.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.UnknownError( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i13.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i13.JsonValue($serialized); + }, + ), + const _i6.TypeToken<_i13.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': SayHelloTarget()}, + setup: (_i3.Context context) async { + await _i14.CelestAuth.init(context); + }, + ); +} diff --git a/apps/cli/fixtures/legacy/auth/goldens/functions/public_lib/streamHello.dart b/apps/cli/fixtures/legacy/auth/goldens/functions/public_lib/streamHello.dart new file mode 100644 index 000000000..4f50e8f83 --- /dev/null +++ b/apps/cli/fixtures/legacy/auth/goldens/functions/public_lib/streamHello.dart @@ -0,0 +1,1557 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i9; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i3; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/public_lib.dart' as _i4; +import 'package:celest_backend/src/generated/auth.celest.dart' as _i13; +import 'package:celest_cloud_auth/celest_cloud_auth.dart' as _i2; +import 'package:celest_core/celest_core.dart' as _i6; +import 'package:celest_core/src/auth/user.dart' as _i11; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i10; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; + +final class StreamHelloTarget extends _i1.CloudEventSourceTarget { + @override + String get name => 'streamHello'; + + @override + List<_i1.Middleware> get middlewares => [ + _i1.Middleware.shelf(_i2.CelestCloudAuth.of(_i3.context).middleware.call), + ]; + + @override + bool get hasBody => false; + + @override + Stream handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async* { + try { + await for (final response in _i4.streamHello( + user: _i3.context.get(_i3.ContextKey.principal), + )) { + yield response; + } + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i6.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i6.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on AssertionError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i6.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i6.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i6.Serializers.instance + .serialize(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i6.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i6.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i6.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on IndexError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i6.Serializers.instance + .serialize(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i6.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i9.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i6.Serializers.instance + .serialize<_i9.JsonUnsupportedObjectError>(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i6.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i6.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i6.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on RangeError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i6.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i10.SerializationException catch (e, st) { + const statusCode = 400; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i6.Serializers.instance + .serialize<_i10.SerializationException>(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i6.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on FormatException catch (e, st) { + const statusCode = 400; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i6.Serializers.instance.serialize( + e, + ), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on StateError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i6.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on TypeError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i6.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i6.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i6.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i6.Serializers.instance.serialize( + e, + ), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i6.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i6.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on Exception catch (e, st) { + const statusCode = 400; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on Error catch (e, st) { + const statusCode = 500; + _i3.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i3.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } + } + + @override + void init() { + _i6.Serializers.instance.put( + _i6.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i6.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i6.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i6.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i6.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define< + _i9.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i9.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: + ($value) => { + if (_i6.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i11.User, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i11.User.fromJson($serialized); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i10.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i10.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i6.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': StreamHelloTarget()}, + setup: (_i3.Context context) async { + await _i13.CelestAuth.init(context); + }, + ); +} diff --git a/apps/cli/fixtures/legacy/auth/lib/fix_data/v1_migration.yaml b/apps/cli/fixtures/legacy/auth/lib/fix_data/v1_migration.yaml new file mode 100644 index 000000000..4e68b1c51 --- /dev/null +++ b/apps/cli/fixtures/legacy/auth/lib/fix_data/v1_migration.yaml @@ -0,0 +1,13 @@ +# Generated by Celest. Do not modify. +version: 1 +transforms: + - title: "Updates the import of the Celest client" + date: 2024-10-06 + element: + uris: ["client.dart"] + variable: celest + changes: + - kind: replacedBy + newElement: + uris: ["package:auth_client/auth_client.dart"] + variable: celest diff --git a/apps/cli/fixtures/legacy/auth/lib/src/functions/authenticated_lib.dart b/apps/cli/fixtures/legacy/auth/lib/src/functions/authenticated_lib.dart new file mode 100644 index 000000000..fba7c750a --- /dev/null +++ b/apps/cli/fixtures/legacy/auth/lib/src/functions/authenticated_lib.dart @@ -0,0 +1,18 @@ +@authenticated +library; + +import 'package:celest/celest.dart'; + +@cloud +Future sayHello({ + @principal required User user, +}) async { + return 'Hello, user!'; +} + +@cloud +Stream streamHello({ + @principal required User user, +}) async* { + yield 'Hello, user!'; +} diff --git a/apps/cli/fixtures/legacy/auth/lib/src/functions/lib.dart b/apps/cli/fixtures/legacy/auth/lib/src/functions/lib.dart new file mode 100644 index 000000000..eae5b1921 --- /dev/null +++ b/apps/cli/fixtures/legacy/auth/lib/src/functions/lib.dart @@ -0,0 +1,51 @@ +import 'package:celest/celest.dart'; + +@cloud +@authenticated +Future sayHelloAuthenticated({ + @principal required User user, +}) async { + return 'Hello, user!'; +} + +@cloud +@authenticated +Stream streamHelloAuthenticated({ + @principal required User user, +}) async* { + yield 'Hello, user!'; +} + +@cloud +@public +Future sayHelloPublic({ + @principal User? user, +}) async { + final name = user == null ? 'anonymous' : 'user'; + return 'Hello, $name!'; +} + +@cloud +@public +Stream streamHelloPublic({ + @principal User? user, +}) async* { + final name = user == null ? 'anonymous' : 'user'; + yield 'Hello, $name!'; +} + +@cloud +Future sayHello({ + @principal User? user, +}) async { + final name = user == null ? 'anonymous' : 'user'; + return 'Hello, $name!'; +} + +@cloud +Stream streamHello({ + @principal User? user, +}) async* { + final name = user == null ? 'anonymous' : 'user'; + yield 'Hello, $name!'; +} diff --git a/apps/cli/fixtures/legacy/auth/lib/src/functions/public_lib.dart b/apps/cli/fixtures/legacy/auth/lib/src/functions/public_lib.dart new file mode 100644 index 000000000..c0ab473c0 --- /dev/null +++ b/apps/cli/fixtures/legacy/auth/lib/src/functions/public_lib.dart @@ -0,0 +1,20 @@ +@public +library; + +import 'package:celest/celest.dart'; + +@cloud +Future sayHello({ + @principal User? user, +}) async { + final name = user == null ? 'anonymous' : 'user'; + return 'Hello, $name!'; +} + +@cloud +Stream streamHello({ + @principal User? user, +}) async* { + final name = user == null ? 'anonymous' : 'user'; + yield 'Hello, $name!'; +} diff --git a/apps/cli/fixtures/legacy/auth/lib/src/generated/auth.celest.dart b/apps/cli/fixtures/legacy/auth/lib/src/generated/auth.celest.dart new file mode 100644 index 000000000..569f3a30d --- /dev/null +++ b/apps/cli/fixtures/legacy/auth/lib/src/generated/auth.celest.dart @@ -0,0 +1,32 @@ +// Generated by Celest. This file should not be modified manually, but +// it can be checked into version control. +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +library; + +import 'package:celest/celest.dart'; +import 'package:celest/src/core/context.dart'; +import 'package:celest/src/runtime/data/connect.dart'; +import 'package:celest_cloud_auth/celest_cloud_auth.dart'; + +/// The auth service for the Celest backend. +/// +/// This class provides access to authentication and authorization +/// operations for the current [CelestEnvironment]. +class CelestAuth { + const CelestAuth(); + + /// Initializes the Celest Auth service in the given [context]. + static Future init(Context context) async { + final database = await connect( + context, + name: 'CelestAuthDatabase', + factory: AuthDatabase.new, + hostnameVariable: const env('CELEST_AUTH_DATABASE_HOST'), + tokenSecret: const secret('CELEST_AUTH_DATABASE_TOKEN'), + ); + final service = await CelestCloudAuth.create(database: database); + context.router.mount('/v1alpha1/auth/', service.handler); + context.put(CelestCloudAuth.contextKey, service); + } +} diff --git a/apps/cli/fixtures/legacy/auth/lib/src/generated/cloud.celest.dart b/apps/cli/fixtures/legacy/auth/lib/src/generated/cloud.celest.dart new file mode 100644 index 000000000..f1a89c399 --- /dev/null +++ b/apps/cli/fixtures/legacy/auth/lib/src/generated/cloud.celest.dart @@ -0,0 +1,45 @@ +// Generated by Celest. This file should not be modified manually, but +// it can be checked into version control. +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +library; + +import 'package:celest/src/core/context.dart'; +import 'package:celest_backend/src/generated/config.celest.dart'; + +/// The interface to your Celest backend. +/// +/// Similar to the `celest` global in the frontend, this +/// provides access to the backend environment and services +/// configured for your project. +const CelestCloud celest = CelestCloud._(); + +/// A per-request context object which propogates request information and common +/// accessors to the Celest server environment. +CelestContext get context => CelestContext._(context); + +/// The interface to your Celest backend. +/// +/// Similar to the `Celest` class in the frontend, this class +/// provides access to the backend environment and services +/// configured for your project. +class CelestCloud { + const CelestCloud._(); + + /// The current environment of the Celest service. + /// + /// This is determined by the `CELEST_ENVIRONMENT` variable + /// which is set for you by the deployment environment. + CelestEnvironment get currentEnvironment => + (variables.currentEnvironment as CelestEnvironment); + + /// The variables of the Celest service. + /// + /// This class provides access to the values configured for the + /// [currentEnvironment]. + CelestVariables get variables => const CelestVariables(); +} + +/// A per-request context object which propogates request information and common +/// accessors to the Celest server environment. +extension type CelestContext._(Context _context) implements Context {} diff --git a/apps/cli/fixtures/legacy/auth/lib/src/generated/config.celest.dart b/apps/cli/fixtures/legacy/auth/lib/src/generated/config.celest.dart new file mode 100644 index 000000000..687b9f186 --- /dev/null +++ b/apps/cli/fixtures/legacy/auth/lib/src/generated/config.celest.dart @@ -0,0 +1,45 @@ +// Generated by Celest. This file should not be modified manually, but +// it can be checked into version control. +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +library; + +import 'package:celest/celest.dart'; +import 'package:celest/src/core/context.dart'; + +/// An environment of a deployed Celest service. +/// +/// Celest services can have multiple isolated branches, for example +/// a `development` and `production` environment. +extension type const CelestEnvironment._(String _env) + implements Environment, String { + /// The local Celest environment, used to delineate when a + /// Celest service is running on a developer machine as opposed + /// to the cloud. + static const CelestEnvironment local = CelestEnvironment._('local'); + + /// The production Celest environment which is common to all + /// Celest projects and labels the environment which is considered + /// live and served to end-users. + static const CelestEnvironment production = CelestEnvironment._('production'); + + /// Whether `this` represents the [local] environment. + bool get isLocal => this == local; + + /// Whether `this` represents the [production] environment. + bool get isProduction => this == production; +} + +/// The environment variables for the Celest service. +/// +/// This class provides access to the environment variable values +/// that are configured for the current [CelestEnvironment]. +class CelestVariables { + const CelestVariables(); + + /// The environment variable that determines the current environment. + /// + /// This is set by the deployment environment and is used to + /// determine the current environment of the Celest service. + String get currentEnvironment => context.expect(env.environment); +} diff --git a/apps/cli/fixtures/legacy/auth/lib/src/project.dart b/apps/cli/fixtures/legacy/auth/lib/src/project.dart new file mode 100644 index 000000000..1c05d6d74 --- /dev/null +++ b/apps/cli/fixtures/legacy/auth/lib/src/project.dart @@ -0,0 +1,9 @@ +import 'package:celest/celest.dart'; + +const project = Project(name: 'auth'); + +const auth = Auth( + providers: [ + AuthProvider.email(), + ], +); diff --git a/apps/cli/fixtures/legacy/auth/pubspec.yaml b/apps/cli/fixtures/legacy/auth/pubspec.yaml new file mode 100644 index 000000000..44f53bb1e --- /dev/null +++ b/apps/cli/fixtures/legacy/auth/pubspec.yaml @@ -0,0 +1,36 @@ +name: celest_backend +publish_to: none + +environment: + sdk: ^3.4.0 + +dependencies: + celest: ^1.0.0 + celest_cloud_auth: 'any' + celest_core: ^1.0.0 + drift_hrana: ^1.0.2 + firebase_auth: ^5.3.1 + gotrue: ^2.9.0 + meta: ^1.12.0 + shelf: ^1.4.1 + stream_transform: ^2.1.0 + +dependency_overrides: + cedar: + path: ../../../../../cedar/packages/cedar + celest: + path: ../../../../../celest/packages/celest + celest_ast: + path: ../../../../../celest/packages/celest_ast + celest_auth: + path: ../../../../../celest/packages/celest_auth + celest_cloud: + path: ../../../../../celest/packages/celest_cloud + celest_cloud_auth: + path: ../../../../../celest/services/celest_cloud_auth + celest_core: + path: ../../../../../celest/packages/celest_core + +dev_dependencies: + lints: ^4.0.0 + test: ^1.25.0 diff --git a/apps/cli/fixtures/legacy/benchmark.dart b/apps/cli/fixtures/legacy/benchmark.dart new file mode 100644 index 000000000..92fd3c918 --- /dev/null +++ b/apps/cli/fixtures/legacy/benchmark.dart @@ -0,0 +1,47 @@ +import 'dart:io'; + +import 'package:benchmark_harness/benchmark_harness.dart'; +import 'package:celest_cli/analyzer/celest_analyzer.dart'; +import 'package:celest_cli/pub/pub_action.dart'; +import 'package:celest_cli/src/context.dart'; +import 'package:path/path.dart' as p; + +Future main() async { + final benchmarks = [LargeProjectBenchmark()]; + + for (final benchmark in benchmarks) { + print('Running benchmark: ${benchmark.name}'); + await benchmark.report(); + } + + exit(0); +} + +final class LargeProjectBenchmark extends AsyncBenchmarkBase { + LargeProjectBenchmark() : super('LargeProject'); + + static final analyzer = CelestAnalyzer(); + + @override + Future setup() async { + final projectRoot = p.join( + Directory.current.path, + 'test', + 'fixtures', + 'legacy', + 'api', + ); + await init(projectRoot: projectRoot); + await runPub(action: PubAction.get, workingDirectory: projectRoot); + } + + @override + Future run() async { + await analyzer.analyzeProject(updateResources: false); + } + + @override + Future teardown() async { + await celestProject.close(); + } +} diff --git a/apps/cli/fixtures/legacy/data/client/lib/data_client.dart b/apps/cli/fixtures/legacy/data/client/lib/data_client.dart new file mode 100644 index 000000000..4c9524443 --- /dev/null +++ b/apps/cli/fixtures/legacy/data/client/lib/data_client.dart @@ -0,0 +1,81 @@ +// Generated by Celest. This file should not be modified manually, but +// it can be checked into version control. +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +library; // ignore_for_file: no_leading_underscores_for_library_prefixes + +import 'dart:io'; + +import 'package:celest_core/_internal.dart' as _$celest; +import 'package:celest_core/celest_core.dart' as _$celest; +import 'package:celest_core/src/util/globals.dart' as _$celest; +import 'package:data_client/src/functions.dart'; +import 'package:data_client/src/serializers.dart'; +import 'package:http/http.dart' as _$http_http; +import 'package:native_storage/native_storage.dart' + as _$native_storage_native_storage; + +export 'package:celest_backend/src/database/task_database.dart' + show Task, Priority; + +final Celest celest = Celest(); + +enum CelestEnvironment { + local, + production; + + Uri get baseUri => switch (this) { + local => + _$celest.kIsWeb || !Platform.isAndroid + ? Uri.parse('http://localhost:7777') + : Uri.parse('http://10.0.2.2:7777'), + production => Uri.parse('https://example.celest.run'), + }; +} + +class Celest with _$celest.CelestBase { + var _initialized = false; + + late CelestEnvironment _currentEnvironment; + + late final _$native_storage_native_storage.NativeStorage nativeStorage = + _$native_storage_native_storage.NativeStorage(scope: 'celest'); + + @override + late _$http_http.Client httpClient = _$celest.CelestHttpClient( + secureStorage: nativeStorage.secure, + ); + + late Uri _baseUri; + + final _functions = CelestFunctions(); + + T _checkInitialized(T Function() value) { + if (!_initialized) { + throw StateError( + 'Celest has not been initialized. Make sure to call `celest.init()` at the start of your `main` method.', + ); + } + return value(); + } + + CelestEnvironment get currentEnvironment => + _checkInitialized(() => _currentEnvironment); + + @override + Uri get baseUri => _checkInitialized(() => _baseUri); + + CelestFunctions get functions => _checkInitialized(() => _functions); + + void init({ + CelestEnvironment environment = CelestEnvironment.local, + _$celest.Serializers? serializers, + }) { + _currentEnvironment = environment; + _baseUri = environment.baseUri; + if (!_initialized) { + initSerializers(serializers: serializers); + } + _initialized = true; + } +} diff --git a/apps/cli/fixtures/legacy/data/client/lib/src/functions.dart b/apps/cli/fixtures/legacy/data/client/lib/src/functions.dart new file mode 100644 index 000000000..6b512b7bc --- /dev/null +++ b/apps/cli/fixtures/legacy/data/client/lib/src/functions.dart @@ -0,0 +1,496 @@ +// Generated by Celest. This file should not be modified manually, but +// it can be checked into version control. +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +library; // ignore_for_file: no_leading_underscores_for_library_prefixes + +import 'dart:async'; +import 'dart:convert'; +import 'dart:io'; +import 'dart:isolate'; + +import 'package:celest/celest.dart' as _$celest; +import 'package:celest_backend/src/database/task_database.dart'; +import 'package:celest_core/celest_core.dart' as _$celest; +import 'package:celest_core/src/exception/cloud_exception.dart' as _$celest; +import 'package:celest_core/src/exception/serialization_exception.dart' + as _$celest; +import 'package:data_client/data_client.dart'; +import 'package:drift/src/remote/communication.dart' as _$drift_communication; +import 'package:drift/src/runtime/cancellation_zone.dart' + as _$drift_cancellation_zone; +import 'package:drift/src/runtime/exceptions.dart' as _$drift_exceptions; +import 'package:hrana/src/exception.dart' as _$hrana_exception; +import 'package:http/src/exception.dart' as _$http_exception; +import 'package:path/src/path_exception.dart' as _$path_path_exception; +import 'package:shelf/src/hijack_exception.dart' as _$shelf_hijack_exception; +import 'package:sqlite3/src/exception.dart' as _$sqlite3_exception; +import 'package:sqlite3/src/vfs.dart' as _$sqlite3_vfs; + +class CelestFunctions { + final tasks = CelestFunctionsTasks(); +} + +class CelestFunctionsTasks { + Never _throwError({int? code, required Map body}) { + final status = body['@status'] as Map?; + final message = status?['message'] as String?; + final details = status?['details'] as _$celest.JsonList?; + final (errorType, errorValue, stackTrace) = switch (details) { + null || [] => const (null, null, StackTrace.empty), + [ + final errorDetails as Map, + { + '@type': 'dart.core.StackTrace', + 'value': final stackTraceValue as String, + }, + ..., + ] => + ( + errorDetails['@type'], + errorDetails['value'], + StackTrace.fromString(stackTraceValue), + ), + [final errorDetails as Map, ...] => ( + errorDetails['@type'], + errorDetails['value'], + StackTrace.empty, + ), + }; + + switch (errorType) { + case 'celest.core.v1.CloudException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.CloudException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.CancelledException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.CancelledException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnknownError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.UnknownError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.BadRequestException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.BadRequestException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnauthorizedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.UnauthorizedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.NotFoundException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.NotFoundException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.AlreadyExistsException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.AlreadyExistsException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.PermissionDeniedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.PermissionDeniedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.ResourceExhaustedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.ResourceExhaustedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.FailedPreconditionException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.FailedPreconditionException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.AbortedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.AbortedException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.OutOfRangeException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.OutOfRangeException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnimplementedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.UnimplementedError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.InternalServerError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.InternalServerError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnavailableError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.UnavailableError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.DataLossError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.DataLossError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.DeadlineExceededError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.DeadlineExceededError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.SerializationException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.SerializationException>(errorValue), + stackTrace, + ); + case 'dart.core.Error': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.AssertionError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.TypeError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.ArgumentError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.RangeError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.IndexError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.UnsupportedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.UnimplementedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.StateError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.ConcurrentModificationError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.core.OutOfMemoryError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.StackOverflowError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.Exception': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.FormatException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.IntegerDivisionByZeroException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.async.AsyncError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.async.TimeoutException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.convert.JsonUnsupportedObjectError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'drift.DriftWrappedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$drift_exceptions.DriftWrappedException>( + errorValue, + ), + stackTrace, + ); + case 'drift.CouldNotRollBackException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$drift_exceptions.CouldNotRollBackException>( + errorValue, + ), + stackTrace, + ); + case 'dart.io.OSError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.io.FileSystemException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.io.PathAccessException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.io.PathExistsException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.io.PathNotFoundException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.io.SignalException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.io.ProcessException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.io.TlsException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.io.HandshakeException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.io.CertificateException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.io.StdoutException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.io.StdinException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart._http.HttpException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart._http.WebSocketException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.isolate.IsolateSpawnException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'http.ClientException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$http_exception.ClientException>(errorValue), + stackTrace, + ); + case 'shelf.HijackException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$shelf_hijack_exception.HijackException>( + errorValue, + ), + stackTrace, + ); + case 'sqlite3.SqliteException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$sqlite3_exception.SqliteException>(errorValue), + stackTrace, + ); + case 'drift.CancellationException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$drift_cancellation_zone.CancellationException>( + errorValue, + ), + stackTrace, + ); + case 'sqlite3.VfsException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$sqlite3_vfs.VfsException>( + errorValue, + ), + stackTrace, + ); + case 'drift.ConnectionClosedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$drift_communication.ConnectionClosedException>( + errorValue, + ), + stackTrace, + ); + case 'path.PathException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$path_path_exception.PathException>(errorValue), + stackTrace, + ); + case 'hrana.ConnectionClosed': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$hrana_exception.ConnectionClosed>(errorValue), + stackTrace, + ); + case 'hrana.ServerException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$hrana_exception.ServerException>(errorValue), + stackTrace, + ); + default: + Error.throwWithStackTrace( + _$celest.CloudException.http( + code: code, + message: message, + details: ((details ?? body) as _$celest.JsonValue), + ), + StackTrace.empty, + ); + } + } + + /// Creates a new [Task]. + @_$celest.CloudFunction(api: 'tasks', function: 'create') + Future create({ + required String title, + Priority priority = Priority.high, + }) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/tasks/create'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'title': title, + r'priority': _$celest.Serializers.instance.serialize( + priority, + ), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize($body); + } +} diff --git a/apps/cli/fixtures/legacy/data/client/lib/src/serializers.dart b/apps/cli/fixtures/legacy/data/client/lib/src/serializers.dart new file mode 100644 index 000000000..943fa2d6c --- /dev/null +++ b/apps/cli/fixtures/legacy/data/client/lib/src/serializers.dart @@ -0,0 +1,1268 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async'; +import 'dart:convert'; +import 'dart:io'; +import 'dart:isolate'; + +import 'package:celest_backend/src/database/task_database.dart'; +import 'package:celest_core/celest_core.dart' as _$celest; +import 'package:celest_core/src/exception/cloud_exception.dart' as _$celest; +import 'package:celest_core/src/exception/serialization_exception.dart' + as _$celest; +import 'package:celest_core/src/serialization/json_value.dart' as _$celest; +import 'package:drift/src/remote/communication.dart' as _$drift_communication; +import 'package:drift/src/runtime/cancellation_zone.dart' + as _$drift_cancellation_zone; +import 'package:drift/src/runtime/exceptions.dart' as _$drift_exceptions; +import 'package:hrana/src/exception.dart' as _$hrana_exception; +import 'package:http/src/exception.dart' as _$http_exception; +import 'package:path/src/path_exception.dart' as _$path_path_exception; +import 'package:shelf/src/hijack_exception.dart' as _$shelf_hijack_exception; +import 'package:sqlite3/src/exception.dart' as _$sqlite3_exception; +import 'package:sqlite3/src/vfs.dart' as _$sqlite3_vfs; + +void initSerializers({_$celest.Serializers? serializers}) { + return runZoned(() { + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _$celest.Serializers.instance + .serialize($value.stackTrace), + }, + deserialize: ($serialized) { + return AsyncError( + $serialized[r'error']!, + _$celest.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_$celest.Serializers.instance.serialize( + $value.duration, + ) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return TimeoutException( + ($serialized[r'message'] as String?), + _$celest.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest + .Serializer.define>( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + ConcurrentModificationError, + Map? + >( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: + ($value) => { + if (_$celest.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: + ($value) => { + r'type': $value.type, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize( + $value.osError, + ) + case final osError?) + r'osError': osError, + }, + deserialize: ($serialized) { + return CertificateException( + (($serialized?[r'message'] as String?)) ?? '', + _$celest.Serializers.instance.deserialize( + $serialized?[r'osError'], + ), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + if ($value.path case final path?) r'path': path, + if (_$celest.Serializers.instance.serialize( + $value.osError, + ) + case final osError?) + r'osError': osError, + }, + deserialize: ($serialized) { + return FileSystemException( + (($serialized?[r'message'] as String?)) ?? '', + (($serialized?[r'path'] as String?)) ?? '', + _$celest.Serializers.instance.deserialize( + $serialized?[r'osError'], + ), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: + ($value) => { + r'type': $value.type, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize( + $value.osError, + ) + case final osError?) + r'osError': osError, + }, + deserialize: ($serialized) { + return HandshakeException( + (($serialized?[r'message'] as String?)) ?? '', + _$celest.Serializers.instance.deserialize( + $serialized?[r'osError'], + ), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + r'message': $value.message, + if (_$celest.Serializers.instance.serialize($value.uri) + case final uri?) + r'uri': uri, + }, + deserialize: ($serialized) { + return HttpException( + ($serialized[r'message'] as String), + uri: _$celest.Serializers.instance.deserialize( + $serialized[r'uri'], + ), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'errorCode': $value.errorCode, + }, + deserialize: ($serialized) { + return OSError( + (($serialized?[r'message'] as String?)) ?? '', + (($serialized?[r'errorCode'] as num?)?.toInt()) ?? + OSError.noErrorCode, + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + r'message': $value.message, + if ($value.path case final path?) r'path': path, + if (_$celest.Serializers.instance.serialize( + $value.osError, + ) + case final osError?) + r'osError': osError, + }, + deserialize: ($serialized) { + return PathAccessException( + ($serialized[r'path'] as String), + _$celest.Serializers.instance.deserialize( + $serialized[r'osError'], + ), + (($serialized[r'message'] as String?)) ?? '', + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + r'message': $value.message, + if ($value.path case final path?) r'path': path, + if (_$celest.Serializers.instance.serialize( + $value.osError, + ) + case final osError?) + r'osError': osError, + }, + deserialize: ($serialized) { + return PathExistsException( + ($serialized[r'path'] as String), + _$celest.Serializers.instance.deserialize( + $serialized[r'osError'], + ), + (($serialized[r'message'] as String?)) ?? '', + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + r'message': $value.message, + if ($value.path case final path?) r'path': path, + if (_$celest.Serializers.instance.serialize( + $value.osError, + ) + case final osError?) + r'osError': osError, + }, + deserialize: ($serialized) { + return PathNotFoundException( + ($serialized[r'path'] as String), + _$celest.Serializers.instance.deserialize( + $serialized[r'osError'], + ), + (($serialized[r'message'] as String?)) ?? '', + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + r'executable': $value.executable, + r'arguments': $value.arguments, + r'message': $value.message, + r'errorCode': $value.errorCode, + }, + deserialize: ($serialized) { + return ProcessException( + ($serialized[r'executable'] as String), + ($serialized[r'arguments'] as Iterable) + .map((el) => (el as String)) + .toList(), + (($serialized[r'message'] as String?)) ?? '', + (($serialized[r'errorCode'] as num?)?.toInt()) ?? 0, + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + r'message': $value.message, + r'osError': $value.osError, + }, + deserialize: ($serialized) { + return SignalException( + ($serialized[r'message'] as String), + $serialized[r'osError'], + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + r'message': $value.message, + if (_$celest.Serializers.instance.serialize( + $value.osError, + ) + case final osError?) + r'osError': osError, + }, + deserialize: ($serialized) { + return StdinException( + ($serialized[r'message'] as String), + _$celest.Serializers.instance.deserialize( + $serialized[r'osError'], + ), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + r'message': $value.message, + if (_$celest.Serializers.instance.serialize( + $value.osError, + ) + case final osError?) + r'osError': osError, + }, + deserialize: ($serialized) { + return StdoutException( + ($serialized[r'message'] as String), + _$celest.Serializers.instance.deserialize( + $serialized[r'osError'], + ), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: + ($value) => { + r'type': $value.type, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize( + $value.osError, + ) + case final osError?) + r'osError': osError, + }, + deserialize: ($serialized) { + return TlsException( + (($serialized?[r'message'] as String?)) ?? '', + _$celest.Serializers.instance.deserialize( + $serialized?[r'osError'], + ), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + if ($value.httpStatusCode case final httpStatusCode?) + r'httpStatusCode': httpStatusCode, + }, + deserialize: ($serialized) { + return WebSocketException( + (($serialized?[r'message'] as String?)) ?? '', + ($serialized?[r'httpStatusCode'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return IsolateSpawnException(($serialized[r'message'] as String)); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define( + serialize: ($value) => $value.name, + deserialize: ($serialized) { + return Priority.values.byName($serialized); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return Task.fromJson($serialized); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest + .Serializer.define<_$celest.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.AbortedException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.AlreadyExistsException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.BadRequestException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.BadRequestException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.CancelledException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.CancelledException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define<_$celest.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.CloudException.fromJson($serialized); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define<_$celest.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.DataLossError( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.DeadlineExceededError, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.InternalServerError, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.InternalServerError( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest + .Serializer.define<_$celest.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.NotFoundException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.OutOfRangeException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.OutOfRangeException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.UnauthorizedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.UnauthorizedException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest + .Serializer.define<_$celest.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.UnavailableError( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.UnimplementedError, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.UnimplementedError( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define<_$celest.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.UnknownError( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.SerializationException, + Map + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define<_$celest.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _$celest.JsonValue($serialized); + }, + ), + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$drift_communication.ConnectionClosedException, + Map? + >( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return _$drift_communication.ConnectionClosedException(); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$drift_cancellation_zone.CancellationException, + Map? + >( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return _$drift_cancellation_zone.CancellationException(); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$drift_exceptions.CouldNotRollBackException, + Map + >( + serialize: + ($value) => { + r'cause': $value.cause, + r'originalStackTrace': _$celest.Serializers.instance + .serialize($value.originalStackTrace), + r'exception': $value.exception, + }, + deserialize: ($serialized) { + return _$drift_exceptions.CouldNotRollBackException( + $serialized[r'cause']!, + _$celest.Serializers.instance.deserialize( + $serialized[r'originalStackTrace'], + ), + $serialized[r'exception']!, + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$drift_exceptions.DriftWrappedException, + Map + >( + serialize: + ($value) => { + r'message': $value.message, + if ($value.cause case final cause?) r'cause': cause, + if (_$celest.Serializers.instance.serialize( + $value.trace, + ) + case final trace?) + r'trace': trace, + }, + deserialize: ($serialized) { + return _$drift_exceptions.DriftWrappedException( + message: ($serialized[r'message'] as String), + cause: $serialized[r'cause'], + trace: _$celest.Serializers.instance.deserialize( + $serialized[r'trace'], + ), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$hrana_exception.ConnectionClosed, + Map? + >( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return _$hrana_exception.ConnectionClosed(); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$hrana_exception.ServerException, + Map + >( + serialize: + ($value) => { + r'message': $value.message, + if ($value.code case final code?) r'code': code, + }, + deserialize: ($serialized) { + return _$hrana_exception.ServerException( + message: ($serialized[r'message'] as String), + code: ($serialized[r'code'] as String?), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$http_exception.ClientException, + Map + >( + serialize: + ($value) => { + r'message': $value.message, + if (_$celest.Serializers.instance.serialize($value.uri) + case final uri?) + r'uri': uri, + }, + deserialize: ($serialized) { + return _$http_exception.ClientException( + ($serialized[r'message'] as String), + _$celest.Serializers.instance.deserialize( + $serialized[r'uri'], + ), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$path_path_exception.PathException, + Map + >( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return _$path_path_exception.PathException( + ($serialized[r'message'] as String), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$shelf_hijack_exception.HijackException, + Map? + >( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return _$shelf_hijack_exception.HijackException(); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$sqlite3_exception.SqliteException, + Map + >( + serialize: + ($value) => { + r'message': $value.message, + if ($value.explanation case final explanation?) + r'explanation': explanation, + r'extendedResultCode': $value.extendedResultCode, + r'resultCode': $value.resultCode, + if ($value.offset case final offset?) r'offset': offset, + if ($value.operation case final operation?) + r'operation': operation, + if ($value.causingStatement case final causingStatement?) + r'causingStatement': causingStatement, + if ($value.parametersToStatement + case final parametersToStatement?) + r'parametersToStatement': parametersToStatement, + }, + deserialize: ($serialized) { + return _$sqlite3_exception.SqliteException( + ($serialized[r'extendedResultCode'] as num).toInt(), + ($serialized[r'message'] as String), + ($serialized[r'explanation'] as String?), + ($serialized[r'causingStatement'] as String?), + ($serialized[r'parametersToStatement'] as Iterable?) + ?.toList(), + ($serialized[r'operation'] as String?), + ($serialized[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest + .Serializer.define<_$sqlite3_vfs.VfsException, Map>( + serialize: + ($value) => {r'returnCode': $value.returnCode}, + deserialize: ($serialized) { + return _$sqlite3_vfs.VfsException( + ($serialized[r'returnCode'] as num).toInt(), + ); + }, + ), + ); + }, zoneValues: {_$celest.Serializers: serializers}); +} diff --git a/apps/cli/fixtures/legacy/data/client/pubspec.yaml b/apps/cli/fixtures/legacy/data/client/pubspec.yaml new file mode 100644 index 000000000..580b6f855 --- /dev/null +++ b/apps/cli/fixtures/legacy/data/client/pubspec.yaml @@ -0,0 +1,29 @@ +name: data_client +description: The Celest client for data. +publish_to: none + +environment: + sdk: ^3.4.0 + +dependencies: + celest: ^1.0.0 + celest_backend: + path: .. + celest_core: ^1.0.0 + http: ^1.0.0 + native_storage: ^0.2.2 + +dependency_overrides: + celest: + path: ../../../../../../celest/packages/celest + celest_ast: + path: ../../../../../../celest/packages/celest_ast + celest_auth: + path: ../../../../../../celest/packages/celest_auth + celest_cloud: + path: ../../../../../../celest/packages/celest_cloud + celest_cloud_auth: + path: ../../../../../../celest/services/celest_cloud_auth + celest_core: + path: ../../../../../../celest/packages/celest_core +dev_dependencies: {} diff --git a/apps/cli/fixtures/legacy/data/goldens/api.local.dart b/apps/cli/fixtures/legacy/data/goldens/api.local.dart new file mode 100644 index 000000000..1491ad9ae --- /dev/null +++ b/apps/cli/fixtures/legacy/data/goldens/api.local.dart @@ -0,0 +1,21 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'package:celest/src/core/context.dart' as _i3; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/generated/data.celest.dart' as _i4; + +import 'functions/tasks/create.dart' as _i2; + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/tasks/create': _i2.CreateTarget()}, + setup: (_i3.Context context) async { + await _i4.CelestData.init(context); + }, + ); +} diff --git a/apps/cli/fixtures/legacy/data/goldens/ast.json b/apps/cli/fixtures/legacy/data/goldens/ast.json new file mode 100644 index 000000000..3eb681ee2 --- /dev/null +++ b/apps/cli/fixtures/legacy/data/goldens/ast.json @@ -0,0 +1,659 @@ +{ + "name": "data", + "environment": "local", + "reference": { + "$": "Reference", + "symbol": "project", + "url": "package:celest_backend/src/project.dart" + }, + "apis": { + "tasks": { + "name": "tasks", + "metadata": [], + "functions": { + "create": { + "name": "create", + "apiName": "tasks", + "typeParameters": [], + "parameters": [ + { + "name": "title", + "type": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + "required": true, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 241, + "uri": "package:celest_backend/src/functions/tasks.dart", + "line": 7, + "column": 18 + }, + "end": { + "offset": 246, + "uri": "package:celest_backend/src/functions/tasks.dart", + "line": 7, + "column": 23 + }, + "text": "title" + } + }, + { + "name": "priority", + "type": { + "$": "TypeReference", + "symbol": "Priority", + "url": "package:celest_backend/src/database/task_database.dart", + "isNullable": false + }, + "required": false, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 259, + "uri": "package:celest_backend/src/functions/tasks.dart", + "line": 8, + "column": 11 + }, + "end": { + "offset": 267, + "uri": "package:celest_backend/src/functions/tasks.dart", + "line": 8, + "column": 19 + }, + "text": "priority" + }, + "defaultTo": { + "$": "DartEnum", + "enumRef": { + "symbol": "Priority", + "url": "package:celest_backend/src/database/task_database.dart", + "isNullable": false + }, + "value": "high", + "staticType": { + "symbol": "Priority", + "url": "package:celest_backend/src/database/task_database.dart", + "isNullable": false + } + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "Future", + "url": "dart:async", + "types": [ + { + "$": "TypeReference", + "symbol": "Task", + "url": "package:celest_backend/src/database/task_database.dart", + "isNullable": false + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "Task", + "url": "package:celest_backend/src/database/task_database.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [ + "/// Creates a new [Task]." + ], + "location": { + "start": { + "offset": 214, + "uri": "package:celest_backend/src/functions/tasks.dart", + "line": 6, + "column": 13 + }, + "end": { + "offset": 220, + "uri": "package:celest_backend/src/functions/tasks.dart", + "line": 6, + "column": 19 + }, + "text": "create" + } + } + }, + "docs": [], + "exceptionTypes": [ + { + "$": "TypeReference", + "symbol": "CloudException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "CancelledException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnknownError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "BadRequestException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnauthorizedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "NotFoundException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AlreadyExistsException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "PermissionDeniedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ResourceExhaustedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "FailedPreconditionException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AbortedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "OutOfRangeException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnimplementedError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "InternalServerError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnavailableError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "DataLossError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "DeadlineExceededError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "SerializationException", + "url": "package:celest_core/src/exception/serialization_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "Error", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AssertionError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "TypeError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ArgumentError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "RangeError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "IndexError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnsupportedError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnimplementedError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "StateError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ConcurrentModificationError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "OutOfMemoryError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "StackOverflowError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "Exception", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "FormatException", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "IntegerDivisionByZeroException", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AsyncError", + "url": "dart:async", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "TimeoutException", + "url": "dart:async", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "JsonUnsupportedObjectError", + "url": "dart:convert", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "DriftWrappedException", + "url": "package:drift/src/runtime/exceptions.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "CouldNotRollBackException", + "url": "package:drift/src/runtime/exceptions.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "OSError", + "url": "dart:io", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "FileSystemException", + "url": "dart:io", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "PathAccessException", + "url": "dart:io", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "PathExistsException", + "url": "dart:io", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "PathNotFoundException", + "url": "dart:io", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "SignalException", + "url": "dart:io", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ProcessException", + "url": "dart:io", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "TlsException", + "url": "dart:io", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "HandshakeException", + "url": "dart:io", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "CertificateException", + "url": "dart:io", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "StdoutException", + "url": "dart:io", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "StdinException", + "url": "dart:io", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "HttpException", + "url": "dart:io", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "WebSocketException", + "url": "dart:io", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "IsolateSpawnException", + "url": "dart:isolate", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ClientException", + "url": "package:http/src/exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "HijackException", + "url": "package:shelf/src/hijack_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "SqliteException", + "url": "package:sqlite3/src/exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "CancellationException", + "url": "package:drift/src/runtime/cancellation_zone.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "VfsException", + "url": "package:sqlite3/src/vfs.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ConnectionClosedException", + "url": "package:drift/src/remote/communication.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "PathException", + "url": "package:path/src/path_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ConnectionClosed", + "url": "package:hrana/src/exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ServerException", + "url": "package:hrana/src/exception.dart", + "isNullable": false + } + ], + "location": { + "start": { + "offset": 0, + "uri": "package:celest_backend/src/functions/tasks.dart", + "line": 0, + "column": 0 + }, + "end": { + "offset": 0, + "uri": "package:celest_backend/src/functions/tasks.dart", + "line": 0, + "column": 0 + }, + "text": "" + } + } + }, + "variables": [], + "secrets": [], + "databases": { + "TaskDatabase": { + "name": "TaskDatabase", + "dartName": "database", + "docs": [], + "schema": { + "$": "DriftDatabaseSchema", + "declaration": { + "symbol": "TaskDatabase", + "url": "package:celest_backend/src/database/task_database.dart", + "isNullable": false + }, + "location": { + "start": { + "offset": 149, + "uri": "package:celest_backend/src/project.dart", + "line": 5, + "column": 6 + }, + "end": { + "offset": 157, + "uri": "package:celest_backend/src/project.dart", + "line": 5, + "column": 14 + }, + "text": "database" + } + }, + "config": { + "$": "CelestDatabaseConfig", + "hostname": { + "location": { + "start": { + "offset": 149, + "uri": "package:celest_backend/src/project.dart", + "line": 5, + "column": 6 + }, + "end": { + "offset": 157, + "uri": "package:celest_backend/src/project.dart", + "line": 5, + "column": 14 + }, + "text": "database" + }, + "name": "CELEST_DATABASE_HOST", + "docs": [] + }, + "token": { + "location": { + "start": { + "offset": 149, + "uri": "package:celest_backend/src/project.dart", + "line": 5, + "column": 6 + }, + "end": { + "offset": 157, + "uri": "package:celest_backend/src/project.dart", + "line": 5, + "column": 14 + }, + "text": "database" + }, + "name": "CELEST_DATABASE_TOKEN", + "docs": [] + } + }, + "location": { + "start": { + "offset": 149, + "uri": "package:celest_backend/src/project.dart", + "line": 5, + "column": 6 + }, + "end": { + "offset": 157, + "uri": "package:celest_backend/src/project.dart", + "line": 5, + "column": 14 + }, + "text": "database" + } + } + }, + "sdkConfig": { + "celest": "1.0.6+2", + "dart": { + "type": "dart", + "version": "3.29.0", + "enabledExperiments": [] + }, + "targetSdk": "dart", + "featureFlags": [ + "streaming" + ], + "flutter": { + "type": "flutter", + "version": "3.29.0", + "enabledExperiments": [] + } + }, + "location": { + "start": { + "offset": 109, + "uri": "project.dart", + "line": 3, + "column": 6 + }, + "end": { + "offset": 140, + "uri": "project.dart", + "line": 3, + "column": 37 + }, + "text": "project = Project(name: 'data')" + } +} \ No newline at end of file diff --git a/apps/cli/fixtures/legacy/data/goldens/ast.resolved.json b/apps/cli/fixtures/legacy/data/goldens/ast.resolved.json new file mode 100644 index 000000000..2ab968011 --- /dev/null +++ b/apps/cli/fixtures/legacy/data/goldens/ast.resolved.json @@ -0,0 +1,74 @@ +{ + "projectId": "data", + "environmentId": "local", + "apis": { + "tasks": { + "apiId": "tasks", + "functions": { + "create": { + "functionId": "create", + "apiId": "tasks", + "httpConfig": { + "route": { + "method": "POST", + "path": "/tasks/create" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + } + } + } + }, + "variables": [ + { + "name": "CELEST_ENVIRONMENT", + "value": "local" + } + ], + "secrets": [], + "databases": { + "TaskDatabase": { + "databaseId": "TaskDatabase", + "schema": { + "$": "ResolvedDriftDatabaseSchema", + "databaseSchemaId": "TaskDatabase", + "version": 1, + "schemaJson": {}, + "type": "drift" + }, + "config": { + "$": "ResolvedCelestDatabaseConfig", + "hostname": { + "name": "CELEST_DATABASE_HOST", + "value": "" + }, + "token": { + "name": "CELEST_DATABASE_TOKEN", + "value": "" + } + } + } + }, + "sdkConfig": { + "celest": "1.0.6+2", + "dart": { + "type": "dart", + "version": "3.29.0", + "enabledExperiments": [] + }, + "targetSdk": "dart", + "featureFlags": [ + "streaming" + ], + "flutter": { + "type": "flutter", + "version": "3.29.0", + "enabledExperiments": [] + } + } +} \ No newline at end of file diff --git a/apps/cli/fixtures/legacy/data/goldens/celest.json b/apps/cli/fixtures/legacy/data/goldens/celest.json new file mode 100644 index 000000000..052f4822e --- /dev/null +++ b/apps/cli/fixtures/legacy/data/goldens/celest.json @@ -0,0 +1,89 @@ +{ + "projectId": "data", + "environmentId": "local", + "apis": { + "tasks": { + "apiId": "tasks", + "functions": { + "create": { + "functionId": "create", + "parentId": "tasks", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/tasks/create" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + } + } + } + }, + "variables": [ + { + "name": "CELEST_ENVIRONMENT", + "value": "local" + } + ], + "databases": { + "TaskDatabase": { + "databaseId": "TaskDatabase", + "type": "CELEST", + "schema": { + "databaseSchemaId": "TaskDatabase", + "type": "DRIFT", + "drift": { + "version": 1, + "schemaJson": {} + } + }, + "celest": { + "hostname": { + "name": "CELEST_DATABASE_HOST", + "value": "" + }, + "token": { + "name": "CELEST_DATABASE_TOKEN", + "value": "" + } + } + } + }, + "sdkConfig": { + "celest": { + "major": 1, + "minor": 0, + "patch": 6, + "build": [ + 2.0 + ], + "canonicalizedVersion": "1.0.6+2" + }, + "dart": { + "type": "DART", + "version": { + "major": 3, + "minor": 29, + "patch": 0, + "canonicalizedVersion": "3.29.0" + } + }, + "flutter": { + "type": "FLUTTER", + "version": { + "major": 3, + "minor": 29, + "patch": 0, + "canonicalizedVersion": "3.29.0" + } + }, + "targetSdk": "DART", + "featureFlags": [ + "STREAMING" + ] + } +} \ No newline at end of file diff --git a/apps/cli/fixtures/legacy/data/goldens/functions/tasks/create.dart b/apps/cli/fixtures/legacy/data/goldens/functions/tasks/create.dart new file mode 100644 index 000000000..169b9b2d6 --- /dev/null +++ b/apps/cli/fixtures/legacy/data/goldens/functions/tasks/create.dart @@ -0,0 +1,2864 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i18; +import 'dart:io' as _i11; +import 'dart:isolate' as _i17; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/database/task_database.dart' as _i5; +import 'package:celest_backend/src/functions/tasks.dart' as _i3; +import 'package:celest_backend/src/generated/data.celest.dart' as _i24; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i20; +import 'package:celest_core/src/serialization/json_value.dart' as _i23; +import 'package:drift/src/remote/communication.dart' as _i14; +import 'package:drift/src/runtime/cancellation_zone.dart' as _i10; +import 'package:drift/src/runtime/exceptions.dart' as _i15; +import 'package:hrana/src/exception.dart' as _i13; +import 'package:http/src/exception.dart' as _i12; +import 'package:path/src/path_exception.dart' as _i19; +import 'package:shelf/shelf.dart' as _i2; +import 'package:shelf/src/hijack_exception.dart' as _i16; +import 'package:sqlite3/src/exception.dart' as _i21; +import 'package:sqlite3/src/vfs.dart' as _i22; + +final class CreateTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'create'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = await _i3.create( + title: (request[r'title'] as String), + priority: + (_i4.Serializers.instance.deserialize<_i5.Priority?>( + request[r'priority'], + )) ?? + _i5.Priority.high, + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.Task>(response), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CancellationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'drift.CancellationException', + 'value': _i4.Serializers.instance + .serialize<_i10.CancellationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.CertificateException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.io.CertificateException', + 'value': _i4.Serializers.instance + .serialize<_i11.CertificateException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i12.ClientException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'http.ClientException', + 'value': _i4.Serializers.instance.serialize<_i12.ClientException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i13.ConnectionClosed catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'hrana.ConnectionClosed', + 'value': _i4.Serializers.instance + .serialize<_i13.ConnectionClosed>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i14.ConnectionClosedException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'drift.ConnectionClosedException', + 'value': _i4.Serializers.instance + .serialize<_i14.ConnectionClosedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i15.CouldNotRollBackException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'drift.CouldNotRollBackException', + 'value': _i4.Serializers.instance + .serialize<_i15.CouldNotRollBackException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i15.DriftWrappedException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'drift.DriftWrappedException', + 'value': _i4.Serializers.instance + .serialize<_i15.DriftWrappedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.HandshakeException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.io.HandshakeException', + 'value': _i4.Serializers.instance + .serialize<_i11.HandshakeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i16.HijackException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'shelf.HijackException', + 'value': _i4.Serializers.instance.serialize<_i16.HijackException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.HttpException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart._http.HttpException', + 'value': _i4.Serializers.instance.serialize<_i11.HttpException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i17.IsolateSpawnException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.isolate.IsolateSpawnException', + 'value': _i4.Serializers.instance + .serialize<_i17.IsolateSpawnException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i18.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i18.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.OSError catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.io.OSError', + 'value': _i4.Serializers.instance.serialize<_i11.OSError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.PathAccessException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.io.PathAccessException', + 'value': _i4.Serializers.instance + .serialize<_i11.PathAccessException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i19.PathException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'path.PathException', + 'value': _i4.Serializers.instance.serialize<_i19.PathException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.PathExistsException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.io.PathExistsException', + 'value': _i4.Serializers.instance + .serialize<_i11.PathExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.PathNotFoundException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.io.PathNotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i11.PathNotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.FileSystemException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.io.FileSystemException', + 'value': _i4.Serializers.instance + .serialize<_i11.FileSystemException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.ProcessException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.io.ProcessException', + 'value': _i4.Serializers.instance + .serialize<_i11.ProcessException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i20.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i20.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i13.ServerException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'hrana.ServerException', + 'value': _i4.Serializers.instance.serialize<_i13.ServerException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SignalException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.io.SignalException', + 'value': _i4.Serializers.instance.serialize<_i11.SignalException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i21.SqliteException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'sqlite3.SqliteException', + 'value': _i4.Serializers.instance.serialize<_i21.SqliteException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.StdinException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.io.StdinException', + 'value': _i4.Serializers.instance.serialize<_i11.StdinException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.StdoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.io.StdoutException', + 'value': _i4.Serializers.instance.serialize<_i11.StdoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.TlsException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.io.TlsException', + 'value': _i4.Serializers.instance.serialize<_i11.TlsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i22.VfsException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'sqlite3.VfsException', + 'value': _i4.Serializers.instance.serialize<_i22.VfsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.WebSocketException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart._http.WebSocketException', + 'value': _i4.Serializers.instance + .serialize<_i11.WebSocketException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i18.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i18.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.CertificateException, Map?>( + serialize: + ($value) => { + r'type': $value.type, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.OSError?>( + $value.osError, + ) + case final osError?) + r'osError': osError, + }, + deserialize: ($serialized) { + return _i11.CertificateException( + (($serialized?[r'message'] as String?)) ?? '', + _i4.Serializers.instance.deserialize<_i11.OSError?>( + $serialized?[r'osError'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.FileSystemException, Map?>( + serialize: + ($value) => { + r'message': $value.message, + if ($value.path case final path?) r'path': path, + if (_i4.Serializers.instance.serialize<_i11.OSError?>( + $value.osError, + ) + case final osError?) + r'osError': osError, + }, + deserialize: ($serialized) { + return _i11.FileSystemException( + (($serialized?[r'message'] as String?)) ?? '', + (($serialized?[r'path'] as String?)) ?? '', + _i4.Serializers.instance.deserialize<_i11.OSError?>( + $serialized?[r'osError'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.HandshakeException, Map?>( + serialize: + ($value) => { + r'type': $value.type, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.OSError?>( + $value.osError, + ) + case final osError?) + r'osError': osError, + }, + deserialize: ($serialized) { + return _i11.HandshakeException( + (($serialized?[r'message'] as String?)) ?? '', + _i4.Serializers.instance.deserialize<_i11.OSError?>( + $serialized?[r'osError'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.HttpException, Map>( + serialize: + ($value) => { + r'message': $value.message, + if (_i4.Serializers.instance.serialize($value.uri) + case final uri?) + r'uri': uri, + }, + deserialize: ($serialized) { + return _i11.HttpException( + ($serialized[r'message'] as String), + uri: _i4.Serializers.instance.deserialize( + $serialized[r'uri'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.OSError, Map?>( + serialize: + ($value) => { + r'message': $value.message, + r'errorCode': $value.errorCode, + }, + deserialize: ($serialized) { + return _i11.OSError( + (($serialized?[r'message'] as String?)) ?? '', + (($serialized?[r'errorCode'] as num?)?.toInt()) ?? + _i11.OSError.noErrorCode, + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.PathAccessException, Map>( + serialize: + ($value) => { + r'message': $value.message, + if ($value.path case final path?) r'path': path, + if (_i4.Serializers.instance.serialize<_i11.OSError?>( + $value.osError, + ) + case final osError?) + r'osError': osError, + }, + deserialize: ($serialized) { + return _i11.PathAccessException( + ($serialized[r'path'] as String), + _i4.Serializers.instance.deserialize<_i11.OSError>( + $serialized[r'osError'], + ), + (($serialized[r'message'] as String?)) ?? '', + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.PathExistsException, Map>( + serialize: + ($value) => { + r'message': $value.message, + if ($value.path case final path?) r'path': path, + if (_i4.Serializers.instance.serialize<_i11.OSError?>( + $value.osError, + ) + case final osError?) + r'osError': osError, + }, + deserialize: ($serialized) { + return _i11.PathExistsException( + ($serialized[r'path'] as String), + _i4.Serializers.instance.deserialize<_i11.OSError>( + $serialized[r'osError'], + ), + (($serialized[r'message'] as String?)) ?? '', + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.PathNotFoundException, Map>( + serialize: + ($value) => { + r'message': $value.message, + if ($value.path case final path?) r'path': path, + if (_i4.Serializers.instance.serialize<_i11.OSError?>( + $value.osError, + ) + case final osError?) + r'osError': osError, + }, + deserialize: ($serialized) { + return _i11.PathNotFoundException( + ($serialized[r'path'] as String), + _i4.Serializers.instance.deserialize<_i11.OSError>( + $serialized[r'osError'], + ), + (($serialized[r'message'] as String?)) ?? '', + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.ProcessException, Map>( + serialize: + ($value) => { + r'executable': $value.executable, + r'arguments': $value.arguments, + r'message': $value.message, + r'errorCode': $value.errorCode, + }, + deserialize: ($serialized) { + return _i11.ProcessException( + ($serialized[r'executable'] as String), + ($serialized[r'arguments'] as Iterable) + .map((el) => (el as String)) + .toList(), + (($serialized[r'message'] as String?)) ?? '', + (($serialized[r'errorCode'] as num?)?.toInt()) ?? 0, + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SignalException, Map>( + serialize: + ($value) => { + r'message': $value.message, + r'osError': $value.osError, + }, + deserialize: ($serialized) { + return _i11.SignalException( + ($serialized[r'message'] as String), + $serialized[r'osError'], + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.StdinException, Map>( + serialize: + ($value) => { + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.OSError?>( + $value.osError, + ) + case final osError?) + r'osError': osError, + }, + deserialize: ($serialized) { + return _i11.StdinException( + ($serialized[r'message'] as String), + _i4.Serializers.instance.deserialize<_i11.OSError?>( + $serialized[r'osError'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.StdoutException, Map>( + serialize: + ($value) => { + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.OSError?>( + $value.osError, + ) + case final osError?) + r'osError': osError, + }, + deserialize: ($serialized) { + return _i11.StdoutException( + ($serialized[r'message'] as String), + _i4.Serializers.instance.deserialize<_i11.OSError?>( + $serialized[r'osError'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.TlsException, Map?>( + serialize: + ($value) => { + r'type': $value.type, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.OSError?>( + $value.osError, + ) + case final osError?) + r'osError': osError, + }, + deserialize: ($serialized) { + return _i11.TlsException( + (($serialized?[r'message'] as String?)) ?? '', + _i4.Serializers.instance.deserialize<_i11.OSError?>( + $serialized?[r'osError'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.WebSocketException, Map?>( + serialize: + ($value) => { + r'message': $value.message, + if ($value.httpStatusCode case final httpStatusCode?) + r'httpStatusCode': httpStatusCode, + }, + deserialize: ($serialized) { + return _i11.WebSocketException( + (($serialized?[r'message'] as String?)) ?? '', + ($serialized?[r'httpStatusCode'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i17.IsolateSpawnException, Map>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return _i17.IsolateSpawnException( + ($serialized[r'message'] as String), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.Priority, String>( + serialize: ($value) => $value.name, + deserialize: ($serialized) { + return _i5.Priority.values.byName($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.Task, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i5.Task.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i23.JsonValue?>( + $value.details, + const _i4.TypeToken<_i23.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i23.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i23.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i23.JsonValue?>( + $value.details, + const _i4.TypeToken<_i23.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i23.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i23.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i23.JsonValue?>( + $value.details, + const _i4.TypeToken<_i23.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i23.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i23.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i23.JsonValue?>( + $value.details, + const _i4.TypeToken<_i23.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i23.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i23.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i23.JsonValue?>( + $value.details, + const _i4.TypeToken<_i23.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i23.JsonValue?>( + $value.details, + const _i4.TypeToken<_i23.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i23.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i23.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i23.JsonValue?>( + $value.details, + const _i4.TypeToken<_i23.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i23.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i23.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i23.JsonValue?>( + $value.details, + const _i4.TypeToken<_i23.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i23.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i23.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i23.JsonValue?>( + $value.details, + const _i4.TypeToken<_i23.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i23.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i23.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i23.JsonValue?>( + $value.details, + const _i4.TypeToken<_i23.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i23.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i23.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i23.JsonValue?>( + $value.details, + const _i4.TypeToken<_i23.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i23.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i23.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i23.JsonValue?>( + $value.details, + const _i4.TypeToken<_i23.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i23.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i23.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i23.JsonValue?>( + $value.details, + const _i4.TypeToken<_i23.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i23.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i23.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i23.JsonValue?>( + $value.details, + const _i4.TypeToken<_i23.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i23.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i23.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i23.JsonValue?>( + $value.details, + const _i4.TypeToken<_i23.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i23.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i23.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i23.JsonValue?>( + $value.details, + const _i4.TypeToken<_i23.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i23.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i23.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i23.JsonValue?>( + $value.details, + const _i4.TypeToken<_i23.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i23.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i23.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i20.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i23.JsonValue?>( + $value.details, + const _i4.TypeToken<_i23.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i20.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i23.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i23.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i23.JsonValue?>('JsonValue'), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i14.ConnectionClosedException, + Map? + >( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return _i14.ConnectionClosedException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.CancellationException, Map?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return _i10.CancellationException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i15.CouldNotRollBackException, + Map + >( + serialize: + ($value) => { + r'cause': $value.cause, + r'originalStackTrace': _i4.Serializers.instance + .serialize($value.originalStackTrace), + r'exception': $value.exception, + }, + deserialize: ($serialized) { + return _i15.CouldNotRollBackException( + $serialized[r'cause']!, + _i4.Serializers.instance.deserialize( + $serialized[r'originalStackTrace'], + ), + $serialized[r'exception']!, + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i15.DriftWrappedException, Map>( + serialize: + ($value) => { + r'message': $value.message, + if ($value.cause case final cause?) r'cause': cause, + if (_i4.Serializers.instance.serialize($value.trace) + case final trace?) + r'trace': trace, + }, + deserialize: ($serialized) { + return _i15.DriftWrappedException( + message: ($serialized[r'message'] as String), + cause: $serialized[r'cause'], + trace: _i4.Serializers.instance.deserialize( + $serialized[r'trace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.ConnectionClosed, Map?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return _i13.ConnectionClosed(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.ServerException, Map>( + serialize: + ($value) => { + r'message': $value.message, + if ($value.code case final code?) r'code': code, + }, + deserialize: ($serialized) { + return _i13.ServerException( + message: ($serialized[r'message'] as String), + code: ($serialized[r'code'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.ClientException, Map>( + serialize: + ($value) => { + r'message': $value.message, + if (_i4.Serializers.instance.serialize($value.uri) + case final uri?) + r'uri': uri, + }, + deserialize: ($serialized) { + return _i12.ClientException( + ($serialized[r'message'] as String), + _i4.Serializers.instance.deserialize($serialized[r'uri']), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i19.PathException, Map>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return _i19.PathException(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i16.HijackException, Map?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return _i16.HijackException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i21.SqliteException, Map>( + serialize: + ($value) => { + r'message': $value.message, + if ($value.explanation case final explanation?) + r'explanation': explanation, + r'extendedResultCode': $value.extendedResultCode, + r'resultCode': $value.resultCode, + if ($value.offset case final offset?) r'offset': offset, + if ($value.operation case final operation?) + r'operation': operation, + if ($value.causingStatement case final causingStatement?) + r'causingStatement': causingStatement, + if ($value.parametersToStatement + case final parametersToStatement?) + r'parametersToStatement': parametersToStatement, + }, + deserialize: ($serialized) { + return _i21.SqliteException( + ($serialized[r'extendedResultCode'] as num).toInt(), + ($serialized[r'message'] as String), + ($serialized[r'explanation'] as String?), + ($serialized[r'causingStatement'] as String?), + ($serialized[r'parametersToStatement'] as Iterable?) + ?.toList(), + ($serialized[r'operation'] as String?), + ($serialized[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i22.VfsException, Map>( + serialize: + ($value) => {r'returnCode': $value.returnCode}, + deserialize: ($serialized) { + return _i22.VfsException(($serialized[r'returnCode'] as num).toInt()); + }, + ), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': CreateTarget()}, + setup: (_i7.Context context) async { + await _i24.CelestData.init(context); + }, + ); +} diff --git a/apps/cli/fixtures/legacy/data/lib/fix_data/v1_migration.yaml b/apps/cli/fixtures/legacy/data/lib/fix_data/v1_migration.yaml new file mode 100644 index 000000000..63808355d --- /dev/null +++ b/apps/cli/fixtures/legacy/data/lib/fix_data/v1_migration.yaml @@ -0,0 +1,13 @@ +# Generated by Celest. Do not modify. +version: 1 +transforms: + - title: "Updates the import of the Celest client" + date: 2024-10-06 + element: + uris: ["client.dart"] + variable: celest + changes: + - kind: replacedBy + newElement: + uris: ["package:simple_client/simple_client.dart"] + variable: celest diff --git a/apps/cli/fixtures/legacy/data/lib/src/database/task_database.dart b/apps/cli/fixtures/legacy/data/lib/src/database/task_database.dart new file mode 100644 index 000000000..37735be5e --- /dev/null +++ b/apps/cli/fixtures/legacy/data/lib/src/database/task_database.dart @@ -0,0 +1,20 @@ +import 'package:drift/drift.dart'; + +part 'task_database.g.dart'; + +enum Priority { low, medium, high } + +class Tasks extends Table { + IntColumn get id => integer().autoIncrement()(); + TextColumn get title => text().withLength(min: 1, max: 100)(); + TextColumn get priority => textEnum()(); + BoolColumn get completed => boolean().withDefault(const Constant(false))(); +} + +@DriftDatabase(tables: [Tasks]) +class TaskDatabase extends _$TaskDatabase { + TaskDatabase(super.e); + + @override + int get schemaVersion => 1; +} diff --git a/apps/cli/fixtures/legacy/data/lib/src/database/task_database.g.dart b/apps/cli/fixtures/legacy/data/lib/src/database/task_database.g.dart new file mode 100644 index 000000000..59e537d6a --- /dev/null +++ b/apps/cli/fixtures/legacy/data/lib/src/database/task_database.g.dart @@ -0,0 +1,434 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'task_database.dart'; + +// ignore_for_file: type=lint +class $TasksTable extends Tasks with TableInfo<$TasksTable, Task> { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + $TasksTable(this.attachedDatabase, [this._alias]); + static const VerificationMeta _idMeta = const VerificationMeta('id'); + @override + late final GeneratedColumn id = GeneratedColumn( + 'id', aliasedName, false, + hasAutoIncrement: true, + type: DriftSqlType.int, + requiredDuringInsert: false, + defaultConstraints: + GeneratedColumn.constraintIsAlways('PRIMARY KEY AUTOINCREMENT')); + static const VerificationMeta _titleMeta = const VerificationMeta('title'); + @override + late final GeneratedColumn title = GeneratedColumn( + 'title', aliasedName, false, + additionalChecks: + GeneratedColumn.checkTextLength(minTextLength: 1, maxTextLength: 100), + type: DriftSqlType.string, + requiredDuringInsert: true); + static const VerificationMeta _priorityMeta = + const VerificationMeta('priority'); + @override + late final GeneratedColumnWithTypeConverter priority = + GeneratedColumn('priority', aliasedName, false, + type: DriftSqlType.string, requiredDuringInsert: true) + .withConverter($TasksTable.$converterpriority); + static const VerificationMeta _completedMeta = + const VerificationMeta('completed'); + @override + late final GeneratedColumn completed = GeneratedColumn( + 'completed', aliasedName, false, + type: DriftSqlType.bool, + requiredDuringInsert: false, + defaultConstraints: + GeneratedColumn.constraintIsAlways('CHECK ("completed" IN (0, 1))'), + defaultValue: const Constant(false)); + @override + List get $columns => [id, title, priority, completed]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'tasks'; + @override + VerificationContext validateIntegrity(Insertable instance, + {bool isInserting = false}) { + final context = VerificationContext(); + final data = instance.toColumns(true); + if (data.containsKey('id')) { + context.handle(_idMeta, id.isAcceptableOrUnknown(data['id']!, _idMeta)); + } + if (data.containsKey('title')) { + context.handle( + _titleMeta, title.isAcceptableOrUnknown(data['title']!, _titleMeta)); + } else if (isInserting) { + context.missing(_titleMeta); + } + context.handle(_priorityMeta, const VerificationResult.success()); + if (data.containsKey('completed')) { + context.handle(_completedMeta, + completed.isAcceptableOrUnknown(data['completed']!, _completedMeta)); + } + return context; + } + + @override + Set get $primaryKey => {id}; + @override + Task map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return Task( + id: attachedDatabase.typeMapping + .read(DriftSqlType.int, data['${effectivePrefix}id'])!, + title: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}title'])!, + priority: $TasksTable.$converterpriority.fromSql(attachedDatabase + .typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}priority'])!), + completed: attachedDatabase.typeMapping + .read(DriftSqlType.bool, data['${effectivePrefix}completed'])!, + ); + } + + @override + $TasksTable createAlias(String alias) { + return $TasksTable(attachedDatabase, alias); + } + + static JsonTypeConverter2 $converterpriority = + const EnumNameConverter(Priority.values); +} + +class Task extends DataClass implements Insertable { + final int id; + final String title; + final Priority priority; + final bool completed; + const Task( + {required this.id, + required this.title, + required this.priority, + required this.completed}); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['id'] = Variable(id); + map['title'] = Variable(title); + { + map['priority'] = + Variable($TasksTable.$converterpriority.toSql(priority)); + } + map['completed'] = Variable(completed); + return map; + } + + TasksCompanion toCompanion(bool nullToAbsent) { + return TasksCompanion( + id: Value(id), + title: Value(title), + priority: Value(priority), + completed: Value(completed), + ); + } + + factory Task.fromJson(Map json, + {ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return Task( + id: serializer.fromJson(json['id']), + title: serializer.fromJson(json['title']), + priority: $TasksTable.$converterpriority + .fromJson(serializer.fromJson(json['priority'])), + completed: serializer.fromJson(json['completed']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'id': serializer.toJson(id), + 'title': serializer.toJson(title), + 'priority': serializer + .toJson($TasksTable.$converterpriority.toJson(priority)), + 'completed': serializer.toJson(completed), + }; + } + + Task copyWith( + {int? id, String? title, Priority? priority, bool? completed}) => + Task( + id: id ?? this.id, + title: title ?? this.title, + priority: priority ?? this.priority, + completed: completed ?? this.completed, + ); + Task copyWithCompanion(TasksCompanion data) { + return Task( + id: data.id.present ? data.id.value : this.id, + title: data.title.present ? data.title.value : this.title, + priority: data.priority.present ? data.priority.value : this.priority, + completed: data.completed.present ? data.completed.value : this.completed, + ); + } + + @override + String toString() { + return (StringBuffer('Task(') + ..write('id: $id, ') + ..write('title: $title, ') + ..write('priority: $priority, ') + ..write('completed: $completed') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash(id, title, priority, completed); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is Task && + other.id == this.id && + other.title == this.title && + other.priority == this.priority && + other.completed == this.completed); +} + +class TasksCompanion extends UpdateCompanion { + final Value id; + final Value title; + final Value priority; + final Value completed; + const TasksCompanion({ + this.id = const Value.absent(), + this.title = const Value.absent(), + this.priority = const Value.absent(), + this.completed = const Value.absent(), + }); + TasksCompanion.insert({ + this.id = const Value.absent(), + required String title, + required Priority priority, + this.completed = const Value.absent(), + }) : title = Value(title), + priority = Value(priority); + static Insertable custom({ + Expression? id, + Expression? title, + Expression? priority, + Expression? completed, + }) { + return RawValuesInsertable({ + if (id != null) 'id': id, + if (title != null) 'title': title, + if (priority != null) 'priority': priority, + if (completed != null) 'completed': completed, + }); + } + + TasksCompanion copyWith( + {Value? id, + Value? title, + Value? priority, + Value? completed}) { + return TasksCompanion( + id: id ?? this.id, + title: title ?? this.title, + priority: priority ?? this.priority, + completed: completed ?? this.completed, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (id.present) { + map['id'] = Variable(id.value); + } + if (title.present) { + map['title'] = Variable(title.value); + } + if (priority.present) { + map['priority'] = Variable( + $TasksTable.$converterpriority.toSql(priority.value)); + } + if (completed.present) { + map['completed'] = Variable(completed.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('TasksCompanion(') + ..write('id: $id, ') + ..write('title: $title, ') + ..write('priority: $priority, ') + ..write('completed: $completed') + ..write(')')) + .toString(); + } +} + +abstract class _$TaskDatabase extends GeneratedDatabase { + _$TaskDatabase(QueryExecutor e) : super(e); + $TaskDatabaseManager get managers => $TaskDatabaseManager(this); + late final $TasksTable tasks = $TasksTable(this); + @override + Iterable> get allTables => + allSchemaEntities.whereType>(); + @override + List get allSchemaEntities => [tasks]; +} + +typedef $$TasksTableCreateCompanionBuilder = TasksCompanion Function({ + Value id, + required String title, + required Priority priority, + Value completed, +}); +typedef $$TasksTableUpdateCompanionBuilder = TasksCompanion Function({ + Value id, + Value title, + Value priority, + Value completed, +}); + +class $$TasksTableFilterComposer extends Composer<_$TaskDatabase, $TasksTable> { + $$TasksTableFilterComposer({ + required super.$db, + required super.$table, + super.joinBuilder, + super.$addJoinBuilderToRootComposer, + super.$removeJoinBuilderFromRootComposer, + }); + ColumnFilters get id => $composableBuilder( + column: $table.id, builder: (column) => ColumnFilters(column)); + + ColumnFilters get title => $composableBuilder( + column: $table.title, builder: (column) => ColumnFilters(column)); + + ColumnWithTypeConverterFilters get priority => + $composableBuilder( + column: $table.priority, + builder: (column) => ColumnWithTypeConverterFilters(column)); + + ColumnFilters get completed => $composableBuilder( + column: $table.completed, builder: (column) => ColumnFilters(column)); +} + +class $$TasksTableOrderingComposer + extends Composer<_$TaskDatabase, $TasksTable> { + $$TasksTableOrderingComposer({ + required super.$db, + required super.$table, + super.joinBuilder, + super.$addJoinBuilderToRootComposer, + super.$removeJoinBuilderFromRootComposer, + }); + ColumnOrderings get id => $composableBuilder( + column: $table.id, builder: (column) => ColumnOrderings(column)); + + ColumnOrderings get title => $composableBuilder( + column: $table.title, builder: (column) => ColumnOrderings(column)); + + ColumnOrderings get priority => $composableBuilder( + column: $table.priority, builder: (column) => ColumnOrderings(column)); + + ColumnOrderings get completed => $composableBuilder( + column: $table.completed, builder: (column) => ColumnOrderings(column)); +} + +class $$TasksTableAnnotationComposer + extends Composer<_$TaskDatabase, $TasksTable> { + $$TasksTableAnnotationComposer({ + required super.$db, + required super.$table, + super.joinBuilder, + super.$addJoinBuilderToRootComposer, + super.$removeJoinBuilderFromRootComposer, + }); + GeneratedColumn get id => + $composableBuilder(column: $table.id, builder: (column) => column); + + GeneratedColumn get title => + $composableBuilder(column: $table.title, builder: (column) => column); + + GeneratedColumnWithTypeConverter get priority => + $composableBuilder(column: $table.priority, builder: (column) => column); + + GeneratedColumn get completed => + $composableBuilder(column: $table.completed, builder: (column) => column); +} + +class $$TasksTableTableManager extends RootTableManager< + _$TaskDatabase, + $TasksTable, + Task, + $$TasksTableFilterComposer, + $$TasksTableOrderingComposer, + $$TasksTableAnnotationComposer, + $$TasksTableCreateCompanionBuilder, + $$TasksTableUpdateCompanionBuilder, + (Task, BaseReferences<_$TaskDatabase, $TasksTable, Task>), + Task, + PrefetchHooks Function()> { + $$TasksTableTableManager(_$TaskDatabase db, $TasksTable table) + : super(TableManagerState( + db: db, + table: table, + createFilteringComposer: () => + $$TasksTableFilterComposer($db: db, $table: table), + createOrderingComposer: () => + $$TasksTableOrderingComposer($db: db, $table: table), + createComputedFieldComposer: () => + $$TasksTableAnnotationComposer($db: db, $table: table), + updateCompanionCallback: ({ + Value id = const Value.absent(), + Value title = const Value.absent(), + Value priority = const Value.absent(), + Value completed = const Value.absent(), + }) => + TasksCompanion( + id: id, + title: title, + priority: priority, + completed: completed, + ), + createCompanionCallback: ({ + Value id = const Value.absent(), + required String title, + required Priority priority, + Value completed = const Value.absent(), + }) => + TasksCompanion.insert( + id: id, + title: title, + priority: priority, + completed: completed, + ), + withReferenceMapper: (p0) => p0 + .map((e) => (e.readTable(table), BaseReferences(db, table, e))) + .toList(), + prefetchHooksCallback: null, + )); +} + +typedef $$TasksTableProcessedTableManager = ProcessedTableManager< + _$TaskDatabase, + $TasksTable, + Task, + $$TasksTableFilterComposer, + $$TasksTableOrderingComposer, + $$TasksTableAnnotationComposer, + $$TasksTableCreateCompanionBuilder, + $$TasksTableUpdateCompanionBuilder, + (Task, BaseReferences<_$TaskDatabase, $TasksTable, Task>), + Task, + PrefetchHooks Function()>; + +class $TaskDatabaseManager { + final _$TaskDatabase _db; + $TaskDatabaseManager(this._db); + $$TasksTableTableManager get tasks => + $$TasksTableTableManager(_db, _db.tasks); +} diff --git a/apps/cli/fixtures/legacy/data/lib/src/functions/tasks.dart b/apps/cli/fixtures/legacy/data/lib/src/functions/tasks.dart new file mode 100644 index 000000000..bd9cbb8e3 --- /dev/null +++ b/apps/cli/fixtures/legacy/data/lib/src/functions/tasks.dart @@ -0,0 +1,19 @@ +import 'package:celest/celest.dart'; +import 'package:celest_backend/src/database/task_database.dart'; +import 'package:celest_backend/src/generated/cloud.celest.dart'; + +/// Creates a new [Task]. +@cloud +Future create({ + required String title, + Priority priority = Priority.high, +}) async { + final db = celest.data.database; + final task = await db.transaction(() async { + return db.into(db.tasks).insertReturning( + TasksCompanion.insert(title: title, priority: priority), + ); + }); + print('Created task: $task'); + return task; +} diff --git a/apps/cli/fixtures/legacy/data/lib/src/generated/cloud.celest.dart b/apps/cli/fixtures/legacy/data/lib/src/generated/cloud.celest.dart new file mode 100644 index 000000000..595befdd5 --- /dev/null +++ b/apps/cli/fixtures/legacy/data/lib/src/generated/cloud.celest.dart @@ -0,0 +1,52 @@ +// Generated by Celest. This file should not be modified manually, but +// it can be checked into version control. +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +library; + +import 'package:celest/src/core/context.dart'; +import 'package:celest_backend/src/generated/config.celest.dart'; +import 'package:celest_backend/src/generated/data.celest.dart'; + +/// The interface to your Celest backend. +/// +/// Similar to the `celest` global in the frontend, this +/// provides access to the backend environment and services +/// configured for your project. +const CelestCloud celest = CelestCloud._(); + +/// A per-request context object which propogates request information and common +/// accessors to the Celest server environment. +CelestContext get context => CelestContext._(context); + +/// The interface to your Celest backend. +/// +/// Similar to the `Celest` class in the frontend, this class +/// provides access to the backend environment and services +/// configured for your project. +class CelestCloud { + const CelestCloud._(); + + /// The current environment of the Celest service. + /// + /// This is determined by the `CELEST_ENVIRONMENT` variable + /// which is set for you by the deployment environment. + CelestEnvironment get currentEnvironment => + (variables.currentEnvironment as CelestEnvironment); + + /// The variables of the Celest service. + /// + /// This class provides access to the values configured for the + /// [currentEnvironment]. + CelestVariables get variables => const CelestVariables(); + + /// The data services for the Celest backend. + /// + /// This class provides access to the databases that are configured + /// for the [currentEnvironment]. + CelestData get data => const CelestData(); +} + +/// A per-request context object which propogates request information and common +/// accessors to the Celest server environment. +extension type CelestContext._(Context _context) implements Context {} diff --git a/apps/cli/fixtures/legacy/data/lib/src/generated/config.celest.dart b/apps/cli/fixtures/legacy/data/lib/src/generated/config.celest.dart new file mode 100644 index 000000000..687b9f186 --- /dev/null +++ b/apps/cli/fixtures/legacy/data/lib/src/generated/config.celest.dart @@ -0,0 +1,45 @@ +// Generated by Celest. This file should not be modified manually, but +// it can be checked into version control. +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +library; + +import 'package:celest/celest.dart'; +import 'package:celest/src/core/context.dart'; + +/// An environment of a deployed Celest service. +/// +/// Celest services can have multiple isolated branches, for example +/// a `development` and `production` environment. +extension type const CelestEnvironment._(String _env) + implements Environment, String { + /// The local Celest environment, used to delineate when a + /// Celest service is running on a developer machine as opposed + /// to the cloud. + static const CelestEnvironment local = CelestEnvironment._('local'); + + /// The production Celest environment which is common to all + /// Celest projects and labels the environment which is considered + /// live and served to end-users. + static const CelestEnvironment production = CelestEnvironment._('production'); + + /// Whether `this` represents the [local] environment. + bool get isLocal => this == local; + + /// Whether `this` represents the [production] environment. + bool get isProduction => this == production; +} + +/// The environment variables for the Celest service. +/// +/// This class provides access to the environment variable values +/// that are configured for the current [CelestEnvironment]. +class CelestVariables { + const CelestVariables(); + + /// The environment variable that determines the current environment. + /// + /// This is set by the deployment environment and is used to + /// determine the current environment of the Celest service. + String get currentEnvironment => context.expect(env.environment); +} diff --git a/apps/cli/fixtures/legacy/data/lib/src/generated/data.celest.dart b/apps/cli/fixtures/legacy/data/lib/src/generated/data.celest.dart new file mode 100644 index 000000000..10dc6ccc1 --- /dev/null +++ b/apps/cli/fixtures/legacy/data/lib/src/generated/data.celest.dart @@ -0,0 +1,39 @@ +// Generated by Celest. This file should not be modified manually, but +// it can be checked into version control. +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +library; + +import 'package:celest/celest.dart'; +import 'package:celest/src/core/context.dart'; +import 'package:celest/src/runtime/data/connect.dart'; +import 'package:celest_backend/src/database/task_database.dart'; + +/// The data services for the Celest backend. +/// +/// This class provides access to the databases that are configured +/// for the current [CelestEnvironment]. +class CelestData { + const CelestData(); + + /// Initializes the databases attached to this project in the given [context]. + static Future init(Context context) async { + context.put( + _databaseKey, + await connect( + context, + name: 'TaskDatabase', + factory: TaskDatabase.new, + hostnameVariable: const env('CELEST_DATABASE_HOST'), + tokenSecret: const secret('CELEST_DATABASE_TOKEN'), + ), + ); + } + + /// The `TaskDatabase` instance for this project. + TaskDatabase get database => Context.current.expect(_databaseKey); + + /// The context key for the [database] instance. + static ContextKey get _databaseKey => + const ContextKey('TaskDatabase'); +} diff --git a/apps/cli/fixtures/legacy/data/lib/src/project.dart b/apps/cli/fixtures/legacy/data/lib/src/project.dart new file mode 100644 index 000000000..346598925 --- /dev/null +++ b/apps/cli/fixtures/legacy/data/lib/src/project.dart @@ -0,0 +1,8 @@ +import 'package:celest/celest.dart'; +import 'package:celest_backend/src/database/task_database.dart'; + +const project = Project(name: 'data'); + +const database = Database( + schema: Schema.drift(TaskDatabase), +); diff --git a/apps/cli/fixtures/legacy/data/pubspec.yaml b/apps/cli/fixtures/legacy/data/pubspec.yaml new file mode 100644 index 000000000..8f9fbfbcc --- /dev/null +++ b/apps/cli/fixtures/legacy/data/pubspec.yaml @@ -0,0 +1,35 @@ +name: celest_backend +publish_to: none + +environment: + sdk: ^3.4.0 + +dependencies: + celest: ^1.0.0 + celest_cloud_auth: 'any' + celest_core: ^1.0.0 + drift: '>=2.25.0 <2.26.0' + drift_hrana: ^1.0.2 + meta: ^1.12.0 + +dependency_overrides: + cedar: + path: ../../../../../cedar/packages/cedar + celest: + path: ../../../../../celest/packages/celest + celest_ast: + path: ../../../../../celest/packages/celest_ast + celest_auth: + path: ../../../../../celest/packages/celest_auth + celest_cloud: + path: ../../../../../celest/packages/celest_cloud + celest_cloud_auth: + path: ../../../../../celest/services/celest_cloud_auth + celest_core: + path: ../../../../../celest/packages/celest_core + +dev_dependencies: + build_runner: ^2.4.13 + drift_dev: '>=2.25.0 <2.26.0' + lints: ^4.0.0 + test: ^1.25.0 diff --git a/apps/cli/fixtures/legacy/env_vars/.env.local b/apps/cli/fixtures/legacy/env_vars/.env.local new file mode 100644 index 000000000..d091f9302 --- /dev/null +++ b/apps/cli/fixtures/legacy/env_vars/.env.local @@ -0,0 +1,7 @@ +MY_NAME=Dillon +MY_AGE=28 +MY_HEIGHT=5.83 +MY_WEIGHT=130 +IM_COOL=true +SUPER_SECRET="SGk=" +MY_WEBSITE="https://dillonnys.com" diff --git a/apps/cli/fixtures/legacy/env_vars/client/lib/env_vars_client.dart b/apps/cli/fixtures/legacy/env_vars/client/lib/env_vars_client.dart new file mode 100644 index 000000000..715e63379 --- /dev/null +++ b/apps/cli/fixtures/legacy/env_vars/client/lib/env_vars_client.dart @@ -0,0 +1,80 @@ +// Generated by Celest. This file should not be modified manually, but +// it can be checked into version control. +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +library; // ignore_for_file: no_leading_underscores_for_library_prefixes + +import 'dart:io'; + +import 'package:celest_core/_internal.dart' as _$celest; +import 'package:celest_core/celest_core.dart' as _$celest; +import 'package:celest_core/src/util/globals.dart' as _$celest; +import 'package:env_vars_client/src/functions.dart'; +import 'package:env_vars_client/src/serializers.dart'; +import 'package:http/http.dart' as _$http_http; +import 'package:native_storage/native_storage.dart' + as _$native_storage_native_storage; + +export 'package:celest_backend/models/person.dart' show Person; + +final Celest celest = Celest(); + +enum CelestEnvironment { + local, + production; + + Uri get baseUri => switch (this) { + local => + _$celest.kIsWeb || !Platform.isAndroid + ? Uri.parse('http://localhost:7777') + : Uri.parse('http://10.0.2.2:7777'), + production => Uri.parse('https://example.celest.run'), + }; +} + +class Celest with _$celest.CelestBase { + var _initialized = false; + + late CelestEnvironment _currentEnvironment; + + late final _$native_storage_native_storage.NativeStorage nativeStorage = + _$native_storage_native_storage.NativeStorage(scope: 'celest'); + + @override + late _$http_http.Client httpClient = _$celest.CelestHttpClient( + secureStorage: nativeStorage.secure, + ); + + late Uri _baseUri; + + final _functions = CelestFunctions(); + + T _checkInitialized(T Function() value) { + if (!_initialized) { + throw StateError( + 'Celest has not been initialized. Make sure to call `celest.init()` at the start of your `main` method.', + ); + } + return value(); + } + + CelestEnvironment get currentEnvironment => + _checkInitialized(() => _currentEnvironment); + + @override + Uri get baseUri => _checkInitialized(() => _baseUri); + + CelestFunctions get functions => _checkInitialized(() => _functions); + + void init({ + CelestEnvironment environment = CelestEnvironment.local, + _$celest.Serializers? serializers, + }) { + _currentEnvironment = environment; + _baseUri = environment.baseUri; + if (!_initialized) { + initSerializers(serializers: serializers); + } + _initialized = true; + } +} diff --git a/apps/cli/fixtures/legacy/env_vars/client/lib/src/functions.dart b/apps/cli/fixtures/legacy/env_vars/client/lib/src/functions.dart new file mode 100644 index 000000000..2fce8ffd8 --- /dev/null +++ b/apps/cli/fixtures/legacy/env_vars/client/lib/src/functions.dart @@ -0,0 +1,319 @@ +// Generated by Celest. This file should not be modified manually, but +// it can be checked into version control. +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +library; // ignore_for_file: no_leading_underscores_for_library_prefixes + +import 'dart:async'; +import 'dart:convert'; + +import 'package:celest/celest.dart' as _$celest; +import 'package:celest_backend/models/person.dart'; +import 'package:celest_core/celest_core.dart' as _$celest; +import 'package:celest_core/src/exception/cloud_exception.dart' as _$celest; +import 'package:celest_core/src/exception/serialization_exception.dart' + as _$celest; +import 'package:env_vars_client/env_vars_client.dart'; + +class CelestFunctions { + final injected = CelestFunctionsInjected(); +} + +class CelestFunctionsInjected { + Never _throwError({int? code, required Map body}) { + final status = body['@status'] as Map?; + final message = status?['message'] as String?; + final details = status?['details'] as _$celest.JsonList?; + final (errorType, errorValue, stackTrace) = switch (details) { + null || [] => const (null, null, StackTrace.empty), + [ + final errorDetails as Map, + { + '@type': 'dart.core.StackTrace', + 'value': final stackTraceValue as String, + }, + ..., + ] => + ( + errorDetails['@type'], + errorDetails['value'], + StackTrace.fromString(stackTraceValue), + ), + [final errorDetails as Map, ...] => ( + errorDetails['@type'], + errorDetails['value'], + StackTrace.empty, + ), + }; + + switch (errorType) { + case 'dart.core.Error': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.AssertionError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.TypeError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.ArgumentError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.RangeError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.IndexError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.UnsupportedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.UnimplementedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.StateError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.ConcurrentModificationError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.core.OutOfMemoryError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.StackOverflowError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.Exception': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.FormatException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.IntegerDivisionByZeroException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.convert.JsonUnsupportedObjectError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.async.AsyncError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.async.TimeoutException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.CloudException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.CloudException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.CancelledException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.CancelledException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnknownError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.UnknownError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.BadRequestException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.BadRequestException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnauthorizedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.UnauthorizedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.NotFoundException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.NotFoundException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.AlreadyExistsException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.AlreadyExistsException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.PermissionDeniedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.PermissionDeniedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.ResourceExhaustedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.ResourceExhaustedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.FailedPreconditionException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.FailedPreconditionException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.AbortedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.AbortedException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.OutOfRangeException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.OutOfRangeException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnimplementedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.UnimplementedError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.InternalServerError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.InternalServerError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnavailableError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.UnavailableError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.DataLossError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.DataLossError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.DeadlineExceededError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.DeadlineExceededError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.SerializationException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.SerializationException>(errorValue), + stackTrace, + ); + default: + Error.throwWithStackTrace( + _$celest.CloudException.http( + code: code, + message: message, + details: ((details ?? body) as _$celest.JsonValue), + ), + StackTrace.empty, + ); + } + } + + @_$celest.CloudFunction(api: 'injected', function: 'sayHello') + Future sayHello() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/injected/say-hello'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return ($body as String); + } + + @_$celest.CloudFunction(api: 'injected', function: 'sayHelloPerson') + Future sayHelloPerson() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/injected/say-hello-person'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize($body); + } +} diff --git a/apps/cli/fixtures/legacy/env_vars/client/lib/src/serializers.dart b/apps/cli/fixtures/legacy/env_vars/client/lib/src/serializers.dart new file mode 100644 index 000000000..8dd7dde62 --- /dev/null +++ b/apps/cli/fixtures/legacy/env_vars/client/lib/src/serializers.dart @@ -0,0 +1,779 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async'; +import 'dart:convert'; + +import 'package:celest_backend/models/person.dart'; +import 'package:celest_core/celest_core.dart' as _$celest; +import 'package:celest_core/src/exception/cloud_exception.dart' as _$celest; +import 'package:celest_core/src/exception/serialization_exception.dart' + as _$celest; +import 'package:celest_core/src/serialization/json_value.dart' as _$celest; + +void initSerializers({_$celest.Serializers? serializers}) { + return runZoned(() { + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _$celest.Serializers.instance + .serialize($value.stackTrace), + }, + deserialize: ($serialized) { + return AsyncError( + $serialized[r'error']!, + _$celest.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_$celest.Serializers.instance.serialize( + $value.duration, + ) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return TimeoutException( + ($serialized[r'message'] as String?), + _$celest.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest + .Serializer.define>( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + ConcurrentModificationError, + Map? + >( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: + ($value) => { + if (_$celest.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + r'name': $value.name, + r'age': $value.age, + r'height': $value.height, + r'weight': $value.weight, + r'isCool': $value.isCool, + r'website': _$celest.Serializers.instance.serialize( + $value.website, + ), + }, + deserialize: ($serialized) { + return Person( + name: ($serialized[r'name'] as String), + age: ($serialized[r'age'] as num).toInt(), + height: ($serialized[r'height'] as num).toDouble(), + weight: ($serialized[r'weight'] as num), + isCool: ($serialized[r'isCool'] as bool), + website: _$celest.Serializers.instance.deserialize( + $serialized[r'website'], + ), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest + .Serializer.define<_$celest.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.AbortedException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.AlreadyExistsException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.BadRequestException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.BadRequestException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.CancelledException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.CancelledException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define<_$celest.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.CloudException.fromJson($serialized); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define<_$celest.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.DataLossError( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.DeadlineExceededError, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.InternalServerError, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.InternalServerError( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest + .Serializer.define<_$celest.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.NotFoundException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.OutOfRangeException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.OutOfRangeException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.UnauthorizedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.UnauthorizedException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest + .Serializer.define<_$celest.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.UnavailableError( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.UnimplementedError, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.UnimplementedError( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define<_$celest.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.UnknownError( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.SerializationException, + Map + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define<_$celest.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _$celest.JsonValue($serialized); + }, + ), + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ); + }, zoneValues: {_$celest.Serializers: serializers}); +} diff --git a/apps/cli/fixtures/legacy/env_vars/client/pubspec.yaml b/apps/cli/fixtures/legacy/env_vars/client/pubspec.yaml new file mode 100644 index 000000000..b2a3f47ad --- /dev/null +++ b/apps/cli/fixtures/legacy/env_vars/client/pubspec.yaml @@ -0,0 +1,29 @@ +name: env_vars_client +description: The Celest client for env_vars. +publish_to: none + +environment: + sdk: ^3.4.0 + +dependencies: + celest: ^1.0.0 + celest_backend: + path: .. + celest_core: ^1.0.0 + http: ^1.0.0 + native_storage: ^0.2.2 + +dependency_overrides: + celest: + path: ../../../../../../celest/packages/celest + celest_ast: + path: ../../../../../../celest/packages/celest_ast + celest_auth: + path: ../../../../../../celest/packages/celest_auth + celest_cloud: + path: ../../../../../../celest/packages/celest_cloud + celest_cloud_auth: + path: ../../../../../../celest/services/celest_cloud_auth + celest_core: + path: ../../../../../../celest/packages/celest_core +dev_dependencies: {} diff --git a/apps/cli/fixtures/legacy/env_vars/config b/apps/cli/fixtures/legacy/env_vars/config new file mode 120000 index 000000000..f4bb8a296 --- /dev/null +++ b/apps/cli/fixtures/legacy/env_vars/config @@ -0,0 +1 @@ +lib/src/config \ No newline at end of file diff --git a/apps/cli/fixtures/legacy/env_vars/goldens/api.local.dart b/apps/cli/fixtures/legacy/env_vars/goldens/api.local.dart new file mode 100644 index 000000000..e4c4bdb76 --- /dev/null +++ b/apps/cli/fixtures/legacy/env_vars/goldens/api.local.dart @@ -0,0 +1,22 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'package:celest/src/core/context.dart' as _i4; +import 'package:celest/src/runtime/serve.dart' as _i1; + +import 'functions/injected/sayHello.dart' as _i2; +import 'functions/injected/sayHelloPerson.dart' as _i3; + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: { + '/injected/say-hello': _i2.SayHelloTarget(), + '/injected/say-hello-person': _i3.SayHelloPersonTarget(), + }, + setup: (_i4.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/env_vars/goldens/ast.json b/apps/cli/fixtures/legacy/env_vars/goldens/ast.json new file mode 100644 index 000000000..955f7c8ae --- /dev/null +++ b/apps/cli/fixtures/legacy/env_vars/goldens/ast.json @@ -0,0 +1,861 @@ +{ + "name": "env_vars", + "environment": "local", + "reference": { + "$": "Reference", + "symbol": "project", + "url": "package:celest_backend/src/project.dart" + }, + "apis": { + "injected": { + "name": "injected", + "metadata": [], + "functions": { + "sayHello": { + "name": "sayHello", + "apiName": "injected", + "typeParameters": [], + "parameters": [ + { + "name": "name", + "type": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + "required": true, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 198, + "uri": "package:celest_backend/src/functions/injected.dart", + "line": 9, + "column": 26 + }, + "end": { + "offset": 202, + "uri": "package:celest_backend/src/functions/injected.dart", + "line": 9, + "column": 30 + }, + "text": "name" + }, + "references": { + "name": "MY_NAME", + "type": "variable" + } + }, + { + "name": "age", + "type": { + "$": "TypeReference", + "symbol": "int", + "url": "dart:core", + "isNullable": false + }, + "required": true, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 226, + "uri": "package:celest_backend/src/functions/injected.dart", + "line": 10, + "column": 22 + }, + "end": { + "offset": 229, + "uri": "package:celest_backend/src/functions/injected.dart", + "line": 10, + "column": 25 + }, + "text": "age" + }, + "references": { + "name": "MY_AGE", + "type": "variable" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 161, + "uri": "package:celest_backend/src/functions/injected.dart", + "line": 8, + "column": 7 + }, + "end": { + "offset": 169, + "uri": "package:celest_backend/src/functions/injected.dart", + "line": 8, + "column": 15 + }, + "text": "sayHello" + } + }, + "sayHelloPerson": { + "name": "sayHelloPerson", + "apiName": "injected", + "typeParameters": [], + "parameters": [ + { + "name": "name", + "type": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + "required": true, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 343, + "uri": "package:celest_backend/src/functions/injected.dart", + "line": 17, + "column": 26 + }, + "end": { + "offset": 347, + "uri": "package:celest_backend/src/functions/injected.dart", + "line": 17, + "column": 30 + }, + "text": "name" + }, + "references": { + "name": "MY_NAME", + "type": "variable" + } + }, + { + "name": "age", + "type": { + "$": "TypeReference", + "symbol": "int", + "url": "dart:core", + "isNullable": false + }, + "required": true, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 371, + "uri": "package:celest_backend/src/functions/injected.dart", + "line": 18, + "column": 22 + }, + "end": { + "offset": 374, + "uri": "package:celest_backend/src/functions/injected.dart", + "line": 18, + "column": 25 + }, + "text": "age" + }, + "references": { + "name": "MY_AGE", + "type": "variable" + } + }, + { + "name": "height", + "type": { + "$": "TypeReference", + "symbol": "double", + "url": "dart:core", + "isNullable": false + }, + "required": true, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 404, + "uri": "package:celest_backend/src/functions/injected.dart", + "line": 19, + "column": 28 + }, + "end": { + "offset": 410, + "uri": "package:celest_backend/src/functions/injected.dart", + "line": 19, + "column": 34 + }, + "text": "height" + }, + "references": { + "name": "MY_HEIGHT", + "type": "variable" + } + }, + { + "name": "weight", + "type": { + "$": "TypeReference", + "symbol": "num", + "url": "dart:core", + "isNullable": false + }, + "required": true, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 445, + "uri": "package:celest_backend/src/functions/injected.dart", + "line": 20, + "column": 33 + }, + "end": { + "offset": 451, + "uri": "package:celest_backend/src/functions/injected.dart", + "line": 20, + "column": 39 + }, + "text": "weight" + }, + "references": { + "name": "MY_WEIGHT", + "type": "variable" + } + }, + { + "name": "website", + "type": { + "$": "Reference", + "symbol": "Uri", + "url": "dart:core" + }, + "required": true, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 487, + "uri": "package:celest_backend/src/functions/injected.dart", + "line": 21, + "column": 34 + }, + "end": { + "offset": 494, + "uri": "package:celest_backend/src/functions/injected.dart", + "line": 21, + "column": 41 + }, + "text": "website" + }, + "references": { + "name": "MY_WEBSITE", + "type": "variable" + } + }, + { + "name": "isCool", + "type": { + "$": "TypeReference", + "symbol": "bool", + "url": "dart:core", + "isNullable": false + }, + "required": true, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 528, + "uri": "package:celest_backend/src/functions/injected.dart", + "line": 22, + "column": 32 + }, + "end": { + "offset": 534, + "uri": "package:celest_backend/src/functions/injected.dart", + "line": 22, + "column": 38 + }, + "text": "isCool" + }, + "references": { + "name": "IM_COOL", + "type": "variable" + } + }, + { + "name": "superSecret", + "type": { + "$": "Reference", + "symbol": "Uint8List", + "url": "dart:typed_data" + }, + "required": true, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 581, + "uri": "package:celest_backend/src/functions/injected.dart", + "line": 23, + "column": 45 + }, + "end": { + "offset": 592, + "uri": "package:celest_backend/src/functions/injected.dart", + "line": 23, + "column": 56 + }, + "text": "superSecret" + }, + "references": { + "name": "SUPER_SECRET", + "type": "secret" + } + }, + { + "name": "currentEnvironment", + "type": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + "required": true, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 629, + "uri": "package:celest_backend/src/functions/injected.dart", + "line": 24, + "column": 35 + }, + "end": { + "offset": 647, + "uri": "package:celest_backend/src/functions/injected.dart", + "line": 24, + "column": 53 + }, + "text": "currentEnvironment" + }, + "references": { + "name": "CELEST_ENVIRONMENT", + "type": "variable" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "Person", + "url": "package:celest_backend/models/person.dart", + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "Person", + "url": "package:celest_backend/models/person.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 300, + "uri": "package:celest_backend/src/functions/injected.dart", + "line": 16, + "column": 7 + }, + "end": { + "offset": 314, + "uri": "package:celest_backend/src/functions/injected.dart", + "line": 16, + "column": 21 + }, + "text": "sayHelloPerson" + } + } + }, + "docs": [], + "exceptionTypes": [ + { + "$": "TypeReference", + "symbol": "Error", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AssertionError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "TypeError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ArgumentError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "RangeError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "IndexError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnsupportedError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnimplementedError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "StateError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ConcurrentModificationError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "OutOfMemoryError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "StackOverflowError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "Exception", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "FormatException", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "IntegerDivisionByZeroException", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "JsonUnsupportedObjectError", + "url": "dart:convert", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AsyncError", + "url": "dart:async", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "TimeoutException", + "url": "dart:async", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "CloudException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "CancelledException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnknownError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "BadRequestException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnauthorizedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "NotFoundException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AlreadyExistsException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "PermissionDeniedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ResourceExhaustedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "FailedPreconditionException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AbortedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "OutOfRangeException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnimplementedError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "InternalServerError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnavailableError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "DataLossError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "DeadlineExceededError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "SerializationException", + "url": "package:celest_core/src/exception/serialization_exception.dart", + "isNullable": false + } + ], + "location": { + "start": { + "offset": 0, + "uri": "package:celest_backend/src/functions/injected.dart", + "line": 0, + "column": 0 + }, + "end": { + "offset": 0, + "uri": "package:celest_backend/src/functions/injected.dart", + "line": 0, + "column": 0 + }, + "text": "" + } + } + }, + "variables": [ + { + "location": { + "start": { + "offset": 44, + "uri": "package:celest_backend/src/config/env.dart", + "line": 2, + "column": 6 + }, + "end": { + "offset": 50, + "uri": "package:celest_backend/src/config/env.dart", + "line": 2, + "column": 12 + }, + "text": "myName" + }, + "name": "MY_NAME", + "docs": [], + "dartName": "myName" + }, + { + "location": { + "start": { + "offset": 75, + "uri": "package:celest_backend/src/config/env.dart", + "line": 3, + "column": 6 + }, + "end": { + "offset": 80, + "uri": "package:celest_backend/src/config/env.dart", + "line": 3, + "column": 11 + }, + "text": "myAge" + }, + "name": "MY_AGE", + "docs": [], + "dartName": "myAge" + }, + { + "location": { + "start": { + "offset": 104, + "uri": "package:celest_backend/src/config/env.dart", + "line": 4, + "column": 6 + }, + "end": { + "offset": 112, + "uri": "package:celest_backend/src/config/env.dart", + "line": 4, + "column": 14 + }, + "text": "myHeight" + }, + "name": "MY_HEIGHT", + "docs": [], + "dartName": "myHeight" + }, + { + "location": { + "start": { + "offset": 219, + "uri": "package:celest_backend/src/config/env.dart", + "line": 8, + "column": 6 + }, + "end": { + "offset": 225, + "uri": "package:celest_backend/src/config/env.dart", + "line": 8, + "column": 12 + }, + "text": "imCool" + }, + "name": "IM_COOL", + "docs": [], + "dartName": "imCool" + }, + { + "location": { + "start": { + "offset": 339, + "uri": "package:celest_backend/src/config/env.dart", + "line": 12, + "column": 6 + }, + "end": { + "offset": 348, + "uri": "package:celest_backend/src/config/env.dart", + "line": 12, + "column": 15 + }, + "text": "myWebsite" + }, + "name": "MY_WEBSITE", + "docs": [], + "dartName": "myWebsite" + }, + { + "location": { + "start": { + "offset": 629, + "uri": "package:celest_backend/src/functions/injected.dart", + "line": 24, + "column": 35 + }, + "end": { + "offset": 647, + "uri": "package:celest_backend/src/functions/injected.dart", + "line": 24, + "column": 53 + }, + "text": "currentEnvironment" + }, + "name": "CELEST_ENVIRONMENT", + "docs": [] + }, + { + "location": { + "start": { + "offset": 445, + "uri": "package:celest_backend/src/functions/injected.dart", + "line": 20, + "column": 33 + }, + "end": { + "offset": 451, + "uri": "package:celest_backend/src/functions/injected.dart", + "line": 20, + "column": 39 + }, + "text": "weight" + }, + "name": "MY_WEIGHT", + "docs": [] + } + ], + "secrets": [ + { + "location": { + "start": { + "offset": 581, + "uri": "package:celest_backend/src/functions/injected.dart", + "line": 23, + "column": 45 + }, + "end": { + "offset": 592, + "uri": "package:celest_backend/src/functions/injected.dart", + "line": 23, + "column": 56 + }, + "text": "superSecret" + }, + "name": "SUPER_SECRET", + "docs": [] + } + ], + "databases": {}, + "sdkConfig": { + "celest": "1.0.6+2", + "dart": { + "type": "dart", + "version": "3.29.0", + "enabledExperiments": [] + }, + "targetSdk": "dart", + "featureFlags": [ + "streaming" + ], + "flutter": { + "type": "flutter", + "version": "3.29.0", + "enabledExperiments": [] + } + }, + "location": { + "start": { + "offset": 44, + "uri": "project.dart", + "line": 2, + "column": 6 + }, + "end": { + "offset": 84, + "uri": "project.dart", + "line": 4, + "column": 1 + }, + "text": "project = Project(\n name: 'env_vars',\n)" + } +} \ No newline at end of file diff --git a/apps/cli/fixtures/legacy/env_vars/goldens/ast.resolved.json b/apps/cli/fixtures/legacy/env_vars/goldens/ast.resolved.json new file mode 100644 index 000000000..3a03d5be3 --- /dev/null +++ b/apps/cli/fixtures/legacy/env_vars/goldens/ast.resolved.json @@ -0,0 +1,110 @@ +{ + "projectId": "env_vars", + "environmentId": "local", + "apis": { + "injected": { + "apiId": "injected", + "functions": { + "sayHello": { + "functionId": "sayHello", + "apiId": "injected", + "httpConfig": { + "route": { + "method": "POST", + "path": "/injected/say-hello" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [ + "MY_NAME", + "MY_AGE" + ], + "secrets": [], + "streamConfig": {} + }, + "sayHelloPerson": { + "functionId": "sayHelloPerson", + "apiId": "injected", + "httpConfig": { + "route": { + "method": "POST", + "path": "/injected/say-hello-person" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [ + "MY_NAME", + "MY_AGE", + "MY_HEIGHT", + "MY_WEIGHT", + "MY_WEBSITE", + "IM_COOL", + "CELEST_ENVIRONMENT" + ], + "secrets": [ + "SUPER_SECRET" + ], + "streamConfig": {} + } + } + } + }, + "variables": [ + { + "name": "MY_NAME", + "value": "Dillon" + }, + { + "name": "MY_AGE", + "value": "28" + }, + { + "name": "MY_HEIGHT", + "value": "5.83" + }, + { + "name": "IM_COOL", + "value": "true" + }, + { + "name": "MY_WEBSITE", + "value": "https://dillonnys.com" + }, + { + "name": "CELEST_ENVIRONMENT", + "value": "local" + }, + { + "name": "MY_WEIGHT", + "value": "130" + } + ], + "secrets": [ + { + "name": "SUPER_SECRET", + "value": "SGk=" + } + ], + "databases": {}, + "sdkConfig": { + "celest": "1.0.6+2", + "dart": { + "type": "dart", + "version": "3.29.0", + "enabledExperiments": [] + }, + "targetSdk": "dart", + "featureFlags": [ + "streaming" + ], + "flutter": { + "type": "flutter", + "version": "3.29.0", + "enabledExperiments": [] + } + } +} \ No newline at end of file diff --git a/apps/cli/fixtures/legacy/env_vars/goldens/celest.json b/apps/cli/fixtures/legacy/env_vars/goldens/celest.json new file mode 100644 index 000000000..f4fec45b0 --- /dev/null +++ b/apps/cli/fixtures/legacy/env_vars/goldens/celest.json @@ -0,0 +1,127 @@ +{ + "projectId": "env_vars", + "environmentId": "local", + "apis": { + "injected": { + "apiId": "injected", + "functions": { + "sayHello": { + "functionId": "sayHello", + "parentId": "injected", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/injected/say-hello" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + }, + "variables": [ + "MY_NAME", + "MY_AGE" + ] + }, + "sayHelloPerson": { + "functionId": "sayHelloPerson", + "parentId": "injected", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/injected/say-hello-person" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + }, + "variables": [ + "MY_NAME", + "MY_AGE", + "MY_HEIGHT", + "MY_WEIGHT", + "MY_WEBSITE", + "IM_COOL", + "CELEST_ENVIRONMENT" + ], + "secrets": [ + "SUPER_SECRET" + ] + } + } + } + }, + "variables": [ + { + "name": "MY_NAME", + "value": "Dillon" + }, + { + "name": "MY_AGE", + "value": "28" + }, + { + "name": "MY_HEIGHT", + "value": "5.83" + }, + { + "name": "IM_COOL", + "value": "true" + }, + { + "name": "MY_WEBSITE", + "value": "https://dillonnys.com" + }, + { + "name": "CELEST_ENVIRONMENT", + "value": "local" + }, + { + "name": "MY_WEIGHT", + "value": "130" + } + ], + "secrets": [ + { + "name": "SUPER_SECRET", + "value": "SGk=" + } + ], + "databases": {}, + "sdkConfig": { + "celest": { + "major": 1, + "minor": 0, + "patch": 6, + "build": [ + 2.0 + ], + "canonicalizedVersion": "1.0.6+2" + }, + "dart": { + "type": "DART", + "version": { + "major": 3, + "minor": 29, + "patch": 0, + "canonicalizedVersion": "3.29.0" + } + }, + "flutter": { + "type": "FLUTTER", + "version": { + "major": 3, + "minor": 29, + "patch": 0, + "canonicalizedVersion": "3.29.0" + } + }, + "targetSdk": "DART", + "featureFlags": [ + "STREAMING" + ] + } +} \ No newline at end of file diff --git a/apps/cli/fixtures/legacy/env_vars/goldens/functions/injected/sayHello.dart b/apps/cli/fixtures/legacy/env_vars/goldens/functions/injected/sayHello.dart new file mode 100644 index 000000000..4b3d9add6 --- /dev/null +++ b/apps/cli/fixtures/legacy/env_vars/goldens/functions/injected/sayHello.dart @@ -0,0 +1,1688 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i9; + +import 'package:celest/celest.dart' as _i5; +import 'package:celest/src/core/context.dart' as _i4; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/injected.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i6; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i7; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i10; +import 'package:celest_core/src/serialization/json_value.dart' as _i11; +import 'package:shelf/shelf.dart' as _i2; + +final class SayHelloTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'sayHello'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.sayHello( + name: _i4.context.expect(const _i5.env(r'MY_NAME')), + age: int.parse(_i4.context.expect(const _i5.env(r'MY_AGE'))), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(response), + ); + } on _i7.AbortedException catch (e, st) { + const statusCode = 409; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i6.Serializers.instance.serialize<_i7.AbortedException>( + e, + ), + }, + if (_i4.context.environment != _i5.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i7.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i6.Serializers.instance + .serialize<_i7.AlreadyExistsException>(e), + }, + if (_i4.context.environment != _i5.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i4.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i4.context.environment != _i5.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i4.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i6.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i4.context.environment != _i5.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i7.CancelledException catch (e, st) { + const statusCode = 499; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i6.Serializers.instance + .serialize<_i7.CancelledException>(e), + }, + if (_i4.context.environment != _i5.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i4.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i6.Serializers.instance + .serialize(e), + }, + if (_i4.context.environment != _i5.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i7.DataLossError catch (e, st) { + const statusCode = 500; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i6.Serializers.instance.serialize<_i7.DataLossError>(e), + }, + if (_i4.context.environment != _i5.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i7.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i6.Serializers.instance + .serialize<_i7.DeadlineExceededError>(e), + }, + if (_i4.context.environment != _i5.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i7.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i6.Serializers.instance + .serialize<_i7.FailedPreconditionException>(e), + }, + if (_i4.context.environment != _i5.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i4.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i4.context.environment != _i5.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i6.Serializers.instance + .serialize(e), + }, + if (_i4.context.environment != _i5.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i7.InternalServerError catch (e, st) { + const statusCode = 500; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i6.Serializers.instance + .serialize<_i7.InternalServerError>(e), + }, + if (_i4.context.environment != _i5.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i9.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i4.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i6.Serializers.instance + .serialize<_i9.JsonUnsupportedObjectError>(e), + }, + if (_i4.context.environment != _i5.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i7.NotFoundException catch (e, st) { + const statusCode = 404; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i6.Serializers.instance + .serialize<_i7.NotFoundException>(e), + }, + if (_i4.context.environment != _i5.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i4.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i4.context.environment != _i5.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i7.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i6.Serializers.instance + .serialize<_i7.OutOfRangeException>(e), + }, + if (_i4.context.environment != _i5.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i7.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i6.Serializers.instance + .serialize<_i7.PermissionDeniedException>(e), + }, + if (_i4.context.environment != _i5.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i4.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i4.context.environment != _i5.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i4.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i4.context.environment != _i5.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i7.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i6.Serializers.instance + .serialize<_i7.ResourceExhaustedException>(e), + }, + if (_i4.context.environment != _i5.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i10.SerializationException catch (e, st) { + const statusCode = 400; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i6.Serializers.instance + .serialize<_i10.SerializationException>(e), + }, + if (_i4.context.environment != _i5.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i7.BadRequestException catch (e, st) { + const statusCode = 400; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i6.Serializers.instance + .serialize<_i7.BadRequestException>(e), + }, + if (_i4.context.environment != _i5.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i4.context.environment != _i5.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i4.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i6.Serializers.instance.serialize( + e, + ), + }, + if (_i4.context.environment != _i5.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i4.context.environment != _i5.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i6.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i4.context.environment != _i5.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i4.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i4.context.environment != _i5.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i7.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i6.Serializers.instance + .serialize<_i7.UnauthorizedException>(e), + }, + if (_i4.context.environment != _i5.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i7.UnavailableError catch (e, st) { + const statusCode = 503; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i6.Serializers.instance.serialize<_i7.UnavailableError>( + e, + ), + }, + if (_i4.context.environment != _i5.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i7.UnimplementedError catch (e, st) { + const statusCode = 501; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i6.Serializers.instance + .serialize<_i7.UnimplementedError>(e), + }, + if (_i4.context.environment != _i5.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i6.Serializers.instance.serialize( + e, + ), + }, + if (_i4.context.environment != _i5.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i7.UnknownError catch (e, st) { + const statusCode = 500; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i6.Serializers.instance.serialize<_i7.UnknownError>(e), + }, + if (_i4.context.environment != _i5.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on _i7.CloudException catch (e, st) { + const statusCode = 400; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i6.Serializers.instance.serialize<_i7.CloudException>( + e, + ), + }, + if (_i4.context.environment != _i5.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i4.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i4.context.environment != _i5.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i4.context.environment != _i5.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i4.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i6.Serializers.instance.serialize(e), + }, + if (_i4.context.environment != _i5.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i6.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i6.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i6.Serializers.instance.put( + _i6.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i6.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i6.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i6.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i6.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define< + _i9.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i9.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: + ($value) => { + if (_i6.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i7.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i6.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.AbortedException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i7.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i6.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i7.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i6.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.BadRequestException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i7.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i6.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.CancelledException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i7.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i6.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.CloudException.fromJson($serialized); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i7.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i6.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.DataLossError( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i7.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i6.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define< + _i7.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i6.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i7.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i6.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.InternalServerError( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i7.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i6.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.NotFoundException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i7.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i6.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define< + _i7.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i6.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define< + _i7.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i6.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i7.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i6.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i7.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i6.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.UnavailableError( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i7.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i6.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.UnimplementedError( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i7.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i6.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i7.UnknownError( + ($serialized?[r'message'] as String?), + _i6.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i6.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i10.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i6.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i6.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i10.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i6.Serializers.instance.put( + _i6.Serializer.define<_i11.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i11.JsonValue($serialized); + }, + ), + const _i6.TypeToken<_i11.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': SayHelloTarget()}, + setup: (_i4.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/env_vars/goldens/functions/injected/sayHelloPerson.dart b/apps/cli/fixtures/legacy/env_vars/goldens/functions/injected/sayHelloPerson.dart new file mode 100644 index 000000000..fbd496f98 --- /dev/null +++ b/apps/cli/fixtures/legacy/env_vars/goldens/functions/injected/sayHelloPerson.dart @@ -0,0 +1,1727 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i10; +import 'dart:convert' as _i6; + +import 'package:celest/celest.dart' as _i5; +import 'package:celest/src/core/context.dart' as _i4; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/person.dart' as _i8; +import 'package:celest_backend/src/functions/injected.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i7; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i9; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class SayHelloPersonTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'sayHelloPerson'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.sayHelloPerson( + name: _i4.context.expect(const _i5.env(r'MY_NAME')), + age: int.parse(_i4.context.expect(const _i5.env(r'MY_AGE'))), + height: double.parse(_i4.context.expect(const _i5.env(r'MY_HEIGHT'))), + weight: num.parse(_i4.context.expect(const _i5.env(r'MY_WEIGHT'))), + website: Uri.parse(_i4.context.expect(const _i5.env(r'MY_WEBSITE'))), + isCool: bool.parse(_i4.context.expect(const _i5.env(r'IM_COOL'))), + superSecret: _i6.base64Decode( + _i4.context.expect(const _i5.secret(r'SUPER_SECRET')), + ), + currentEnvironment: _i4.context.expect( + const _i5.env(r'CELEST_ENVIRONMENT'), + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i7.JsonUtf8.encode( + _i7.Serializers.instance.serialize<_i8.Person>(response), + ), + ); + } on _i9.AbortedException catch (e, st) { + const statusCode = 409; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i7.Serializers.instance.serialize<_i9.AbortedException>( + e, + ), + }, + if (_i4.context.environment != _i5.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i7.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i7.JsonUtf8.encode(status), + ); + } on _i9.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i7.Serializers.instance + .serialize<_i9.AlreadyExistsException>(e), + }, + if (_i4.context.environment != _i5.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i7.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i7.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i4.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i7.Serializers.instance.serialize(e), + }, + if (_i4.context.environment != _i5.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i7.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i7.JsonUtf8.encode(status), + ); + } on _i10.AsyncError catch (e, st) { + const statusCode = 500; + _i4.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i7.Serializers.instance.serialize<_i10.AsyncError>(e), + }, + if (_i4.context.environment != _i5.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i7.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i7.JsonUtf8.encode(status), + ); + } on _i9.CancelledException catch (e, st) { + const statusCode = 499; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i7.Serializers.instance + .serialize<_i9.CancelledException>(e), + }, + if (_i4.context.environment != _i5.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i7.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i7.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i4.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i7.Serializers.instance + .serialize(e), + }, + if (_i4.context.environment != _i5.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i7.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i7.JsonUtf8.encode(status), + ); + } on _i9.DataLossError catch (e, st) { + const statusCode = 500; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i7.Serializers.instance.serialize<_i9.DataLossError>(e), + }, + if (_i4.context.environment != _i5.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i7.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i7.JsonUtf8.encode(status), + ); + } on _i9.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i7.Serializers.instance + .serialize<_i9.DeadlineExceededError>(e), + }, + if (_i4.context.environment != _i5.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i7.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i7.JsonUtf8.encode(status), + ); + } on _i9.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i7.Serializers.instance + .serialize<_i9.FailedPreconditionException>(e), + }, + if (_i4.context.environment != _i5.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i7.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i7.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i4.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i7.Serializers.instance.serialize(e), + }, + if (_i4.context.environment != _i5.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i7.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i7.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i7.Serializers.instance + .serialize(e), + }, + if (_i4.context.environment != _i5.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i7.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i7.JsonUtf8.encode(status), + ); + } on _i9.InternalServerError catch (e, st) { + const statusCode = 500; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i7.Serializers.instance + .serialize<_i9.InternalServerError>(e), + }, + if (_i4.context.environment != _i5.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i7.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i7.JsonUtf8.encode(status), + ); + } on _i6.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i4.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i7.Serializers.instance + .serialize<_i6.JsonUnsupportedObjectError>(e), + }, + if (_i4.context.environment != _i5.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i7.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i7.JsonUtf8.encode(status), + ); + } on _i9.NotFoundException catch (e, st) { + const statusCode = 404; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i7.Serializers.instance + .serialize<_i9.NotFoundException>(e), + }, + if (_i4.context.environment != _i5.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i7.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i7.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i4.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i7.Serializers.instance.serialize(e), + }, + if (_i4.context.environment != _i5.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i7.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i7.JsonUtf8.encode(status), + ); + } on _i9.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i7.Serializers.instance + .serialize<_i9.OutOfRangeException>(e), + }, + if (_i4.context.environment != _i5.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i7.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i7.JsonUtf8.encode(status), + ); + } on _i9.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i7.Serializers.instance + .serialize<_i9.PermissionDeniedException>(e), + }, + if (_i4.context.environment != _i5.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i7.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i7.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i4.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i7.Serializers.instance.serialize(e), + }, + if (_i4.context.environment != _i5.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i7.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i7.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i4.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i7.Serializers.instance.serialize(e), + }, + if (_i4.context.environment != _i5.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i7.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i7.JsonUtf8.encode(status), + ); + } on _i9.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i7.Serializers.instance + .serialize<_i9.ResourceExhaustedException>(e), + }, + if (_i4.context.environment != _i5.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i7.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i7.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i7.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i4.context.environment != _i5.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i7.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i7.JsonUtf8.encode(status), + ); + } on _i9.BadRequestException catch (e, st) { + const statusCode = 400; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i7.Serializers.instance + .serialize<_i9.BadRequestException>(e), + }, + if (_i4.context.environment != _i5.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i7.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i7.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i7.Serializers.instance.serialize(e), + }, + if (_i4.context.environment != _i5.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i7.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i7.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i4.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i7.Serializers.instance.serialize( + e, + ), + }, + if (_i4.context.environment != _i5.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i7.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i7.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i7.Serializers.instance.serialize(e), + }, + if (_i4.context.environment != _i5.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i7.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i7.JsonUtf8.encode(status), + ); + } on _i10.TimeoutException catch (e, st) { + const statusCode = 400; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i7.Serializers.instance + .serialize<_i10.TimeoutException>(e), + }, + if (_i4.context.environment != _i5.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i7.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i7.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i4.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i7.Serializers.instance.serialize(e), + }, + if (_i4.context.environment != _i5.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i7.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i7.JsonUtf8.encode(status), + ); + } on _i9.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i7.Serializers.instance + .serialize<_i9.UnauthorizedException>(e), + }, + if (_i4.context.environment != _i5.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i7.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i7.JsonUtf8.encode(status), + ); + } on _i9.UnavailableError catch (e, st) { + const statusCode = 503; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i7.Serializers.instance.serialize<_i9.UnavailableError>( + e, + ), + }, + if (_i4.context.environment != _i5.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i7.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i7.JsonUtf8.encode(status), + ); + } on _i9.UnimplementedError catch (e, st) { + const statusCode = 501; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i7.Serializers.instance + .serialize<_i9.UnimplementedError>(e), + }, + if (_i4.context.environment != _i5.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i7.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i7.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i7.Serializers.instance.serialize( + e, + ), + }, + if (_i4.context.environment != _i5.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i7.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i7.JsonUtf8.encode(status), + ); + } on _i9.UnknownError catch (e, st) { + const statusCode = 500; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i7.Serializers.instance.serialize<_i9.UnknownError>(e), + }, + if (_i4.context.environment != _i5.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i7.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i7.JsonUtf8.encode(status), + ); + } on _i9.CloudException catch (e, st) { + const statusCode = 400; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i7.Serializers.instance.serialize<_i9.CloudException>( + e, + ), + }, + if (_i4.context.environment != _i5.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i7.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i7.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i4.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i7.Serializers.instance.serialize(e), + }, + if (_i4.context.environment != _i5.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i7.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i7.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i7.Serializers.instance.serialize(e), + }, + if (_i4.context.environment != _i5.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i7.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i7.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i4.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i7.Serializers.instance.serialize(e), + }, + if (_i4.context.environment != _i5.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i7.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i7.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i7.Serializers.instance.put( + _i7.Serializer.define<_i10.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i7.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i10.AsyncError( + $serialized[r'error']!, + _i7.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i7.Serializers.instance.put( + _i7.Serializer.define<_i10.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i7.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i10.TimeoutException( + ($serialized[r'message'] as String?), + _i7.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i7.Serializers.instance.put( + _i7.Serializer.define< + _i6.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i6.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i7.Serializers.instance.put( + _i7.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i7.Serializers.instance.put( + _i7.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i7.Serializers.instance.put( + _i7.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i7.Serializers.instance.put( + _i7.Serializer.define?>( + serialize: + ($value) => { + if (_i7.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i7.Serializers.instance.put( + _i7.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i7.Serializers.instance.put( + _i7.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i7.Serializers.instance.put( + _i7.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i7.Serializers.instance.put( + _i7.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i7.Serializers.instance.put( + _i7.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i7.Serializers.instance.put( + _i7.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i7.Serializers.instance.put( + _i7.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i7.Serializers.instance.put( + _i7.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i7.Serializers.instance.put( + _i7.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i7.Serializers.instance.put( + _i7.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i7.Serializers.instance.put( + _i7.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i7.Serializers.instance.put( + _i7.Serializer.define<_i8.Person, Map>( + serialize: + ($value) => { + r'name': $value.name, + r'age': $value.age, + r'height': $value.height, + r'weight': $value.weight, + r'isCool': $value.isCool, + r'website': _i7.Serializers.instance.serialize( + $value.website, + ), + }, + deserialize: ($serialized) { + return _i8.Person( + name: ($serialized[r'name'] as String), + age: ($serialized[r'age'] as num).toInt(), + height: ($serialized[r'height'] as num).toDouble(), + weight: ($serialized[r'weight'] as num), + isCool: ($serialized[r'isCool'] as bool), + website: _i7.Serializers.instance.deserialize( + $serialized[r'website'], + ), + ); + }, + ), + ); + _i7.Serializers.instance.put( + _i7.Serializer.define<_i9.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i7.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i7.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i9.AbortedException( + ($serialized?[r'message'] as String?), + _i7.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i7.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i7.Serializers.instance.put( + _i7.Serializer.define<_i9.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i7.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i7.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i9.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i7.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i7.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i7.Serializers.instance.put( + _i7.Serializer.define<_i9.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i7.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i7.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i9.BadRequestException( + ($serialized?[r'message'] as String?), + _i7.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i7.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i7.Serializers.instance.put( + _i7.Serializer.define<_i9.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i7.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i7.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i9.CancelledException( + ($serialized?[r'message'] as String?), + _i7.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i7.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i7.Serializers.instance.put( + _i7.Serializer.define<_i9.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i7.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i7.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i9.CloudException.fromJson($serialized); + }, + ), + ); + _i7.Serializers.instance.put( + _i7.Serializer.define<_i9.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i7.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i7.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i9.DataLossError( + ($serialized?[r'message'] as String?), + _i7.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i7.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i7.Serializers.instance.put( + _i7.Serializer.define<_i9.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i7.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i7.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i9.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i7.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i7.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i7.Serializers.instance.put( + _i7.Serializer.define< + _i9.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i7.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i7.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i9.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i7.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i7.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i7.Serializers.instance.put( + _i7.Serializer.define<_i9.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i7.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i7.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i9.InternalServerError( + ($serialized?[r'message'] as String?), + _i7.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i7.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i7.Serializers.instance.put( + _i7.Serializer.define<_i9.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i7.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i7.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i9.NotFoundException( + ($serialized?[r'message'] as String?), + _i7.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i7.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i7.Serializers.instance.put( + _i7.Serializer.define<_i9.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i7.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i7.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i9.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i7.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i7.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i7.Serializers.instance.put( + _i7.Serializer.define< + _i9.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i7.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i7.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i9.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i7.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i7.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i7.Serializers.instance.put( + _i7.Serializer.define< + _i9.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i7.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i7.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i9.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i7.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i7.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i7.Serializers.instance.put( + _i7.Serializer.define<_i9.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i7.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i7.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i9.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i7.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i7.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i7.Serializers.instance.put( + _i7.Serializer.define<_i9.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i7.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i7.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i9.UnavailableError( + ($serialized?[r'message'] as String?), + _i7.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i7.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i7.Serializers.instance.put( + _i7.Serializer.define<_i9.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i7.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i7.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i9.UnimplementedError( + ($serialized?[r'message'] as String?), + _i7.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i7.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i7.Serializers.instance.put( + _i7.Serializer.define<_i9.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i7.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i7.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i9.UnknownError( + ($serialized?[r'message'] as String?), + _i7.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i7.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i7.Serializers.instance.put( + _i7.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i7.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i7.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i7.Serializers.instance.put( + _i7.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i7.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': SayHelloPersonTarget()}, + setup: (_i4.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/env_vars/lib/fix_data/v1_migration.yaml b/apps/cli/fixtures/legacy/env_vars/lib/fix_data/v1_migration.yaml new file mode 100644 index 000000000..d9a84faf2 --- /dev/null +++ b/apps/cli/fixtures/legacy/env_vars/lib/fix_data/v1_migration.yaml @@ -0,0 +1,13 @@ +# Generated by Celest. Do not modify. +version: 1 +transforms: + - title: "Updates the import of the Celest client" + date: 2024-10-06 + element: + uris: ["client.dart"] + variable: celest + changes: + - kind: replacedBy + newElement: + uris: ["package:env_vars_client/env_vars_client.dart"] + variable: celest diff --git a/apps/cli/fixtures/legacy/env_vars/lib/models/person.dart b/apps/cli/fixtures/legacy/env_vars/lib/models/person.dart new file mode 100644 index 000000000..abfbee341 --- /dev/null +++ b/apps/cli/fixtures/legacy/env_vars/lib/models/person.dart @@ -0,0 +1,17 @@ +class Person { + const Person({ + required this.name, + required this.age, + required this.height, + required this.weight, + required this.isCool, + required this.website, + }); + + final String name; + final int age; + final double height; + final num weight; + final bool isCool; + final Uri website; +} diff --git a/apps/cli/fixtures/legacy/env_vars/lib/src/config/env.dart b/apps/cli/fixtures/legacy/env_vars/lib/src/config/env.dart new file mode 100644 index 000000000..5092e205d --- /dev/null +++ b/apps/cli/fixtures/legacy/env_vars/lib/src/config/env.dart @@ -0,0 +1,13 @@ +import 'package:celest/celest.dart'; + +const myName = env('MY_NAME'); +const myAge = env('MY_AGE'); +const myHeight = env('MY_HEIGHT'); + +// Non-const variables should be allowed. +// ignore: prefer_const_declarations +final imCool = const env('IM_COOL'); + +// Non-const initializers should be allowed. +// ignore: prefer_const_constructors +final myWebsite = env('MY_WEBSITE'); diff --git a/apps/cli/fixtures/legacy/env_vars/lib/src/functions/injected.dart b/apps/cli/fixtures/legacy/env_vars/lib/src/functions/injected.dart new file mode 100644 index 000000000..782a47f21 --- /dev/null +++ b/apps/cli/fixtures/legacy/env_vars/lib/src/functions/injected.dart @@ -0,0 +1,40 @@ +import 'dart:typed_data'; + +import 'package:celest/celest.dart'; +import 'package:celest_backend/models/person.dart'; + +import '../config/env.dart'; + +@cloud +String sayHello({ + @myName required String name, + @myAge required int age, +}) { + return 'Hello, $name! I am $age years old.'; +} + +@cloud +Person sayHelloPerson({ + @myName required String name, + @myAge required int age, + @myHeight required double height, + @env('MY_WEIGHT') required num weight, + @env('MY_WEBSITE') required Uri website, + @env('IM_COOL') required bool isCool, + @secret('SUPER_SECRET') required Uint8List superSecret, + @env.environment required String currentEnvironment, +}) { + print( + '($currentEnvironment) $name is $age years old, ${height}ft tall, $weight lbs, ' + 'and ${isCool ? 'is cool' : 'is not cool'}. Find him at $website.', + ); + print('Super secret: ${String.fromCharCodes(superSecret)}'); + return Person( + name: name, + age: age, + height: height, + weight: weight, + isCool: isCool, + website: website, + ); +} diff --git a/apps/cli/fixtures/legacy/env_vars/lib/src/generated/cloud.celest.dart b/apps/cli/fixtures/legacy/env_vars/lib/src/generated/cloud.celest.dart new file mode 100644 index 000000000..1a3e01e9c --- /dev/null +++ b/apps/cli/fixtures/legacy/env_vars/lib/src/generated/cloud.celest.dart @@ -0,0 +1,51 @@ +// Generated by Celest. This file should not be modified manually, but +// it can be checked into version control. +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +library; + +import 'package:celest/src/core/context.dart'; +import 'package:celest_backend/src/generated/config.celest.dart'; + +/// The interface to your Celest backend. +/// +/// Similar to the `celest` global in the frontend, this +/// provides access to the backend environment and services +/// configured for your project. +const CelestCloud celest = CelestCloud._(); + +/// A per-request context object which propogates request information and common +/// accessors to the Celest server environment. +CelestContext get context => CelestContext._(context); + +/// The interface to your Celest backend. +/// +/// Similar to the `Celest` class in the frontend, this class +/// provides access to the backend environment and services +/// configured for your project. +class CelestCloud { + const CelestCloud._(); + + /// The current environment of the Celest service. + /// + /// This is determined by the `CELEST_ENVIRONMENT` variable + /// which is set for you by the deployment environment. + CelestEnvironment get currentEnvironment => + (variables.currentEnvironment as CelestEnvironment); + + /// The variables of the Celest service. + /// + /// This class provides access to the values configured for the + /// [currentEnvironment]. + CelestVariables get variables => const CelestVariables(); + + /// The secrets for the Celest service. + /// + /// This class provides access to the secret values that are configured + /// for the [currentEnvironment]. + CelestSecrets get secrets => const CelestSecrets(); +} + +/// A per-request context object which propogates request information and common +/// accessors to the Celest server environment. +extension type CelestContext._(Context _context) implements Context {} diff --git a/apps/cli/fixtures/legacy/env_vars/lib/src/generated/config.celest.dart b/apps/cli/fixtures/legacy/env_vars/lib/src/generated/config.celest.dart new file mode 100644 index 000000000..8597a8464 --- /dev/null +++ b/apps/cli/fixtures/legacy/env_vars/lib/src/generated/config.celest.dart @@ -0,0 +1,78 @@ +// Generated by Celest. This file should not be modified manually, but +// it can be checked into version control. +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +library; + +import 'package:celest/celest.dart'; +import 'package:celest/src/core/context.dart'; + +/// An environment of a deployed Celest service. +/// +/// Celest services can have multiple isolated branches, for example +/// a `development` and `production` environment. +extension type const CelestEnvironment._(String _env) + implements Environment, String { + /// The local Celest environment, used to delineate when a + /// Celest service is running on a developer machine as opposed + /// to the cloud. + static const CelestEnvironment local = CelestEnvironment._('local'); + + /// The production Celest environment which is common to all + /// Celest projects and labels the environment which is considered + /// live and served to end-users. + static const CelestEnvironment production = CelestEnvironment._('production'); + + /// Whether `this` represents the [local] environment. + bool get isLocal => this == local; + + /// Whether `this` represents the [production] environment. + bool get isProduction => this == production; +} + +/// The environment variables for the Celest service. +/// +/// This class provides access to the environment variable values +/// that are configured for the current [CelestEnvironment]. +class CelestVariables { + const CelestVariables(); + + /// The environment variable that determines the current environment. + /// + /// This is set by the deployment environment and is used to + /// determine the current environment of the Celest service. + String get currentEnvironment => context.expect(env.environment); + + /// The value of the `MY_NAME` environment variable. + String get myName => context.expect(const env('MY_NAME')); + + /// The value of the `MY_AGE` environment variable. + String get myAge => context.expect(const env('MY_AGE')); + + /// The value of the `MY_HEIGHT` environment variable. + String get myHeight => context.expect(const env('MY_HEIGHT')); + + /// The value of the `IM_COOL` environment variable. + String get imCool => context.expect(const env('IM_COOL')); + + /// The value of the `MY_WEBSITE` environment variable. + String get myWebsite => context.expect(const env('MY_WEBSITE')); + + /// The value of the `CELEST_ENVIRONMENT` environment variable. + String get celestEnvironment => + context.expect(const env('CELEST_ENVIRONMENT')); + + /// The value of the `MY_WEIGHT` environment variable. + String get myWeight => context.expect(const env('MY_WEIGHT')); +} + +/// The secrets for the Celest service. +/// +/// This class provides access to the secret values that are configured +/// for the current [CelestEnvironment]. +class CelestSecrets { + const CelestSecrets(); + + /// The value of the `SUPER_SECRET` secret. + String get superSecret => context.expect(const env('SUPER_SECRET')); +} diff --git a/apps/cli/fixtures/legacy/env_vars/lib/src/project.dart b/apps/cli/fixtures/legacy/env_vars/lib/src/project.dart new file mode 100644 index 000000000..cd02ff249 --- /dev/null +++ b/apps/cli/fixtures/legacy/env_vars/lib/src/project.dart @@ -0,0 +1,5 @@ +import 'package:celest/celest.dart'; + +const project = Project( + name: 'env_vars', +); diff --git a/apps/cli/fixtures/legacy/env_vars/pubspec.yaml b/apps/cli/fixtures/legacy/env_vars/pubspec.yaml new file mode 100644 index 000000000..76787a958 --- /dev/null +++ b/apps/cli/fixtures/legacy/env_vars/pubspec.yaml @@ -0,0 +1,29 @@ +name: celest_backend +publish_to: none + +environment: + sdk: ^3.4.0 + +dependencies: + celest: ^1.0.0 + celest_core: ^1.0.0 + meta: ^1.12.0 + +dependency_overrides: + cedar: + path: ../../../../../cedar/packages/cedar + celest: + path: ../../../../../celest/packages/celest + celest_ast: + path: ../../../../../celest/packages/celest_ast + celest_auth: + path: ../../../../../celest/packages/celest_auth + celest_cloud: + path: ../../../../../celest/packages/celest_cloud + celest_cloud_auth: + path: ../../../../../celest/services/celest_cloud_auth + celest_core: + path: ../../../../../celest/packages/celest_core +dev_dependencies: + lints: ^4.0.0 + test: ^1.25.0 diff --git a/apps/cli/fixtures/legacy/exceptions/analysis_options.yaml b/apps/cli/fixtures/legacy/exceptions/analysis_options.yaml new file mode 100644 index 000000000..cef4bc91f --- /dev/null +++ b/apps/cli/fixtures/legacy/exceptions/analysis_options.yaml @@ -0,0 +1,4 @@ +analyzer: + errors: + deprecated_member_use_from_same_package: ignore + unused_element: ignore diff --git a/apps/cli/fixtures/legacy/exceptions/client/lib/exceptions_client.dart b/apps/cli/fixtures/legacy/exceptions/client/lib/exceptions_client.dart new file mode 100644 index 000000000..859e35c97 --- /dev/null +++ b/apps/cli/fixtures/legacy/exceptions/client/lib/exceptions_client.dart @@ -0,0 +1,81 @@ +// Generated by Celest. This file should not be modified manually, but +// it can be checked into version control. +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +library; // ignore_for_file: no_leading_underscores_for_library_prefixes + +import 'dart:io'; + +import 'package:celest_core/_internal.dart' as _$celest; +import 'package:celest_core/celest_core.dart' as _$celest; +import 'package:celest_core/src/util/globals.dart' as _$celest; +import 'package:exceptions_client/src/functions.dart'; +import 'package:exceptions_client/src/serializers.dart'; +import 'package:http/http.dart' as _$http_http; +import 'package:native_storage/native_storage.dart' + as _$native_storage_native_storage; + +export 'package:celest_backend/exceptions/exceptions.dart' + show BaseException, CustomException, BaseError, CustomError; + +final Celest celest = Celest(); + +enum CelestEnvironment { + local, + production; + + Uri get baseUri => switch (this) { + local => + _$celest.kIsWeb || !Platform.isAndroid + ? Uri.parse('http://localhost:7777') + : Uri.parse('http://10.0.2.2:7777'), + production => Uri.parse('https://example.celest.run'), + }; +} + +class Celest with _$celest.CelestBase { + var _initialized = false; + + late CelestEnvironment _currentEnvironment; + + late final _$native_storage_native_storage.NativeStorage nativeStorage = + _$native_storage_native_storage.NativeStorage(scope: 'celest'); + + @override + late _$http_http.Client httpClient = _$celest.CelestHttpClient( + secureStorage: nativeStorage.secure, + ); + + late Uri _baseUri; + + final _functions = CelestFunctions(); + + T _checkInitialized(T Function() value) { + if (!_initialized) { + throw StateError( + 'Celest has not been initialized. Make sure to call `celest.init()` at the start of your `main` method.', + ); + } + return value(); + } + + CelestEnvironment get currentEnvironment => + _checkInitialized(() => _currentEnvironment); + + @override + Uri get baseUri => _checkInitialized(() => _baseUri); + + CelestFunctions get functions => _checkInitialized(() => _functions); + + void init({ + CelestEnvironment environment = CelestEnvironment.local, + _$celest.Serializers? serializers, + }) { + _currentEnvironment = environment; + _baseUri = environment.baseUri; + if (!_initialized) { + initSerializers(serializers: serializers); + } + _initialized = true; + } +} diff --git a/apps/cli/fixtures/legacy/exceptions/client/lib/src/functions.dart b/apps/cli/fixtures/legacy/exceptions/client/lib/src/functions.dart new file mode 100644 index 000000000..aa90640fd --- /dev/null +++ b/apps/cli/fixtures/legacy/exceptions/client/lib/src/functions.dart @@ -0,0 +1,1081 @@ +// Generated by Celest. This file should not be modified manually, but +// it can be checked into version control. +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +library; // ignore_for_file: no_leading_underscores_for_library_prefixes + +import 'dart:async'; +import 'dart:convert'; + +import 'package:_common/_common.dart' as _$_common__common; +import 'package:celest/celest.dart' as _$celest; +import 'package:celest_backend/exceptions/exceptions.dart'; +import 'package:celest_core/celest_core.dart' as _$celest; +import 'package:celest_core/src/exception/cloud_exception.dart' as _$celest; +import 'package:celest_core/src/exception/serialization_exception.dart' + as _$celest; +import 'package:exceptions_client/exceptions_client.dart'; + +class CelestFunctions { + /// Tests that types thrown from external packages can be detected via + /// recursive imports and serialized correctly. + final external = CelestFunctionsExternal(); + + /// A library with methods that do not through but call methods that do throw. + final nonthrowing = CelestFunctionsNonthrowing(); + + final throwing = CelestFunctionsThrowing(); +} + +/// Tests that types thrown from external packages can be detected via +/// recursive imports and serialized correctly. +class CelestFunctionsExternal { + Never _throwError({int? code, required Map body}) { + final status = body['@status'] as Map?; + final message = status?['message'] as String?; + final details = status?['details'] as _$celest.JsonList?; + final (errorType, errorValue, stackTrace) = switch (details) { + null || [] => const (null, null, StackTrace.empty), + [ + final errorDetails as Map, + { + '@type': 'dart.core.StackTrace', + 'value': final stackTraceValue as String, + }, + ..., + ] => + ( + errorDetails['@type'], + errorDetails['value'], + StackTrace.fromString(stackTraceValue), + ), + [final errorDetails as Map, ...] => ( + errorDetails['@type'], + errorDetails['value'], + StackTrace.empty, + ), + }; + + switch (errorType) { + case '_common.CustomException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$_common__common.CustomException>(errorValue), + stackTrace, + ); + case '_common.CommonException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$_common__common.CommonException>(errorValue), + stackTrace, + ); + case '_common.OverriddenException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$_common__common.OverriddenException>(errorValue), + stackTrace, + ); + case 'dart.core.Error': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.AssertionError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.TypeError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.ArgumentError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.RangeError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.IndexError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.UnsupportedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.UnimplementedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.StateError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.ConcurrentModificationError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.core.OutOfMemoryError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.StackOverflowError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.Exception': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.FormatException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.IntegerDivisionByZeroException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.async.AsyncError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.async.TimeoutException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.convert.JsonUnsupportedObjectError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.CloudException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.CloudException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.CancelledException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.CancelledException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnknownError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.UnknownError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.BadRequestException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.BadRequestException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnauthorizedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.UnauthorizedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.NotFoundException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.NotFoundException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.AlreadyExistsException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.AlreadyExistsException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.PermissionDeniedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.PermissionDeniedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.ResourceExhaustedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.ResourceExhaustedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.FailedPreconditionException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.FailedPreconditionException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.AbortedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.AbortedException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.OutOfRangeException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.OutOfRangeException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnimplementedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.UnimplementedError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.InternalServerError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.InternalServerError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnavailableError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.UnavailableError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.DataLossError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.DataLossError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.DeadlineExceededError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.DeadlineExceededError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.SerializationException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.SerializationException>(errorValue), + stackTrace, + ); + default: + Error.throwWithStackTrace( + _$celest.CloudException.http( + code: code, + message: message, + details: ((details ?? body) as _$celest.JsonValue), + ), + StackTrace.empty, + ); + } + } + + @_$celest.CloudFunction( + api: 'external', + function: 'callsThrowsCommonException', + ) + Future callsThrowsCommonException() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/external/calls-throws-common-exception'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return; + } + + @_$celest.CloudFunction( + api: 'external', + function: 'callsThrowsCustomException', + ) + Future callsThrowsCustomException() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/external/calls-throws-custom-exception'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return; + } +} + +/// A library with methods that do not through but call methods that do throw. +class CelestFunctionsNonthrowing { + Never _throwError({int? code, required Map body}) { + final status = body['@status'] as Map?; + final message = status?['message'] as String?; + final details = status?['details'] as _$celest.JsonList?; + final (errorType, errorValue, stackTrace) = switch (details) { + null || [] => const (null, null, StackTrace.empty), + [ + final errorDetails as Map, + { + '@type': 'dart.core.StackTrace', + 'value': final stackTraceValue as String, + }, + ..., + ] => + ( + errorDetails['@type'], + errorDetails['value'], + StackTrace.fromString(stackTraceValue), + ), + [final errorDetails as Map, ...] => ( + errorDetails['@type'], + errorDetails['value'], + StackTrace.empty, + ), + }; + + switch (errorType) { + case 'celest.core.v1.CloudException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.CloudException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.CancelledException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.CancelledException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnknownError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.UnknownError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.BadRequestException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.BadRequestException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnauthorizedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.UnauthorizedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.NotFoundException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.NotFoundException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.AlreadyExistsException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.AlreadyExistsException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.PermissionDeniedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.PermissionDeniedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.ResourceExhaustedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.ResourceExhaustedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.FailedPreconditionException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.FailedPreconditionException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.AbortedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.AbortedException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.OutOfRangeException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.OutOfRangeException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnimplementedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.UnimplementedError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.InternalServerError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.InternalServerError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnavailableError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.UnavailableError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.DataLossError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.DataLossError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.DeadlineExceededError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.DeadlineExceededError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.SerializationException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.SerializationException>(errorValue), + stackTrace, + ); + case 'dart.core.Error': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.AssertionError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.TypeError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.ArgumentError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.RangeError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.IndexError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.UnsupportedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.UnimplementedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.StateError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.ConcurrentModificationError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.core.OutOfMemoryError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.StackOverflowError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.Exception': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.FormatException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.IntegerDivisionByZeroException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.async.AsyncError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.async.TimeoutException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.convert.JsonUnsupportedObjectError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'exceptions.v1.BaseException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'exceptions.v1.CustomException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'exceptions.v1.BaseError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'exceptions.v1.CustomError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + default: + Error.throwWithStackTrace( + _$celest.CloudException.http( + code: code, + message: message, + details: ((details ?? body) as _$celest.JsonValue), + ), + StackTrace.empty, + ); + } + } + + @_$celest.CloudFunction( + api: 'nonthrowing', + function: 'callsThrowsCustomError', + ) + Future callsThrowsCustomError() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/nonthrowing/calls-throws-custom-error'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return; + } + + @_$celest.CloudFunction(api: 'nonthrowing', function: 'callsThrowsBaseError') + Future callsThrowsBaseError() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/nonthrowing/calls-throws-base-error'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return; + } + + @_$celest.CloudFunction( + api: 'nonthrowing', + function: 'callsThrowsCustomException', + ) + Future callsThrowsCustomException() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/nonthrowing/calls-throws-custom-exception'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return; + } + + @_$celest.CloudFunction( + api: 'nonthrowing', + function: 'callsThrowsBaseException', + ) + Future callsThrowsBaseException() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/nonthrowing/calls-throws-base-exception'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return; + } +} + +class CelestFunctionsThrowing { + Never _throwError({int? code, required Map body}) { + final status = body['@status'] as Map?; + final message = status?['message'] as String?; + final details = status?['details'] as _$celest.JsonList?; + final (errorType, errorValue, stackTrace) = switch (details) { + null || [] => const (null, null, StackTrace.empty), + [ + final errorDetails as Map, + { + '@type': 'dart.core.StackTrace', + 'value': final stackTraceValue as String, + }, + ..., + ] => + ( + errorDetails['@type'], + errorDetails['value'], + StackTrace.fromString(stackTraceValue), + ), + [final errorDetails as Map, ...] => ( + errorDetails['@type'], + errorDetails['value'], + StackTrace.empty, + ), + }; + + switch (errorType) { + case 'celest.core.v1.CloudException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.CloudException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.CancelledException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.CancelledException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnknownError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.UnknownError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.BadRequestException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.BadRequestException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnauthorizedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.UnauthorizedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.NotFoundException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.NotFoundException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.AlreadyExistsException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.AlreadyExistsException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.PermissionDeniedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.PermissionDeniedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.ResourceExhaustedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.ResourceExhaustedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.FailedPreconditionException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.FailedPreconditionException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.AbortedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.AbortedException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.OutOfRangeException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.OutOfRangeException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnimplementedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.UnimplementedError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.InternalServerError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.InternalServerError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnavailableError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.UnavailableError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.DataLossError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.DataLossError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.DeadlineExceededError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.DeadlineExceededError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.SerializationException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.SerializationException>(errorValue), + stackTrace, + ); + case 'dart.core.Error': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.AssertionError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.TypeError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.ArgumentError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.RangeError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.IndexError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.UnsupportedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.UnimplementedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.StateError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.ConcurrentModificationError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.core.OutOfMemoryError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.StackOverflowError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.Exception': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.FormatException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.IntegerDivisionByZeroException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.async.AsyncError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.async.TimeoutException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.convert.JsonUnsupportedObjectError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'exceptions.v1.BaseException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'exceptions.v1.CustomException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'exceptions.v1.BaseError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'exceptions.v1.CustomError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + default: + Error.throwWithStackTrace( + _$celest.CloudException.http( + code: code, + message: message, + details: ((details ?? body) as _$celest.JsonValue), + ), + StackTrace.empty, + ); + } + } + + @_$celest.CloudFunction(api: 'throwing', function: 'throwsCustomError') + Future throwsCustomError() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/throwing/throws-custom-error'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return; + } + + @_$celest.CloudFunction(api: 'throwing', function: 'throwsBaseError') + Future throwsBaseError() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/throwing/throws-base-error'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return; + } + + @_$celest.CloudFunction(api: 'throwing', function: 'throwsCustomException') + Future throwsCustomException() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/throwing/throws-custom-exception'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return; + } + + @_$celest.CloudFunction(api: 'throwing', function: 'throwsBaseException') + Future throwsBaseException() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/throwing/throws-base-exception'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return; + } +} diff --git a/apps/cli/fixtures/legacy/exceptions/client/lib/src/serializers.dart b/apps/cli/fixtures/legacy/exceptions/client/lib/src/serializers.dart new file mode 100644 index 000000000..c030a514c --- /dev/null +++ b/apps/cli/fixtures/legacy/exceptions/client/lib/src/serializers.dart @@ -0,0 +1,819 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async'; +import 'dart:convert'; + +import 'package:_common/_common.dart' as _$_common__common; +import 'package:celest_backend/exceptions/exceptions.dart'; +import 'package:celest_core/celest_core.dart' as _$celest; +import 'package:celest_core/src/exception/cloud_exception.dart' as _$celest; +import 'package:celest_core/src/exception/serialization_exception.dart' + as _$celest; +import 'package:celest_core/src/serialization/json_value.dart' as _$celest; + +void initSerializers({_$celest.Serializers? serializers}) { + return runZoned(() { + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _$celest.Serializers.instance + .serialize($value.stackTrace), + }, + deserialize: ($serialized) { + return AsyncError( + $serialized[r'error']!, + _$celest.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_$celest.Serializers.instance.serialize( + $value.duration, + ) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return TimeoutException( + ($serialized[r'message'] as String?), + _$celest.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest + .Serializer.define>( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + ConcurrentModificationError, + Map? + >( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: + ($value) => { + if (_$celest.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$_common__common.CommonException, + Map + >( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return _$_common__common.CommonException( + ($serialized[r'message'] as String), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$_common__common.CustomException, + Map + >( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return _$_common__common.CustomException( + ($serialized[r'message'] as String), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define<_$_common__common.OverriddenException, String>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _$_common__common.OverriddenException.fromJson($serialized); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: ($value) => {r'fault': $value.fault}, + deserialize: ($serialized) { + return BaseError(($serialized[r'fault'] as String)); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: ($value) => {r'fault': $value.fault}, + deserialize: ($serialized) { + return BaseException(($serialized[r'fault'] as String)); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: ($value) => {r'fault': $value.fault}, + deserialize: ($serialized) { + return CustomError(($serialized[r'fault'] as String)); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: ($value) => {r'fault': $value.fault}, + deserialize: ($serialized) { + return CustomException(($serialized[r'fault'] as String)); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest + .Serializer.define<_$celest.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.AbortedException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.AlreadyExistsException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.BadRequestException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.BadRequestException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.CancelledException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.CancelledException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define<_$celest.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.CloudException.fromJson($serialized); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define<_$celest.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.DataLossError( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.DeadlineExceededError, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.InternalServerError, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.InternalServerError( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest + .Serializer.define<_$celest.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.NotFoundException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.OutOfRangeException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.OutOfRangeException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.UnauthorizedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.UnauthorizedException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest + .Serializer.define<_$celest.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.UnavailableError( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.UnimplementedError, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.UnimplementedError( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define<_$celest.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.UnknownError( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.SerializationException, + Map + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define<_$celest.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _$celest.JsonValue($serialized); + }, + ), + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ); + }, zoneValues: {_$celest.Serializers: serializers}); +} diff --git a/apps/cli/fixtures/legacy/exceptions/client/pubspec.yaml b/apps/cli/fixtures/legacy/exceptions/client/pubspec.yaml new file mode 100644 index 000000000..8d6747609 --- /dev/null +++ b/apps/cli/fixtures/legacy/exceptions/client/pubspec.yaml @@ -0,0 +1,29 @@ +name: exceptions_client +description: The Celest client for exceptions. +publish_to: none + +environment: + sdk: ^3.4.0 + +dependencies: + celest: ^1.0.0 + celest_backend: + path: .. + celest_core: ^1.0.0 + http: ^1.0.0 + native_storage: ^0.2.2 + +dependency_overrides: + celest: + path: ../../../../../../celest/packages/celest + celest_ast: + path: ../../../../../../celest/packages/celest_ast + celest_auth: + path: ../../../../../../celest/packages/celest_auth + celest_cloud: + path: ../../../../../../celest/packages/celest_cloud + celest_cloud_auth: + path: ../../../../../../celest/services/celest_cloud_auth + celest_core: + path: ../../../../../../celest/packages/celest_core +dev_dependencies: {} diff --git a/apps/cli/fixtures/legacy/exceptions/goldens/api.local.dart b/apps/cli/fixtures/legacy/exceptions/goldens/api.local.dart new file mode 100644 index 000000000..872314e04 --- /dev/null +++ b/apps/cli/fixtures/legacy/exceptions/goldens/api.local.dart @@ -0,0 +1,43 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'package:celest/src/core/context.dart' as _i12; +import 'package:celest/src/runtime/serve.dart' as _i1; + +import 'functions/external/callsThrowsCommonException.dart' as _i2; +import 'functions/external/callsThrowsCustomException.dart' as _i3; +import 'functions/nonthrowing/callsThrowsBaseError.dart' as _i4; +import 'functions/nonthrowing/callsThrowsBaseException.dart' as _i5; +import 'functions/nonthrowing/callsThrowsCustomError.dart' as _i6; +import 'functions/nonthrowing/callsThrowsCustomException.dart' as _i7; +import 'functions/throwing/throwsBaseError.dart' as _i8; +import 'functions/throwing/throwsBaseException.dart' as _i9; +import 'functions/throwing/throwsCustomError.dart' as _i10; +import 'functions/throwing/throwsCustomException.dart' as _i11; + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: { + '/external/calls-throws-common-exception': + _i2.CallsThrowsCommonExceptionTarget(), + '/external/calls-throws-custom-exception': + _i3.CallsThrowsCustomExceptionTarget(), + '/nonthrowing/calls-throws-base-error': _i4.CallsThrowsBaseErrorTarget(), + '/nonthrowing/calls-throws-base-exception': + _i5.CallsThrowsBaseExceptionTarget(), + '/nonthrowing/calls-throws-custom-error': + _i6.CallsThrowsCustomErrorTarget(), + '/nonthrowing/calls-throws-custom-exception': + _i7.CallsThrowsCustomExceptionTarget(), + '/throwing/throws-base-error': _i8.ThrowsBaseErrorTarget(), + '/throwing/throws-base-exception': _i9.ThrowsBaseExceptionTarget(), + '/throwing/throws-custom-error': _i10.ThrowsCustomErrorTarget(), + '/throwing/throws-custom-exception': _i11.ThrowsCustomExceptionTarget(), + }, + setup: (_i12.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/exceptions/goldens/ast.json b/apps/cli/fixtures/legacy/exceptions/goldens/ast.json new file mode 100644 index 000000000..cf3cf8579 --- /dev/null +++ b/apps/cli/fixtures/legacy/exceptions/goldens/ast.json @@ -0,0 +1,1347 @@ +{ + "name": "exceptions", + "environment": "local", + "reference": { + "$": "Reference", + "symbol": "project", + "url": "package:celest_backend/src/project.dart" + }, + "apis": { + "external": { + "name": "external", + "metadata": [], + "functions": { + "callsThrowsCommonException": { + "name": "callsThrowsCommonException", + "apiName": "external", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "flattenedReturnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 228, + "uri": "package:celest_backend/src/functions/external.dart", + "line": 8, + "column": 5 + }, + "end": { + "offset": 254, + "uri": "package:celest_backend/src/functions/external.dart", + "line": 8, + "column": 31 + }, + "text": "callsThrowsCommonException" + } + }, + "callsThrowsCustomException": { + "name": "callsThrowsCustomException", + "apiName": "external", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "flattenedReturnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 308, + "uri": "package:celest_backend/src/functions/external.dart", + "line": 13, + "column": 5 + }, + "end": { + "offset": 334, + "uri": "package:celest_backend/src/functions/external.dart", + "line": 13, + "column": 31 + }, + "text": "callsThrowsCustomException" + } + } + }, + "docs": [ + "/// Tests that types thrown from external packages can be detected via", + "/// recursive imports and serialized correctly." + ], + "exceptionTypes": [ + { + "$": "TypeReference", + "symbol": "CustomException", + "url": "package:_common/_common.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "CommonException", + "url": "package:_common/_common.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "OverriddenException", + "url": "package:_common/_common.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "Error", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AssertionError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "TypeError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ArgumentError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "RangeError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "IndexError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnsupportedError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnimplementedError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "StateError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ConcurrentModificationError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "OutOfMemoryError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "StackOverflowError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "Exception", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "FormatException", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "IntegerDivisionByZeroException", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AsyncError", + "url": "dart:async", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "TimeoutException", + "url": "dart:async", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "JsonUnsupportedObjectError", + "url": "dart:convert", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "CloudException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "CancelledException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnknownError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "BadRequestException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnauthorizedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "NotFoundException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AlreadyExistsException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "PermissionDeniedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ResourceExhaustedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "FailedPreconditionException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AbortedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "OutOfRangeException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnimplementedError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "InternalServerError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnavailableError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "DataLossError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "DeadlineExceededError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "SerializationException", + "url": "package:celest_core/src/exception/serialization_exception.dart", + "isNullable": false + } + ], + "location": { + "start": { + "offset": 0, + "uri": "package:celest_backend/src/functions/external.dart", + "line": 0, + "column": 0 + }, + "end": { + "offset": 0, + "uri": "package:celest_backend/src/functions/external.dart", + "line": 0, + "column": 0 + }, + "text": "" + } + }, + "nonthrowing": { + "name": "nonthrowing", + "metadata": [], + "functions": { + "callsThrowsCustomError": { + "name": "callsThrowsCustomError", + "apiName": "nonthrowing", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "flattenedReturnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 164, + "uri": "package:celest_backend/src/functions/nonthrowing.dart", + "line": 8, + "column": 5 + }, + "end": { + "offset": 186, + "uri": "package:celest_backend/src/functions/nonthrowing.dart", + "line": 8, + "column": 27 + }, + "text": "callsThrowsCustomError" + } + }, + "callsThrowsBaseError": { + "name": "callsThrowsBaseError", + "apiName": "nonthrowing", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "flattenedReturnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 229, + "uri": "package:celest_backend/src/functions/nonthrowing.dart", + "line": 13, + "column": 5 + }, + "end": { + "offset": 249, + "uri": "package:celest_backend/src/functions/nonthrowing.dart", + "line": 13, + "column": 25 + }, + "text": "callsThrowsBaseError" + } + }, + "callsThrowsCustomException": { + "name": "callsThrowsCustomException", + "apiName": "nonthrowing", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "flattenedReturnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 290, + "uri": "package:celest_backend/src/functions/nonthrowing.dart", + "line": 18, + "column": 5 + }, + "end": { + "offset": 316, + "uri": "package:celest_backend/src/functions/nonthrowing.dart", + "line": 18, + "column": 31 + }, + "text": "callsThrowsCustomException" + } + }, + "callsThrowsBaseException": { + "name": "callsThrowsBaseException", + "apiName": "nonthrowing", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "flattenedReturnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 363, + "uri": "package:celest_backend/src/functions/nonthrowing.dart", + "line": 23, + "column": 5 + }, + "end": { + "offset": 387, + "uri": "package:celest_backend/src/functions/nonthrowing.dart", + "line": 23, + "column": 29 + }, + "text": "callsThrowsBaseException" + } + } + }, + "docs": [ + "/// A library with methods that do not through but call methods that do throw." + ], + "exceptionTypes": [ + { + "$": "TypeReference", + "symbol": "CloudException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "CancelledException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnknownError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "BadRequestException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnauthorizedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "NotFoundException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AlreadyExistsException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "PermissionDeniedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ResourceExhaustedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "FailedPreconditionException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AbortedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "OutOfRangeException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnimplementedError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "InternalServerError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnavailableError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "DataLossError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "DeadlineExceededError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "SerializationException", + "url": "package:celest_core/src/exception/serialization_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "Error", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AssertionError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "TypeError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ArgumentError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "RangeError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "IndexError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnsupportedError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnimplementedError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "StateError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ConcurrentModificationError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "OutOfMemoryError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "StackOverflowError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "Exception", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "FormatException", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "IntegerDivisionByZeroException", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AsyncError", + "url": "dart:async", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "TimeoutException", + "url": "dart:async", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "JsonUnsupportedObjectError", + "url": "dart:convert", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "BaseException", + "url": "package:celest_backend/exceptions/exceptions.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "CustomException", + "url": "package:celest_backend/exceptions/exceptions.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "BaseError", + "url": "package:celest_backend/exceptions/exceptions.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "CustomError", + "url": "package:celest_backend/exceptions/exceptions.dart", + "isNullable": false + } + ], + "location": { + "start": { + "offset": 0, + "uri": "package:celest_backend/src/functions/nonthrowing.dart", + "line": 0, + "column": 0 + }, + "end": { + "offset": 0, + "uri": "package:celest_backend/src/functions/nonthrowing.dart", + "line": 0, + "column": 0 + }, + "text": "" + } + }, + "throwing": { + "name": "throwing", + "metadata": [], + "functions": { + "throwsCustomError": { + "name": "throwsCustomError", + "apiName": "throwing", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "flattenedReturnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 110, + "uri": "package:celest_backend/src/functions/throwing.dart", + "line": 4, + "column": 5 + }, + "end": { + "offset": 127, + "uri": "package:celest_backend/src/functions/throwing.dart", + "line": 4, + "column": 22 + }, + "text": "throwsCustomError" + } + }, + "throwsBaseError": { + "name": "throwsBaseError", + "apiName": "throwing", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "flattenedReturnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 179, + "uri": "package:celest_backend/src/functions/throwing.dart", + "line": 9, + "column": 5 + }, + "end": { + "offset": 194, + "uri": "package:celest_backend/src/functions/throwing.dart", + "line": 9, + "column": 20 + }, + "text": "throwsBaseError" + } + }, + "throwsCustomException": { + "name": "throwsCustomException", + "apiName": "throwing", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "flattenedReturnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 244, + "uri": "package:celest_backend/src/functions/throwing.dart", + "line": 14, + "column": 5 + }, + "end": { + "offset": 265, + "uri": "package:celest_backend/src/functions/throwing.dart", + "line": 14, + "column": 26 + }, + "text": "throwsCustomException" + } + }, + "throwsBaseException": { + "name": "throwsBaseException", + "apiName": "throwing", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "flattenedReturnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 321, + "uri": "package:celest_backend/src/functions/throwing.dart", + "line": 19, + "column": 5 + }, + "end": { + "offset": 340, + "uri": "package:celest_backend/src/functions/throwing.dart", + "line": 19, + "column": 24 + }, + "text": "throwsBaseException" + } + } + }, + "docs": [], + "exceptionTypes": [ + { + "$": "TypeReference", + "symbol": "CloudException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "CancelledException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnknownError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "BadRequestException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnauthorizedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "NotFoundException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AlreadyExistsException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "PermissionDeniedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ResourceExhaustedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "FailedPreconditionException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AbortedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "OutOfRangeException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnimplementedError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "InternalServerError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnavailableError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "DataLossError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "DeadlineExceededError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "SerializationException", + "url": "package:celest_core/src/exception/serialization_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "Error", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AssertionError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "TypeError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ArgumentError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "RangeError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "IndexError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnsupportedError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnimplementedError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "StateError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ConcurrentModificationError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "OutOfMemoryError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "StackOverflowError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "Exception", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "FormatException", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "IntegerDivisionByZeroException", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AsyncError", + "url": "dart:async", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "TimeoutException", + "url": "dart:async", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "JsonUnsupportedObjectError", + "url": "dart:convert", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "BaseException", + "url": "package:celest_backend/exceptions/exceptions.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "CustomException", + "url": "package:celest_backend/exceptions/exceptions.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "BaseError", + "url": "package:celest_backend/exceptions/exceptions.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "CustomError", + "url": "package:celest_backend/exceptions/exceptions.dart", + "isNullable": false + } + ], + "location": { + "start": { + "offset": 0, + "uri": "package:celest_backend/src/functions/throwing.dart", + "line": 0, + "column": 0 + }, + "end": { + "offset": 0, + "uri": "package:celest_backend/src/functions/throwing.dart", + "line": 0, + "column": 0 + }, + "text": "" + } + } + }, + "variables": [], + "secrets": [], + "databases": {}, + "sdkConfig": { + "celest": "1.0.6+2", + "dart": { + "type": "dart", + "version": "3.29.0", + "enabledExperiments": [] + }, + "targetSdk": "dart", + "featureFlags": [ + "streaming" + ], + "flutter": { + "type": "flutter", + "version": "3.29.0", + "enabledExperiments": [] + } + }, + "location": { + "start": { + "offset": 44, + "uri": "project.dart", + "line": 2, + "column": 6 + }, + "end": { + "offset": 81, + "uri": "project.dart", + "line": 2, + "column": 43 + }, + "text": "project = Project(name: 'exceptions')" + } +} \ No newline at end of file diff --git a/apps/cli/fixtures/legacy/exceptions/goldens/ast.resolved.json b/apps/cli/fixtures/legacy/exceptions/goldens/ast.resolved.json new file mode 100644 index 000000000..7988d42f0 --- /dev/null +++ b/apps/cli/fixtures/legacy/exceptions/goldens/ast.resolved.json @@ -0,0 +1,206 @@ +{ + "projectId": "exceptions", + "environmentId": "local", + "apis": { + "external": { + "apiId": "external", + "functions": { + "callsThrowsCommonException": { + "functionId": "callsThrowsCommonException", + "apiId": "external", + "httpConfig": { + "route": { + "method": "POST", + "path": "/external/calls-throws-common-exception" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "callsThrowsCustomException": { + "functionId": "callsThrowsCustomException", + "apiId": "external", + "httpConfig": { + "route": { + "method": "POST", + "path": "/external/calls-throws-custom-exception" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + } + } + }, + "nonthrowing": { + "apiId": "nonthrowing", + "functions": { + "callsThrowsCustomError": { + "functionId": "callsThrowsCustomError", + "apiId": "nonthrowing", + "httpConfig": { + "route": { + "method": "POST", + "path": "/nonthrowing/calls-throws-custom-error" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "callsThrowsBaseError": { + "functionId": "callsThrowsBaseError", + "apiId": "nonthrowing", + "httpConfig": { + "route": { + "method": "POST", + "path": "/nonthrowing/calls-throws-base-error" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "callsThrowsCustomException": { + "functionId": "callsThrowsCustomException", + "apiId": "nonthrowing", + "httpConfig": { + "route": { + "method": "POST", + "path": "/nonthrowing/calls-throws-custom-exception" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "callsThrowsBaseException": { + "functionId": "callsThrowsBaseException", + "apiId": "nonthrowing", + "httpConfig": { + "route": { + "method": "POST", + "path": "/nonthrowing/calls-throws-base-exception" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + } + } + }, + "throwing": { + "apiId": "throwing", + "functions": { + "throwsCustomError": { + "functionId": "throwsCustomError", + "apiId": "throwing", + "httpConfig": { + "route": { + "method": "POST", + "path": "/throwing/throws-custom-error" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "throwsBaseError": { + "functionId": "throwsBaseError", + "apiId": "throwing", + "httpConfig": { + "route": { + "method": "POST", + "path": "/throwing/throws-base-error" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "throwsCustomException": { + "functionId": "throwsCustomException", + "apiId": "throwing", + "httpConfig": { + "route": { + "method": "POST", + "path": "/throwing/throws-custom-exception" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "throwsBaseException": { + "functionId": "throwsBaseException", + "apiId": "throwing", + "httpConfig": { + "route": { + "method": "POST", + "path": "/throwing/throws-base-exception" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + } + } + } + }, + "variables": [ + { + "name": "CELEST_ENVIRONMENT", + "value": "local" + } + ], + "secrets": [], + "databases": {}, + "sdkConfig": { + "celest": "1.0.6+2", + "dart": { + "type": "dart", + "version": "3.29.0", + "enabledExperiments": [] + }, + "targetSdk": "dart", + "featureFlags": [ + "streaming" + ], + "flutter": { + "type": "flutter", + "version": "3.29.0", + "enabledExperiments": [] + } + } +} \ No newline at end of file diff --git a/apps/cli/fixtures/legacy/exceptions/goldens/celest.json b/apps/cli/fixtures/legacy/exceptions/goldens/celest.json new file mode 100644 index 000000000..c778439fe --- /dev/null +++ b/apps/cli/fixtures/legacy/exceptions/goldens/celest.json @@ -0,0 +1,211 @@ +{ + "projectId": "exceptions", + "environmentId": "local", + "apis": { + "external": { + "apiId": "external", + "functions": { + "callsThrowsCommonException": { + "functionId": "callsThrowsCommonException", + "parentId": "external", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/external/calls-throws-common-exception" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "callsThrowsCustomException": { + "functionId": "callsThrowsCustomException", + "parentId": "external", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/external/calls-throws-custom-exception" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + } + } + }, + "nonthrowing": { + "apiId": "nonthrowing", + "functions": { + "callsThrowsCustomError": { + "functionId": "callsThrowsCustomError", + "parentId": "nonthrowing", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/nonthrowing/calls-throws-custom-error" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "callsThrowsBaseError": { + "functionId": "callsThrowsBaseError", + "parentId": "nonthrowing", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/nonthrowing/calls-throws-base-error" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "callsThrowsCustomException": { + "functionId": "callsThrowsCustomException", + "parentId": "nonthrowing", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/nonthrowing/calls-throws-custom-exception" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "callsThrowsBaseException": { + "functionId": "callsThrowsBaseException", + "parentId": "nonthrowing", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/nonthrowing/calls-throws-base-exception" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + } + } + }, + "throwing": { + "apiId": "throwing", + "functions": { + "throwsCustomError": { + "functionId": "throwsCustomError", + "parentId": "throwing", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/throwing/throws-custom-error" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "throwsBaseError": { + "functionId": "throwsBaseError", + "parentId": "throwing", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/throwing/throws-base-error" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "throwsCustomException": { + "functionId": "throwsCustomException", + "parentId": "throwing", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/throwing/throws-custom-exception" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "throwsBaseException": { + "functionId": "throwsBaseException", + "parentId": "throwing", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/throwing/throws-base-exception" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + } + } + } + }, + "variables": [ + { + "name": "CELEST_ENVIRONMENT", + "value": "local" + } + ], + "databases": {}, + "sdkConfig": { + "celest": { + "major": 1, + "minor": 0, + "patch": 6, + "build": [ + 2.0 + ], + "canonicalizedVersion": "1.0.6+2" + }, + "dart": { + "type": "DART", + "version": { + "major": 3, + "minor": 29, + "patch": 0, + "canonicalizedVersion": "3.29.0" + } + }, + "flutter": { + "type": "FLUTTER", + "version": { + "major": 3, + "minor": 29, + "patch": 0, + "canonicalizedVersion": "3.29.0" + } + }, + "targetSdk": "DART", + "featureFlags": [ + "STREAMING" + ] + } +} \ No newline at end of file diff --git a/apps/cli/fixtures/legacy/exceptions/goldens/functions/external/callsThrowsCommonException.dart b/apps/cli/fixtures/legacy/exceptions/goldens/functions/external/callsThrowsCommonException.dart new file mode 100644 index 000000000..1d5fd8874 --- /dev/null +++ b/apps/cli/fixtures/legacy/exceptions/goldens/functions/external/callsThrowsCommonException.dart @@ -0,0 +1,1791 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i10; + +import 'package:_common/_common.dart' as _i9; +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/external.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class CallsThrowsCommonExceptionTarget + extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'callsThrowsCommonException'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + _i3.callsThrowsCommonException(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(null), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.CommonException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': '_common.CommonException', + 'value': _i4.Serializers.instance.serialize<_i9.CommonException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.CustomException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': '_common.CustomException', + 'value': _i4.Serializers.instance.serialize<_i9.CustomException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.OverriddenException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': '_common.OverriddenException', + 'value': _i4.Serializers.instance + .serialize<_i9.OverriddenException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.CommonException, Map>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return _i9.CommonException(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.CustomException, Map>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return _i9.CustomException(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.OverriddenException, String>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i9.OverriddenException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': CallsThrowsCommonExceptionTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/exceptions/goldens/functions/external/callsThrowsCustomException.dart b/apps/cli/fixtures/legacy/exceptions/goldens/functions/external/callsThrowsCustomException.dart new file mode 100644 index 000000000..5c528ba4b --- /dev/null +++ b/apps/cli/fixtures/legacy/exceptions/goldens/functions/external/callsThrowsCustomException.dart @@ -0,0 +1,1791 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i10; + +import 'package:_common/_common.dart' as _i9; +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/external.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class CallsThrowsCustomExceptionTarget + extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'callsThrowsCustomException'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + _i3.callsThrowsCustomException(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(null), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.CommonException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': '_common.CommonException', + 'value': _i4.Serializers.instance.serialize<_i9.CommonException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.CustomException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': '_common.CustomException', + 'value': _i4.Serializers.instance.serialize<_i9.CustomException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.OverriddenException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': '_common.OverriddenException', + 'value': _i4.Serializers.instance + .serialize<_i9.OverriddenException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.CommonException, Map>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return _i9.CommonException(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.CustomException, Map>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return _i9.CustomException(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.OverriddenException, String>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i9.OverriddenException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': CallsThrowsCustomExceptionTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/exceptions/goldens/functions/nonthrowing/callsThrowsBaseError.dart b/apps/cli/fixtures/legacy/exceptions/goldens/functions/nonthrowing/callsThrowsBaseError.dart new file mode 100644 index 000000000..787199a47 --- /dev/null +++ b/apps/cli/fixtures/legacy/exceptions/goldens/functions/nonthrowing/callsThrowsBaseError.dart @@ -0,0 +1,1820 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/exceptions/exceptions.dart' as _i9; +import 'package:celest_backend/src/functions/nonthrowing.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class CallsThrowsBaseErrorTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'callsThrowsBaseError'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + _i3.callsThrowsBaseError(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(null), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.CustomError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'exceptions.v1.CustomError', + 'value': _i4.Serializers.instance.serialize<_i9.CustomError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.BaseError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'exceptions.v1.BaseError', + 'value': _i4.Serializers.instance.serialize<_i9.BaseError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.CustomException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'exceptions.v1.CustomException', + 'value': _i4.Serializers.instance.serialize<_i9.CustomException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.BaseException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'exceptions.v1.BaseException', + 'value': _i4.Serializers.instance.serialize<_i9.BaseException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.BaseError, Map>( + serialize: ($value) => {r'fault': $value.fault}, + deserialize: ($serialized) { + return _i9.BaseError(($serialized[r'fault'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.BaseException, Map>( + serialize: ($value) => {r'fault': $value.fault}, + deserialize: ($serialized) { + return _i9.BaseException(($serialized[r'fault'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.CustomError, Map>( + serialize: ($value) => {r'fault': $value.fault}, + deserialize: ($serialized) { + return _i9.CustomError(($serialized[r'fault'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.CustomException, Map>( + serialize: ($value) => {r'fault': $value.fault}, + deserialize: ($serialized) { + return _i9.CustomException(($serialized[r'fault'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': CallsThrowsBaseErrorTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/exceptions/goldens/functions/nonthrowing/callsThrowsBaseException.dart b/apps/cli/fixtures/legacy/exceptions/goldens/functions/nonthrowing/callsThrowsBaseException.dart new file mode 100644 index 000000000..2e24013fe --- /dev/null +++ b/apps/cli/fixtures/legacy/exceptions/goldens/functions/nonthrowing/callsThrowsBaseException.dart @@ -0,0 +1,1820 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/exceptions/exceptions.dart' as _i9; +import 'package:celest_backend/src/functions/nonthrowing.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class CallsThrowsBaseExceptionTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'callsThrowsBaseException'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + _i3.callsThrowsBaseException(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(null), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.CustomError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'exceptions.v1.CustomError', + 'value': _i4.Serializers.instance.serialize<_i9.CustomError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.BaseError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'exceptions.v1.BaseError', + 'value': _i4.Serializers.instance.serialize<_i9.BaseError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.CustomException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'exceptions.v1.CustomException', + 'value': _i4.Serializers.instance.serialize<_i9.CustomException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.BaseException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'exceptions.v1.BaseException', + 'value': _i4.Serializers.instance.serialize<_i9.BaseException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.BaseError, Map>( + serialize: ($value) => {r'fault': $value.fault}, + deserialize: ($serialized) { + return _i9.BaseError(($serialized[r'fault'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.BaseException, Map>( + serialize: ($value) => {r'fault': $value.fault}, + deserialize: ($serialized) { + return _i9.BaseException(($serialized[r'fault'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.CustomError, Map>( + serialize: ($value) => {r'fault': $value.fault}, + deserialize: ($serialized) { + return _i9.CustomError(($serialized[r'fault'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.CustomException, Map>( + serialize: ($value) => {r'fault': $value.fault}, + deserialize: ($serialized) { + return _i9.CustomException(($serialized[r'fault'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': CallsThrowsBaseExceptionTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/exceptions/goldens/functions/nonthrowing/callsThrowsCustomError.dart b/apps/cli/fixtures/legacy/exceptions/goldens/functions/nonthrowing/callsThrowsCustomError.dart new file mode 100644 index 000000000..2c58e1111 --- /dev/null +++ b/apps/cli/fixtures/legacy/exceptions/goldens/functions/nonthrowing/callsThrowsCustomError.dart @@ -0,0 +1,1820 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/exceptions/exceptions.dart' as _i9; +import 'package:celest_backend/src/functions/nonthrowing.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class CallsThrowsCustomErrorTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'callsThrowsCustomError'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + _i3.callsThrowsCustomError(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(null), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.CustomError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'exceptions.v1.CustomError', + 'value': _i4.Serializers.instance.serialize<_i9.CustomError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.BaseError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'exceptions.v1.BaseError', + 'value': _i4.Serializers.instance.serialize<_i9.BaseError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.CustomException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'exceptions.v1.CustomException', + 'value': _i4.Serializers.instance.serialize<_i9.CustomException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.BaseException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'exceptions.v1.BaseException', + 'value': _i4.Serializers.instance.serialize<_i9.BaseException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.BaseError, Map>( + serialize: ($value) => {r'fault': $value.fault}, + deserialize: ($serialized) { + return _i9.BaseError(($serialized[r'fault'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.BaseException, Map>( + serialize: ($value) => {r'fault': $value.fault}, + deserialize: ($serialized) { + return _i9.BaseException(($serialized[r'fault'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.CustomError, Map>( + serialize: ($value) => {r'fault': $value.fault}, + deserialize: ($serialized) { + return _i9.CustomError(($serialized[r'fault'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.CustomException, Map>( + serialize: ($value) => {r'fault': $value.fault}, + deserialize: ($serialized) { + return _i9.CustomException(($serialized[r'fault'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': CallsThrowsCustomErrorTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/exceptions/goldens/functions/nonthrowing/callsThrowsCustomException.dart b/apps/cli/fixtures/legacy/exceptions/goldens/functions/nonthrowing/callsThrowsCustomException.dart new file mode 100644 index 000000000..8fd697ed1 --- /dev/null +++ b/apps/cli/fixtures/legacy/exceptions/goldens/functions/nonthrowing/callsThrowsCustomException.dart @@ -0,0 +1,1821 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/exceptions/exceptions.dart' as _i9; +import 'package:celest_backend/src/functions/nonthrowing.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class CallsThrowsCustomExceptionTarget + extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'callsThrowsCustomException'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + _i3.callsThrowsCustomException(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(null), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.CustomError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'exceptions.v1.CustomError', + 'value': _i4.Serializers.instance.serialize<_i9.CustomError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.BaseError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'exceptions.v1.BaseError', + 'value': _i4.Serializers.instance.serialize<_i9.BaseError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.CustomException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'exceptions.v1.CustomException', + 'value': _i4.Serializers.instance.serialize<_i9.CustomException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.BaseException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'exceptions.v1.BaseException', + 'value': _i4.Serializers.instance.serialize<_i9.BaseException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.BaseError, Map>( + serialize: ($value) => {r'fault': $value.fault}, + deserialize: ($serialized) { + return _i9.BaseError(($serialized[r'fault'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.BaseException, Map>( + serialize: ($value) => {r'fault': $value.fault}, + deserialize: ($serialized) { + return _i9.BaseException(($serialized[r'fault'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.CustomError, Map>( + serialize: ($value) => {r'fault': $value.fault}, + deserialize: ($serialized) { + return _i9.CustomError(($serialized[r'fault'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.CustomException, Map>( + serialize: ($value) => {r'fault': $value.fault}, + deserialize: ($serialized) { + return _i9.CustomException(($serialized[r'fault'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': CallsThrowsCustomExceptionTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/exceptions/goldens/functions/throwing/throwsBaseError.dart b/apps/cli/fixtures/legacy/exceptions/goldens/functions/throwing/throwsBaseError.dart new file mode 100644 index 000000000..e831b7fd7 --- /dev/null +++ b/apps/cli/fixtures/legacy/exceptions/goldens/functions/throwing/throwsBaseError.dart @@ -0,0 +1,1820 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/exceptions/exceptions.dart' as _i9; +import 'package:celest_backend/src/functions/throwing.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class ThrowsBaseErrorTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'throwsBaseError'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + _i3.throwsBaseError(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(null), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.CustomError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'exceptions.v1.CustomError', + 'value': _i4.Serializers.instance.serialize<_i9.CustomError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.BaseError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'exceptions.v1.BaseError', + 'value': _i4.Serializers.instance.serialize<_i9.BaseError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.CustomException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'exceptions.v1.CustomException', + 'value': _i4.Serializers.instance.serialize<_i9.CustomException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.BaseException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'exceptions.v1.BaseException', + 'value': _i4.Serializers.instance.serialize<_i9.BaseException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.BaseError, Map>( + serialize: ($value) => {r'fault': $value.fault}, + deserialize: ($serialized) { + return _i9.BaseError(($serialized[r'fault'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.BaseException, Map>( + serialize: ($value) => {r'fault': $value.fault}, + deserialize: ($serialized) { + return _i9.BaseException(($serialized[r'fault'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.CustomError, Map>( + serialize: ($value) => {r'fault': $value.fault}, + deserialize: ($serialized) { + return _i9.CustomError(($serialized[r'fault'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.CustomException, Map>( + serialize: ($value) => {r'fault': $value.fault}, + deserialize: ($serialized) { + return _i9.CustomException(($serialized[r'fault'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': ThrowsBaseErrorTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/exceptions/goldens/functions/throwing/throwsBaseException.dart b/apps/cli/fixtures/legacy/exceptions/goldens/functions/throwing/throwsBaseException.dart new file mode 100644 index 000000000..b472c22ac --- /dev/null +++ b/apps/cli/fixtures/legacy/exceptions/goldens/functions/throwing/throwsBaseException.dart @@ -0,0 +1,1820 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/exceptions/exceptions.dart' as _i9; +import 'package:celest_backend/src/functions/throwing.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class ThrowsBaseExceptionTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'throwsBaseException'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + _i3.throwsBaseException(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(null), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.CustomError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'exceptions.v1.CustomError', + 'value': _i4.Serializers.instance.serialize<_i9.CustomError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.BaseError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'exceptions.v1.BaseError', + 'value': _i4.Serializers.instance.serialize<_i9.BaseError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.CustomException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'exceptions.v1.CustomException', + 'value': _i4.Serializers.instance.serialize<_i9.CustomException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.BaseException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'exceptions.v1.BaseException', + 'value': _i4.Serializers.instance.serialize<_i9.BaseException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.BaseError, Map>( + serialize: ($value) => {r'fault': $value.fault}, + deserialize: ($serialized) { + return _i9.BaseError(($serialized[r'fault'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.BaseException, Map>( + serialize: ($value) => {r'fault': $value.fault}, + deserialize: ($serialized) { + return _i9.BaseException(($serialized[r'fault'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.CustomError, Map>( + serialize: ($value) => {r'fault': $value.fault}, + deserialize: ($serialized) { + return _i9.CustomError(($serialized[r'fault'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.CustomException, Map>( + serialize: ($value) => {r'fault': $value.fault}, + deserialize: ($serialized) { + return _i9.CustomException(($serialized[r'fault'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': ThrowsBaseExceptionTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/exceptions/goldens/functions/throwing/throwsCustomError.dart b/apps/cli/fixtures/legacy/exceptions/goldens/functions/throwing/throwsCustomError.dart new file mode 100644 index 000000000..5dd147f53 --- /dev/null +++ b/apps/cli/fixtures/legacy/exceptions/goldens/functions/throwing/throwsCustomError.dart @@ -0,0 +1,1820 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/exceptions/exceptions.dart' as _i9; +import 'package:celest_backend/src/functions/throwing.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class ThrowsCustomErrorTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'throwsCustomError'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + _i3.throwsCustomError(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(null), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.CustomError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'exceptions.v1.CustomError', + 'value': _i4.Serializers.instance.serialize<_i9.CustomError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.BaseError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'exceptions.v1.BaseError', + 'value': _i4.Serializers.instance.serialize<_i9.BaseError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.CustomException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'exceptions.v1.CustomException', + 'value': _i4.Serializers.instance.serialize<_i9.CustomException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.BaseException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'exceptions.v1.BaseException', + 'value': _i4.Serializers.instance.serialize<_i9.BaseException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.BaseError, Map>( + serialize: ($value) => {r'fault': $value.fault}, + deserialize: ($serialized) { + return _i9.BaseError(($serialized[r'fault'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.BaseException, Map>( + serialize: ($value) => {r'fault': $value.fault}, + deserialize: ($serialized) { + return _i9.BaseException(($serialized[r'fault'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.CustomError, Map>( + serialize: ($value) => {r'fault': $value.fault}, + deserialize: ($serialized) { + return _i9.CustomError(($serialized[r'fault'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.CustomException, Map>( + serialize: ($value) => {r'fault': $value.fault}, + deserialize: ($serialized) { + return _i9.CustomException(($serialized[r'fault'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': ThrowsCustomErrorTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/exceptions/goldens/functions/throwing/throwsCustomException.dart b/apps/cli/fixtures/legacy/exceptions/goldens/functions/throwing/throwsCustomException.dart new file mode 100644 index 000000000..9a2e8f8b4 --- /dev/null +++ b/apps/cli/fixtures/legacy/exceptions/goldens/functions/throwing/throwsCustomException.dart @@ -0,0 +1,1820 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/exceptions/exceptions.dart' as _i9; +import 'package:celest_backend/src/functions/throwing.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class ThrowsCustomExceptionTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'throwsCustomException'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + _i3.throwsCustomException(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(null), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.CustomError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'exceptions.v1.CustomError', + 'value': _i4.Serializers.instance.serialize<_i9.CustomError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.BaseError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'exceptions.v1.BaseError', + 'value': _i4.Serializers.instance.serialize<_i9.BaseError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.CustomException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'exceptions.v1.CustomException', + 'value': _i4.Serializers.instance.serialize<_i9.CustomException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.BaseException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'exceptions.v1.BaseException', + 'value': _i4.Serializers.instance.serialize<_i9.BaseException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.BaseError, Map>( + serialize: ($value) => {r'fault': $value.fault}, + deserialize: ($serialized) { + return _i9.BaseError(($serialized[r'fault'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.BaseException, Map>( + serialize: ($value) => {r'fault': $value.fault}, + deserialize: ($serialized) { + return _i9.BaseException(($serialized[r'fault'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.CustomError, Map>( + serialize: ($value) => {r'fault': $value.fault}, + deserialize: ($serialized) { + return _i9.CustomError(($serialized[r'fault'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.CustomException, Map>( + serialize: ($value) => {r'fault': $value.fault}, + deserialize: ($serialized) { + return _i9.CustomException(($serialized[r'fault'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': ThrowsCustomExceptionTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/exceptions/lib/exceptions/exceptions.dart b/apps/cli/fixtures/legacy/exceptions/lib/exceptions/exceptions.dart new file mode 100644 index 000000000..a4f0138d2 --- /dev/null +++ b/apps/cli/fixtures/legacy/exceptions/lib/exceptions/exceptions.dart @@ -0,0 +1,27 @@ +sealed class Fault {} + +final class BaseException implements Exception, Fault { + BaseException(String fault) : fault = 'base: $fault'; + + final String fault; + + @override + String toString() => 'BaseException: $fault'; +} + +final class CustomException extends BaseException { + CustomException(String fault) : super('custom: $fault'); +} + +final class BaseError extends Error implements Fault { + BaseError(String fault) : fault = 'base: $fault'; + + final String fault; + + @override + String toString() => 'BaseError: $fault'; +} + +final class CustomError extends BaseError { + CustomError(String fault) : super('custom: $fault'); +} diff --git a/apps/cli/fixtures/legacy/exceptions/lib/fix_data/v1_migration.yaml b/apps/cli/fixtures/legacy/exceptions/lib/fix_data/v1_migration.yaml new file mode 100644 index 000000000..e156a3f9d --- /dev/null +++ b/apps/cli/fixtures/legacy/exceptions/lib/fix_data/v1_migration.yaml @@ -0,0 +1,13 @@ +# Generated by Celest. Do not modify. +version: 1 +transforms: + - title: "Updates the import of the Celest client" + date: 2024-10-06 + element: + uris: ["client.dart"] + variable: celest + changes: + - kind: replacedBy + newElement: + uris: ["package:exceptions_client/exceptions_client.dart"] + variable: celest diff --git a/apps/cli/fixtures/legacy/exceptions/lib/src/functions/external.dart b/apps/cli/fixtures/legacy/exceptions/lib/src/functions/external.dart new file mode 100644 index 000000000..87de84004 --- /dev/null +++ b/apps/cli/fixtures/legacy/exceptions/lib/src/functions/external.dart @@ -0,0 +1,16 @@ +/// Tests that types thrown from external packages can be detected via +/// recursive imports and serialized correctly. +library; + +import 'package:_common/_common.dart' as common; +import 'package:celest/celest.dart'; + +@cloud +void callsThrowsCommonException() { + common.throwsCommonException(); +} + +@cloud +void callsThrowsCustomException() { + common.throwsCustomException(); +} diff --git a/apps/cli/fixtures/legacy/exceptions/lib/src/functions/nonthrowing.dart b/apps/cli/fixtures/legacy/exceptions/lib/src/functions/nonthrowing.dart new file mode 100644 index 000000000..bca9f02c2 --- /dev/null +++ b/apps/cli/fixtures/legacy/exceptions/lib/src/functions/nonthrowing.dart @@ -0,0 +1,26 @@ +/// A library with methods that do not through but call methods that do throw. +library; + +import 'package:celest/celest.dart'; + +import 'throwing.dart'; + +@cloud +void callsThrowsCustomError() { + throwsCustomError(); +} + +@cloud +void callsThrowsBaseError() { + throwsBaseError(); +} + +@cloud +void callsThrowsCustomException() { + throwsCustomException(); +} + +@cloud +void callsThrowsBaseException() { + throwsBaseException(); +} diff --git a/apps/cli/fixtures/legacy/exceptions/lib/src/functions/throwing.dart b/apps/cli/fixtures/legacy/exceptions/lib/src/functions/throwing.dart new file mode 100644 index 000000000..98f6e88df --- /dev/null +++ b/apps/cli/fixtures/legacy/exceptions/lib/src/functions/throwing.dart @@ -0,0 +1,22 @@ +import 'package:celest/celest.dart'; +import 'package:celest_backend/exceptions/exceptions.dart'; + +@cloud +void throwsCustomError() { + throw CustomError('message'); +} + +@cloud +void throwsBaseError() { + throw BaseError('message'); +} + +@cloud +void throwsCustomException() { + throw CustomException('message'); +} + +@cloud +void throwsBaseException() { + throw BaseException('message'); +} diff --git a/apps/cli/fixtures/legacy/exceptions/lib/src/generated/cloud.celest.dart b/apps/cli/fixtures/legacy/exceptions/lib/src/generated/cloud.celest.dart new file mode 100644 index 000000000..f1a89c399 --- /dev/null +++ b/apps/cli/fixtures/legacy/exceptions/lib/src/generated/cloud.celest.dart @@ -0,0 +1,45 @@ +// Generated by Celest. This file should not be modified manually, but +// it can be checked into version control. +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +library; + +import 'package:celest/src/core/context.dart'; +import 'package:celest_backend/src/generated/config.celest.dart'; + +/// The interface to your Celest backend. +/// +/// Similar to the `celest` global in the frontend, this +/// provides access to the backend environment and services +/// configured for your project. +const CelestCloud celest = CelestCloud._(); + +/// A per-request context object which propogates request information and common +/// accessors to the Celest server environment. +CelestContext get context => CelestContext._(context); + +/// The interface to your Celest backend. +/// +/// Similar to the `Celest` class in the frontend, this class +/// provides access to the backend environment and services +/// configured for your project. +class CelestCloud { + const CelestCloud._(); + + /// The current environment of the Celest service. + /// + /// This is determined by the `CELEST_ENVIRONMENT` variable + /// which is set for you by the deployment environment. + CelestEnvironment get currentEnvironment => + (variables.currentEnvironment as CelestEnvironment); + + /// The variables of the Celest service. + /// + /// This class provides access to the values configured for the + /// [currentEnvironment]. + CelestVariables get variables => const CelestVariables(); +} + +/// A per-request context object which propogates request information and common +/// accessors to the Celest server environment. +extension type CelestContext._(Context _context) implements Context {} diff --git a/apps/cli/fixtures/legacy/exceptions/lib/src/generated/config.celest.dart b/apps/cli/fixtures/legacy/exceptions/lib/src/generated/config.celest.dart new file mode 100644 index 000000000..687b9f186 --- /dev/null +++ b/apps/cli/fixtures/legacy/exceptions/lib/src/generated/config.celest.dart @@ -0,0 +1,45 @@ +// Generated by Celest. This file should not be modified manually, but +// it can be checked into version control. +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +library; + +import 'package:celest/celest.dart'; +import 'package:celest/src/core/context.dart'; + +/// An environment of a deployed Celest service. +/// +/// Celest services can have multiple isolated branches, for example +/// a `development` and `production` environment. +extension type const CelestEnvironment._(String _env) + implements Environment, String { + /// The local Celest environment, used to delineate when a + /// Celest service is running on a developer machine as opposed + /// to the cloud. + static const CelestEnvironment local = CelestEnvironment._('local'); + + /// The production Celest environment which is common to all + /// Celest projects and labels the environment which is considered + /// live and served to end-users. + static const CelestEnvironment production = CelestEnvironment._('production'); + + /// Whether `this` represents the [local] environment. + bool get isLocal => this == local; + + /// Whether `this` represents the [production] environment. + bool get isProduction => this == production; +} + +/// The environment variables for the Celest service. +/// +/// This class provides access to the environment variable values +/// that are configured for the current [CelestEnvironment]. +class CelestVariables { + const CelestVariables(); + + /// The environment variable that determines the current environment. + /// + /// This is set by the deployment environment and is used to + /// determine the current environment of the Celest service. + String get currentEnvironment => context.expect(env.environment); +} diff --git a/apps/cli/fixtures/legacy/exceptions/lib/src/project.dart b/apps/cli/fixtures/legacy/exceptions/lib/src/project.dart new file mode 100644 index 000000000..789309a23 --- /dev/null +++ b/apps/cli/fixtures/legacy/exceptions/lib/src/project.dart @@ -0,0 +1,3 @@ +import 'package:celest/celest.dart'; + +const project = Project(name: 'exceptions'); diff --git a/apps/cli/fixtures/legacy/exceptions/pubspec.yaml b/apps/cli/fixtures/legacy/exceptions/pubspec.yaml new file mode 100644 index 000000000..bec67c0b5 --- /dev/null +++ b/apps/cli/fixtures/legacy/exceptions/pubspec.yaml @@ -0,0 +1,32 @@ +name: celest_backend +publish_to: none + +environment: + sdk: ^3.4.0 + +dependencies: + _common: + path: ../_common + celest: ^1.0.0 + celest_core: ^1.0.0 + meta: ^1.12.0 + +dependency_overrides: + cedar: + path: ../../../../../cedar/packages/cedar + celest: + path: ../../../../../celest/packages/celest + celest_ast: + path: ../../../../../celest/packages/celest_ast + celest_auth: + path: ../../../../../celest/packages/celest_auth + celest_cloud: + path: ../../../../../celest/packages/celest_cloud + celest_cloud_auth: + path: ../../../../../celest/services/celest_cloud_auth + celest_core: + path: ../../../../../celest/packages/celest_core + +dev_dependencies: + lints: ^4.0.0 + test: ^1.25.0 diff --git a/apps/cli/fixtures/legacy/firebase/.firebaserc b/apps/cli/fixtures/legacy/firebase/.firebaserc new file mode 100644 index 000000000..e704dfedb --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/.firebaserc @@ -0,0 +1,8 @@ +{ + "projects": { + "dev": "prj-d-firebase-test", + "nonprod": "prj-n-firebase-test" + }, + "targets": {}, + "etags": {} +} \ No newline at end of file diff --git a/apps/cli/fixtures/legacy/firebase/.gitignore b/apps/cli/fixtures/legacy/firebase/.gitignore new file mode 100644 index 000000000..29a3a5017 --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/.gitignore @@ -0,0 +1,43 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ +migrate_working_dir/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +**/doc/api/ +**/ios/Flutter/.last_build_id +.dart_tool/ +.flutter-plugins +.flutter-plugins-dependencies +.pub-cache/ +.pub/ +/build/ + +# Symbolication related +app.*.symbols + +# Obfuscation related +app.*.map.json + +# Android Studio will place build artifacts here +/android/app/debug +/android/app/profile +/android/app/release diff --git a/apps/cli/fixtures/legacy/firebase/.metadata b/apps/cli/fixtures/legacy/firebase/.metadata new file mode 100644 index 000000000..2d1be89a7 --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/.metadata @@ -0,0 +1,45 @@ +# This file tracks properties of this Flutter project. +# Used by Flutter tool to assess capabilities and perform upgrades etc. +# +# This file should be version controlled and should not be manually edited. + +version: + revision: "2663184aa79047d0a33a14a3b607954f8fdd8730" + channel: "stable" + +project_type: app + +# Tracks metadata for the flutter migrate command +migration: + platforms: + - platform: root + create_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730 + base_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730 + - platform: android + create_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730 + base_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730 + - platform: ios + create_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730 + base_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730 + - platform: linux + create_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730 + base_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730 + - platform: macos + create_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730 + base_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730 + - platform: web + create_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730 + base_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730 + - platform: windows + create_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730 + base_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730 + + # User provided section + + # List of Local paths (relative to this file) that should be + # ignored by the migrate tool. + # + # Files that are not part of the templates will be ignored by default. + unmanaged_files: + - 'lib/main.dart' + - 'ios/Runner.xcodeproj/project.pbxproj' diff --git a/apps/cli/fixtures/legacy/firebase/README.md b/apps/cli/fixtures/legacy/firebase/README.md new file mode 100644 index 000000000..003d859bb --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/README.md @@ -0,0 +1,16 @@ +# firebase_test + +A new Flutter project. + +## Getting Started + +This project is a starting point for a Flutter application. + +A few resources to get you started if this is your first Flutter project: + +- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab) +- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook) + +For help getting started with Flutter development, view the +[online documentation](https://docs.flutter.dev/), which offers tutorials, +samples, guidance on mobile development, and a full API reference. diff --git a/apps/cli/fixtures/legacy/firebase/analysis_options.yaml b/apps/cli/fixtures/legacy/firebase/analysis_options.yaml new file mode 100644 index 000000000..ac83d24fe --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/analysis_options.yaml @@ -0,0 +1,32 @@ +# This file configures the analyzer, which statically analyzes Dart code to +# check for errors, warnings, and lints. +# +# The issues identified by the analyzer are surfaced in the UI of Dart-enabled +# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be +# invoked from the command line by running `flutter analyze`. + +# The following line activates a set of recommended lints for Flutter apps, +# packages, and plugins designed to encourage good coding practices. +include: package:flutter_lints/flutter.yaml + +linter: + # The lint rules applied to this project can be customized in the + # section below to disable rules from the `package:flutter_lints/flutter.yaml` + # included above or to enable additional rules. A list of all available lints + # and their documentation is published at https://dart.dev/lints. + # + # Instead of disabling a lint rule for the entire project in the + # section below, it can also be suppressed for a single line of code + # or a specific dart file by using the `// ignore: name_of_lint` and + # `// ignore_for_file: name_of_lint` syntax on the line or in the file + # producing the lint. + rules: + # avoid_print: false # Uncomment to disable the `avoid_print` rule + # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule + +# Additional information about this file can be found at +# https://dart.dev/guides/language/analysis-options + +analyzer: + plugins: + - celest diff --git a/apps/cli/fixtures/legacy/firebase/android/.gitignore b/apps/cli/fixtures/legacy/firebase/android/.gitignore new file mode 100644 index 000000000..55afd919c --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/android/.gitignore @@ -0,0 +1,13 @@ +gradle-wrapper.jar +/.gradle +/captures/ +/gradlew +/gradlew.bat +/local.properties +GeneratedPluginRegistrant.java + +# Remember to never publicly share your keystore. +# See https://flutter.dev/to/reference-keystore +key.properties +**/*.keystore +**/*.jks diff --git a/apps/cli/fixtures/legacy/firebase/android/app/build.gradle b/apps/cli/fixtures/legacy/firebase/android/app/build.gradle new file mode 100644 index 000000000..8887997ca --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/android/app/build.gradle @@ -0,0 +1,44 @@ +plugins { + id "com.android.application" + id "kotlin-android" + // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins. + id "dev.flutter.flutter-gradle-plugin" +} + +android { + namespace = "dev.celest.firebase_test" + compileSdk = flutter.compileSdkVersion + ndkVersion = flutter.ndkVersion + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } + + kotlinOptions { + jvmTarget = JavaVersion.VERSION_1_8 + } + + defaultConfig { + // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). + applicationId = "dev.celest.firebase_test" + // You can update the following values to match your application needs. + // For more information, see: https://flutter.dev/to/review-gradle-config. + minSdk = flutter.minSdkVersion + targetSdk = flutter.targetSdkVersion + versionCode = flutter.versionCode + versionName = flutter.versionName + } + + buildTypes { + release { + // TODO: Add your own signing config for the release build. + // Signing with the debug keys for now, so `flutter run --release` works. + signingConfig = signingConfigs.debug + } + } +} + +flutter { + source = "../.." +} diff --git a/apps/cli/fixtures/legacy/firebase/android/app/src/main/AndroidManifest.xml b/apps/cli/fixtures/legacy/firebase/android/app/src/main/AndroidManifest.xml new file mode 100644 index 000000000..787476532 --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/android/app/src/main/AndroidManifest.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/apps/cli/fixtures/legacy/firebase/android/app/src/main/kotlin/dev/celest/firebase_test/MainActivity.kt b/apps/cli/fixtures/legacy/firebase/android/app/src/main/kotlin/dev/celest/firebase_test/MainActivity.kt new file mode 100644 index 000000000..ed056ed79 --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/android/app/src/main/kotlin/dev/celest/firebase_test/MainActivity.kt @@ -0,0 +1,5 @@ +package dev.celest.firebase_test + +import io.flutter.embedding.android.FlutterActivity + +class MainActivity: FlutterActivity() diff --git a/apps/cli/fixtures/legacy/firebase/android/app/src/main/res/drawable-v21/launch_background.xml b/apps/cli/fixtures/legacy/firebase/android/app/src/main/res/drawable-v21/launch_background.xml new file mode 100644 index 000000000..f74085f3f --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/android/app/src/main/res/drawable-v21/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/apps/cli/fixtures/legacy/firebase/android/app/src/main/res/drawable/launch_background.xml b/apps/cli/fixtures/legacy/firebase/android/app/src/main/res/drawable/launch_background.xml new file mode 100644 index 000000000..304732f88 --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/android/app/src/main/res/drawable/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/apps/cli/fixtures/legacy/firebase/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/apps/cli/fixtures/legacy/firebase/android/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 000000000..db77bb4b7 Binary files /dev/null and b/apps/cli/fixtures/legacy/firebase/android/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/apps/cli/fixtures/legacy/firebase/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/apps/cli/fixtures/legacy/firebase/android/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 000000000..17987b79b Binary files /dev/null and b/apps/cli/fixtures/legacy/firebase/android/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/apps/cli/fixtures/legacy/firebase/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/apps/cli/fixtures/legacy/firebase/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 000000000..09d439148 Binary files /dev/null and b/apps/cli/fixtures/legacy/firebase/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/apps/cli/fixtures/legacy/firebase/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/apps/cli/fixtures/legacy/firebase/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 000000000..d5f1c8d34 Binary files /dev/null and b/apps/cli/fixtures/legacy/firebase/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/apps/cli/fixtures/legacy/firebase/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/apps/cli/fixtures/legacy/firebase/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 000000000..4d6372eeb Binary files /dev/null and b/apps/cli/fixtures/legacy/firebase/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/apps/cli/fixtures/legacy/firebase/android/app/src/main/res/values-night/styles.xml b/apps/cli/fixtures/legacy/firebase/android/app/src/main/res/values-night/styles.xml new file mode 100644 index 000000000..06952be74 --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/android/app/src/main/res/values-night/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/apps/cli/fixtures/legacy/firebase/android/app/src/main/res/values/styles.xml b/apps/cli/fixtures/legacy/firebase/android/app/src/main/res/values/styles.xml new file mode 100644 index 000000000..cb1ef8805 --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/android/app/src/main/res/values/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/apps/cli/fixtures/legacy/firebase/android/app/src/profile/AndroidManifest.xml b/apps/cli/fixtures/legacy/firebase/android/app/src/profile/AndroidManifest.xml new file mode 100644 index 000000000..399f6981d --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/android/app/src/profile/AndroidManifest.xml @@ -0,0 +1,7 @@ + + + + diff --git a/apps/cli/fixtures/legacy/firebase/android/build.gradle b/apps/cli/fixtures/legacy/firebase/android/build.gradle new file mode 100644 index 000000000..d2ffbffa4 --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/android/build.gradle @@ -0,0 +1,18 @@ +allprojects { + repositories { + google() + mavenCentral() + } +} + +rootProject.buildDir = "../build" +subprojects { + project.buildDir = "${rootProject.buildDir}/${project.name}" +} +subprojects { + project.evaluationDependsOn(":app") +} + +tasks.register("clean", Delete) { + delete rootProject.buildDir +} diff --git a/apps/cli/fixtures/legacy/firebase/android/gradle.properties b/apps/cli/fixtures/legacy/firebase/android/gradle.properties new file mode 100644 index 000000000..259717082 --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/android/gradle.properties @@ -0,0 +1,3 @@ +org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=2G -XX:+HeapDumpOnOutOfMemoryError +android.useAndroidX=true +android.enableJetifier=true diff --git a/apps/cli/fixtures/legacy/firebase/android/gradle/wrapper/gradle-wrapper.properties b/apps/cli/fixtures/legacy/firebase/android/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 000000000..7bb2df6ba --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/android/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-all.zip diff --git a/apps/cli/fixtures/legacy/firebase/android/settings.gradle b/apps/cli/fixtures/legacy/firebase/android/settings.gradle new file mode 100644 index 000000000..b9e43bd37 --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/android/settings.gradle @@ -0,0 +1,25 @@ +pluginManagement { + def flutterSdkPath = { + def properties = new Properties() + file("local.properties").withInputStream { properties.load(it) } + def flutterSdkPath = properties.getProperty("flutter.sdk") + assert flutterSdkPath != null, "flutter.sdk not set in local.properties" + return flutterSdkPath + }() + + includeBuild("$flutterSdkPath/packages/flutter_tools/gradle") + + repositories { + google() + mavenCentral() + gradlePluginPortal() + } +} + +plugins { + id "dev.flutter.flutter-plugin-loader" version "1.0.0" + id "com.android.application" version "8.1.0" apply false + id "org.jetbrains.kotlin.android" version "1.8.22" apply false +} + +include ":app" diff --git a/apps/cli/fixtures/legacy/firebase/celest/.gitignore b/apps/cli/fixtures/legacy/firebase/celest/.gitignore new file mode 100644 index 000000000..0e877d12c --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/celest/.gitignore @@ -0,0 +1,6 @@ +# Dart +.dart_tool/ +pubspec.lock + +# Celest +**/.env diff --git a/apps/cli/fixtures/legacy/firebase/celest/analysis_options.yaml b/apps/cli/fixtures/legacy/firebase/celest/analysis_options.yaml new file mode 100644 index 000000000..a4f073cc3 --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/celest/analysis_options.yaml @@ -0,0 +1,5 @@ +include: package:lints/recommended.yaml + +analyzer: + errors: + depend_on_referenced_packages: ignore diff --git a/apps/cli/fixtures/legacy/firebase/celest/client/lib/firebase_test_client.dart b/apps/cli/fixtures/legacy/firebase/celest/client/lib/firebase_test_client.dart new file mode 100644 index 000000000..304f4323e --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/celest/client/lib/firebase_test_client.dart @@ -0,0 +1,94 @@ +// Generated by Celest. This file should not be modified manually, but +// it can be checked into version control. +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +library; // ignore_for_file: no_leading_underscores_for_library_prefixes + +import 'dart:async'; +import 'dart:io'; + +import 'package:celest_core/_internal.dart' as _$celest; +import 'package:celest_core/celest_core.dart' as _$celest; +import 'package:celest_core/src/util/globals.dart' as _$celest; +import 'package:firebase_test_client/src/auth.dart'; +import 'package:firebase_test_client/src/functions.dart'; +import 'package:firebase_test_client/src/serializers.dart'; +import 'package:http/http.dart' as _$http_http; +import 'package:native_storage/native_storage.dart' + as _$native_storage_native_storage; + +export 'package:celest_auth/celest_auth.dart'; +export 'package:celest_backend/src/functions/greeting.dart' + show BadNameException, Person; +export 'src/auth.dart'; + +final Celest celest = Celest(); + +enum CelestEnvironment { + local, + production; + + Uri get baseUri => switch (this) { + local => + _$celest.kIsWeb || !Platform.isAndroid + ? Uri.parse('http://localhost:7777') + : Uri.parse('http://10.0.2.2:7777'), + production => Uri.parse('https://example.celest.run'), + }; +} + +class Celest with _$celest.CelestBase { + var _initialized = false; + + late CelestEnvironment _currentEnvironment; + + late final _$native_storage_native_storage.NativeStorage nativeStorage = + _$native_storage_native_storage.NativeStorage(scope: 'celest'); + + @override + late _$http_http.Client httpClient = _$celest.CelestHttpClient( + secureStorage: nativeStorage.secure, + ); + + late Uri _baseUri; + + final _functions = CelestFunctions(); + + late final CelestAuth _auth = CelestAuth(this, storage: nativeStorage); + + T _checkInitialized(T Function() value) { + if (!_initialized) { + throw StateError( + 'Celest has not been initialized. Make sure to call `celest.init()` at the start of your `main` method.', + ); + } + return value(); + } + + CelestEnvironment get currentEnvironment => + _checkInitialized(() => _currentEnvironment); + + @override + Uri get baseUri => _checkInitialized(() => _baseUri); + + CelestFunctions get functions => _checkInitialized(() => _functions); + + CelestAuth get auth => _checkInitialized(() => _auth); + + void init({ + CelestEnvironment environment = CelestEnvironment.local, + _$celest.Serializers? serializers, + ExternalAuth? externalAuth, + }) { + if (_initialized && environment != _currentEnvironment) { + _auth.signOut(); + } + _currentEnvironment = environment; + _baseUri = environment.baseUri; + scheduleMicrotask(() => _auth.init(externalAuth: externalAuth)); + if (!_initialized) { + initSerializers(serializers: serializers); + } + _initialized = true; + } +} diff --git a/apps/cli/fixtures/legacy/firebase/celest/client/lib/src/auth.dart b/apps/cli/fixtures/legacy/firebase/celest/client/lib/src/auth.dart new file mode 100644 index 000000000..48f0d4471 --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/celest/client/lib/src/auth.dart @@ -0,0 +1,53 @@ +// Generated by Celest. This file should not be modified manually, but +// it can be checked into version control. +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +library; // ignore_for_file: no_leading_underscores_for_library_prefixes + +import 'package:celest_auth/celest_auth.dart' as _$celest; +import 'package:celest_auth/src/auth_impl.dart' as _$celest; +import 'package:celest_core/_internal.dart' as _$celest; +import 'package:firebase_auth/firebase_auth.dart' + as _$firebase_auth_firebase_auth; +import 'package:native_storage/native_storage.dart' + as _$native_storage_native_storage; + +extension type CelestAuth._(_$celest.AuthImpl _hub) implements _$celest.Auth { + CelestAuth( + _$celest.CelestBase celest, { + required _$native_storage_native_storage.NativeStorage storage, + }) : _hub = _$celest.AuthImpl(celest, storage: storage); +} + +/// External authentication providers which can be used to sign in to Celest. +/// +/// This class is passed to `celest.init` to configure the token sources for +/// the external auth providers. +class ExternalAuth extends _$celest.TokenSource { + /// {@macro celest_auth.token_source.of} + const ExternalAuth.of({required super.provider, required super.stream}) + : super.of(); + + /// Creates an instance of [ExternalAuth] for Firebase Auth. + /// + /// See the [Firebase docs](https://firebase.google.com/docs/flutter/setup) + /// for more information on how to initialize Firebase. + /// + /// ```dart + /// Future main() async { + /// WidgetsFlutterBinding.ensureInitialized(); + /// await Firebase.initializeApp(); + /// celest.init( + /// externalAuth: ExternalAuth.firebase(FirebaseAuth.instance), + /// ); + /// } + /// ``` + factory ExternalAuth.firebase( + _$firebase_auth_firebase_auth.FirebaseAuth firebase, + ) { + return ExternalAuth.of( + provider: _$celest.AuthProviderType.firebase, + stream: firebase.idTokenChanges().asyncMap((user) => user?.getIdToken()), + ); + } +} diff --git a/apps/cli/fixtures/legacy/firebase/celest/client/lib/src/functions.dart b/apps/cli/fixtures/legacy/firebase/celest/client/lib/src/functions.dart new file mode 100644 index 000000000..686d4e956 --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/celest/client/lib/src/functions.dart @@ -0,0 +1,311 @@ +// Generated by Celest. This file should not be modified manually, but +// it can be checked into version control. +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +library; // ignore_for_file: no_leading_underscores_for_library_prefixes + +import 'dart:async'; +import 'dart:convert'; + +import 'package:celest/celest.dart' as _$celest; +import 'package:celest_backend/src/functions/greeting.dart'; +import 'package:celest_core/celest_core.dart' as _$celest; +import 'package:celest_core/src/exception/cloud_exception.dart' as _$celest; +import 'package:celest_core/src/exception/serialization_exception.dart' + as _$celest; +import 'package:firebase_test_client/firebase_test_client.dart'; + +class CelestFunctions { + final greeting = CelestFunctionsGreeting(); +} + +class CelestFunctionsGreeting { + Never _throwError({int? code, required Map body}) { + final status = body['@status'] as Map?; + final message = status?['message'] as String?; + final details = status?['details'] as _$celest.JsonList?; + final (errorType, errorValue, stackTrace) = switch (details) { + null || [] => const (null, null, StackTrace.empty), + [ + final errorDetails as Map, + { + '@type': 'dart.core.StackTrace', + 'value': final stackTraceValue as String, + }, + ..., + ] => + ( + errorDetails['@type'], + errorDetails['value'], + StackTrace.fromString(stackTraceValue), + ), + [final errorDetails as Map, ...] => ( + errorDetails['@type'], + errorDetails['value'], + StackTrace.empty, + ), + }; + + switch (errorType) { + case 'firebase_test.v1.BadNameException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.CloudException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.CloudException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.CancelledException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.CancelledException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnknownError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.UnknownError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.BadRequestException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.BadRequestException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnauthorizedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.UnauthorizedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.NotFoundException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.NotFoundException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.AlreadyExistsException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.AlreadyExistsException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.PermissionDeniedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.PermissionDeniedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.ResourceExhaustedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.ResourceExhaustedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.FailedPreconditionException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.FailedPreconditionException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.AbortedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.AbortedException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.OutOfRangeException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.OutOfRangeException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnimplementedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.UnimplementedError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.InternalServerError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.InternalServerError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnavailableError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.UnavailableError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.DataLossError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.DataLossError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.DeadlineExceededError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.DeadlineExceededError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.SerializationException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.SerializationException>(errorValue), + stackTrace, + ); + case 'dart.core.Error': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.AssertionError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.TypeError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.ArgumentError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.RangeError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.IndexError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.UnsupportedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.UnimplementedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.StateError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.ConcurrentModificationError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.core.OutOfMemoryError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.StackOverflowError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.Exception': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.FormatException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.IntegerDivisionByZeroException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.async.AsyncError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.async.TimeoutException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.convert.JsonUnsupportedObjectError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + default: + Error.throwWithStackTrace( + _$celest.CloudException.http( + code: code, + message: message, + details: ((details ?? body) as _$celest.JsonValue), + ), + StackTrace.empty, + ); + } + } + + /// Says hello to a [person]. + @_$celest.CloudFunction(api: 'greeting', function: 'sayHello') + Future sayHello({required Person person}) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/greeting/say-hello'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'person': _$celest.Serializers.instance.serialize(person), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return ($body as String); + } +} diff --git a/apps/cli/fixtures/legacy/firebase/celest/client/lib/src/serializers.dart b/apps/cli/fixtures/legacy/firebase/celest/client/lib/src/serializers.dart new file mode 100644 index 000000000..4d2925c0f --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/celest/client/lib/src/serializers.dart @@ -0,0 +1,768 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async'; +import 'dart:convert'; + +import 'package:celest_backend/src/functions/greeting.dart'; +import 'package:celest_core/celest_core.dart' as _$celest; +import 'package:celest_core/src/exception/cloud_exception.dart' as _$celest; +import 'package:celest_core/src/exception/serialization_exception.dart' + as _$celest; +import 'package:celest_core/src/serialization/json_value.dart' as _$celest; + +void initSerializers({_$celest.Serializers? serializers}) { + return runZoned(() { + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _$celest.Serializers.instance + .serialize($value.stackTrace), + }, + deserialize: ($serialized) { + return AsyncError( + $serialized[r'error']!, + _$celest.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_$celest.Serializers.instance.serialize( + $value.duration, + ) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return TimeoutException( + ($serialized[r'message'] as String?), + _$celest.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest + .Serializer.define>( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + ConcurrentModificationError, + Map? + >( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: + ($value) => { + if (_$celest.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return BadNameException(($serialized[r'message'] as String)); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: ($value) => {r'name': $value.name}, + deserialize: ($serialized) { + return Person(name: ($serialized[r'name'] as String)); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest + .Serializer.define<_$celest.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.AbortedException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.AlreadyExistsException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.BadRequestException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.BadRequestException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.CancelledException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.CancelledException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define<_$celest.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.CloudException.fromJson($serialized); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define<_$celest.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.DataLossError( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.DeadlineExceededError, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.InternalServerError, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.InternalServerError( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest + .Serializer.define<_$celest.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.NotFoundException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.OutOfRangeException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.OutOfRangeException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.UnauthorizedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.UnauthorizedException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest + .Serializer.define<_$celest.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.UnavailableError( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.UnimplementedError, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.UnimplementedError( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define<_$celest.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.UnknownError( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.SerializationException, + Map + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define<_$celest.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _$celest.JsonValue($serialized); + }, + ), + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ); + }, zoneValues: {_$celest.Serializers: serializers}); +} diff --git a/apps/cli/fixtures/legacy/firebase/celest/client/pubspec.yaml b/apps/cli/fixtures/legacy/firebase/celest/client/pubspec.yaml new file mode 100644 index 000000000..d81ad5d56 --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/celest/client/pubspec.yaml @@ -0,0 +1,30 @@ +name: firebase_test_client +description: The Celest client for firebase_test. +publish_to: none + +environment: + sdk: ^3.4.0 + +dependencies: + celest: ^1.0.0 + celest_backend: + path: .. + celest_core: ^1.0.0 + firebase_auth: ^5.2.0 + http: ^1.0.0 + native_storage: ^0.2.2 + +dependency_overrides: + celest: + path: ../../../../../../../celest/packages/celest + celest_ast: + path: ../../../../../../../celest/packages/celest_ast + celest_auth: + path: ../../../../../../../celest/packages/celest_auth + celest_cloud: + path: ../../../../../../../celest/packages/celest_cloud + celest_cloud_auth: + path: ../../../../../../../celest/services/celest_cloud_auth + celest_core: + path: ../../../../../../../celest/packages/celest_core +dev_dependencies: {} diff --git a/apps/cli/fixtures/legacy/firebase/celest/goldens/api.local.dart b/apps/cli/fixtures/legacy/firebase/celest/goldens/api.local.dart new file mode 100644 index 000000000..63511db2e --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/celest/goldens/api.local.dart @@ -0,0 +1,18 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'package:celest/src/core/context.dart' as _i3; +import 'package:celest/src/runtime/serve.dart' as _i1; + +import 'functions/greeting/sayHello.dart' as _i2; + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/greeting/say-hello': _i2.SayHelloTarget()}, + setup: (_i3.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/firebase/celest/goldens/ast.json b/apps/cli/fixtures/legacy/firebase/celest/goldens/ast.json new file mode 100644 index 000000000..f58bbf3f7 --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/celest/goldens/ast.json @@ -0,0 +1,462 @@ +{ + "name": "firebase_test", + "environment": "local", + "reference": { + "$": "Reference", + "symbol": "project", + "url": "package:celest_backend/src/project.dart" + }, + "apis": { + "greeting": { + "name": "greeting", + "metadata": [], + "functions": { + "sayHello": { + "name": "sayHello", + "apiName": "greeting", + "typeParameters": [], + "parameters": [ + { + "name": "person", + "type": { + "$": "TypeReference", + "symbol": "Person", + "url": "package:celest_backend/src/functions/greeting.dart", + "isNullable": false + }, + "required": true, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 227, + "uri": "package:celest_backend/src/functions/greeting.dart", + "line": 7, + "column": 41 + }, + "end": { + "offset": 233, + "uri": "package:celest_backend/src/functions/greeting.dart", + "line": 7, + "column": 47 + }, + "text": "person" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "Future", + "url": "dart:async", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [ + "/// Says hello to a [person]." + ], + "location": { + "start": { + "offset": 201, + "uri": "package:celest_backend/src/functions/greeting.dart", + "line": 7, + "column": 15 + }, + "end": { + "offset": 209, + "uri": "package:celest_backend/src/functions/greeting.dart", + "line": 7, + "column": 23 + }, + "text": "sayHello" + } + } + }, + "docs": [], + "exceptionTypes": [ + { + "$": "TypeReference", + "symbol": "BadNameException", + "url": "package:celest_backend/src/functions/greeting.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "CloudException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "CancelledException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnknownError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "BadRequestException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnauthorizedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "NotFoundException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AlreadyExistsException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "PermissionDeniedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ResourceExhaustedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "FailedPreconditionException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AbortedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "OutOfRangeException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnimplementedError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "InternalServerError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnavailableError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "DataLossError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "DeadlineExceededError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "SerializationException", + "url": "package:celest_core/src/exception/serialization_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "Error", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AssertionError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "TypeError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ArgumentError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "RangeError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "IndexError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnsupportedError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnimplementedError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "StateError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ConcurrentModificationError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "OutOfMemoryError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "StackOverflowError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "Exception", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "FormatException", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "IntegerDivisionByZeroException", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AsyncError", + "url": "dart:async", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "TimeoutException", + "url": "dart:async", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "JsonUnsupportedObjectError", + "url": "dart:convert", + "isNullable": false + } + ], + "location": { + "start": { + "offset": 0, + "uri": "package:celest_backend/src/functions/greeting.dart", + "line": 0, + "column": 0 + }, + "end": { + "offset": 0, + "uri": "package:celest_backend/src/functions/greeting.dart", + "line": 0, + "column": 0 + }, + "text": "" + } + } + }, + "variables": [ + { + "location": { + "start": { + "offset": 98, + "uri": "package:celest_backend/src/project.dart", + "line": 6, + "column": 6 + }, + "end": { + "offset": 102, + "uri": "package:celest_backend/src/project.dart", + "line": 6, + "column": 10 + }, + "text": "auth" + }, + "name": "FIREBASE_PROJECT_ID", + "docs": [] + } + ], + "secrets": [], + "databases": {}, + "sdkConfig": { + "celest": "1.0.6+2", + "dart": { + "type": "dart", + "version": "3.29.0", + "enabledExperiments": [] + }, + "targetSdk": "dart", + "featureFlags": [ + "streaming" + ], + "flutter": { + "type": "flutter", + "version": "3.29.0", + "enabledExperiments": [] + } + }, + "location": { + "start": { + "offset": 44, + "uri": "project.dart", + "line": 2, + "column": 6 + }, + "end": { + "offset": 89, + "uri": "project.dart", + "line": 4, + "column": 1 + }, + "text": "project = Project(\n name: 'firebase_test',\n)" + }, + "auth": { + "providers": [], + "externalProviders": [ + { + "$": "FirebaseExternalAuthProvider", + "projectId": { + "location": { + "start": { + "offset": 98, + "uri": "package:celest_backend/src/project.dart", + "line": 6, + "column": 6 + }, + "end": { + "offset": 102, + "uri": "package:celest_backend/src/project.dart", + "line": 6, + "column": 10 + }, + "text": "auth" + }, + "name": "FIREBASE_PROJECT_ID", + "docs": [] + }, + "name": "firebase", + "type": "FIREBASE", + "location": { + "start": { + "offset": 98, + "uri": "package:celest_backend/src/project.dart", + "line": 6, + "column": 6 + }, + "end": { + "offset": 102, + "uri": "package:celest_backend/src/project.dart", + "line": 6, + "column": 10 + }, + "text": "auth" + } + } + ], + "location": { + "start": { + "offset": 98, + "uri": "package:celest_backend/src/project.dart", + "line": 6, + "column": 6 + }, + "end": { + "offset": 102, + "uri": "package:celest_backend/src/project.dart", + "line": 6, + "column": 10 + }, + "text": "auth" + } + } +} \ No newline at end of file diff --git a/apps/cli/fixtures/legacy/firebase/celest/goldens/ast.resolved.json b/apps/cli/fixtures/legacy/firebase/celest/goldens/ast.resolved.json new file mode 100644 index 000000000..a4f6c12a8 --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/celest/goldens/ast.resolved.json @@ -0,0 +1,70 @@ +{ + "projectId": "firebase_test", + "environmentId": "local", + "apis": { + "greeting": { + "apiId": "greeting", + "functions": { + "sayHello": { + "functionId": "sayHello", + "apiId": "greeting", + "httpConfig": { + "route": { + "method": "POST", + "path": "/greeting/say-hello" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + } + } + } + }, + "variables": [ + { + "name": "FIREBASE_PROJECT_ID", + "value": "prj-d-firebase-test" + }, + { + "name": "CELEST_ENVIRONMENT", + "value": "local" + } + ], + "secrets": [], + "databases": {}, + "sdkConfig": { + "celest": "1.0.6+2", + "dart": { + "type": "dart", + "version": "3.29.0", + "enabledExperiments": [] + }, + "targetSdk": "dart", + "featureFlags": [ + "streaming" + ], + "flutter": { + "type": "flutter", + "version": "3.29.0", + "enabledExperiments": [] + } + }, + "auth": { + "providers": [], + "externalProviders": [ + { + "$": "ResolvedFirebaseExternalAuthProvider", + "projectId": { + "name": "FIREBASE_PROJECT_ID", + "value": "prj-d-firebase-test" + }, + "authProviderId": "firebase", + "type": "FIREBASE" + } + ] + } +} \ No newline at end of file diff --git a/apps/cli/fixtures/legacy/firebase/celest/goldens/functions/greeting/sayHello.dart b/apps/cli/fixtures/legacy/firebase/celest/goldens/functions/greeting/sayHello.dart new file mode 100644 index 000000000..5d8fbaa53 --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/celest/goldens/functions/greeting/sayHello.dart @@ -0,0 +1,1732 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i9; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/greeting.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i10; +import 'package:celest_core/src/serialization/json_value.dart' as _i11; +import 'package:shelf/shelf.dart' as _i2; + +final class SayHelloTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'sayHello'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = await _i3.sayHello( + person: _i4.Serializers.instance.deserialize<_i3.Person>( + request[r'person'], + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(response), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i3.BadNameException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'firebase_test.v1.BadNameException', + 'value': _i4.Serializers.instance.serialize<_i3.BadNameException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i9.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i10.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i9.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i3.BadNameException, Map>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return _i3.BadNameException(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i3.Person, Map>( + serialize: ($value) => {r'name': $value.name}, + deserialize: ($serialized) { + return _i3.Person(name: ($serialized[r'name'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i10.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i11.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': SayHelloTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/firebase/celest/lib/fix_data/v1_migration.yaml b/apps/cli/fixtures/legacy/firebase/celest/lib/fix_data/v1_migration.yaml new file mode 100644 index 000000000..90195902a --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/celest/lib/fix_data/v1_migration.yaml @@ -0,0 +1,13 @@ +# Generated by Celest. Do not modify. +version: 1 +transforms: + - title: "Updates the import of the Celest client" + date: 2024-10-06 + element: + uris: ["client.dart"] + variable: celest + changes: + - kind: replacedBy + newElement: + uris: ["package:firebase_test_client/firebase_test_client.dart"] + variable: celest diff --git a/apps/cli/fixtures/legacy/firebase/celest/lib/src/functions/greeting.dart b/apps/cli/fixtures/legacy/firebase/celest/lib/src/functions/greeting.dart new file mode 100644 index 000000000..f2d20aefc --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/celest/lib/src/functions/greeting.dart @@ -0,0 +1,35 @@ +// Cloud functions are top-level Dart functions defined in the `functions/` +// folder of your Celest project. + +import 'package:celest/celest.dart'; + +/// Says hello to a [person]. +@cloud +Future sayHello({required Person person}) async { + if (person.name.isEmpty) { + // Throw a custom exception and catch it on the frontend. + throw BadNameException('Name cannot be empty'); + } + + // Logging is handled automatically when you print to the console. + print('Saying hello to ${person.name}'); + + return 'Hello, ${person.name}!'; +} + +/// A person who can be greeted. +class Person { + const Person({required this.name}); + + final String name; +} + +/// Thrown when a [Person] has an invalid name. +class BadNameException implements Exception { + const BadNameException(this.message); + + final String message; + + @override + String toString() => 'BadNameException: $message'; +} diff --git a/apps/cli/fixtures/legacy/firebase/celest/lib/src/generated/README.md b/apps/cli/fixtures/legacy/firebase/celest/lib/src/generated/README.md new file mode 100644 index 000000000..a5b5cb795 --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/celest/lib/src/generated/README.md @@ -0,0 +1,9 @@ +# Generated Celest code + +This directory contains code generated by the Celest CLI to assist in building +your backend. + +This code can be safely checked into version control, but it should not be +modified directly. + +It is planned to replace this directory with macros when they become stable. diff --git a/apps/cli/fixtures/legacy/firebase/celest/lib/src/generated/cloud.celest.dart b/apps/cli/fixtures/legacy/firebase/celest/lib/src/generated/cloud.celest.dart new file mode 100644 index 000000000..f1a89c399 --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/celest/lib/src/generated/cloud.celest.dart @@ -0,0 +1,45 @@ +// Generated by Celest. This file should not be modified manually, but +// it can be checked into version control. +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +library; + +import 'package:celest/src/core/context.dart'; +import 'package:celest_backend/src/generated/config.celest.dart'; + +/// The interface to your Celest backend. +/// +/// Similar to the `celest` global in the frontend, this +/// provides access to the backend environment and services +/// configured for your project. +const CelestCloud celest = CelestCloud._(); + +/// A per-request context object which propogates request information and common +/// accessors to the Celest server environment. +CelestContext get context => CelestContext._(context); + +/// The interface to your Celest backend. +/// +/// Similar to the `Celest` class in the frontend, this class +/// provides access to the backend environment and services +/// configured for your project. +class CelestCloud { + const CelestCloud._(); + + /// The current environment of the Celest service. + /// + /// This is determined by the `CELEST_ENVIRONMENT` variable + /// which is set for you by the deployment environment. + CelestEnvironment get currentEnvironment => + (variables.currentEnvironment as CelestEnvironment); + + /// The variables of the Celest service. + /// + /// This class provides access to the values configured for the + /// [currentEnvironment]. + CelestVariables get variables => const CelestVariables(); +} + +/// A per-request context object which propogates request information and common +/// accessors to the Celest server environment. +extension type CelestContext._(Context _context) implements Context {} diff --git a/apps/cli/fixtures/legacy/firebase/celest/lib/src/generated/config.celest.dart b/apps/cli/fixtures/legacy/firebase/celest/lib/src/generated/config.celest.dart new file mode 100644 index 000000000..e7d49cd17 --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/celest/lib/src/generated/config.celest.dart @@ -0,0 +1,49 @@ +// Generated by Celest. This file should not be modified manually, but +// it can be checked into version control. +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +library; + +import 'package:celest/celest.dart'; +import 'package:celest/src/core/context.dart'; + +/// An environment of a deployed Celest service. +/// +/// Celest services can have multiple isolated branches, for example +/// a `development` and `production` environment. +extension type const CelestEnvironment._(String _env) + implements Environment, String { + /// The local Celest environment, used to delineate when a + /// Celest service is running on a developer machine as opposed + /// to the cloud. + static const CelestEnvironment local = CelestEnvironment._('local'); + + /// The production Celest environment which is common to all + /// Celest projects and labels the environment which is considered + /// live and served to end-users. + static const CelestEnvironment production = CelestEnvironment._('production'); + + /// Whether `this` represents the [local] environment. + bool get isLocal => this == local; + + /// Whether `this` represents the [production] environment. + bool get isProduction => this == production; +} + +/// The environment variables for the Celest service. +/// +/// This class provides access to the environment variable values +/// that are configured for the current [CelestEnvironment]. +class CelestVariables { + const CelestVariables(); + + /// The environment variable that determines the current environment. + /// + /// This is set by the deployment environment and is used to + /// determine the current environment of the Celest service. + String get currentEnvironment => context.expect(env.environment); + + /// The value of the `FIREBASE_PROJECT_ID` environment variable. + String get firebaseProjectId => + context.expect(const env('FIREBASE_PROJECT_ID')); +} diff --git a/apps/cli/fixtures/legacy/firebase/celest/lib/src/project.dart b/apps/cli/fixtures/legacy/firebase/celest/lib/src/project.dart new file mode 100644 index 000000000..4406273dc --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/celest/lib/src/project.dart @@ -0,0 +1,11 @@ +import 'package:celest/celest.dart'; + +const project = Project( + name: 'firebase_test', +); + +const auth = Auth( + providers: [ + ExternalAuthProvider.firebase(), + ], +); diff --git a/apps/cli/fixtures/legacy/firebase/celest/pubspec.yaml b/apps/cli/fixtures/legacy/firebase/celest/pubspec.yaml new file mode 100644 index 000000000..ac87d1014 --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/celest/pubspec.yaml @@ -0,0 +1,31 @@ +name: celest_backend +description: The Celest backend for firebase_test. +publish_to: none + +environment: + sdk: ^3.4.0 + +dependencies: + celest: ^1.0.0 + celest_core: ^1.0.0 + meta: ^1.12.0 + +dependency_overrides: + cedar: + path: ../../../../../../cedar/packages/cedar + celest: + path: ../../../../../../celest/packages/celest + celest_ast: + path: ../../../../../../celest/packages/celest_ast + celest_auth: + path: ../../../../../../celest/packages/celest_auth + celest_cloud: + path: ../../../../../../celest/packages/celest_cloud + celest_cloud_auth: + path: ../../../../../../celest/services/celest_cloud_auth + celest_core: + path: ../../../../../../celest/packages/celest_core + +dev_dependencies: + lints: ^4.0.0 + test: ^1.25.0 diff --git a/apps/cli/fixtures/legacy/firebase/firebase.json b/apps/cli/fixtures/legacy/firebase/firebase.json new file mode 100644 index 000000000..16b211cc2 --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/firebase.json @@ -0,0 +1 @@ +{"flutter":{"platforms":{"dart":{"lib/firebase_options_dev.dart":{"projectId":"prj-d-firebase-test","configurations":{"web":"1:447767341722:web:2f018b95ea2ca005e20d23","windows":"1:447767341722:web:8cf866f5d8ce560be20d23"}},"lib/firebase_options_nonprod.dart":{"projectId":"prj-n-firebase-test","configurations":{"web":"1:438379435794:web:ed76b1dc03c053fc1245cb","windows":"1:438379435794:web:d47feb696c86b9f91245cb"}}}}}} \ No newline at end of file diff --git a/apps/cli/fixtures/legacy/firebase/ios/.gitignore b/apps/cli/fixtures/legacy/firebase/ios/.gitignore new file mode 100644 index 000000000..7a7f9873a --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/ios/.gitignore @@ -0,0 +1,34 @@ +**/dgph +*.mode1v3 +*.mode2v3 +*.moved-aside +*.pbxuser +*.perspectivev3 +**/*sync/ +.sconsign.dblite +.tags* +**/.vagrant/ +**/DerivedData/ +Icon? +**/Pods/ +**/.symlinks/ +profile +xcuserdata +**/.generated/ +Flutter/App.framework +Flutter/Flutter.framework +Flutter/Flutter.podspec +Flutter/Generated.xcconfig +Flutter/ephemeral/ +Flutter/app.flx +Flutter/app.zip +Flutter/flutter_assets/ +Flutter/flutter_export_environment.sh +ServiceDefinitions.json +Runner/GeneratedPluginRegistrant.* + +# Exceptions to above rules. +!default.mode1v3 +!default.mode2v3 +!default.pbxuser +!default.perspectivev3 diff --git a/apps/cli/fixtures/legacy/firebase/ios/Flutter/AppFrameworkInfo.plist b/apps/cli/fixtures/legacy/firebase/ios/Flutter/AppFrameworkInfo.plist new file mode 100644 index 000000000..7c5696400 --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/ios/Flutter/AppFrameworkInfo.plist @@ -0,0 +1,26 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + App + CFBundleIdentifier + io.flutter.flutter.app + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + App + CFBundlePackageType + FMWK + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1.0 + MinimumOSVersion + 12.0 + + diff --git a/apps/cli/fixtures/legacy/firebase/ios/Flutter/Debug.xcconfig b/apps/cli/fixtures/legacy/firebase/ios/Flutter/Debug.xcconfig new file mode 100644 index 000000000..ec97fc6f3 --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/ios/Flutter/Debug.xcconfig @@ -0,0 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" +#include "Generated.xcconfig" diff --git a/apps/cli/fixtures/legacy/firebase/ios/Flutter/Release.xcconfig b/apps/cli/fixtures/legacy/firebase/ios/Flutter/Release.xcconfig new file mode 100644 index 000000000..c4855bfe2 --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/ios/Flutter/Release.xcconfig @@ -0,0 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" +#include "Generated.xcconfig" diff --git a/apps/cli/fixtures/legacy/firebase/ios/Podfile b/apps/cli/fixtures/legacy/firebase/ios/Podfile new file mode 100644 index 000000000..d97f17e22 --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/ios/Podfile @@ -0,0 +1,44 @@ +# Uncomment this line to define a global platform for your project +# platform :ios, '12.0' + +# CocoaPods analytics sends network stats synchronously affecting flutter build latency. +ENV['COCOAPODS_DISABLE_STATS'] = 'true' + +project 'Runner', { + 'Debug' => :debug, + 'Profile' => :release, + 'Release' => :release, +} + +def flutter_root + generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) + unless File.exist?(generated_xcode_build_settings_path) + raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" + end + + File.foreach(generated_xcode_build_settings_path) do |line| + matches = line.match(/FLUTTER_ROOT\=(.*)/) + return matches[1].strip if matches + end + raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" +end + +require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) + +flutter_ios_podfile_setup + +target 'Runner' do + use_frameworks! + use_modular_headers! + + flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) + target 'RunnerTests' do + inherit! :search_paths + end +end + +post_install do |installer| + installer.pods_project.targets.each do |target| + flutter_additional_ios_build_settings(target) + end +end diff --git a/apps/cli/fixtures/legacy/firebase/ios/Runner.xcodeproj/project.pbxproj b/apps/cli/fixtures/legacy/firebase/ios/Runner.xcodeproj/project.pbxproj new file mode 100644 index 000000000..5dcb0148f --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/ios/Runner.xcodeproj/project.pbxproj @@ -0,0 +1,619 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 54; + objects = { + +/* Begin PBXBuildFile section */ + 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; + 331C808B294A63AB00263BE5 /* RunnerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 331C807B294A618700263BE5 /* RunnerTests.swift */; }; + 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; + 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; }; + 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; + 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; + 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 331C8085294A63A400263BE5 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 97C146E61CF9000F007C117D /* Project object */; + proxyType = 1; + remoteGlobalIDString = 97C146ED1CF9000F007C117D; + remoteInfo = Runner; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 9705A1C41CF9048500538489 /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; + 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; + 331C807B294A618700263BE5 /* RunnerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunnerTests.swift; sourceTree = ""; }; + 331C8081294A63A400263BE5 /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; + 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; }; + 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; + 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; + 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; + 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 97C146EB1CF9000F007C117D /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 331C8082294A63A400263BE5 /* RunnerTests */ = { + isa = PBXGroup; + children = ( + 331C807B294A618700263BE5 /* RunnerTests.swift */, + ); + path = RunnerTests; + sourceTree = ""; + }; + 9740EEB11CF90186004384FC /* Flutter */ = { + isa = PBXGroup; + children = ( + 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */, + 9740EEB21CF90195004384FC /* Debug.xcconfig */, + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, + 9740EEB31CF90195004384FC /* Generated.xcconfig */, + ); + name = Flutter; + sourceTree = ""; + }; + 97C146E51CF9000F007C117D = { + isa = PBXGroup; + children = ( + 9740EEB11CF90186004384FC /* Flutter */, + 97C146F01CF9000F007C117D /* Runner */, + 97C146EF1CF9000F007C117D /* Products */, + 331C8082294A63A400263BE5 /* RunnerTests */, + ); + sourceTree = ""; + }; + 97C146EF1CF9000F007C117D /* Products */ = { + isa = PBXGroup; + children = ( + 97C146EE1CF9000F007C117D /* Runner.app */, + 331C8081294A63A400263BE5 /* RunnerTests.xctest */, + ); + name = Products; + sourceTree = ""; + }; + 97C146F01CF9000F007C117D /* Runner */ = { + isa = PBXGroup; + children = ( + 97C146FA1CF9000F007C117D /* Main.storyboard */, + 97C146FD1CF9000F007C117D /* Assets.xcassets */, + 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */, + 97C147021CF9000F007C117D /* Info.plist */, + 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */, + 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */, + 74858FAE1ED2DC5600515810 /* AppDelegate.swift */, + 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */, + ); + path = Runner; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 331C8080294A63A400263BE5 /* RunnerTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 331C8087294A63A400263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */; + buildPhases = ( + 331C807D294A63A400263BE5 /* Sources */, + 331C807F294A63A400263BE5 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + 331C8086294A63A400263BE5 /* PBXTargetDependency */, + ); + name = RunnerTests; + productName = RunnerTests; + productReference = 331C8081294A63A400263BE5 /* RunnerTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; + 97C146ED1CF9000F007C117D /* Runner */ = { + isa = PBXNativeTarget; + buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; + buildPhases = ( + 9740EEB61CF901F6004384FC /* Run Script */, + 97C146EA1CF9000F007C117D /* Sources */, + 97C146EB1CF9000F007C117D /* Frameworks */, + 97C146EC1CF9000F007C117D /* Resources */, + 9705A1C41CF9048500538489 /* Embed Frameworks */, + 3B06AD1E1E4923F5004D2608 /* Thin Binary */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = Runner; + productName = Runner; + productReference = 97C146EE1CF9000F007C117D /* Runner.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 97C146E61CF9000F007C117D /* Project object */ = { + isa = PBXProject; + attributes = { + BuildIndependentTargetsInParallel = YES; + LastUpgradeCheck = 1510; + ORGANIZATIONNAME = ""; + TargetAttributes = { + 331C8080294A63A400263BE5 = { + CreatedOnToolsVersion = 14.0; + TestTargetID = 97C146ED1CF9000F007C117D; + }; + 97C146ED1CF9000F007C117D = { + CreatedOnToolsVersion = 7.3.1; + LastSwiftMigration = 1100; + }; + }; + }; + buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 97C146E51CF9000F007C117D; + productRefGroup = 97C146EF1CF9000F007C117D /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 97C146ED1CF9000F007C117D /* Runner */, + 331C8080294A63A400263BE5 /* RunnerTests */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 331C807F294A63A400263BE5 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 97C146EC1CF9000F007C117D /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */, + 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */, + 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */, + 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { + isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}", + ); + name = "Thin Binary"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin"; + }; + 9740EEB61CF901F6004384FC /* Run Script */ = { + isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Run Script"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 331C807D294A63A400263BE5 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 331C808B294A63AB00263BE5 /* RunnerTests.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 97C146EA1CF9000F007C117D /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */, + 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 331C8086294A63A400263BE5 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 97C146ED1CF9000F007C117D /* Runner */; + targetProxy = 331C8085294A63A400263BE5 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin PBXVariantGroup section */ + 97C146FA1CF9000F007C117D /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 97C146FB1CF9000F007C117D /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 97C147001CF9000F007C117D /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 249021D3217E4FDB00AE95B9 /* Profile */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_USER_SCRIPT_SANDBOXING = NO; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + SUPPORTED_PLATFORMS = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Profile; + }; + 249021D4217E4FDB00AE95B9 /* Profile */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + DEVELOPMENT_TEAM = 3N44X5LWWW; + ENABLE_BITCODE = NO; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = dev.celest.firebaseTest; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; + SWIFT_VERSION = 5.0; + VERSIONING_SYSTEM = "apple-generic"; + }; + name = Profile; + }; + 331C8088294A63A400263BE5 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = dev.celest.firebaseTest.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner"; + }; + name = Debug; + }; + 331C8089294A63A400263BE5 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = dev.celest.firebaseTest.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner"; + }; + name = Release; + }; + 331C808A294A63A400263BE5 /* Profile */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = dev.celest.firebaseTest.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner"; + }; + name = Profile; + }; + 97C147031CF9000F007C117D /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + ENABLE_USER_SCRIPT_SANDBOXING = NO; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 97C147041CF9000F007C117D /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_USER_SCRIPT_SANDBOXING = NO; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + SUPPORTED_PLATFORMS = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 97C147061CF9000F007C117D /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + DEVELOPMENT_TEAM = 3N44X5LWWW; + ENABLE_BITCODE = NO; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = dev.celest.firebaseTest; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; + VERSIONING_SYSTEM = "apple-generic"; + }; + name = Debug; + }; + 97C147071CF9000F007C117D /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + DEVELOPMENT_TEAM = 3N44X5LWWW; + ENABLE_BITCODE = NO; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = dev.celest.firebaseTest; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; + SWIFT_VERSION = 5.0; + VERSIONING_SYSTEM = "apple-generic"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 331C8087294A63A400263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 331C8088294A63A400263BE5 /* Debug */, + 331C8089294A63A400263BE5 /* Release */, + 331C808A294A63A400263BE5 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 97C147031CF9000F007C117D /* Debug */, + 97C147041CF9000F007C117D /* Release */, + 249021D3217E4FDB00AE95B9 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 97C147061CF9000F007C117D /* Debug */, + 97C147071CF9000F007C117D /* Release */, + 249021D4217E4FDB00AE95B9 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 97C146E61CF9000F007C117D /* Project object */; +} diff --git a/apps/cli/fixtures/legacy/firebase/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/apps/cli/fixtures/legacy/firebase/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 000000000..919434a62 --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/apps/cli/fixtures/legacy/firebase/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/apps/cli/fixtures/legacy/firebase/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 000000000..18d981003 --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/apps/cli/fixtures/legacy/firebase/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/apps/cli/fixtures/legacy/firebase/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings new file mode 100644 index 000000000..f9b0d7c5e --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings @@ -0,0 +1,8 @@ + + + + + PreviewsEnabled + + + diff --git a/apps/cli/fixtures/legacy/firebase/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/apps/cli/fixtures/legacy/firebase/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme new file mode 100644 index 000000000..8e3ca5dfe --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -0,0 +1,98 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/apps/cli/fixtures/legacy/firebase/ios/Runner.xcworkspace/contents.xcworkspacedata b/apps/cli/fixtures/legacy/firebase/ios/Runner.xcworkspace/contents.xcworkspacedata new file mode 100644 index 000000000..1d526a16e --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/ios/Runner.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/apps/cli/fixtures/legacy/firebase/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/apps/cli/fixtures/legacy/firebase/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 000000000..18d981003 --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/apps/cli/fixtures/legacy/firebase/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/apps/cli/fixtures/legacy/firebase/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings new file mode 100644 index 000000000..f9b0d7c5e --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings @@ -0,0 +1,8 @@ + + + + + PreviewsEnabled + + + diff --git a/apps/cli/fixtures/legacy/firebase/ios/Runner/AppDelegate.swift b/apps/cli/fixtures/legacy/firebase/ios/Runner/AppDelegate.swift new file mode 100644 index 000000000..626664468 --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/ios/Runner/AppDelegate.swift @@ -0,0 +1,13 @@ +import Flutter +import UIKit + +@main +@objc class AppDelegate: FlutterAppDelegate { + override func application( + _ application: UIApplication, + didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? + ) -> Bool { + GeneratedPluginRegistrant.register(with: self) + return super.application(application, didFinishLaunchingWithOptions: launchOptions) + } +} diff --git a/apps/cli/fixtures/legacy/firebase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json b/apps/cli/fixtures/legacy/firebase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 000000000..d36b1fab2 --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,122 @@ +{ + "images" : [ + { + "size" : "20x20", + "idiom" : "iphone", + "filename" : "Icon-App-20x20@2x.png", + "scale" : "2x" + }, + { + "size" : "20x20", + "idiom" : "iphone", + "filename" : "Icon-App-20x20@3x.png", + "scale" : "3x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-App-29x29@1x.png", + "scale" : "1x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-App-29x29@2x.png", + "scale" : "2x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-App-29x29@3x.png", + "scale" : "3x" + }, + { + "size" : "40x40", + "idiom" : "iphone", + "filename" : "Icon-App-40x40@2x.png", + "scale" : "2x" + }, + { + "size" : "40x40", + "idiom" : "iphone", + "filename" : "Icon-App-40x40@3x.png", + "scale" : "3x" + }, + { + "size" : "60x60", + "idiom" : "iphone", + "filename" : "Icon-App-60x60@2x.png", + "scale" : "2x" + }, + { + "size" : "60x60", + "idiom" : "iphone", + "filename" : "Icon-App-60x60@3x.png", + "scale" : "3x" + }, + { + "size" : "20x20", + "idiom" : "ipad", + "filename" : "Icon-App-20x20@1x.png", + "scale" : "1x" + }, + { + "size" : "20x20", + "idiom" : "ipad", + "filename" : "Icon-App-20x20@2x.png", + "scale" : "2x" + }, + { + "size" : "29x29", + "idiom" : "ipad", + "filename" : "Icon-App-29x29@1x.png", + "scale" : "1x" + }, + { + "size" : "29x29", + "idiom" : "ipad", + "filename" : "Icon-App-29x29@2x.png", + "scale" : "2x" + }, + { + "size" : "40x40", + "idiom" : "ipad", + "filename" : "Icon-App-40x40@1x.png", + "scale" : "1x" + }, + { + "size" : "40x40", + "idiom" : "ipad", + "filename" : "Icon-App-40x40@2x.png", + "scale" : "2x" + }, + { + "size" : "76x76", + "idiom" : "ipad", + "filename" : "Icon-App-76x76@1x.png", + "scale" : "1x" + }, + { + "size" : "76x76", + "idiom" : "ipad", + "filename" : "Icon-App-76x76@2x.png", + "scale" : "2x" + }, + { + "size" : "83.5x83.5", + "idiom" : "ipad", + "filename" : "Icon-App-83.5x83.5@2x.png", + "scale" : "2x" + }, + { + "size" : "1024x1024", + "idiom" : "ios-marketing", + "filename" : "Icon-App-1024x1024@1x.png", + "scale" : "1x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} diff --git a/apps/cli/fixtures/legacy/firebase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png b/apps/cli/fixtures/legacy/firebase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png new file mode 100644 index 000000000..dc9ada472 Binary files /dev/null and b/apps/cli/fixtures/legacy/firebase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png differ diff --git a/apps/cli/fixtures/legacy/firebase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png b/apps/cli/fixtures/legacy/firebase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png new file mode 100644 index 000000000..7353c41ec Binary files /dev/null and b/apps/cli/fixtures/legacy/firebase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png differ diff --git a/apps/cli/fixtures/legacy/firebase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png b/apps/cli/fixtures/legacy/firebase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png new file mode 100644 index 000000000..797d452e4 Binary files /dev/null and b/apps/cli/fixtures/legacy/firebase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png differ diff --git a/apps/cli/fixtures/legacy/firebase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png b/apps/cli/fixtures/legacy/firebase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png new file mode 100644 index 000000000..6ed2d933e Binary files /dev/null and b/apps/cli/fixtures/legacy/firebase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png differ diff --git a/apps/cli/fixtures/legacy/firebase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png b/apps/cli/fixtures/legacy/firebase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png new file mode 100644 index 000000000..4cd7b0099 Binary files /dev/null and b/apps/cli/fixtures/legacy/firebase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png differ diff --git a/apps/cli/fixtures/legacy/firebase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png b/apps/cli/fixtures/legacy/firebase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png new file mode 100644 index 000000000..fe730945a Binary files /dev/null and b/apps/cli/fixtures/legacy/firebase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png differ diff --git a/apps/cli/fixtures/legacy/firebase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png b/apps/cli/fixtures/legacy/firebase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png new file mode 100644 index 000000000..321773cd8 Binary files /dev/null and b/apps/cli/fixtures/legacy/firebase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png differ diff --git a/apps/cli/fixtures/legacy/firebase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png b/apps/cli/fixtures/legacy/firebase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png new file mode 100644 index 000000000..797d452e4 Binary files /dev/null and b/apps/cli/fixtures/legacy/firebase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png differ diff --git a/apps/cli/fixtures/legacy/firebase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png b/apps/cli/fixtures/legacy/firebase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png new file mode 100644 index 000000000..502f463a9 Binary files /dev/null and b/apps/cli/fixtures/legacy/firebase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png differ diff --git a/apps/cli/fixtures/legacy/firebase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png b/apps/cli/fixtures/legacy/firebase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png new file mode 100644 index 000000000..0ec303439 Binary files /dev/null and b/apps/cli/fixtures/legacy/firebase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png differ diff --git a/apps/cli/fixtures/legacy/firebase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png b/apps/cli/fixtures/legacy/firebase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png new file mode 100644 index 000000000..0ec303439 Binary files /dev/null and b/apps/cli/fixtures/legacy/firebase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png differ diff --git a/apps/cli/fixtures/legacy/firebase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png b/apps/cli/fixtures/legacy/firebase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png new file mode 100644 index 000000000..e9f5fea27 Binary files /dev/null and b/apps/cli/fixtures/legacy/firebase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png differ diff --git a/apps/cli/fixtures/legacy/firebase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png b/apps/cli/fixtures/legacy/firebase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png new file mode 100644 index 000000000..84ac32ae7 Binary files /dev/null and b/apps/cli/fixtures/legacy/firebase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png differ diff --git a/apps/cli/fixtures/legacy/firebase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png b/apps/cli/fixtures/legacy/firebase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png new file mode 100644 index 000000000..8953cba09 Binary files /dev/null and b/apps/cli/fixtures/legacy/firebase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png differ diff --git a/apps/cli/fixtures/legacy/firebase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png b/apps/cli/fixtures/legacy/firebase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png new file mode 100644 index 000000000..0467bf12a Binary files /dev/null and b/apps/cli/fixtures/legacy/firebase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png differ diff --git a/apps/cli/fixtures/legacy/firebase/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json b/apps/cli/fixtures/legacy/firebase/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json new file mode 100644 index 000000000..0bedcf2fd --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "LaunchImage.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "LaunchImage@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "LaunchImage@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} diff --git a/apps/cli/fixtures/legacy/firebase/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png b/apps/cli/fixtures/legacy/firebase/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png new file mode 100644 index 000000000..9da19eaca Binary files /dev/null and b/apps/cli/fixtures/legacy/firebase/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png differ diff --git a/apps/cli/fixtures/legacy/firebase/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png b/apps/cli/fixtures/legacy/firebase/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png new file mode 100644 index 000000000..9da19eaca Binary files /dev/null and b/apps/cli/fixtures/legacy/firebase/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png differ diff --git a/apps/cli/fixtures/legacy/firebase/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png b/apps/cli/fixtures/legacy/firebase/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png new file mode 100644 index 000000000..9da19eaca Binary files /dev/null and b/apps/cli/fixtures/legacy/firebase/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png differ diff --git a/apps/cli/fixtures/legacy/firebase/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md b/apps/cli/fixtures/legacy/firebase/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md new file mode 100644 index 000000000..89c2725b7 --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md @@ -0,0 +1,5 @@ +# Launch Screen Assets + +You can customize the launch screen with your own desired assets by replacing the image files in this directory. + +You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images. \ No newline at end of file diff --git a/apps/cli/fixtures/legacy/firebase/ios/Runner/Base.lproj/LaunchScreen.storyboard b/apps/cli/fixtures/legacy/firebase/ios/Runner/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 000000000..f2e259c7c --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/ios/Runner/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/apps/cli/fixtures/legacy/firebase/ios/Runner/Base.lproj/Main.storyboard b/apps/cli/fixtures/legacy/firebase/ios/Runner/Base.lproj/Main.storyboard new file mode 100644 index 000000000..f3c28516f --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/ios/Runner/Base.lproj/Main.storyboard @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/apps/cli/fixtures/legacy/firebase/ios/Runner/Info.plist b/apps/cli/fixtures/legacy/firebase/ios/Runner/Info.plist new file mode 100644 index 000000000..fc220576d --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/ios/Runner/Info.plist @@ -0,0 +1,49 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleDisplayName + Firebase Test + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + firebase_test + CFBundlePackageType + APPL + CFBundleShortVersionString + $(FLUTTER_BUILD_NAME) + CFBundleSignature + ???? + CFBundleVersion + $(FLUTTER_BUILD_NUMBER) + LSRequiresIPhoneOS + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + CADisableMinimumFrameDurationOnPhone + + UIApplicationSupportsIndirectInputEvents + + + diff --git a/apps/cli/fixtures/legacy/firebase/ios/Runner/Runner-Bridging-Header.h b/apps/cli/fixtures/legacy/firebase/ios/Runner/Runner-Bridging-Header.h new file mode 100644 index 000000000..308a2a560 --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/ios/Runner/Runner-Bridging-Header.h @@ -0,0 +1 @@ +#import "GeneratedPluginRegistrant.h" diff --git a/apps/cli/fixtures/legacy/firebase/ios/RunnerTests/RunnerTests.swift b/apps/cli/fixtures/legacy/firebase/ios/RunnerTests/RunnerTests.swift new file mode 100644 index 000000000..86a7c3b1b --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/ios/RunnerTests/RunnerTests.swift @@ -0,0 +1,12 @@ +import Flutter +import UIKit +import XCTest + +class RunnerTests: XCTestCase { + + func testExample() { + // If you add code to the Runner application, consider adding tests here. + // See https://developer.apple.com/documentation/xctest for more information about using XCTest. + } + +} diff --git a/apps/cli/fixtures/legacy/firebase/lib/firebase_options_dev.dart b/apps/cli/fixtures/legacy/firebase/lib/firebase_options_dev.dart new file mode 100644 index 000000000..2d7e49354 --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/lib/firebase_options_dev.dart @@ -0,0 +1,71 @@ +// File generated by FlutterFire CLI. +// ignore_for_file: type=lint +import 'package:firebase_core/firebase_core.dart' show FirebaseOptions; +import 'package:flutter/foundation.dart' + show defaultTargetPlatform, kIsWeb, TargetPlatform; + +/// Default [FirebaseOptions] for use with your Firebase apps. +/// +/// Example: +/// ```dart +/// import 'firebase_options_dev.dart'; +/// // ... +/// await Firebase.initializeApp( +/// options: DefaultFirebaseOptions.currentPlatform, +/// ); +/// ``` +class DefaultFirebaseOptions { + static FirebaseOptions get currentPlatform { + if (kIsWeb) { + return web; + } + switch (defaultTargetPlatform) { + case TargetPlatform.android: + throw UnsupportedError( + 'DefaultFirebaseOptions have not been configured for android - ' + 'you can reconfigure this by running the FlutterFire CLI again.', + ); + case TargetPlatform.iOS: + throw UnsupportedError( + 'DefaultFirebaseOptions have not been configured for ios - ' + 'you can reconfigure this by running the FlutterFire CLI again.', + ); + case TargetPlatform.macOS: + throw UnsupportedError( + 'DefaultFirebaseOptions have not been configured for macos - ' + 'you can reconfigure this by running the FlutterFire CLI again.', + ); + case TargetPlatform.windows: + return windows; + case TargetPlatform.linux: + throw UnsupportedError( + 'DefaultFirebaseOptions have not been configured for linux - ' + 'you can reconfigure this by running the FlutterFire CLI again.', + ); + default: + throw UnsupportedError( + 'DefaultFirebaseOptions are not supported for this platform.', + ); + } + } + + static const FirebaseOptions web = FirebaseOptions( + apiKey: 'AIzaSyB0IJtPk1Agkm0QTINukmHhdi3b5rWPEc4', + appId: '1:447767341722:web:2f018b95ea2ca005e20d23', + messagingSenderId: '447767341722', + projectId: 'prj-d-firebase-test', + authDomain: 'prj-d-firebase-test.firebaseapp.com', + storageBucket: 'prj-d-firebase-test.appspot.com', + measurementId: 'G-2C8DVB2PDL', + ); + + static const FirebaseOptions windows = FirebaseOptions( + apiKey: 'AIzaSyB0IJtPk1Agkm0QTINukmHhdi3b5rWPEc4', + appId: '1:447767341722:web:8cf866f5d8ce560be20d23', + messagingSenderId: '447767341722', + projectId: 'prj-d-firebase-test', + authDomain: 'prj-d-firebase-test.firebaseapp.com', + storageBucket: 'prj-d-firebase-test.appspot.com', + measurementId: 'G-R77M376X79', + ); +} diff --git a/apps/cli/fixtures/legacy/firebase/lib/firebase_options_nonprod.dart b/apps/cli/fixtures/legacy/firebase/lib/firebase_options_nonprod.dart new file mode 100644 index 000000000..7c8c2ddd2 --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/lib/firebase_options_nonprod.dart @@ -0,0 +1,71 @@ +// File generated by FlutterFire CLI. +// ignore_for_file: type=lint +import 'package:firebase_core/firebase_core.dart' show FirebaseOptions; +import 'package:flutter/foundation.dart' + show defaultTargetPlatform, kIsWeb, TargetPlatform; + +/// Default [FirebaseOptions] for use with your Firebase apps. +/// +/// Example: +/// ```dart +/// import 'firebase_options_nonprod.dart'; +/// // ... +/// await Firebase.initializeApp( +/// options: DefaultFirebaseOptions.currentPlatform, +/// ); +/// ``` +class DefaultFirebaseOptions { + static FirebaseOptions get currentPlatform { + if (kIsWeb) { + return web; + } + switch (defaultTargetPlatform) { + case TargetPlatform.android: + throw UnsupportedError( + 'DefaultFirebaseOptions have not been configured for android - ' + 'you can reconfigure this by running the FlutterFire CLI again.', + ); + case TargetPlatform.iOS: + throw UnsupportedError( + 'DefaultFirebaseOptions have not been configured for ios - ' + 'you can reconfigure this by running the FlutterFire CLI again.', + ); + case TargetPlatform.macOS: + throw UnsupportedError( + 'DefaultFirebaseOptions have not been configured for macos - ' + 'you can reconfigure this by running the FlutterFire CLI again.', + ); + case TargetPlatform.windows: + return windows; + case TargetPlatform.linux: + throw UnsupportedError( + 'DefaultFirebaseOptions have not been configured for linux - ' + 'you can reconfigure this by running the FlutterFire CLI again.', + ); + default: + throw UnsupportedError( + 'DefaultFirebaseOptions are not supported for this platform.', + ); + } + } + + static const FirebaseOptions web = FirebaseOptions( + apiKey: 'AIzaSyCGs_3veghdRI10PSIlkv-wyFwXCxr9ndo', + appId: '1:438379435794:web:ed76b1dc03c053fc1245cb', + messagingSenderId: '438379435794', + projectId: 'prj-n-firebase-test', + authDomain: 'prj-n-firebase-test.firebaseapp.com', + storageBucket: 'prj-n-firebase-test.appspot.com', + measurementId: 'G-SG5Q1CZ9VY', + ); + + static const FirebaseOptions windows = FirebaseOptions( + apiKey: 'AIzaSyCGs_3veghdRI10PSIlkv-wyFwXCxr9ndo', + appId: '1:438379435794:web:d47feb696c86b9f91245cb', + messagingSenderId: '438379435794', + projectId: 'prj-n-firebase-test', + authDomain: 'prj-n-firebase-test.firebaseapp.com', + storageBucket: 'prj-n-firebase-test.appspot.com', + measurementId: 'G-N4MBCYTJZ5', + ); +} diff --git a/apps/cli/fixtures/legacy/firebase/lib/main.dart b/apps/cli/fixtures/legacy/firebase/lib/main.dart new file mode 100644 index 000000000..1aaff3615 --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/lib/main.dart @@ -0,0 +1,77 @@ +import 'package:firebase_auth/firebase_auth.dart'; +import 'package:firebase_core/firebase_core.dart'; +import 'package:firebase_test_client/firebase_test_client.dart'; +import 'package:flutter/material.dart'; + +Future main() async { + WidgetsFlutterBinding.ensureInitialized(); + await Firebase.initializeApp(); + celest.init( + externalAuth: ExternalAuth.firebase(FirebaseAuth.instance), + ); + runApp(const MyApp()); +} + +class MyApp extends StatelessWidget { + const MyApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + title: 'Flutter Demo', + theme: ThemeData( + colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple), + useMaterial3: true, + ), + home: const MyHomePage(title: 'Flutter Demo Home Page'), + ); + } +} + +class MyHomePage extends StatefulWidget { + const MyHomePage({super.key, required this.title}); + + final String title; + + @override + State createState() => _MyHomePageState(); +} + +class _MyHomePageState extends State { + int _counter = 0; + + void _incrementCounter() { + setState(() { + _counter++; + }); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + backgroundColor: Theme.of(context).colorScheme.inversePrimary, + title: Text(widget.title), + ), + body: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const Text( + 'You have pushed the button this many times:', + ), + Text( + '$_counter', + style: Theme.of(context).textTheme.headlineMedium, + ), + ], + ), + ), + floatingActionButton: FloatingActionButton( + onPressed: _incrementCounter, + tooltip: 'Increment', + child: const Icon(Icons.add), + ), + ); + } +} diff --git a/apps/cli/fixtures/legacy/firebase/linux/.gitignore b/apps/cli/fixtures/legacy/firebase/linux/.gitignore new file mode 100644 index 000000000..d3896c984 --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/linux/.gitignore @@ -0,0 +1 @@ +flutter/ephemeral diff --git a/apps/cli/fixtures/legacy/firebase/linux/CMakeLists.txt b/apps/cli/fixtures/legacy/firebase/linux/CMakeLists.txt new file mode 100644 index 000000000..b2ce5f2fa --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/linux/CMakeLists.txt @@ -0,0 +1,145 @@ +# Project-level configuration. +cmake_minimum_required(VERSION 3.10) +project(runner LANGUAGES CXX) + +# The name of the executable created for the application. Change this to change +# the on-disk name of your application. +set(BINARY_NAME "firebase_test") +# The unique GTK application identifier for this application. See: +# https://wiki.gnome.org/HowDoI/ChooseApplicationID +set(APPLICATION_ID "dev.celest.firebase_test") + +# Explicitly opt in to modern CMake behaviors to avoid warnings with recent +# versions of CMake. +cmake_policy(SET CMP0063 NEW) + +# Load bundled libraries from the lib/ directory relative to the binary. +set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") + +# Root filesystem for cross-building. +if(FLUTTER_TARGET_PLATFORM_SYSROOT) + set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT}) + set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT}) + set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) + set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) + set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) + set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +endif() + +# Define build configuration options. +if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + set(CMAKE_BUILD_TYPE "Debug" CACHE + STRING "Flutter build mode" FORCE) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS + "Debug" "Profile" "Release") +endif() + +# Compilation settings that should be applied to most targets. +# +# Be cautious about adding new options here, as plugins use this function by +# default. In most cases, you should add new options to specific targets instead +# of modifying this function. +function(APPLY_STANDARD_SETTINGS TARGET) + target_compile_features(${TARGET} PUBLIC cxx_std_14) + target_compile_options(${TARGET} PRIVATE -Wall -Werror) + target_compile_options(${TARGET} PRIVATE "$<$>:-O3>") + target_compile_definitions(${TARGET} PRIVATE "$<$>:NDEBUG>") +endfunction() + +# Flutter library and tool build rules. +set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") +add_subdirectory(${FLUTTER_MANAGED_DIR}) + +# System-level dependencies. +find_package(PkgConfig REQUIRED) +pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) + +add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}") + +# Define the application target. To change its name, change BINARY_NAME above, +# not the value here, or `flutter run` will no longer work. +# +# Any new source files that you add to the application should be added here. +add_executable(${BINARY_NAME} + "main.cc" + "my_application.cc" + "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" +) + +# Apply the standard set of build settings. This can be removed for applications +# that need different build settings. +apply_standard_settings(${BINARY_NAME}) + +# Add dependency libraries. Add any application-specific dependencies here. +target_link_libraries(${BINARY_NAME} PRIVATE flutter) +target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK) + +# Run the Flutter tool portions of the build. This must not be removed. +add_dependencies(${BINARY_NAME} flutter_assemble) + +# Only the install-generated bundle's copy of the executable will launch +# correctly, since the resources must in the right relative locations. To avoid +# people trying to run the unbundled copy, put it in a subdirectory instead of +# the default top-level location. +set_target_properties(${BINARY_NAME} + PROPERTIES + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run" +) + + +# Generated plugin build rules, which manage building the plugins and adding +# them to the application. +include(flutter/generated_plugins.cmake) + + +# === Installation === +# By default, "installing" just makes a relocatable bundle in the build +# directory. +set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") +if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) +endif() + +# Start with a clean build bundle directory every time. +install(CODE " + file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") + " COMPONENT Runtime) + +set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") +set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") + +install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" + COMPONENT Runtime) + +install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" + COMPONENT Runtime) + +install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) + +foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES}) + install(FILES "${bundled_library}" + DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) +endforeach(bundled_library) + +# Copy the native assets provided by the build.dart from all packages. +set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/linux/") +install(DIRECTORY "${NATIVE_ASSETS_DIR}" + DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) + +# Fully re-copy the assets directory on each build to avoid having stale files +# from a previous install. +set(FLUTTER_ASSET_DIR_NAME "flutter_assets") +install(CODE " + file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") + " COMPONENT Runtime) +install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" + DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) + +# Install the AOT library on non-Debug builds only. +if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") + install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) +endif() diff --git a/apps/cli/fixtures/legacy/firebase/linux/flutter/CMakeLists.txt b/apps/cli/fixtures/legacy/firebase/linux/flutter/CMakeLists.txt new file mode 100644 index 000000000..d5bd01648 --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/linux/flutter/CMakeLists.txt @@ -0,0 +1,88 @@ +# This file controls Flutter-level build steps. It should not be edited. +cmake_minimum_required(VERSION 3.10) + +set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") + +# Configuration provided via flutter tool. +include(${EPHEMERAL_DIR}/generated_config.cmake) + +# TODO: Move the rest of this into files in ephemeral. See +# https://github.com/flutter/flutter/issues/57146. + +# Serves the same purpose as list(TRANSFORM ... PREPEND ...), +# which isn't available in 3.10. +function(list_prepend LIST_NAME PREFIX) + set(NEW_LIST "") + foreach(element ${${LIST_NAME}}) + list(APPEND NEW_LIST "${PREFIX}${element}") + endforeach(element) + set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE) +endfunction() + +# === Flutter Library === +# System-level dependencies. +find_package(PkgConfig REQUIRED) +pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) +pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0) +pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0) + +set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so") + +# Published to parent scope for install step. +set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) +set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) +set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) +set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE) + +list(APPEND FLUTTER_LIBRARY_HEADERS + "fl_basic_message_channel.h" + "fl_binary_codec.h" + "fl_binary_messenger.h" + "fl_dart_project.h" + "fl_engine.h" + "fl_json_message_codec.h" + "fl_json_method_codec.h" + "fl_message_codec.h" + "fl_method_call.h" + "fl_method_channel.h" + "fl_method_codec.h" + "fl_method_response.h" + "fl_plugin_registrar.h" + "fl_plugin_registry.h" + "fl_standard_message_codec.h" + "fl_standard_method_codec.h" + "fl_string_codec.h" + "fl_value.h" + "fl_view.h" + "flutter_linux.h" +) +list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/") +add_library(flutter INTERFACE) +target_include_directories(flutter INTERFACE + "${EPHEMERAL_DIR}" +) +target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}") +target_link_libraries(flutter INTERFACE + PkgConfig::GTK + PkgConfig::GLIB + PkgConfig::GIO +) +add_dependencies(flutter flutter_assemble) + +# === Flutter tool backend === +# _phony_ is a non-existent file to force this command to run every time, +# since currently there's no way to get a full input/output list from the +# flutter tool. +add_custom_command( + OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} + ${CMAKE_CURRENT_BINARY_DIR}/_phony_ + COMMAND ${CMAKE_COMMAND} -E env + ${FLUTTER_TOOL_ENVIRONMENT} + "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh" + ${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE} + VERBATIM +) +add_custom_target(flutter_assemble DEPENDS + "${FLUTTER_LIBRARY}" + ${FLUTTER_LIBRARY_HEADERS} +) diff --git a/apps/cli/fixtures/legacy/firebase/linux/flutter/generated_plugin_registrant.cc b/apps/cli/fixtures/legacy/firebase/linux/flutter/generated_plugin_registrant.cc new file mode 100644 index 000000000..e71a16d23 --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/linux/flutter/generated_plugin_registrant.cc @@ -0,0 +1,11 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#include "generated_plugin_registrant.h" + + +void fl_register_plugins(FlPluginRegistry* registry) { +} diff --git a/apps/cli/fixtures/legacy/firebase/linux/flutter/generated_plugin_registrant.h b/apps/cli/fixtures/legacy/firebase/linux/flutter/generated_plugin_registrant.h new file mode 100644 index 000000000..e0f0a47bc --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/linux/flutter/generated_plugin_registrant.h @@ -0,0 +1,15 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#ifndef GENERATED_PLUGIN_REGISTRANT_ +#define GENERATED_PLUGIN_REGISTRANT_ + +#include + +// Registers Flutter plugins. +void fl_register_plugins(FlPluginRegistry* registry); + +#endif // GENERATED_PLUGIN_REGISTRANT_ diff --git a/apps/cli/fixtures/legacy/firebase/linux/flutter/generated_plugins.cmake b/apps/cli/fixtures/legacy/firebase/linux/flutter/generated_plugins.cmake new file mode 100644 index 000000000..be1ee3e5b --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/linux/flutter/generated_plugins.cmake @@ -0,0 +1,24 @@ +# +# Generated file, do not edit. +# + +list(APPEND FLUTTER_PLUGIN_LIST +) + +list(APPEND FLUTTER_FFI_PLUGIN_LIST + jni +) + +set(PLUGIN_BUNDLED_LIBRARIES) + +foreach(plugin ${FLUTTER_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin}) + target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) + list(APPEND PLUGIN_BUNDLED_LIBRARIES $) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) +endforeach(plugin) + +foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin}) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) +endforeach(ffi_plugin) diff --git a/apps/cli/fixtures/legacy/firebase/linux/main.cc b/apps/cli/fixtures/legacy/firebase/linux/main.cc new file mode 100644 index 000000000..e7c5c5437 --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/linux/main.cc @@ -0,0 +1,6 @@ +#include "my_application.h" + +int main(int argc, char** argv) { + g_autoptr(MyApplication) app = my_application_new(); + return g_application_run(G_APPLICATION(app), argc, argv); +} diff --git a/apps/cli/fixtures/legacy/firebase/linux/my_application.cc b/apps/cli/fixtures/legacy/firebase/linux/my_application.cc new file mode 100644 index 000000000..91892ae84 --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/linux/my_application.cc @@ -0,0 +1,124 @@ +#include "my_application.h" + +#include +#ifdef GDK_WINDOWING_X11 +#include +#endif + +#include "flutter/generated_plugin_registrant.h" + +struct _MyApplication { + GtkApplication parent_instance; + char** dart_entrypoint_arguments; +}; + +G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION) + +// Implements GApplication::activate. +static void my_application_activate(GApplication* application) { + MyApplication* self = MY_APPLICATION(application); + GtkWindow* window = + GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application))); + + // Use a header bar when running in GNOME as this is the common style used + // by applications and is the setup most users will be using (e.g. Ubuntu + // desktop). + // If running on X and not using GNOME then just use a traditional title bar + // in case the window manager does more exotic layout, e.g. tiling. + // If running on Wayland assume the header bar will work (may need changing + // if future cases occur). + gboolean use_header_bar = TRUE; +#ifdef GDK_WINDOWING_X11 + GdkScreen* screen = gtk_window_get_screen(window); + if (GDK_IS_X11_SCREEN(screen)) { + const gchar* wm_name = gdk_x11_screen_get_window_manager_name(screen); + if (g_strcmp0(wm_name, "GNOME Shell") != 0) { + use_header_bar = FALSE; + } + } +#endif + if (use_header_bar) { + GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new()); + gtk_widget_show(GTK_WIDGET(header_bar)); + gtk_header_bar_set_title(header_bar, "firebase_test"); + gtk_header_bar_set_show_close_button(header_bar, TRUE); + gtk_window_set_titlebar(window, GTK_WIDGET(header_bar)); + } else { + gtk_window_set_title(window, "firebase_test"); + } + + gtk_window_set_default_size(window, 1280, 720); + gtk_widget_show(GTK_WIDGET(window)); + + g_autoptr(FlDartProject) project = fl_dart_project_new(); + fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments); + + FlView* view = fl_view_new(project); + gtk_widget_show(GTK_WIDGET(view)); + gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view)); + + fl_register_plugins(FL_PLUGIN_REGISTRY(view)); + + gtk_widget_grab_focus(GTK_WIDGET(view)); +} + +// Implements GApplication::local_command_line. +static gboolean my_application_local_command_line(GApplication* application, gchar*** arguments, int* exit_status) { + MyApplication* self = MY_APPLICATION(application); + // Strip out the first argument as it is the binary name. + self->dart_entrypoint_arguments = g_strdupv(*arguments + 1); + + g_autoptr(GError) error = nullptr; + if (!g_application_register(application, nullptr, &error)) { + g_warning("Failed to register: %s", error->message); + *exit_status = 1; + return TRUE; + } + + g_application_activate(application); + *exit_status = 0; + + return TRUE; +} + +// Implements GApplication::startup. +static void my_application_startup(GApplication* application) { + //MyApplication* self = MY_APPLICATION(object); + + // Perform any actions required at application startup. + + G_APPLICATION_CLASS(my_application_parent_class)->startup(application); +} + +// Implements GApplication::shutdown. +static void my_application_shutdown(GApplication* application) { + //MyApplication* self = MY_APPLICATION(object); + + // Perform any actions required at application shutdown. + + G_APPLICATION_CLASS(my_application_parent_class)->shutdown(application); +} + +// Implements GObject::dispose. +static void my_application_dispose(GObject* object) { + MyApplication* self = MY_APPLICATION(object); + g_clear_pointer(&self->dart_entrypoint_arguments, g_strfreev); + G_OBJECT_CLASS(my_application_parent_class)->dispose(object); +} + +static void my_application_class_init(MyApplicationClass* klass) { + G_APPLICATION_CLASS(klass)->activate = my_application_activate; + G_APPLICATION_CLASS(klass)->local_command_line = my_application_local_command_line; + G_APPLICATION_CLASS(klass)->startup = my_application_startup; + G_APPLICATION_CLASS(klass)->shutdown = my_application_shutdown; + G_OBJECT_CLASS(klass)->dispose = my_application_dispose; +} + +static void my_application_init(MyApplication* self) {} + +MyApplication* my_application_new() { + return MY_APPLICATION(g_object_new(my_application_get_type(), + "application-id", APPLICATION_ID, + "flags", G_APPLICATION_NON_UNIQUE, + nullptr)); +} diff --git a/apps/cli/fixtures/legacy/firebase/linux/my_application.h b/apps/cli/fixtures/legacy/firebase/linux/my_application.h new file mode 100644 index 000000000..72271d5e4 --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/linux/my_application.h @@ -0,0 +1,18 @@ +#ifndef FLUTTER_MY_APPLICATION_H_ +#define FLUTTER_MY_APPLICATION_H_ + +#include + +G_DECLARE_FINAL_TYPE(MyApplication, my_application, MY, APPLICATION, + GtkApplication) + +/** + * my_application_new: + * + * Creates a new Flutter-based application. + * + * Returns: a new #MyApplication. + */ +MyApplication* my_application_new(); + +#endif // FLUTTER_MY_APPLICATION_H_ diff --git a/apps/cli/fixtures/legacy/firebase/macos/.gitignore b/apps/cli/fixtures/legacy/firebase/macos/.gitignore new file mode 100644 index 000000000..746adbb6b --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/macos/.gitignore @@ -0,0 +1,7 @@ +# Flutter-related +**/Flutter/ephemeral/ +**/Pods/ + +# Xcode-related +**/dgph +**/xcuserdata/ diff --git a/apps/cli/fixtures/legacy/firebase/macos/Flutter/Flutter-Debug.xcconfig b/apps/cli/fixtures/legacy/firebase/macos/Flutter/Flutter-Debug.xcconfig new file mode 100644 index 000000000..4b81f9b2d --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/macos/Flutter/Flutter-Debug.xcconfig @@ -0,0 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" +#include "ephemeral/Flutter-Generated.xcconfig" diff --git a/apps/cli/fixtures/legacy/firebase/macos/Flutter/Flutter-Release.xcconfig b/apps/cli/fixtures/legacy/firebase/macos/Flutter/Flutter-Release.xcconfig new file mode 100644 index 000000000..5caa9d157 --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/macos/Flutter/Flutter-Release.xcconfig @@ -0,0 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" +#include "ephemeral/Flutter-Generated.xcconfig" diff --git a/apps/cli/fixtures/legacy/firebase/macos/Flutter/GeneratedPluginRegistrant.swift b/apps/cli/fixtures/legacy/firebase/macos/Flutter/GeneratedPluginRegistrant.swift new file mode 100644 index 000000000..7b9be2038 --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/macos/Flutter/GeneratedPluginRegistrant.swift @@ -0,0 +1,14 @@ +// +// Generated file. Do not edit. +// + +import FlutterMacOS +import Foundation + +import firebase_auth +import firebase_core + +func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { + FLTFirebaseAuthPlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseAuthPlugin")) + FLTFirebaseCorePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseCorePlugin")) +} diff --git a/apps/cli/fixtures/legacy/firebase/macos/Podfile b/apps/cli/fixtures/legacy/firebase/macos/Podfile new file mode 100644 index 000000000..c795730db --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/macos/Podfile @@ -0,0 +1,43 @@ +platform :osx, '10.14' + +# CocoaPods analytics sends network stats synchronously affecting flutter build latency. +ENV['COCOAPODS_DISABLE_STATS'] = 'true' + +project 'Runner', { + 'Debug' => :debug, + 'Profile' => :release, + 'Release' => :release, +} + +def flutter_root + generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__) + unless File.exist?(generated_xcode_build_settings_path) + raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first" + end + + File.foreach(generated_xcode_build_settings_path) do |line| + matches = line.match(/FLUTTER_ROOT\=(.*)/) + return matches[1].strip if matches + end + raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\"" +end + +require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) + +flutter_macos_podfile_setup + +target 'Runner' do + use_frameworks! + use_modular_headers! + + flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__)) + target 'RunnerTests' do + inherit! :search_paths + end +end + +post_install do |installer| + installer.pods_project.targets.each do |target| + flutter_additional_macos_build_settings(target) + end +end diff --git a/apps/cli/fixtures/legacy/firebase/macos/Runner.xcodeproj/project.pbxproj b/apps/cli/fixtures/legacy/firebase/macos/Runner.xcodeproj/project.pbxproj new file mode 100644 index 000000000..c2632e598 --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/macos/Runner.xcodeproj/project.pbxproj @@ -0,0 +1,705 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 54; + objects = { + +/* Begin PBXAggregateTarget section */ + 33CC111A2044C6BA0003C045 /* Flutter Assemble */ = { + isa = PBXAggregateTarget; + buildConfigurationList = 33CC111B2044C6BA0003C045 /* Build configuration list for PBXAggregateTarget "Flutter Assemble" */; + buildPhases = ( + 33CC111E2044C6BF0003C045 /* ShellScript */, + ); + dependencies = ( + ); + name = "Flutter Assemble"; + productName = FLX; + }; +/* End PBXAggregateTarget section */ + +/* Begin PBXBuildFile section */ + 331C80D8294CF71000263BE5 /* RunnerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 331C80D7294CF71000263BE5 /* RunnerTests.swift */; }; + 335BBD1B22A9A15E00E9071D /* GeneratedPluginRegistrant.swift in Sources */ = {isa = PBXBuildFile; fileRef = 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */; }; + 33CC10F12044A3C60003C045 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC10F02044A3C60003C045 /* AppDelegate.swift */; }; + 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F22044A3C60003C045 /* Assets.xcassets */; }; + 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F42044A3C60003C045 /* MainMenu.xib */; }; + 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 331C80D9294CF71000263BE5 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 33CC10E52044A3C60003C045 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 33CC10EC2044A3C60003C045; + remoteInfo = Runner; + }; + 33CC111F2044C79F0003C045 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 33CC10E52044A3C60003C045 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 33CC111A2044C6BA0003C045; + remoteInfo = FLX; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 33CC110E2044A8840003C045 /* Bundle Framework */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + ); + name = "Bundle Framework"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 331C80D5294CF71000263BE5 /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + 331C80D7294CF71000263BE5 /* RunnerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunnerTests.swift; sourceTree = ""; }; + 333000ED22D3DE5D00554162 /* Warnings.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Warnings.xcconfig; sourceTree = ""; }; + 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GeneratedPluginRegistrant.swift; sourceTree = ""; }; + 33CC10ED2044A3C60003C045 /* firebase_test.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "firebase_test.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + 33CC10F02044A3C60003C045 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 33CC10F22044A3C60003C045 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Assets.xcassets; path = Runner/Assets.xcassets; sourceTree = ""; }; + 33CC10F52044A3C60003C045 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = ""; }; + 33CC10F72044A3C60003C045 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Info.plist; path = Runner/Info.plist; sourceTree = ""; }; + 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainFlutterWindow.swift; sourceTree = ""; }; + 33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Debug.xcconfig"; sourceTree = ""; }; + 33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Release.xcconfig"; sourceTree = ""; }; + 33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = "Flutter-Generated.xcconfig"; path = "ephemeral/Flutter-Generated.xcconfig"; sourceTree = ""; }; + 33E51913231747F40026EE4D /* DebugProfile.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = DebugProfile.entitlements; sourceTree = ""; }; + 33E51914231749380026EE4D /* Release.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = Release.entitlements; sourceTree = ""; }; + 33E5194F232828860026EE4D /* AppInfo.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = AppInfo.xcconfig; sourceTree = ""; }; + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = ""; }; + 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 331C80D2294CF70F00263BE5 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 33CC10EA2044A3C60003C045 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 331C80D6294CF71000263BE5 /* RunnerTests */ = { + isa = PBXGroup; + children = ( + 331C80D7294CF71000263BE5 /* RunnerTests.swift */, + ); + path = RunnerTests; + sourceTree = ""; + }; + 33BA886A226E78AF003329D5 /* Configs */ = { + isa = PBXGroup; + children = ( + 33E5194F232828860026EE4D /* AppInfo.xcconfig */, + 9740EEB21CF90195004384FC /* Debug.xcconfig */, + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, + 333000ED22D3DE5D00554162 /* Warnings.xcconfig */, + ); + path = Configs; + sourceTree = ""; + }; + 33CC10E42044A3C60003C045 = { + isa = PBXGroup; + children = ( + 33FAB671232836740065AC1E /* Runner */, + 33CEB47122A05771004F2AC0 /* Flutter */, + 331C80D6294CF71000263BE5 /* RunnerTests */, + 33CC10EE2044A3C60003C045 /* Products */, + D73912EC22F37F3D000D13A0 /* Frameworks */, + ); + sourceTree = ""; + }; + 33CC10EE2044A3C60003C045 /* Products */ = { + isa = PBXGroup; + children = ( + 33CC10ED2044A3C60003C045 /* firebase_test.app */, + 331C80D5294CF71000263BE5 /* RunnerTests.xctest */, + ); + name = Products; + sourceTree = ""; + }; + 33CC11242044D66E0003C045 /* Resources */ = { + isa = PBXGroup; + children = ( + 33CC10F22044A3C60003C045 /* Assets.xcassets */, + 33CC10F42044A3C60003C045 /* MainMenu.xib */, + 33CC10F72044A3C60003C045 /* Info.plist */, + ); + name = Resources; + path = ..; + sourceTree = ""; + }; + 33CEB47122A05771004F2AC0 /* Flutter */ = { + isa = PBXGroup; + children = ( + 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */, + 33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */, + 33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */, + 33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */, + ); + path = Flutter; + sourceTree = ""; + }; + 33FAB671232836740065AC1E /* Runner */ = { + isa = PBXGroup; + children = ( + 33CC10F02044A3C60003C045 /* AppDelegate.swift */, + 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */, + 33E51913231747F40026EE4D /* DebugProfile.entitlements */, + 33E51914231749380026EE4D /* Release.entitlements */, + 33CC11242044D66E0003C045 /* Resources */, + 33BA886A226E78AF003329D5 /* Configs */, + ); + path = Runner; + sourceTree = ""; + }; + D73912EC22F37F3D000D13A0 /* Frameworks */ = { + isa = PBXGroup; + children = ( + ); + name = Frameworks; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 331C80D4294CF70F00263BE5 /* RunnerTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 331C80DE294CF71000263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */; + buildPhases = ( + 331C80D1294CF70F00263BE5 /* Sources */, + 331C80D2294CF70F00263BE5 /* Frameworks */, + 331C80D3294CF70F00263BE5 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + 331C80DA294CF71000263BE5 /* PBXTargetDependency */, + ); + name = RunnerTests; + productName = RunnerTests; + productReference = 331C80D5294CF71000263BE5 /* RunnerTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; + 33CC10EC2044A3C60003C045 /* Runner */ = { + isa = PBXNativeTarget; + buildConfigurationList = 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */; + buildPhases = ( + 33CC10E92044A3C60003C045 /* Sources */, + 33CC10EA2044A3C60003C045 /* Frameworks */, + 33CC10EB2044A3C60003C045 /* Resources */, + 33CC110E2044A8840003C045 /* Bundle Framework */, + 3399D490228B24CF009A79C7 /* ShellScript */, + ); + buildRules = ( + ); + dependencies = ( + 33CC11202044C79F0003C045 /* PBXTargetDependency */, + ); + name = Runner; + productName = Runner; + productReference = 33CC10ED2044A3C60003C045 /* firebase_test.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 33CC10E52044A3C60003C045 /* Project object */ = { + isa = PBXProject; + attributes = { + BuildIndependentTargetsInParallel = YES; + LastSwiftUpdateCheck = 0920; + LastUpgradeCheck = 1510; + ORGANIZATIONNAME = ""; + TargetAttributes = { + 331C80D4294CF70F00263BE5 = { + CreatedOnToolsVersion = 14.0; + TestTargetID = 33CC10EC2044A3C60003C045; + }; + 33CC10EC2044A3C60003C045 = { + CreatedOnToolsVersion = 9.2; + LastSwiftMigration = 1100; + ProvisioningStyle = Automatic; + SystemCapabilities = { + com.apple.Sandbox = { + enabled = 1; + }; + }; + }; + 33CC111A2044C6BA0003C045 = { + CreatedOnToolsVersion = 9.2; + ProvisioningStyle = Manual; + }; + }; + }; + buildConfigurationList = 33CC10E82044A3C60003C045 /* Build configuration list for PBXProject "Runner" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 33CC10E42044A3C60003C045; + productRefGroup = 33CC10EE2044A3C60003C045 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 33CC10EC2044A3C60003C045 /* Runner */, + 331C80D4294CF70F00263BE5 /* RunnerTests */, + 33CC111A2044C6BA0003C045 /* Flutter Assemble */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 331C80D3294CF70F00263BE5 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 33CC10EB2044A3C60003C045 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */, + 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 3399D490228B24CF009A79C7 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + ); + outputFileListPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "echo \"$PRODUCT_NAME.app\" > \"$PROJECT_DIR\"/Flutter/ephemeral/.app_filename && \"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh embed\n"; + }; + 33CC111E2044C6BF0003C045 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + Flutter/ephemeral/FlutterInputs.xcfilelist, + ); + inputPaths = ( + Flutter/ephemeral/tripwire, + ); + outputFileListPaths = ( + Flutter/ephemeral/FlutterOutputs.xcfilelist, + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh && touch Flutter/ephemeral/tripwire"; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 331C80D1294CF70F00263BE5 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 331C80D8294CF71000263BE5 /* RunnerTests.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 33CC10E92044A3C60003C045 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */, + 33CC10F12044A3C60003C045 /* AppDelegate.swift in Sources */, + 335BBD1B22A9A15E00E9071D /* GeneratedPluginRegistrant.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 331C80DA294CF71000263BE5 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 33CC10EC2044A3C60003C045 /* Runner */; + targetProxy = 331C80D9294CF71000263BE5 /* PBXContainerItemProxy */; + }; + 33CC11202044C79F0003C045 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 33CC111A2044C6BA0003C045 /* Flutter Assemble */; + targetProxy = 33CC111F2044C79F0003C045 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin PBXVariantGroup section */ + 33CC10F42044A3C60003C045 /* MainMenu.xib */ = { + isa = PBXVariantGroup; + children = ( + 33CC10F52044A3C60003C045 /* Base */, + ); + name = MainMenu.xib; + path = Runner; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 331C80DB294CF71000263BE5 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = dev.celest.firebaseTest.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/firebase_test.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/firebase_test"; + }; + name = Debug; + }; + 331C80DC294CF71000263BE5 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = dev.celest.firebaseTest.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/firebase_test.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/firebase_test"; + }; + name = Release; + }; + 331C80DD294CF71000263BE5 /* Profile */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = dev.celest.firebaseTest.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/firebase_test.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/firebase_test"; + }; + name = Profile; + }; + 338D0CE9231458BD00FA5F75 /* Profile */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEAD_CODE_STRIPPING = YES; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_USER_SCRIPT_SANDBOXING = NO; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.14; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = macosx; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + }; + name = Profile; + }; + 338D0CEA231458BD00FA5F75 /* Profile */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_VERSION = 5.0; + }; + name = Profile; + }; + 338D0CEB231458BD00FA5F75 /* Profile */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Manual; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Profile; + }; + 33CC10F92044A3C60003C045 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEAD_CODE_STRIPPING = YES; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + ENABLE_USER_SCRIPT_SANDBOXING = NO; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.14; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 33CC10FA2044A3C60003C045 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEAD_CODE_STRIPPING = YES; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_USER_SCRIPT_SANDBOXING = NO; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.14; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = macosx; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + }; + name = Release; + }; + 33CC10FC2044A3C60003C045 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; + }; + name = Debug; + }; + 33CC10FD2044A3C60003C045 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = Runner/Release.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_VERSION = 5.0; + }; + name = Release; + }; + 33CC111C2044C6BA0003C045 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Manual; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + 33CC111D2044C6BA0003C045 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 331C80DE294CF71000263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 331C80DB294CF71000263BE5 /* Debug */, + 331C80DC294CF71000263BE5 /* Release */, + 331C80DD294CF71000263BE5 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 33CC10E82044A3C60003C045 /* Build configuration list for PBXProject "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 33CC10F92044A3C60003C045 /* Debug */, + 33CC10FA2044A3C60003C045 /* Release */, + 338D0CE9231458BD00FA5F75 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 33CC10FC2044A3C60003C045 /* Debug */, + 33CC10FD2044A3C60003C045 /* Release */, + 338D0CEA231458BD00FA5F75 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 33CC111B2044C6BA0003C045 /* Build configuration list for PBXAggregateTarget "Flutter Assemble" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 33CC111C2044C6BA0003C045 /* Debug */, + 33CC111D2044C6BA0003C045 /* Release */, + 338D0CEB231458BD00FA5F75 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 33CC10E52044A3C60003C045 /* Project object */; +} diff --git a/apps/cli/fixtures/legacy/firebase/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/apps/cli/fixtures/legacy/firebase/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 000000000..18d981003 --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/apps/cli/fixtures/legacy/firebase/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/apps/cli/fixtures/legacy/firebase/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme new file mode 100644 index 000000000..a52dc56c2 --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -0,0 +1,98 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/apps/cli/fixtures/legacy/firebase/macos/Runner.xcworkspace/contents.xcworkspacedata b/apps/cli/fixtures/legacy/firebase/macos/Runner.xcworkspace/contents.xcworkspacedata new file mode 100644 index 000000000..1d526a16e --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/macos/Runner.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/apps/cli/fixtures/legacy/firebase/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/apps/cli/fixtures/legacy/firebase/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 000000000..18d981003 --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/apps/cli/fixtures/legacy/firebase/macos/Runner/AppDelegate.swift b/apps/cli/fixtures/legacy/firebase/macos/Runner/AppDelegate.swift new file mode 100644 index 000000000..8e02df288 --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/macos/Runner/AppDelegate.swift @@ -0,0 +1,9 @@ +import Cocoa +import FlutterMacOS + +@main +class AppDelegate: FlutterAppDelegate { + override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { + return true + } +} diff --git a/apps/cli/fixtures/legacy/firebase/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json b/apps/cli/fixtures/legacy/firebase/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 000000000..a2ec33f19 --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,68 @@ +{ + "images" : [ + { + "size" : "16x16", + "idiom" : "mac", + "filename" : "app_icon_16.png", + "scale" : "1x" + }, + { + "size" : "16x16", + "idiom" : "mac", + "filename" : "app_icon_32.png", + "scale" : "2x" + }, + { + "size" : "32x32", + "idiom" : "mac", + "filename" : "app_icon_32.png", + "scale" : "1x" + }, + { + "size" : "32x32", + "idiom" : "mac", + "filename" : "app_icon_64.png", + "scale" : "2x" + }, + { + "size" : "128x128", + "idiom" : "mac", + "filename" : "app_icon_128.png", + "scale" : "1x" + }, + { + "size" : "128x128", + "idiom" : "mac", + "filename" : "app_icon_256.png", + "scale" : "2x" + }, + { + "size" : "256x256", + "idiom" : "mac", + "filename" : "app_icon_256.png", + "scale" : "1x" + }, + { + "size" : "256x256", + "idiom" : "mac", + "filename" : "app_icon_512.png", + "scale" : "2x" + }, + { + "size" : "512x512", + "idiom" : "mac", + "filename" : "app_icon_512.png", + "scale" : "1x" + }, + { + "size" : "512x512", + "idiom" : "mac", + "filename" : "app_icon_1024.png", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} diff --git a/apps/cli/fixtures/legacy/firebase/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png b/apps/cli/fixtures/legacy/firebase/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png new file mode 100644 index 000000000..82b6f9d9a Binary files /dev/null and b/apps/cli/fixtures/legacy/firebase/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png differ diff --git a/apps/cli/fixtures/legacy/firebase/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png b/apps/cli/fixtures/legacy/firebase/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png new file mode 100644 index 000000000..13b35eba5 Binary files /dev/null and b/apps/cli/fixtures/legacy/firebase/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png differ diff --git a/apps/cli/fixtures/legacy/firebase/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png b/apps/cli/fixtures/legacy/firebase/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png new file mode 100644 index 000000000..0a3f5fa40 Binary files /dev/null and b/apps/cli/fixtures/legacy/firebase/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png differ diff --git a/apps/cli/fixtures/legacy/firebase/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png b/apps/cli/fixtures/legacy/firebase/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png new file mode 100644 index 000000000..bdb57226d Binary files /dev/null and b/apps/cli/fixtures/legacy/firebase/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png differ diff --git a/apps/cli/fixtures/legacy/firebase/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png b/apps/cli/fixtures/legacy/firebase/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png new file mode 100644 index 000000000..f083318e0 Binary files /dev/null and b/apps/cli/fixtures/legacy/firebase/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png differ diff --git a/apps/cli/fixtures/legacy/firebase/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png b/apps/cli/fixtures/legacy/firebase/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png new file mode 100644 index 000000000..326c0e72c Binary files /dev/null and b/apps/cli/fixtures/legacy/firebase/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png differ diff --git a/apps/cli/fixtures/legacy/firebase/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png b/apps/cli/fixtures/legacy/firebase/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png new file mode 100644 index 000000000..2f1632cfd Binary files /dev/null and b/apps/cli/fixtures/legacy/firebase/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png differ diff --git a/apps/cli/fixtures/legacy/firebase/macos/Runner/Base.lproj/MainMenu.xib b/apps/cli/fixtures/legacy/firebase/macos/Runner/Base.lproj/MainMenu.xib new file mode 100644 index 000000000..80e867a4e --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/macos/Runner/Base.lproj/MainMenu.xib @@ -0,0 +1,343 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/apps/cli/fixtures/legacy/firebase/macos/Runner/Configs/AppInfo.xcconfig b/apps/cli/fixtures/legacy/firebase/macos/Runner/Configs/AppInfo.xcconfig new file mode 100644 index 000000000..193152975 --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/macos/Runner/Configs/AppInfo.xcconfig @@ -0,0 +1,14 @@ +// Application-level settings for the Runner target. +// +// This may be replaced with something auto-generated from metadata (e.g., pubspec.yaml) in the +// future. If not, the values below would default to using the project name when this becomes a +// 'flutter create' template. + +// The application's name. By default this is also the title of the Flutter window. +PRODUCT_NAME = firebase_test + +// The application's bundle identifier +PRODUCT_BUNDLE_IDENTIFIER = dev.celest.firebaseTest + +// The copyright displayed in application information +PRODUCT_COPYRIGHT = Copyright © 2024 dev.celest. All rights reserved. diff --git a/apps/cli/fixtures/legacy/firebase/macos/Runner/Configs/Debug.xcconfig b/apps/cli/fixtures/legacy/firebase/macos/Runner/Configs/Debug.xcconfig new file mode 100644 index 000000000..36b0fd946 --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/macos/Runner/Configs/Debug.xcconfig @@ -0,0 +1,2 @@ +#include "../../Flutter/Flutter-Debug.xcconfig" +#include "Warnings.xcconfig" diff --git a/apps/cli/fixtures/legacy/firebase/macos/Runner/Configs/Release.xcconfig b/apps/cli/fixtures/legacy/firebase/macos/Runner/Configs/Release.xcconfig new file mode 100644 index 000000000..dff4f4956 --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/macos/Runner/Configs/Release.xcconfig @@ -0,0 +1,2 @@ +#include "../../Flutter/Flutter-Release.xcconfig" +#include "Warnings.xcconfig" diff --git a/apps/cli/fixtures/legacy/firebase/macos/Runner/Configs/Warnings.xcconfig b/apps/cli/fixtures/legacy/firebase/macos/Runner/Configs/Warnings.xcconfig new file mode 100644 index 000000000..42bcbf478 --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/macos/Runner/Configs/Warnings.xcconfig @@ -0,0 +1,13 @@ +WARNING_CFLAGS = -Wall -Wconditional-uninitialized -Wnullable-to-nonnull-conversion -Wmissing-method-return-type -Woverlength-strings +GCC_WARN_UNDECLARED_SELECTOR = YES +CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES +CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE +CLANG_WARN__DUPLICATE_METHOD_MATCH = YES +CLANG_WARN_PRAGMA_PACK = YES +CLANG_WARN_STRICT_PROTOTYPES = YES +CLANG_WARN_COMMA = YES +GCC_WARN_STRICT_SELECTOR_MATCH = YES +CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES +CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES +GCC_WARN_SHADOW = YES +CLANG_WARN_UNREACHABLE_CODE = YES diff --git a/apps/cli/fixtures/legacy/firebase/macos/Runner/DebugProfile.entitlements b/apps/cli/fixtures/legacy/firebase/macos/Runner/DebugProfile.entitlements new file mode 100644 index 000000000..3ba6c1266 --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/macos/Runner/DebugProfile.entitlements @@ -0,0 +1,14 @@ + + + + + com.apple.security.app-sandbox + + com.apple.security.cs.allow-jit + + com.apple.security.network.client + + com.apple.security.network.server + + + diff --git a/apps/cli/fixtures/legacy/firebase/macos/Runner/Info.plist b/apps/cli/fixtures/legacy/firebase/macos/Runner/Info.plist new file mode 100644 index 000000000..4789daa6a --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/macos/Runner/Info.plist @@ -0,0 +1,32 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIconFile + + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + $(FLUTTER_BUILD_NAME) + CFBundleVersion + $(FLUTTER_BUILD_NUMBER) + LSMinimumSystemVersion + $(MACOSX_DEPLOYMENT_TARGET) + NSHumanReadableCopyright + $(PRODUCT_COPYRIGHT) + NSMainNibFile + MainMenu + NSPrincipalClass + NSApplication + + diff --git a/apps/cli/fixtures/legacy/firebase/macos/Runner/MainFlutterWindow.swift b/apps/cli/fixtures/legacy/firebase/macos/Runner/MainFlutterWindow.swift new file mode 100644 index 000000000..3cc05eb23 --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/macos/Runner/MainFlutterWindow.swift @@ -0,0 +1,15 @@ +import Cocoa +import FlutterMacOS + +class MainFlutterWindow: NSWindow { + override func awakeFromNib() { + let flutterViewController = FlutterViewController() + let windowFrame = self.frame + self.contentViewController = flutterViewController + self.setFrame(windowFrame, display: true) + + RegisterGeneratedPlugins(registry: flutterViewController) + + super.awakeFromNib() + } +} diff --git a/apps/cli/fixtures/legacy/firebase/macos/Runner/Release.entitlements b/apps/cli/fixtures/legacy/firebase/macos/Runner/Release.entitlements new file mode 100644 index 000000000..ee95ab7e5 --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/macos/Runner/Release.entitlements @@ -0,0 +1,10 @@ + + + + + com.apple.security.app-sandbox + + com.apple.security.network.client + + + diff --git a/apps/cli/fixtures/legacy/firebase/macos/RunnerTests/RunnerTests.swift b/apps/cli/fixtures/legacy/firebase/macos/RunnerTests/RunnerTests.swift new file mode 100644 index 000000000..61f3bd1fc --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/macos/RunnerTests/RunnerTests.swift @@ -0,0 +1,12 @@ +import Cocoa +import FlutterMacOS +import XCTest + +class RunnerTests: XCTestCase { + + func testExample() { + // If you add code to the Runner application, consider adding tests here. + // See https://developer.apple.com/documentation/xctest for more information about using XCTest. + } + +} diff --git a/apps/cli/fixtures/legacy/firebase/pubspec.yaml b/apps/cli/fixtures/legacy/firebase/pubspec.yaml new file mode 100644 index 000000000..4628d63fa --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/pubspec.yaml @@ -0,0 +1,23 @@ +name: firebase_test +description: Testbed for Firebase integration with Celest +publish_to: none +version: 1.0.0+1 + +environment: + sdk: ^3.7.0 + +dependencies: + firebase_auth: ^5.3.1 + firebase_core: ^3.6.0 + firebase_test_client: + path: celest/client/ + flutter: + sdk: flutter + +dev_dependencies: + flutter_lints: ^4.0.0 + flutter_test: + sdk: flutter + +flutter: + uses-material-design: true diff --git a/apps/cli/fixtures/legacy/firebase/web/favicon.png b/apps/cli/fixtures/legacy/firebase/web/favicon.png new file mode 100644 index 000000000..8aaa46ac1 Binary files /dev/null and b/apps/cli/fixtures/legacy/firebase/web/favicon.png differ diff --git a/apps/cli/fixtures/legacy/firebase/web/icons/Icon-192.png b/apps/cli/fixtures/legacy/firebase/web/icons/Icon-192.png new file mode 100644 index 000000000..b749bfef0 Binary files /dev/null and b/apps/cli/fixtures/legacy/firebase/web/icons/Icon-192.png differ diff --git a/apps/cli/fixtures/legacy/firebase/web/icons/Icon-512.png b/apps/cli/fixtures/legacy/firebase/web/icons/Icon-512.png new file mode 100644 index 000000000..88cfd48df Binary files /dev/null and b/apps/cli/fixtures/legacy/firebase/web/icons/Icon-512.png differ diff --git a/apps/cli/fixtures/legacy/firebase/web/icons/Icon-maskable-192.png b/apps/cli/fixtures/legacy/firebase/web/icons/Icon-maskable-192.png new file mode 100644 index 000000000..eb9b4d76e Binary files /dev/null and b/apps/cli/fixtures/legacy/firebase/web/icons/Icon-maskable-192.png differ diff --git a/apps/cli/fixtures/legacy/firebase/web/icons/Icon-maskable-512.png b/apps/cli/fixtures/legacy/firebase/web/icons/Icon-maskable-512.png new file mode 100644 index 000000000..d69c56691 Binary files /dev/null and b/apps/cli/fixtures/legacy/firebase/web/icons/Icon-maskable-512.png differ diff --git a/apps/cli/fixtures/legacy/firebase/web/index.html b/apps/cli/fixtures/legacy/firebase/web/index.html new file mode 100644 index 000000000..d9f0cbc0d --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/web/index.html @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + firebase_test + + + + + + diff --git a/apps/cli/fixtures/legacy/firebase/web/manifest.json b/apps/cli/fixtures/legacy/firebase/web/manifest.json new file mode 100644 index 000000000..311488901 --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/web/manifest.json @@ -0,0 +1,35 @@ +{ + "name": "firebase_test", + "short_name": "firebase_test", + "start_url": ".", + "display": "standalone", + "background_color": "#0175C2", + "theme_color": "#0175C2", + "description": "A new Flutter project.", + "orientation": "portrait-primary", + "prefer_related_applications": false, + "icons": [ + { + "src": "icons/Icon-192.png", + "sizes": "192x192", + "type": "image/png" + }, + { + "src": "icons/Icon-512.png", + "sizes": "512x512", + "type": "image/png" + }, + { + "src": "icons/Icon-maskable-192.png", + "sizes": "192x192", + "type": "image/png", + "purpose": "maskable" + }, + { + "src": "icons/Icon-maskable-512.png", + "sizes": "512x512", + "type": "image/png", + "purpose": "maskable" + } + ] +} diff --git a/apps/cli/fixtures/legacy/firebase/windows/.gitignore b/apps/cli/fixtures/legacy/firebase/windows/.gitignore new file mode 100644 index 000000000..d492d0d98 --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/windows/.gitignore @@ -0,0 +1,17 @@ +flutter/ephemeral/ + +# Visual Studio user-specific files. +*.suo +*.user +*.userosscache +*.sln.docstates + +# Visual Studio build-related files. +x64/ +x86/ + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ diff --git a/apps/cli/fixtures/legacy/firebase/windows/CMakeLists.txt b/apps/cli/fixtures/legacy/firebase/windows/CMakeLists.txt new file mode 100644 index 000000000..3c2b4bfab --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/windows/CMakeLists.txt @@ -0,0 +1,108 @@ +# Project-level configuration. +cmake_minimum_required(VERSION 3.14) +project(firebase_test LANGUAGES CXX) + +# The name of the executable created for the application. Change this to change +# the on-disk name of your application. +set(BINARY_NAME "firebase_test") + +# Explicitly opt in to modern CMake behaviors to avoid warnings with recent +# versions of CMake. +cmake_policy(VERSION 3.14...3.25) + +# Define build configuration option. +get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if(IS_MULTICONFIG) + set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release" + CACHE STRING "" FORCE) +else() + if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + set(CMAKE_BUILD_TYPE "Debug" CACHE + STRING "Flutter build mode" FORCE) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS + "Debug" "Profile" "Release") + endif() +endif() +# Define settings for the Profile build mode. +set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") +set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") +set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}") +set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}") + +# Use Unicode for all projects. +add_definitions(-DUNICODE -D_UNICODE) + +# Compilation settings that should be applied to most targets. +# +# Be cautious about adding new options here, as plugins use this function by +# default. In most cases, you should add new options to specific targets instead +# of modifying this function. +function(APPLY_STANDARD_SETTINGS TARGET) + target_compile_features(${TARGET} PUBLIC cxx_std_17) + target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100") + target_compile_options(${TARGET} PRIVATE /EHsc) + target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0") + target_compile_definitions(${TARGET} PRIVATE "$<$:_DEBUG>") +endfunction() + +# Flutter library and tool build rules. +set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") +add_subdirectory(${FLUTTER_MANAGED_DIR}) + +# Application build; see runner/CMakeLists.txt. +add_subdirectory("runner") + + +# Generated plugin build rules, which manage building the plugins and adding +# them to the application. +include(flutter/generated_plugins.cmake) + + +# === Installation === +# Support files are copied into place next to the executable, so that it can +# run in place. This is done instead of making a separate bundle (as on Linux) +# so that building and running from within Visual Studio will work. +set(BUILD_BUNDLE_DIR "$") +# Make the "install" step default, as it's required to run. +set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) +if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) +endif() + +set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") +set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") + +install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" + COMPONENT Runtime) + +install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" + COMPONENT Runtime) + +install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) + +if(PLUGIN_BUNDLED_LIBRARIES) + install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" + DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) +endif() + +# Copy the native assets provided by the build.dart from all packages. +set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/windows/") +install(DIRECTORY "${NATIVE_ASSETS_DIR}" + DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) + +# Fully re-copy the assets directory on each build to avoid having stale files +# from a previous install. +set(FLUTTER_ASSET_DIR_NAME "flutter_assets") +install(CODE " + file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") + " COMPONENT Runtime) +install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" + DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) + +# Install the AOT library on non-Debug builds only. +install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" + CONFIGURATIONS Profile;Release + COMPONENT Runtime) diff --git a/apps/cli/fixtures/legacy/firebase/windows/flutter/CMakeLists.txt b/apps/cli/fixtures/legacy/firebase/windows/flutter/CMakeLists.txt new file mode 100644 index 000000000..903f4899d --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/windows/flutter/CMakeLists.txt @@ -0,0 +1,109 @@ +# This file controls Flutter-level build steps. It should not be edited. +cmake_minimum_required(VERSION 3.14) + +set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") + +# Configuration provided via flutter tool. +include(${EPHEMERAL_DIR}/generated_config.cmake) + +# TODO: Move the rest of this into files in ephemeral. See +# https://github.com/flutter/flutter/issues/57146. +set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") + +# Set fallback configurations for older versions of the flutter tool. +if (NOT DEFINED FLUTTER_TARGET_PLATFORM) + set(FLUTTER_TARGET_PLATFORM "windows-x64") +endif() + +# === Flutter Library === +set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") + +# Published to parent scope for install step. +set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) +set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) +set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) +set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) + +list(APPEND FLUTTER_LIBRARY_HEADERS + "flutter_export.h" + "flutter_windows.h" + "flutter_messenger.h" + "flutter_plugin_registrar.h" + "flutter_texture_registrar.h" +) +list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/") +add_library(flutter INTERFACE) +target_include_directories(flutter INTERFACE + "${EPHEMERAL_DIR}" +) +target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") +add_dependencies(flutter flutter_assemble) + +# === Wrapper === +list(APPEND CPP_WRAPPER_SOURCES_CORE + "core_implementations.cc" + "standard_codec.cc" +) +list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") +list(APPEND CPP_WRAPPER_SOURCES_PLUGIN + "plugin_registrar.cc" +) +list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") +list(APPEND CPP_WRAPPER_SOURCES_APP + "flutter_engine.cc" + "flutter_view_controller.cc" +) +list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") + +# Wrapper sources needed for a plugin. +add_library(flutter_wrapper_plugin STATIC + ${CPP_WRAPPER_SOURCES_CORE} + ${CPP_WRAPPER_SOURCES_PLUGIN} +) +apply_standard_settings(flutter_wrapper_plugin) +set_target_properties(flutter_wrapper_plugin PROPERTIES + POSITION_INDEPENDENT_CODE ON) +set_target_properties(flutter_wrapper_plugin PROPERTIES + CXX_VISIBILITY_PRESET hidden) +target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) +target_include_directories(flutter_wrapper_plugin PUBLIC + "${WRAPPER_ROOT}/include" +) +add_dependencies(flutter_wrapper_plugin flutter_assemble) + +# Wrapper sources needed for the runner. +add_library(flutter_wrapper_app STATIC + ${CPP_WRAPPER_SOURCES_CORE} + ${CPP_WRAPPER_SOURCES_APP} +) +apply_standard_settings(flutter_wrapper_app) +target_link_libraries(flutter_wrapper_app PUBLIC flutter) +target_include_directories(flutter_wrapper_app PUBLIC + "${WRAPPER_ROOT}/include" +) +add_dependencies(flutter_wrapper_app flutter_assemble) + +# === Flutter tool backend === +# _phony_ is a non-existent file to force this command to run every time, +# since currently there's no way to get a full input/output list from the +# flutter tool. +set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_") +set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE) +add_custom_command( + OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} + ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} + ${CPP_WRAPPER_SOURCES_APP} + ${PHONY_OUTPUT} + COMMAND ${CMAKE_COMMAND} -E env + ${FLUTTER_TOOL_ENVIRONMENT} + "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" + ${FLUTTER_TARGET_PLATFORM} $ + VERBATIM +) +add_custom_target(flutter_assemble DEPENDS + "${FLUTTER_LIBRARY}" + ${FLUTTER_LIBRARY_HEADERS} + ${CPP_WRAPPER_SOURCES_CORE} + ${CPP_WRAPPER_SOURCES_PLUGIN} + ${CPP_WRAPPER_SOURCES_APP} +) diff --git a/apps/cli/fixtures/legacy/firebase/windows/flutter/generated_plugin_registrant.cc b/apps/cli/fixtures/legacy/firebase/windows/flutter/generated_plugin_registrant.cc new file mode 100644 index 000000000..d141b74f5 --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/windows/flutter/generated_plugin_registrant.cc @@ -0,0 +1,17 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#include "generated_plugin_registrant.h" + +#include +#include + +void RegisterPlugins(flutter::PluginRegistry* registry) { + FirebaseAuthPluginCApiRegisterWithRegistrar( + registry->GetRegistrarForPlugin("FirebaseAuthPluginCApi")); + FirebaseCorePluginCApiRegisterWithRegistrar( + registry->GetRegistrarForPlugin("FirebaseCorePluginCApi")); +} diff --git a/apps/cli/fixtures/legacy/firebase/windows/flutter/generated_plugin_registrant.h b/apps/cli/fixtures/legacy/firebase/windows/flutter/generated_plugin_registrant.h new file mode 100644 index 000000000..dc139d85a --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/windows/flutter/generated_plugin_registrant.h @@ -0,0 +1,15 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#ifndef GENERATED_PLUGIN_REGISTRANT_ +#define GENERATED_PLUGIN_REGISTRANT_ + +#include + +// Registers Flutter plugins. +void RegisterPlugins(flutter::PluginRegistry* registry); + +#endif // GENERATED_PLUGIN_REGISTRANT_ diff --git a/apps/cli/fixtures/legacy/firebase/windows/flutter/generated_plugins.cmake b/apps/cli/fixtures/legacy/firebase/windows/flutter/generated_plugins.cmake new file mode 100644 index 000000000..f805f2399 --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/windows/flutter/generated_plugins.cmake @@ -0,0 +1,26 @@ +# +# Generated file, do not edit. +# + +list(APPEND FLUTTER_PLUGIN_LIST + firebase_auth + firebase_core +) + +list(APPEND FLUTTER_FFI_PLUGIN_LIST + jni +) + +set(PLUGIN_BUNDLED_LIBRARIES) + +foreach(plugin ${FLUTTER_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin}) + target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) + list(APPEND PLUGIN_BUNDLED_LIBRARIES $) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) +endforeach(plugin) + +foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) +endforeach(ffi_plugin) diff --git a/apps/cli/fixtures/legacy/firebase/windows/runner/CMakeLists.txt b/apps/cli/fixtures/legacy/firebase/windows/runner/CMakeLists.txt new file mode 100644 index 000000000..394917c05 --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/windows/runner/CMakeLists.txt @@ -0,0 +1,40 @@ +cmake_minimum_required(VERSION 3.14) +project(runner LANGUAGES CXX) + +# Define the application target. To change its name, change BINARY_NAME in the +# top-level CMakeLists.txt, not the value here, or `flutter run` will no longer +# work. +# +# Any new source files that you add to the application should be added here. +add_executable(${BINARY_NAME} WIN32 + "flutter_window.cpp" + "main.cpp" + "utils.cpp" + "win32_window.cpp" + "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" + "Runner.rc" + "runner.exe.manifest" +) + +# Apply the standard set of build settings. This can be removed for applications +# that need different build settings. +apply_standard_settings(${BINARY_NAME}) + +# Add preprocessor definitions for the build version. +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION=\"${FLUTTER_VERSION}\"") +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}") +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}") +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}") +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}") + +# Disable Windows macros that collide with C++ standard library functions. +target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") + +# Add dependency libraries and include directories. Add any application-specific +# dependencies here. +target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) +target_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib") +target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") + +# Run the Flutter tool portions of the build. This must not be removed. +add_dependencies(${BINARY_NAME} flutter_assemble) diff --git a/apps/cli/fixtures/legacy/firebase/windows/runner/Runner.rc b/apps/cli/fixtures/legacy/firebase/windows/runner/Runner.rc new file mode 100644 index 000000000..b0d0b97e2 --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/windows/runner/Runner.rc @@ -0,0 +1,121 @@ +// Microsoft Visual C++ generated resource script. +// +#pragma code_page(65001) +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "winres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (United States) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""winres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDI_APP_ICON ICON "resources\\app_icon.ico" + + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +#if defined(FLUTTER_VERSION_MAJOR) && defined(FLUTTER_VERSION_MINOR) && defined(FLUTTER_VERSION_PATCH) && defined(FLUTTER_VERSION_BUILD) +#define VERSION_AS_NUMBER FLUTTER_VERSION_MAJOR,FLUTTER_VERSION_MINOR,FLUTTER_VERSION_PATCH,FLUTTER_VERSION_BUILD +#else +#define VERSION_AS_NUMBER 1,0,0,0 +#endif + +#if defined(FLUTTER_VERSION) +#define VERSION_AS_STRING FLUTTER_VERSION +#else +#define VERSION_AS_STRING "1.0.0" +#endif + +VS_VERSION_INFO VERSIONINFO + FILEVERSION VERSION_AS_NUMBER + PRODUCTVERSION VERSION_AS_NUMBER + FILEFLAGSMASK VS_FFI_FILEFLAGSMASK +#ifdef _DEBUG + FILEFLAGS VS_FF_DEBUG +#else + FILEFLAGS 0x0L +#endif + FILEOS VOS__WINDOWS32 + FILETYPE VFT_APP + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904e4" + BEGIN + VALUE "CompanyName", "dev.celest" "\0" + VALUE "FileDescription", "firebase_test" "\0" + VALUE "FileVersion", VERSION_AS_STRING "\0" + VALUE "InternalName", "firebase_test" "\0" + VALUE "LegalCopyright", "Copyright (C) 2024 dev.celest. All rights reserved." "\0" + VALUE "OriginalFilename", "firebase_test.exe" "\0" + VALUE "ProductName", "firebase_test" "\0" + VALUE "ProductVersion", VERSION_AS_STRING "\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1252 + END +END + +#endif // English (United States) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED diff --git a/apps/cli/fixtures/legacy/firebase/windows/runner/flutter_window.cpp b/apps/cli/fixtures/legacy/firebase/windows/runner/flutter_window.cpp new file mode 100644 index 000000000..955ee3038 --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/windows/runner/flutter_window.cpp @@ -0,0 +1,71 @@ +#include "flutter_window.h" + +#include + +#include "flutter/generated_plugin_registrant.h" + +FlutterWindow::FlutterWindow(const flutter::DartProject& project) + : project_(project) {} + +FlutterWindow::~FlutterWindow() {} + +bool FlutterWindow::OnCreate() { + if (!Win32Window::OnCreate()) { + return false; + } + + RECT frame = GetClientArea(); + + // The size here must match the window dimensions to avoid unnecessary surface + // creation / destruction in the startup path. + flutter_controller_ = std::make_unique( + frame.right - frame.left, frame.bottom - frame.top, project_); + // Ensure that basic setup of the controller was successful. + if (!flutter_controller_->engine() || !flutter_controller_->view()) { + return false; + } + RegisterPlugins(flutter_controller_->engine()); + SetChildContent(flutter_controller_->view()->GetNativeWindow()); + + flutter_controller_->engine()->SetNextFrameCallback([&]() { + this->Show(); + }); + + // Flutter can complete the first frame before the "show window" callback is + // registered. The following call ensures a frame is pending to ensure the + // window is shown. It is a no-op if the first frame hasn't completed yet. + flutter_controller_->ForceRedraw(); + + return true; +} + +void FlutterWindow::OnDestroy() { + if (flutter_controller_) { + flutter_controller_ = nullptr; + } + + Win32Window::OnDestroy(); +} + +LRESULT +FlutterWindow::MessageHandler(HWND hwnd, UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept { + // Give Flutter, including plugins, an opportunity to handle window messages. + if (flutter_controller_) { + std::optional result = + flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam, + lparam); + if (result) { + return *result; + } + } + + switch (message) { + case WM_FONTCHANGE: + flutter_controller_->engine()->ReloadSystemFonts(); + break; + } + + return Win32Window::MessageHandler(hwnd, message, wparam, lparam); +} diff --git a/apps/cli/fixtures/legacy/firebase/windows/runner/flutter_window.h b/apps/cli/fixtures/legacy/firebase/windows/runner/flutter_window.h new file mode 100644 index 000000000..6da0652f0 --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/windows/runner/flutter_window.h @@ -0,0 +1,33 @@ +#ifndef RUNNER_FLUTTER_WINDOW_H_ +#define RUNNER_FLUTTER_WINDOW_H_ + +#include +#include + +#include + +#include "win32_window.h" + +// A window that does nothing but host a Flutter view. +class FlutterWindow : public Win32Window { + public: + // Creates a new FlutterWindow hosting a Flutter view running |project|. + explicit FlutterWindow(const flutter::DartProject& project); + virtual ~FlutterWindow(); + + protected: + // Win32Window: + bool OnCreate() override; + void OnDestroy() override; + LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam, + LPARAM const lparam) noexcept override; + + private: + // The project to run. + flutter::DartProject project_; + + // The Flutter instance hosted by this window. + std::unique_ptr flutter_controller_; +}; + +#endif // RUNNER_FLUTTER_WINDOW_H_ diff --git a/apps/cli/fixtures/legacy/firebase/windows/runner/main.cpp b/apps/cli/fixtures/legacy/firebase/windows/runner/main.cpp new file mode 100644 index 000000000..dee687fcc --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/windows/runner/main.cpp @@ -0,0 +1,43 @@ +#include +#include +#include + +#include "flutter_window.h" +#include "utils.h" + +int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, + _In_ wchar_t *command_line, _In_ int show_command) { + // Attach to console when present (e.g., 'flutter run') or create a + // new console when running with a debugger. + if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) { + CreateAndAttachConsole(); + } + + // Initialize COM, so that it is available for use in the library and/or + // plugins. + ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); + + flutter::DartProject project(L"data"); + + std::vector command_line_arguments = + GetCommandLineArguments(); + + project.set_dart_entrypoint_arguments(std::move(command_line_arguments)); + + FlutterWindow window(project); + Win32Window::Point origin(10, 10); + Win32Window::Size size(1280, 720); + if (!window.Create(L"firebase_test", origin, size)) { + return EXIT_FAILURE; + } + window.SetQuitOnClose(true); + + ::MSG msg; + while (::GetMessage(&msg, nullptr, 0, 0)) { + ::TranslateMessage(&msg); + ::DispatchMessage(&msg); + } + + ::CoUninitialize(); + return EXIT_SUCCESS; +} diff --git a/apps/cli/fixtures/legacy/firebase/windows/runner/resource.h b/apps/cli/fixtures/legacy/firebase/windows/runner/resource.h new file mode 100644 index 000000000..66a65d1e4 --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/windows/runner/resource.h @@ -0,0 +1,16 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by Runner.rc +// +#define IDI_APP_ICON 101 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 102 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1001 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/apps/cli/fixtures/legacy/firebase/windows/runner/resources/app_icon.ico b/apps/cli/fixtures/legacy/firebase/windows/runner/resources/app_icon.ico new file mode 100644 index 000000000..c04e20caf Binary files /dev/null and b/apps/cli/fixtures/legacy/firebase/windows/runner/resources/app_icon.ico differ diff --git a/apps/cli/fixtures/legacy/firebase/windows/runner/runner.exe.manifest b/apps/cli/fixtures/legacy/firebase/windows/runner/runner.exe.manifest new file mode 100644 index 000000000..153653e8d --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/windows/runner/runner.exe.manifest @@ -0,0 +1,14 @@ + + + + + PerMonitorV2 + + + + + + + + + diff --git a/apps/cli/fixtures/legacy/firebase/windows/runner/utils.cpp b/apps/cli/fixtures/legacy/firebase/windows/runner/utils.cpp new file mode 100644 index 000000000..3a0b46511 --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/windows/runner/utils.cpp @@ -0,0 +1,65 @@ +#include "utils.h" + +#include +#include +#include +#include + +#include + +void CreateAndAttachConsole() { + if (::AllocConsole()) { + FILE *unused; + if (freopen_s(&unused, "CONOUT$", "w", stdout)) { + _dup2(_fileno(stdout), 1); + } + if (freopen_s(&unused, "CONOUT$", "w", stderr)) { + _dup2(_fileno(stdout), 2); + } + std::ios::sync_with_stdio(); + FlutterDesktopResyncOutputStreams(); + } +} + +std::vector GetCommandLineArguments() { + // Convert the UTF-16 command line arguments to UTF-8 for the Engine to use. + int argc; + wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc); + if (argv == nullptr) { + return std::vector(); + } + + std::vector command_line_arguments; + + // Skip the first argument as it's the binary name. + for (int i = 1; i < argc; i++) { + command_line_arguments.push_back(Utf8FromUtf16(argv[i])); + } + + ::LocalFree(argv); + + return command_line_arguments; +} + +std::string Utf8FromUtf16(const wchar_t* utf16_string) { + if (utf16_string == nullptr) { + return std::string(); + } + unsigned int target_length = ::WideCharToMultiByte( + CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, + -1, nullptr, 0, nullptr, nullptr) + -1; // remove the trailing null character + int input_length = (int)wcslen(utf16_string); + std::string utf8_string; + if (target_length == 0 || target_length > utf8_string.max_size()) { + return utf8_string; + } + utf8_string.resize(target_length); + int converted_length = ::WideCharToMultiByte( + CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, + input_length, utf8_string.data(), target_length, nullptr, nullptr); + if (converted_length == 0) { + return std::string(); + } + return utf8_string; +} diff --git a/apps/cli/fixtures/legacy/firebase/windows/runner/utils.h b/apps/cli/fixtures/legacy/firebase/windows/runner/utils.h new file mode 100644 index 000000000..3879d5475 --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/windows/runner/utils.h @@ -0,0 +1,19 @@ +#ifndef RUNNER_UTILS_H_ +#define RUNNER_UTILS_H_ + +#include +#include + +// Creates a console for the process, and redirects stdout and stderr to +// it for both the runner and the Flutter library. +void CreateAndAttachConsole(); + +// Takes a null-terminated wchar_t* encoded in UTF-16 and returns a std::string +// encoded in UTF-8. Returns an empty std::string on failure. +std::string Utf8FromUtf16(const wchar_t* utf16_string); + +// Gets the command line arguments passed in as a std::vector, +// encoded in UTF-8. Returns an empty std::vector on failure. +std::vector GetCommandLineArguments(); + +#endif // RUNNER_UTILS_H_ diff --git a/apps/cli/fixtures/legacy/firebase/windows/runner/win32_window.cpp b/apps/cli/fixtures/legacy/firebase/windows/runner/win32_window.cpp new file mode 100644 index 000000000..60608d0fe --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/windows/runner/win32_window.cpp @@ -0,0 +1,288 @@ +#include "win32_window.h" + +#include +#include + +#include "resource.h" + +namespace { + +/// Window attribute that enables dark mode window decorations. +/// +/// Redefined in case the developer's machine has a Windows SDK older than +/// version 10.0.22000.0. +/// See: https://docs.microsoft.com/windows/win32/api/dwmapi/ne-dwmapi-dwmwindowattribute +#ifndef DWMWA_USE_IMMERSIVE_DARK_MODE +#define DWMWA_USE_IMMERSIVE_DARK_MODE 20 +#endif + +constexpr const wchar_t kWindowClassName[] = L"FLUTTER_RUNNER_WIN32_WINDOW"; + +/// Registry key for app theme preference. +/// +/// A value of 0 indicates apps should use dark mode. A non-zero or missing +/// value indicates apps should use light mode. +constexpr const wchar_t kGetPreferredBrightnessRegKey[] = + L"Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize"; +constexpr const wchar_t kGetPreferredBrightnessRegValue[] = L"AppsUseLightTheme"; + +// The number of Win32Window objects that currently exist. +static int g_active_window_count = 0; + +using EnableNonClientDpiScaling = BOOL __stdcall(HWND hwnd); + +// Scale helper to convert logical scaler values to physical using passed in +// scale factor +int Scale(int source, double scale_factor) { + return static_cast(source * scale_factor); +} + +// Dynamically loads the |EnableNonClientDpiScaling| from the User32 module. +// This API is only needed for PerMonitor V1 awareness mode. +void EnableFullDpiSupportIfAvailable(HWND hwnd) { + HMODULE user32_module = LoadLibraryA("User32.dll"); + if (!user32_module) { + return; + } + auto enable_non_client_dpi_scaling = + reinterpret_cast( + GetProcAddress(user32_module, "EnableNonClientDpiScaling")); + if (enable_non_client_dpi_scaling != nullptr) { + enable_non_client_dpi_scaling(hwnd); + } + FreeLibrary(user32_module); +} + +} // namespace + +// Manages the Win32Window's window class registration. +class WindowClassRegistrar { + public: + ~WindowClassRegistrar() = default; + + // Returns the singleton registrar instance. + static WindowClassRegistrar* GetInstance() { + if (!instance_) { + instance_ = new WindowClassRegistrar(); + } + return instance_; + } + + // Returns the name of the window class, registering the class if it hasn't + // previously been registered. + const wchar_t* GetWindowClass(); + + // Unregisters the window class. Should only be called if there are no + // instances of the window. + void UnregisterWindowClass(); + + private: + WindowClassRegistrar() = default; + + static WindowClassRegistrar* instance_; + + bool class_registered_ = false; +}; + +WindowClassRegistrar* WindowClassRegistrar::instance_ = nullptr; + +const wchar_t* WindowClassRegistrar::GetWindowClass() { + if (!class_registered_) { + WNDCLASS window_class{}; + window_class.hCursor = LoadCursor(nullptr, IDC_ARROW); + window_class.lpszClassName = kWindowClassName; + window_class.style = CS_HREDRAW | CS_VREDRAW; + window_class.cbClsExtra = 0; + window_class.cbWndExtra = 0; + window_class.hInstance = GetModuleHandle(nullptr); + window_class.hIcon = + LoadIcon(window_class.hInstance, MAKEINTRESOURCE(IDI_APP_ICON)); + window_class.hbrBackground = 0; + window_class.lpszMenuName = nullptr; + window_class.lpfnWndProc = Win32Window::WndProc; + RegisterClass(&window_class); + class_registered_ = true; + } + return kWindowClassName; +} + +void WindowClassRegistrar::UnregisterWindowClass() { + UnregisterClass(kWindowClassName, nullptr); + class_registered_ = false; +} + +Win32Window::Win32Window() { + ++g_active_window_count; +} + +Win32Window::~Win32Window() { + --g_active_window_count; + Destroy(); +} + +bool Win32Window::Create(const std::wstring& title, + const Point& origin, + const Size& size) { + Destroy(); + + const wchar_t* window_class = + WindowClassRegistrar::GetInstance()->GetWindowClass(); + + const POINT target_point = {static_cast(origin.x), + static_cast(origin.y)}; + HMONITOR monitor = MonitorFromPoint(target_point, MONITOR_DEFAULTTONEAREST); + UINT dpi = FlutterDesktopGetDpiForMonitor(monitor); + double scale_factor = dpi / 96.0; + + HWND window = CreateWindow( + window_class, title.c_str(), WS_OVERLAPPEDWINDOW, + Scale(origin.x, scale_factor), Scale(origin.y, scale_factor), + Scale(size.width, scale_factor), Scale(size.height, scale_factor), + nullptr, nullptr, GetModuleHandle(nullptr), this); + + if (!window) { + return false; + } + + UpdateTheme(window); + + return OnCreate(); +} + +bool Win32Window::Show() { + return ShowWindow(window_handle_, SW_SHOWNORMAL); +} + +// static +LRESULT CALLBACK Win32Window::WndProc(HWND const window, + UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept { + if (message == WM_NCCREATE) { + auto window_struct = reinterpret_cast(lparam); + SetWindowLongPtr(window, GWLP_USERDATA, + reinterpret_cast(window_struct->lpCreateParams)); + + auto that = static_cast(window_struct->lpCreateParams); + EnableFullDpiSupportIfAvailable(window); + that->window_handle_ = window; + } else if (Win32Window* that = GetThisFromHandle(window)) { + return that->MessageHandler(window, message, wparam, lparam); + } + + return DefWindowProc(window, message, wparam, lparam); +} + +LRESULT +Win32Window::MessageHandler(HWND hwnd, + UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept { + switch (message) { + case WM_DESTROY: + window_handle_ = nullptr; + Destroy(); + if (quit_on_close_) { + PostQuitMessage(0); + } + return 0; + + case WM_DPICHANGED: { + auto newRectSize = reinterpret_cast(lparam); + LONG newWidth = newRectSize->right - newRectSize->left; + LONG newHeight = newRectSize->bottom - newRectSize->top; + + SetWindowPos(hwnd, nullptr, newRectSize->left, newRectSize->top, newWidth, + newHeight, SWP_NOZORDER | SWP_NOACTIVATE); + + return 0; + } + case WM_SIZE: { + RECT rect = GetClientArea(); + if (child_content_ != nullptr) { + // Size and position the child window. + MoveWindow(child_content_, rect.left, rect.top, rect.right - rect.left, + rect.bottom - rect.top, TRUE); + } + return 0; + } + + case WM_ACTIVATE: + if (child_content_ != nullptr) { + SetFocus(child_content_); + } + return 0; + + case WM_DWMCOLORIZATIONCOLORCHANGED: + UpdateTheme(hwnd); + return 0; + } + + return DefWindowProc(window_handle_, message, wparam, lparam); +} + +void Win32Window::Destroy() { + OnDestroy(); + + if (window_handle_) { + DestroyWindow(window_handle_); + window_handle_ = nullptr; + } + if (g_active_window_count == 0) { + WindowClassRegistrar::GetInstance()->UnregisterWindowClass(); + } +} + +Win32Window* Win32Window::GetThisFromHandle(HWND const window) noexcept { + return reinterpret_cast( + GetWindowLongPtr(window, GWLP_USERDATA)); +} + +void Win32Window::SetChildContent(HWND content) { + child_content_ = content; + SetParent(content, window_handle_); + RECT frame = GetClientArea(); + + MoveWindow(content, frame.left, frame.top, frame.right - frame.left, + frame.bottom - frame.top, true); + + SetFocus(child_content_); +} + +RECT Win32Window::GetClientArea() { + RECT frame; + GetClientRect(window_handle_, &frame); + return frame; +} + +HWND Win32Window::GetHandle() { + return window_handle_; +} + +void Win32Window::SetQuitOnClose(bool quit_on_close) { + quit_on_close_ = quit_on_close; +} + +bool Win32Window::OnCreate() { + // No-op; provided for subclasses. + return true; +} + +void Win32Window::OnDestroy() { + // No-op; provided for subclasses. +} + +void Win32Window::UpdateTheme(HWND const window) { + DWORD light_mode; + DWORD light_mode_size = sizeof(light_mode); + LSTATUS result = RegGetValue(HKEY_CURRENT_USER, kGetPreferredBrightnessRegKey, + kGetPreferredBrightnessRegValue, + RRF_RT_REG_DWORD, nullptr, &light_mode, + &light_mode_size); + + if (result == ERROR_SUCCESS) { + BOOL enable_dark_mode = light_mode == 0; + DwmSetWindowAttribute(window, DWMWA_USE_IMMERSIVE_DARK_MODE, + &enable_dark_mode, sizeof(enable_dark_mode)); + } +} diff --git a/apps/cli/fixtures/legacy/firebase/windows/runner/win32_window.h b/apps/cli/fixtures/legacy/firebase/windows/runner/win32_window.h new file mode 100644 index 000000000..e901dde68 --- /dev/null +++ b/apps/cli/fixtures/legacy/firebase/windows/runner/win32_window.h @@ -0,0 +1,102 @@ +#ifndef RUNNER_WIN32_WINDOW_H_ +#define RUNNER_WIN32_WINDOW_H_ + +#include + +#include +#include +#include + +// A class abstraction for a high DPI-aware Win32 Window. Intended to be +// inherited from by classes that wish to specialize with custom +// rendering and input handling +class Win32Window { + public: + struct Point { + unsigned int x; + unsigned int y; + Point(unsigned int x, unsigned int y) : x(x), y(y) {} + }; + + struct Size { + unsigned int width; + unsigned int height; + Size(unsigned int width, unsigned int height) + : width(width), height(height) {} + }; + + Win32Window(); + virtual ~Win32Window(); + + // Creates a win32 window with |title| that is positioned and sized using + // |origin| and |size|. New windows are created on the default monitor. Window + // sizes are specified to the OS in physical pixels, hence to ensure a + // consistent size this function will scale the inputted width and height as + // as appropriate for the default monitor. The window is invisible until + // |Show| is called. Returns true if the window was created successfully. + bool Create(const std::wstring& title, const Point& origin, const Size& size); + + // Show the current window. Returns true if the window was successfully shown. + bool Show(); + + // Release OS resources associated with window. + void Destroy(); + + // Inserts |content| into the window tree. + void SetChildContent(HWND content); + + // Returns the backing Window handle to enable clients to set icon and other + // window properties. Returns nullptr if the window has been destroyed. + HWND GetHandle(); + + // If true, closing this window will quit the application. + void SetQuitOnClose(bool quit_on_close); + + // Return a RECT representing the bounds of the current client area. + RECT GetClientArea(); + + protected: + // Processes and route salient window messages for mouse handling, + // size change and DPI. Delegates handling of these to member overloads that + // inheriting classes can handle. + virtual LRESULT MessageHandler(HWND window, + UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept; + + // Called when CreateAndShow is called, allowing subclass window-related + // setup. Subclasses should return false if setup fails. + virtual bool OnCreate(); + + // Called when Destroy is called. + virtual void OnDestroy(); + + private: + friend class WindowClassRegistrar; + + // OS callback called by message pump. Handles the WM_NCCREATE message which + // is passed when the non-client area is being created and enables automatic + // non-client DPI scaling so that the non-client area automatically + // responds to changes in DPI. All other messages are handled by + // MessageHandler. + static LRESULT CALLBACK WndProc(HWND const window, + UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept; + + // Retrieves a class instance pointer for |window| + static Win32Window* GetThisFromHandle(HWND const window) noexcept; + + // Update the window frame's theme to match the system theme. + static void UpdateTheme(HWND const window); + + bool quit_on_close_ = false; + + // window handle for top level window. + HWND window_handle_ = nullptr; + + // window handle for hosted content. + HWND child_content_ = nullptr; +}; + +#endif // RUNNER_WIN32_WINDOW_H_ diff --git a/apps/cli/fixtures/legacy/fixtures_test.dart b/apps/cli/fixtures/legacy/fixtures_test.dart new file mode 100644 index 000000000..cfd0e7388 --- /dev/null +++ b/apps/cli/fixtures/legacy/fixtures_test.dart @@ -0,0 +1,4508 @@ +// ignore_for_file: invalid_use_of_visible_for_testing_member + +@Tags(['goldens']) +library; + +import 'dart:convert'; +import 'dart:io' hide Directory; +import 'dart:isolate'; +import 'dart:math'; + +import 'package:async/async.dart'; +import 'package:celest/src/runtime/serve.dart'; +import 'package:celest_cli/analyzer/analysis_result.dart'; +import 'package:celest_cli/analyzer/celest_analyzer.dart'; +import 'package:celest_cli/codegen/client_code_generator.dart'; +import 'package:celest_cli/codegen/cloud_code_generator.dart'; +import 'package:celest_cli/compiler/api/local_api_runner.dart'; +import 'package:celest_cli/database/project/project_database.dart'; +import 'package:celest_cli/env/config_value_solver.dart'; +import 'package:celest_cli/init/project_migrator.dart'; +import 'package:celest_cli/project/celest_project.dart'; +import 'package:celest_cli/project/project_resolver.dart'; +import 'package:celest_cli/pub/pub_action.dart'; +import 'package:celest_cli/src/context.dart'; +import 'package:celest_cli/src/utils/recase.dart'; +import 'package:dart_jsonwebtoken/dart_jsonwebtoken.dart'; +import 'package:file/file.dart'; +import 'package:http/http.dart'; +import 'package:path/path.dart' as p; +import 'package:stream_transform/stream_transform.dart'; +import 'package:test/test.dart'; + +import '../../test/common.dart'; +import 'types.dart'; + +final testDir = p.join(fileSystem.currentDirectory.path, 'fixtures', 'legacy'); + +void main() { + final updateGoldens = switch (Platform.environment['UPDATE_GOLDENS']) { + 'true' => true, + _ => false, + }; + final includeTests = Platform.environment['INCLUDE_TESTS']?.split(','); + final skipTests = Platform.environment['SKIP_TESTS']?.split(','); + final includeApis = Platform.environment['INCLUDE_APIS']?.split(','); + final clearCache = Platform.environment['CLEAR_CACHE'] == 'true'; + + if (updateGoldens && Platform.isWindows) { + throw Exception( + 'Cannot update goldens on Windows due to path differences.', + ); + } + + final testRunners = []; + final testDirs = + fileSystem.directory(testDir).listSync().whereType(); + for (final testDir in testDirs) { + final (projectDir, useCelestLayout) = + testDir.childDirectory('celest').existsSync() + ? (testDir.childDirectory('celest'), true) + : (testDir, false); + if (!projectDir.childFile('pubspec.yaml').existsSync()) { + continue; + } + if (p.basename(projectDir.path).startsWith('_')) { + continue; + } + if (includeTests != null && + !includeTests.contains(p.basename(testDir.path))) { + continue; + } + if (skipTests != null && skipTests.contains(p.basename(testDir.path))) { + continue; + } + final testRunner = TestRunner( + testName: p.basename(testDir.path), + projectRoot: projectDir.path, + updateGoldens: updateGoldens, + clearCache: clearCache, + parentProject: + useCelestLayout ? ParentProject.loadSync(testDir.path) : null, + clientDir: projectDir.childDirectory('client'), + goldensDir: fileSystem.directory(p.join(projectDir.path, 'goldens')), + includeApis: includeApis, + ); + testRunners.add(testRunner); + } + + group('Fixture', () { + setUpAll(initTests); + + for (final runner in testRunners) { + runner.run(); + } + }); +} + +class TestRunner { + TestRunner({ + required this.testName, + required this.projectRoot, + required this.updateGoldens, + required this.clearCache, + this.parentProject, + required this.clientDir, + required this.goldensDir, + this.includeApis, + }); + + final String testName; + final String projectRoot; + final bool updateGoldens; + final bool clearCache; + final Directory clientDir; + final ParentProject? parentProject; + final Directory goldensDir; + final List? includeApis; + + late final testCases = tests[testName]; + + late Client client; + late CelestAnalyzer analyzer; + + static Future _warmUp(String projectRoot) { + return Isolate.run(() => CelestAnalyzer.warmUp(projectRoot)); + } + + void run() { + group(testName, () { + setUpAll(() async { + await runPub( + exe: Platform.resolvedExecutable, + action: PubAction.upgrade, + workingDirectory: projectRoot, + ).timeout(const Duration(seconds: 10)); + if (updateGoldens) { + if (goldensDir.existsSync()) { + goldensDir.deleteSync(recursive: true); + } + if (clientDir.existsSync()) { + clientDir.deleteSync(recursive: true); + } + } + if (clearCache) { + final cacheDir = fileSystem.directory( + p.join(projectRoot, '.dart_tool', 'celest'), + ); + if (cacheDir.existsSync()) { + cacheDir.deleteSync(recursive: true); + } + } + await init( + projectRoot: projectRoot, + parentProject: parentProject, + clientDir: clientDir.path, + outputsDir: goldensDir.path, + projectDb: ProjectDatabase.memory(), + ); + analyzer = CelestAnalyzer(); + goldensDir.createSync(); + client = Client(); + + final migrator = ProjectMigrator( + projectRoot: projectRoot, + projectName: celestProject.projectName, + parentProject: parentProject, + ); + await (_warmUp(projectRoot), migrator.migrate()).wait; + }); + + tearDownAll(() async { + client.close(); + analyzer.reset(); + await celestProject.close(); + }); + + testAnalyzer(); + testResolve(); + testCodegen(); + testClient(); + + final apisDir = fileSystem.directory( + p.join(projectRoot, 'lib', 'src', 'functions'), + ); + if (apisDir.existsSync()) { + testApis(apisDir, includeApis); + } + }); + } + + void testAnalyzer() { + // Analyzer needs a bit longer. + // TODO(dnys1): Benchmark + improve performance of analysis. + test('analyzer', timeout: const Timeout.factor(3), () async { + final CelestAnalysisResult(:project, :errors, :warnings) = await analyzer + .analyzeProject( + migrateProject: false, + updateResources: updateGoldens, + ); + expect(errors, isEmpty); + expect(warnings, isEmpty); + expect(project, isNotNull); + + if (Platform.isWindows) { + // Cannot check/update goldens on Windows due to path differences. + return; + } + final goldenAst = fileSystem.file( + p.join(projectPaths.outputsDir, 'ast.json'), + ); + if (updateGoldens) { + await goldenAst.writeAsString( + const JsonEncoder.withIndent(' ').convert(project!.toJson()), + ); + } else { + final expectedAst = jsonDecode(await goldenAst.readAsString()); + expect(project!.toJson(), expectedAst); + } + }); + } + + void testCodegen() { + test('codegen', () async { + final CelestAnalysisResult(:project, :errors, :warnings) = await analyzer + .analyzeProject( + migrateProject: false, + updateResources: updateGoldens, + ); + expect(errors, isEmpty); + expect(warnings, isEmpty); + expect(project, isNotNull); + + final configValues = + await ConfigValueSolver( + project: project!, + environmentId: 'local', + ).solveAll(); + final projectResolver = ProjectResolver( + configValues: configValues, + environmentId: 'local', + ); + project.acceptWithArg(projectResolver, project); + + final codegen = CloudCodeGenerator( + project: project, + resolvedProject: projectResolver.resolvedProject, + ); + project.accept(codegen); + + // final openApiSpec = OpenApiRenderer( + // project: project, + // resolvedProject: projectResolver.resolvedProject, + // ).renderToYaml(); + + final fileOutputs = { + ...codegen.fileOutputs, + // p.join(goldensDir.path, 'openapi.yaml'): openApiSpec, + }; + + for (final MapEntry(key: path, value: content) in fileOutputs.entries) { + final goldenFile = fileSystem.file(path); + if (updateGoldens) { + await goldenFile.create(recursive: true); + await goldenFile.writeAsString(content); + } else { + final expected = await goldenFile.readAsString(); + expect(content, equalsIgnoringWhitespace(expected)); + } + } + }); + } + + void testResolve() { + test('resolve', () async { + final CelestAnalysisResult(:project, :errors, :warnings) = await analyzer + .analyzeProject( + migrateProject: false, + updateResources: updateGoldens, + ); + expect(errors, isEmpty); + expect(warnings, isEmpty); + expect(project, isNotNull); + + final configValues = + await ConfigValueSolver( + project: project!, + environmentId: 'local', + ).solveAll(); + final projectResolver = ProjectResolver( + configValues: configValues, + environmentId: 'local', + ); + project.acceptWithArg(projectResolver, project); + final resolvedAstFile = fileSystem.file( + p.join(projectPaths.outputsDir, 'ast.resolved.json'), + ); + final resolvedAst = projectResolver.resolvedProject.toJson(); + if (updateGoldens) { + resolvedAstFile + ..createSync(recursive: true) + ..writeAsStringSync( + const JsonEncoder.withIndent(' ').convert(resolvedAst), + ); + } else { + final expectedAst = jsonDecode(resolvedAstFile.readAsStringSync()); + expect(resolvedAst, expectedAst); + } + }); + } + + void testClient() { + test('client', () async { + final CelestAnalysisResult(:project, :errors) = await analyzer + .analyzeProject( + migrateProject: false, + updateResources: updateGoldens, + ); + expect(errors, isEmpty); + expect(project, isNotNull); + + final configValues = + await ConfigValueSolver( + project: project!, + environmentId: 'local', + ).solveAll(); + final projectResolver = ProjectResolver( + configValues: configValues, + environmentId: 'local', + ); + project.acceptWithArg(projectResolver, project); + + final clientGen = ClientCodeGenerator( + project: project, + resolvedProject: projectResolver.resolvedProject, + projectUris: ( + localUri: Uri.http('localhost:$defaultCelestPort'), + productionUri: Uri.parse('https://example.celest.run'), + ), + ); + final outputs = clientGen.generate(); + if (updateGoldens) { + await outputs.write(); + } else { + outputs.forEach((path, library) { + expect( + library, + equalsIgnoringWhitespace(fileSystem.file(path).readAsStringSync()), + ); + }); + } + + // TODO(dnys1): Needed? Or can we just verify visually? This is very + // flaky when the previous command adds new dependencies. + + // final analyzeResult = await processManager.run( + // [Platform.resolvedExecutable, 'analyze', '.'], + // workingDirectory: projectRoot, + // ); + // expect( + // analyzeResult.exitCode, + // 0, + // reason: '${analyzeResult.stdout}\n${analyzeResult.stderr}', + // ); + }); + } + + void testApis(Directory apisDir, List? includeApis) { + final apis = testCases?.apis ?? const {}; + if (apis.isEmpty) { + return; + } + group('apis', () { + for (final MapEntry(key: apiName, value: apiTest) in apis.entries) { + if (includeApis != null && + (!includeApis.contains(apiName) || includeApis.contains('none'))) { + continue; + } + testApi(apiName, apiTest); + } + }); + } + + void testApi(String apiName, ApiTest apiTest) { + group(apiName, () { + late Uri apiUri; + final logs = []; + final logSink = LogSink(logs); + late LocalApiRunner apiRunner; + + setUpAll(() async { + final entrypoint = projectPaths.localApiEntrypoint; + final CelestAnalysisResult(:project, :errors) = await analyzer + .analyzeProject( + migrateProject: false, + updateResources: updateGoldens, + ); + expect(errors, isEmpty); + expect(project, isNotNull); + + final configValues = + await ConfigValueSolver( + project: project!, + environmentId: 'local', + ).solveAll(); + final projectResolver = ProjectResolver( + configValues: configValues, + environmentId: 'local', + ); + project.acceptWithArg(projectResolver, project); + apiRunner = await LocalApiRunner.start( + resolvedProject: projectResolver.resolvedProject, + path: entrypoint, + configValues: configValues, + environmentId: 'local', + verbose: false, + stdoutPipe: logSink, + stderrPipe: logSink, + vmServiceTimeout: const Duration(seconds: 30), + ); + apiUri = Uri.parse('http://localhost:${apiRunner.port}'); + + await expectLater(client.get(apiUri), completes); + }); + + setUp(logs.clear); + + tearDownAll(() async { + await apiRunner.close(); + }); + + final functions = { + ...apiTest.functionTests.keys, + ...apiTest.eventTests.keys, + }; + for (final functionName in functions) { + testFunction( + apiName, + functionName, + apiTest.functionTests[functionName] ?? const [], + apiTest.eventTests[functionName] ?? const [], + logs, + () => apiRunner, + () => apiUri, + ); + } + }); + } + + void testFunction( + String apiName, + String functionName, + List httpTests, + List eventTests, + List logs, + LocalApiRunner Function() runner, + Uri Function() apiUri, + ) { + group(functionName, () { + for (final testCase in httpTests) { + test(testCase.name, () async { + final request = + Request( + testCase.method, + apiUri() + .resolve( + '/${apiName.paramCase}/${functionName.paramCase}', + ) + .replace(queryParameters: testCase.queryParameters), + ) + ..headers.addAll({ + 'Content-Type': 'application/json', + ...testCase.headers, + }) + ..body = jsonEncode(testCase.input); + if (testCase.setup case final setup?) { + await setup(request); + } + print('${request.method} ${request.url}'); + final response = client.send(request); + final result = await Result.capture(response); + try { + switch (testCase) { + case FunctionTestError(:final output): + switch (result) { + case ErrorResult(error: final e): + fail('Unexpected error: $e'); + case ValueResult(value: final resp): + expect(resp.statusCode, testCase.statusCode); + final body = await resp.stream.bytesToString(); + final respJson = jsonDecode(body); + expect(respJson, equals(output)); + } + case FunctionTestSuccess(:final output): + expect(result.isValue, isTrue); + final resp = result.asValue!.value; + final body = await resp.stream.bytesToString(); + expect(resp.statusCode, testCase.statusCode, reason: body); + if (testCase.method == 'HEAD') { + expect(body, isEmpty); + } else { + final respJson = jsonDecode(body); + expect(respJson, equals(output)); + } + } + if (testCase.logs case final expectedLogs?) { + expect(logs, containsAllInOrder(expectedLogs.map(contains))); + } + } on Object { + await runner().close(); + print(logs.join('\n')); + rethrow; + } + }); + } + + for (final testCase in eventTests) { + test(testCase.name, () async { + final socket = await WebSocket.connect( + apiUri() + .resolve('/${apiName.paramCase}/${functionName.paramCase}') + .replace( + scheme: 'ws', + queryParameters: testCase.queryParameters, + ) + .toString(), + ); + addTearDown(socket.close); + socket.add(jsonEncode(testCase.input)); + try { + switch (testCase) { + case EventTestSuccess(:final output): + await expectLater( + socket.tap((evt) => print('[${testCase.name}] $evt')), + output, + ); + case EventTestError(:final error): + await expectLater( + socket.tap((evt) => print('[${testCase.name}] $evt')), + emitsError(error), + ); + } + if (testCase.logs case final expectedLogs?) { + expect(logs, containsAllInOrder(expectedLogs.map(contains))); + } + } on Object { + await runner().close(); + print(logs.join('\n')); + rethrow; + } + }); + } + }); + } +} + +final class LogSink implements StringSink { + LogSink(this.logs); + + final List logs; + + @override + void write(Object? object) { + logs.add('$object'); + } + + @override + void writeAll(Iterable objects, [String separator = '']) { + logs.addAll(objects.join(separator).split('\n')); + } + + @override + void writeCharCode(int charCode) { + logs.add(String.fromCharCode(charCode)); + } + + @override + void writeln([Object? object = '']) { + logs.add('$object'); + } +} + +const simpleStruct = {}; + +const complexStruct = { + 'aString': 'hello', + 'anInt': 42, + 'aDouble': 3.14, + 'aBool': true, + 'anEnum': 'a', + 'aNull': null, + 'aBigInt': '42', + 'aDateTime': '2021-01-01T00:00:00.000Z', + 'aDuration': { + 'days': 1, + 'hours': 2, + 'minutes': 3, + 'seconds': 4, + 'milliseconds': 5, + 'microseconds': 6, + }, + 'aRegExp': '.*', + 'aStackTrace': ''' +#0 main (file:///Users/test/projects/hello/lib/src/main.dart:10:3) +''', + 'aUri': 'https://google.com', + 'aUriData': 'data:text/plain;base64,SGVsbG8sIFdvcmxkIQ==', + 'aUint8List': 'SGVsbG8sIFdvcmxkIQ==', + 'aSimpleStruct': simpleStruct, + 'aSimpleClass': simpleStruct, + 'anIterableOfString': ['hello', 'world'], + 'anIterableOfUint8List': ['SGVsbG8sIFdvcmxkIQ==', 'SGVsbG8sIFdvcmxkIQ=='], + 'anIterableOfSimpleClass': [simpleStruct, simpleStruct], + 'aListOfString': ['hello', 'world'], + 'aListOfInt': [1, 2, 3], + 'aListOfDouble': [1.0, 2.0, 3.0], + 'aListOfBool': [true, false], + 'aListOfEnum': ['a', 'b', 'c'], + 'aListOfNull': [null, null], + 'aListOfBigInt': ['42', '43'], + 'aListOfDateTime': ['2021-01-01T00:00:00.000Z', '2021-01-02T00:00:00.000Z'], + 'aListOfDuration': [ + { + 'days': 1, + 'hours': 2, + 'minutes': 3, + 'seconds': 4, + 'milliseconds': 5, + 'microseconds': 6, + }, + { + 'days': 1, + 'hours': 2, + 'minutes': 3, + 'seconds': 4, + 'milliseconds': 5, + 'microseconds': 6, + }, + ], + 'aListOfRegExp': ['.*', '.*'], + 'aListOfStackTrace': [ + ''' +#0 main (file:///Users/test/projects/hello/lib/src/main.dart:10:3) +''', + ''' +#0 main (file:///Users/test/projects/hello/lib/src/main.dart:10:3) +''', + ], + 'aListOfUri': ['https://google.com', 'https://google.com'], + 'aListOfUriData': [ + 'data:text/plain;base64,SGVsbG8sIFdvcmxkIQ==', + 'data:text/plain;base64,SGVsbG8sIFdvcmxkIQ==', + ], + 'aListOfUint8List': ['SGVsbG8sIFdvcmxkIQ==', 'SGVsbG8sIFdvcmxkIQ=='], + 'aListOfSimpleStruct': [simpleStruct, simpleStruct], + 'aListOfSimpleClass': [simpleStruct, simpleStruct], + 'aMapOfString': {'hello': 'world'}, + 'aMapOfInt': {'one': 1, 'two': 2, 'three': 3}, + 'aMapOfDouble': {'one': 1.0, 'two': 2.0, 'three': 3.0}, + 'aMapOfBool': {'true': true, 'false': false}, + 'aMapOfEnum': {'a': 'a', 'b': 'b', 'c': 'c'}, + 'aMapOfNull': {'null': null}, + 'aMapOfBigInt': {'one': '1', 'two': '2', 'three': '3'}, + 'aMapOfDateTime': { + 'one': '2021-01-01T00:00:00.000Z', + 'two': '2021-01-02T00:00:00.000Z', + 'three': '2021-01-03T00:00:00.000Z', + }, + 'aMapOfDuration': { + 'one': { + 'days': 1, + 'hours': 2, + 'minutes': 3, + 'seconds': 4, + 'milliseconds': 5, + 'microseconds': 6, + }, + 'two': { + 'days': 1, + 'hours': 2, + 'minutes': 3, + 'seconds': 4, + 'milliseconds': 5, + 'microseconds': 6, + }, + 'three': { + 'days': 1, + 'hours': 2, + 'minutes': 3, + 'seconds': 4, + 'milliseconds': 5, + 'microseconds': 6, + }, + }, + 'aMapOfRegExp': {'one': '.*', 'two': '.*', 'three': '.*'}, + 'aMapOfStackTrace': { + 'one': ''' +#0 main (file:///Users/test/projects/hello/lib/src/main.dart:10:3) +''', + 'two': ''' +#0 main (file:///Users/test/projects/hello/lib/src/main.dart:10:3) +''', + 'three': ''' +#0 main (file:///Users/test/projects/hello/lib/src/main.dart:10:3) +''', + }, + 'aMapOfUri': { + 'one': 'https://google.com', + 'two': 'https://google.com', + 'three': 'https://google.com', + }, + 'aMapOfUriData': { + 'one': 'data:text/plain;base64,SGVsbG8sIFdvcmxkIQ==', + 'two': 'data:text/plain;base64,SGVsbG8sIFdvcmxkIQ==', + 'three': 'data:text/plain;base64,SGVsbG8sIFdvcmxkIQ==', + }, + 'aMapOfUint8List': { + 'one': 'SGVsbG8sIFdvcmxkIQ==', + 'two': 'SGVsbG8sIFdvcmxkIQ==', + 'three': 'SGVsbG8sIFdvcmxkIQ==', + }, + 'aMapOfSimpleStruct': { + 'one': simpleStruct, + 'two': simpleStruct, + 'three': simpleStruct, + }, + 'aMapOfSimpleClass': { + 'one': simpleStruct, + 'two': simpleStruct, + 'three': simpleStruct, + }, +}; + +final tests = { + 'api': Test( + apis: { + 'asserts': ApiTest( + functionTests: { + 'assertsEnabled': [ + FunctionTestSuccess( + name: 'assertsEnabled', + input: {}, + output: true, + ), + ], + }, + ), + 'collections': ApiTest( + functionTests: { + 'simpleList': [ + FunctionTestSuccess( + name: 'simpleList', + input: { + 'list': ['hello', 'world'], + }, + output: ['hello', 'world'], + ), + ], + 'complexList': [ + FunctionTestSuccess( + name: 'complexList', + input: { + 'list': [simpleStruct, simpleStruct], + }, + output: [simpleStruct, simpleStruct], + ), + ], + 'simpleMap': [ + FunctionTestSuccess( + name: 'simpleMap', + input: { + 'map': {'hello': 'world'}, + }, + output: {'hello': 'world'}, + ), + ], + 'dynamicMap': [ + FunctionTestSuccess( + name: 'dynamicMap', + input: { + 'map': {'hello': 'world'}, + }, + output: {'hello': 'world'}, + ), + ], + 'objectMap': [ + FunctionTestSuccess( + name: 'objectMap', + input: { + 'map': {'hello': 'world'}, + }, + output: {'hello': 'world'}, + ), + ], + 'objectNullableMap': [ + FunctionTestSuccess( + name: 'objectNullableMap', + input: { + 'map': {'hello': 'world'}, + }, + output: {'hello': 'world'}, + ), + ], + 'complexMap': [ + FunctionTestSuccess( + name: 'complexMap', + input: { + 'map': {'hello': simpleStruct}, + }, + output: {'hello': simpleStruct}, + ), + ], + }, + ), + 'extension_types': ApiTest( + functionTests: { + 'string': [ + FunctionTestSuccess( + name: 'stringString', + input: {'s': 'hello'}, + output: 'hello', + ), + ], + 'asyncOrString': [ + FunctionTestSuccess( + name: 'asyncOrString', + input: {'s': 'hello'}, + output: 'hello', + ), + ], + 'asyncString': [ + FunctionTestSuccess( + name: 'asyncString', + input: {'s': 'hello'}, + output: 'hello', + ), + ], + 'stringImpl': [ + FunctionTestSuccess( + name: 'stringImpl', + input: {'s': 'hello'}, + output: 'hello', + ), + ], + 'stringToFromJson': [ + FunctionTestSuccess( + name: 'stringToFromJson', + input: {'s': 'hello'}, + output: 'olleh', + ), + ], + 'stringToJson': [ + FunctionTestSuccess( + name: 'stringToJson', + input: {'s': 'hello'}, + output: 'olleh', + ), + ], + 'stringToJsonImpl': [ + FunctionTestSuccess( + name: 'stringToJsonImpl', + input: {'s': 'hello'}, + output: 'olleh', + ), + ], + 'stringFromJson': [ + FunctionTestSuccess( + name: 'stringFromJson', + input: {'s': 'hello'}, + output: 'olleh', + ), + ], + 'stringFromJsonImpl': [ + FunctionTestSuccess( + name: 'stringFromJsonImpl', + input: {'s': 'hello'}, + output: 'olleh', + ), + ], + 'stringFromJsonStatic': [ + FunctionTestSuccess( + name: 'stringFromJsonStatic', + input: {'s': 'hello'}, + output: 'olleh', + ), + ], + 'stringPrivateField': [ + FunctionTestSuccess( + name: 'stringPrivateField', + input: {'s': 'hello'}, + output: 'hello', + ), + ], + 'stringPrivateFieldImpl': [ + FunctionTestSuccess( + name: 'stringPrivateFieldImpl', + input: {'s': 'hello'}, + output: 'hello', + ), + ], + 'stringPrivateCtor': [ + FunctionTestSuccess( + name: 'stringPrivateCtor', + input: {'s': 'hello'}, + output: 'hello', + ), + ], + 'stringPrivateCtorImpl': [ + FunctionTestSuccess( + name: 'stringPrivateCtorImpl', + input: {'s': 'hello'}, + output: 'hello', + ), + ], + 'value': [ + FunctionTestSuccess( + name: 'value', + input: {'v': 'hello'}, + output: 'hello', + ), + ], + 'valueX': [ + FunctionTestSuccess( + name: 'valueX', + input: { + 'v': {'value': 'hello'}, + }, + output: {'value': 'hello'}, + ), + ], + 'valueXImpl': [ + FunctionTestSuccess( + name: 'valueXImpl', + input: { + 'v': {'value': 'hello'}, + }, + output: {'value': 'hello'}, + ), + ], + 'valueXToFromJson': [ + FunctionTestSuccess( + name: 'valueXImpl', + input: {'v': 'hello'}, + output: 'helloFromJsonToJson', + ), + ], + 'valueXToJson': [ + FunctionTestSuccess( + name: 'valueXToJson', + input: { + 'v': {'value': 'hello'}, + }, + output: {'value': 'helloToJson'}, + ), + ], + 'valueXToJsonImpl': [ + FunctionTestSuccess( + name: 'valueXToJson', + input: {'v': 'hello'}, + output: 'helloToJson', + ), + ], + 'valueXFromJson': [ + FunctionTestSuccess( + name: 'valueXFromJson', + input: { + 'v': {'value': 'hello'}, + }, + output: {'value': 'helloFromJson'}, + ), + ], + 'valueXFromJsonImpl': [ + FunctionTestSuccess( + name: 'valueXFromJsonImpl', + input: {'v': 'hello'}, + output: 'helloFromJson', + ), + ], + 'valueXFromJsonStatic': [ + FunctionTestSuccess( + name: 'valueXFromJsonStatic', + input: { + 'v': {'value': 'hello'}, + }, + output: {'value': 'helloFromJson'}, + ), + ], + 'jsonValue': [ + FunctionTestSuccess( + name: 'string', + input: {'value': 'hello'}, + output: 'hello', + ), + FunctionTestSuccess( + name: 'int', + input: {'value': 123}, + output: 123, + ), + FunctionTestSuccess( + name: 'double', + input: {'value': 123.456}, + output: 123.456, + ), + FunctionTestSuccess( + name: 'bool', + input: {'value': true}, + output: true, + ), + FunctionTestSuccess( + name: 'list', + input: { + 'value': ['hello', 123, 123.456, true], + }, + output: ['hello', 123, 123.456, true], + ), + FunctionTestSuccess( + name: 'map', + input: { + 'value': { + 'hello': 'world', + 'int': 123, + 'double': 123.456, + 'bool': true, + }, + }, + output: { + 'hello': 'world', + 'int': 123, + 'double': 123.456, + 'bool': true, + }, + ), + FunctionTestSuccess( + name: 'nested', + input: { + 'value': { + 'hello': 'world', + 'int': 123, + 'double': 123.456, + 'bool': true, + 'list': ['hello', 123, 123.456, true], + 'map': { + 'hello': 'world', + 'int': 123, + 'double': 123.456, + 'bool': true, + }, + }, + }, + output: { + 'hello': 'world', + 'int': 123, + 'double': 123.456, + 'bool': true, + 'list': ['hello', 123, 123.456, true], + 'map': { + 'hello': 'world', + 'int': 123, + 'double': 123.456, + 'bool': true, + }, + }, + ), + ], + 'jsonString': [ + FunctionTestSuccess( + name: 'jsonString', + input: {'value': 'hello'}, + output: 'hello', + ), + ], + 'jsonNum': [ + FunctionTestSuccess( + name: 'int', + input: {'value': 123}, + output: 123, + ), + FunctionTestSuccess( + name: 'double', + input: {'value': 123.456}, + output: 123.456, + ), + ], + 'jsonInt': [ + FunctionTestSuccess( + name: 'jsonInt', + input: {'value': 123}, + output: 123, + ), + ], + 'jsonDouble': [ + FunctionTestSuccess( + name: 'jsonDouble', + input: {'value': 123.456}, + output: 123.456, + ), + ], + 'jsonBool': [ + FunctionTestSuccess( + name: 'jsonBool', + input: {'value': true}, + output: true, + ), + ], + 'jsonList': [ + FunctionTestSuccess( + name: 'simple', + input: { + 'value': ['hello', 123, 123.456, true], + }, + output: ['hello', 123, 123.456, true], + ), + FunctionTestSuccess( + name: 'complex', + input: { + 'value': [complexStruct, complexStruct], + }, + output: [complexStruct, complexStruct], + ), + ], + 'jsonMap': [ + FunctionTestSuccess( + name: 'simple', + input: { + 'value': { + 'hello': 'world', + 'int': 123, + 'double': 123.456, + 'bool': true, + }, + }, + output: { + 'hello': 'world', + 'int': 123, + 'double': 123.456, + 'bool': true, + }, + ), + FunctionTestSuccess( + name: 'complex', + input: { + 'value': {'a': complexStruct, 'b': complexStruct}, + }, + output: {'a': complexStruct, 'b': complexStruct}, + ), + ], + 'color': [ + FunctionTestSuccess( + name: 'color', + input: {'color': 'r'}, + output: 'r', + ), + ], + 'colorX': [ + FunctionTestSuccess( + name: 'colorX', + input: {'color': 'red'}, + output: 'red', + ), + ], + 'colorXImpl': [ + FunctionTestSuccess( + name: 'colorX', + input: {'color': 'red'}, + output: 'red', + ), + ], + 'colorXToFromJson': [ + FunctionTestSuccess( + name: 'colorXToFromJson', + input: {'color': 'RED'}, + output: 'RED', + ), + ], + 'colorXToJson': [ + FunctionTestSuccess( + name: 'colorXToJson', + input: {'color': 'red'}, + output: 'RED', + ), + ], + 'colorXToJsonImpl': [ + FunctionTestSuccess( + name: 'colorXToJson', + input: {'color': 'red'}, + output: 'RED', + ), + ], + 'colorXFromJson': [ + FunctionTestSuccess( + name: 'colorXFromJson', + input: {'color': 'RED'}, + output: 'red', + ), + ], + 'colorXFromJsonImpl': [ + FunctionTestSuccess( + name: 'colorXFromJsonImpl', + input: {'color': 'RED'}, + output: 'r', + ), + ], + 'colorXFromJsonStatic': [ + FunctionTestSuccess( + name: 'colorXFromJsonStatic', + input: {'color': 'RED'}, + output: 'red', + ), + ], + }, + ), + 'parameter_types': ApiTest( + functionTests: { + 'simple': [ + FunctionTestSuccess( + name: 'valid input', + input: complexStruct, + output: null, + ), + ], + 'simpleOptional': [ + FunctionTestSuccess( + name: 'all present', + input: complexStruct, + output: null, + ), + FunctionTestSuccess(name: 'all null', input: {}, output: null), + ], + 'complex': [ + FunctionTestSuccess( + name: 'all present', + input: { + 'aSimpleStruct': simpleStruct, + 'aComplexStruct': complexStruct, + 'aSimpleClass': simpleStruct, + 'aComplexClass': complexStruct, + 'aNullableSimpleStruct': simpleStruct, + 'aNullableComplexStruct': complexStruct, + 'aNullableSimpleClass': simpleStruct, + 'aNullableComplexClass': complexStruct, + 'anIterableOfSimpleStruct': [simpleStruct, simpleStruct], + 'anIterableOfComplexStruct': [complexStruct, complexStruct], + 'anIterableOfSimpleClass': [simpleStruct, simpleStruct], + 'anIterableOfComplexClass': [complexStruct, complexStruct], + 'aNullableIterableOfSimpleStruct': [simpleStruct, simpleStruct], + 'aNullableIterableOfComplexStruct': [ + complexStruct, + complexStruct, + ], + 'aNullableIterableOfSimpleClass': [simpleStruct, simpleStruct], + 'aNullableIterableOfComplexClass': [ + complexStruct, + complexStruct, + ], + 'anIterableOfNullableSimpleStruct': [ + simpleStruct, + null, + simpleStruct, + ], + 'anIterableOfNullableComplexStruct': [ + complexStruct, + null, + complexStruct, + ], + 'anIterableOfNullableSimpleClass': [ + simpleStruct, + null, + simpleStruct, + ], + 'anIterableOfNullableComplexClass': [ + complexStruct, + null, + complexStruct, + ], + 'aListOfSimpleStruct': [simpleStruct, simpleStruct], + 'aListOfComplexStruct': [complexStruct, complexStruct], + 'aListOfSimpleClass': [simpleStruct, simpleStruct], + 'aListOfComplexClass': [complexStruct, complexStruct], + 'aNullableListOfSimpleStruct': [simpleStruct, simpleStruct], + 'aNullableListOfComplexStruct': [complexStruct, complexStruct], + 'aNullableListOfSimpleClass': [simpleStruct, simpleStruct], + 'aNullableListOfComplexClass': [complexStruct, complexStruct], + 'aListOfNullableSimpleStruct': [ + simpleStruct, + null, + simpleStruct, + ], + 'aListOfNullableComplexStruct': [ + complexStruct, + null, + complexStruct, + ], + 'aListOfNullableSimpleClass': [ + simpleStruct, + null, + simpleStruct, + ], + 'aListOfNullableComplexClass': [ + complexStruct, + null, + complexStruct, + ], + 'aMapOfSimpleStruct': { + 'one': simpleStruct, + 'two': simpleStruct, + 'three': simpleStruct, + }, + 'aMapOfComplexStruct': { + 'one': complexStruct, + 'two': complexStruct, + 'three': complexStruct, + }, + 'aMapOfSimpleClass': { + 'one': simpleStruct, + 'two': simpleStruct, + 'three': simpleStruct, + }, + 'aMapOfComplexClass': { + 'one': complexStruct, + 'two': complexStruct, + 'three': complexStruct, + }, + 'aNullableMapOfSimpleStruct': { + 'one': simpleStruct, + 'two': simpleStruct, + 'three': simpleStruct, + }, + 'aNullableMapOfComplexStruct': { + 'one': complexStruct, + 'two': complexStruct, + 'three': complexStruct, + }, + 'aNullableMapOfSimpleClass': { + 'one': simpleStruct, + 'two': simpleStruct, + 'three': simpleStruct, + }, + 'aNullableMapOfComplexClass': { + 'one': complexStruct, + 'two': complexStruct, + 'three': complexStruct, + }, + 'aMapOfNullableSimpleStruct': { + 'one': simpleStruct, + 'two': null, + 'three': simpleStruct, + }, + 'aMapOfNullableComplexStruct': { + 'one': complexStruct, + 'two': null, + 'three': complexStruct, + }, + 'aMapOfNullableSimpleClass': { + 'one': simpleStruct, + 'two': null, + 'three': simpleStruct, + }, + 'aMapOfNullableComplexClass': { + 'one': complexStruct, + 'two': null, + 'three': complexStruct, + }, + 'aNullableMapOfNullableSimpleStruct': { + 'one': simpleStruct, + 'two': null, + 'three': simpleStruct, + }, + 'aNullableMapOfNullableComplexStruct': { + 'one': complexStruct, + 'two': null, + 'three': complexStruct, + }, + 'aNullableMapOfNullableSimpleClass': { + 'one': simpleStruct, + 'two': null, + 'three': simpleStruct, + }, + 'aNullableMapOfNullableComplexClass': { + 'one': complexStruct, + 'two': null, + 'three': complexStruct, + }, + }, + output: null, + ), + FunctionTestSuccess( + name: 'all required present', + input: { + 'aSimpleStruct': simpleStruct, + 'aComplexStruct': complexStruct, + 'aSimpleClass': simpleStruct, + 'aComplexClass': complexStruct, + 'aNullableSimpleStruct': null, + 'aNullableComplexStruct': null, + 'aNullableSimpleClass': null, + 'aNullableComplexClass': null, + 'anIterableOfSimpleStruct': [simpleStruct, simpleStruct], + 'anIterableOfComplexStruct': [complexStruct, complexStruct], + 'anIterableOfSimpleClass': [simpleStruct, simpleStruct], + 'anIterableOfComplexClass': [complexStruct, complexStruct], + 'aNullableIterableOfSimpleStruct': null, + 'aNullableIterableOfComplexStruct': null, + 'aNullableIterableOfSimpleClass': null, + 'aNullableIterableOfComplexClass': null, + 'anIterableOfNullableSimpleStruct': [ + simpleStruct, + null, + simpleStruct, + ], + 'anIterableOfNullableComplexStruct': [ + complexStruct, + null, + complexStruct, + ], + 'anIterableOfNullableSimpleClass': [ + simpleStruct, + null, + simpleStruct, + ], + 'anIterableOfNullableComplexClass': [ + complexStruct, + null, + complexStruct, + ], + 'aListOfSimpleStruct': [simpleStruct, simpleStruct], + 'aListOfComplexStruct': [complexStruct, complexStruct], + 'aListOfSimpleClass': [simpleStruct, simpleStruct], + 'aListOfComplexClass': [complexStruct, complexStruct], + 'aNullableListOfSimpleStruct': null, + 'aNullableListOfComplexStruct': null, + 'aNullableListOfSimpleClass': null, + 'aNullableListOfComplexClass': null, + 'aListOfNullableSimpleStruct': [ + simpleStruct, + null, + simpleStruct, + ], + 'aListOfNullableComplexStruct': [ + complexStruct, + null, + complexStruct, + ], + 'aListOfNullableSimpleClass': [ + simpleStruct, + null, + simpleStruct, + ], + 'aListOfNullableComplexClass': [ + complexStruct, + null, + complexStruct, + ], + 'aMapOfSimpleStruct': { + 'one': simpleStruct, + 'two': simpleStruct, + 'three': simpleStruct, + }, + 'aMapOfComplexStruct': { + 'one': complexStruct, + 'two': complexStruct, + 'three': complexStruct, + }, + 'aMapOfSimpleClass': { + 'one': simpleStruct, + 'two': simpleStruct, + 'three': simpleStruct, + }, + 'aMapOfComplexClass': { + 'one': complexStruct, + 'two': complexStruct, + 'three': complexStruct, + }, + 'aNullableMapOfSimpleStruct': null, + 'aNullableMapOfComplexStruct': null, + 'aNullableMapOfSimpleClass': null, + 'aNullableMapOfComplexClass': null, + 'aMapOfNullableSimpleStruct': { + 'one': simpleStruct, + 'two': null, + 'three': simpleStruct, + }, + 'aMapOfNullableComplexStruct': { + 'one': complexStruct, + 'two': null, + 'three': complexStruct, + }, + 'aMapOfNullableSimpleClass': { + 'one': simpleStruct, + 'two': null, + 'three': simpleStruct, + }, + 'aMapOfNullableComplexClass': { + 'one': complexStruct, + 'two': null, + 'three': complexStruct, + }, + 'aNullableMapOfNullableSimpleStruct': null, + 'aNullableMapOfNullableComplexStruct': null, + 'aNullableMapOfNullableSimpleClass': null, + 'aNullableMapOfNullableComplexClass': null, + }, + output: null, + ), + ], + }, + ), + 'overrides': ApiTest( + functionTests: { + 'commonNestedParent': [ + FunctionTestSuccess( + name: 'commonNestedParent', + input: { + 'parent': { + 'child': {'name': 'hello'}, + }, + }, + output: { + 'child': {'name': 'hello'}, + }, + ), + ], + 'commonNestedChild': [ + FunctionTestSuccess( + name: 'commonNestedChild', + input: { + 'child': {'name': 'hello'}, + }, + output: {'name': 'hello'}, + ), + ], + 'nestedGrandparent': [ + FunctionTestSuccess( + name: 'nestedGrandparent', + input: { + 'grandparent': { + 'parent': { + 'child': {'name': 'hello'}, + }, + }, + }, + output: { + 'parent': { + 'child': {'name': 'hello'}, + }, + }, + ), + ], + 'nestedParent': [ + FunctionTestSuccess( + name: 'nestedParent', + input: { + 'parent': { + 'child': {'name': 'hello'}, + }, + }, + output: { + 'child': {'name': 'hello'}, + }, + ), + ], + 'nestedChild': [ + FunctionTestSuccess( + name: 'nestedChild', + input: { + 'child': {'name': 'hello'}, + }, + output: {'name': 'hello'}, + ), + ], + 'callsThrowsCommonOverriddenException': [ + const FunctionTestError( + name: 'callsThrowsCommonOverriddenException', + input: {}, + statusCode: 400, + output: { + '@status': { + 'code': 400, + 'message': null, + 'details': [ + { + '@type': 'api.v1.OverriddenException', + 'value': {'message': 'message'}, + }, + {'@type': 'dart.core.StackTrace', 'value': anything}, + ], + }, + }, + ), + ], + 'throwsCommonOverriddenException': [ + const FunctionTestError( + name: 'throwsCommonOverriddenException', + input: {}, + statusCode: 400, + output: { + '@status': { + 'code': 400, + 'message': null, + 'details': [ + { + '@type': 'api.v1.OverriddenException', + 'value': {'message': 'message'}, + }, + {'@type': 'dart.core.StackTrace', 'value': anything}, + ], + }, + }, + ), + ], + 'throwsOverriddenException': [ + const FunctionTestError( + name: 'throwsOverriddenException', + input: {}, + statusCode: 400, + output: { + '@status': { + 'code': 400, + 'message': null, + 'details': [ + { + '@type': 'api.v1.OverriddenException', + 'value': {'message': 'message'}, + }, + {'@type': 'dart.core.StackTrace', 'value': anything}, + ], + }, + }, + ), + ], + 'callsThrowsOverriddenException': [ + const FunctionTestError( + name: 'callsThrowsOverriddenException', + input: {}, + statusCode: 400, + output: { + '@status': { + 'code': 400, + 'message': null, + 'details': [ + { + '@type': 'api.v1.OverriddenException', + 'value': {'message': 'message'}, + }, + {'@type': 'dart.core.StackTrace', 'value': anything}, + ], + }, + }, + ), + ], + }, + ), + 'classes': ApiTest( + functionTests: { + 'empty': [FunctionTestSuccess(name: 'empty', input: {}, output: {})], + 'asyncEmpty': [ + FunctionTestSuccess(name: 'asyncEmpty', input: {}, output: {}), + ], + 'fields': [ + FunctionTestSuccess( + name: 'fields', + input: { + 'value': {'superField': 'superField', 'field': 'field'}, + }, + output: {'superField': 'superField', 'field': 'field'}, + ), + ], + 'asyncFields': [ + FunctionTestSuccess( + name: 'asyncFields', + input: { + 'value': {'superField': 'superField', 'field': 'field'}, + }, + output: {'superField': 'superField', 'field': 'field'}, + ), + ], + 'nullableFields': [ + FunctionTestSuccess(name: 'null', input: {}, output: null), + FunctionTestSuccess( + name: 'present', + input: { + 'value': {'superField': 'superField', 'field': 'field'}, + }, + output: {'superField': 'superField', 'field': 'field'}, + ), + ], + 'asyncNullableFields': [ + FunctionTestSuccess(name: 'null', input: {}, output: null), + FunctionTestSuccess( + name: 'present', + input: { + 'value': {'superField': 'superField', 'field': 'field'}, + }, + output: {'superField': 'superField', 'field': 'field'}, + ), + ], + 'namedFields': [ + FunctionTestSuccess( + name: 'namedFields', + input: { + 'value': {'superField': 'superField', 'field': 'field'}, + }, + output: {'superField': 'superField', 'field': 'field'}, + ), + ], + 'asyncNamedFields': [ + FunctionTestSuccess( + name: 'asyncNamedFields', + input: { + 'value': {'superField': 'superField', 'field': 'field'}, + }, + output: {'superField': 'superField', 'field': 'field'}, + ), + ], + 'mixedFields': [ + FunctionTestSuccess( + name: 'mixedFields', + input: { + 'value': {'superField': 'superField', 'field': 'field'}, + }, + output: {'superField': 'superField', 'field': 'field'}, + ), + ], + 'asyncMixedFields': [ + FunctionTestSuccess( + name: 'asyncMixedFields', + input: { + 'value': {'superField': 'superField', 'field': 'field'}, + }, + output: {'superField': 'superField', 'field': 'field'}, + ), + ], + 'defaultValues': [ + FunctionTestSuccess( + name: 'all fields set', + input: { + 'value': { + 'field': 'field', + 'nullableField': 'nullableField', + 'nullableFieldWithDefault': 'nullableFieldWithDefault', + }, + }, + output: { + 'field': 'field', + 'nullableField': 'nullableField', + 'nullableFieldWithDefault': 'nullableFieldWithDefault', + 'fieldWithoutInitializer': 'default', + }, + ), + FunctionTestSuccess( + name: 'all defaults', + input: {'value': {}}, + output: { + 'field': 'default', + 'nullableFieldWithDefault': 'default', + 'fieldWithoutInitializer': 'default', + }, + ), + ], + 'asyncDefaultValues': [ + FunctionTestSuccess( + name: 'all fields set', + input: { + 'value': { + 'field': 'field', + 'nullableField': 'nullableField', + 'nullableFieldWithDefault': 'nullableFieldWithDefault', + }, + }, + output: { + 'field': 'field', + 'nullableField': 'nullableField', + 'nullableFieldWithDefault': 'nullableFieldWithDefault', + 'fieldWithoutInitializer': 'default', + }, + ), + FunctionTestSuccess( + name: 'all defaults', + input: {'value': {}}, + output: { + 'field': 'default', + 'nullableFieldWithDefault': 'default', + 'fieldWithoutInitializer': 'default', + }, + ), + ], + 'nestedClass': [ + FunctionTestSuccess( + name: 'present', + input: { + 'value': { + 'fields': {'superField': 'superField', 'field': 'field'}, + 'nullableFields': { + 'superField': 'superField', + 'field': 'field', + }, + }, + }, + output: { + 'fields': {'superField': 'superField', 'field': 'field'}, + 'nullableFields': { + 'superField': 'superField', + 'field': 'field', + }, + }, + ), + FunctionTestSuccess( + name: 'null', + input: { + 'value': { + 'fields': {'superField': 'superField', 'field': 'field'}, + }, + }, + output: { + 'fields': {'superField': 'superField', 'field': 'field'}, + }, + ), + ], + 'asyncNestedClass': [ + FunctionTestSuccess( + name: 'present', + input: { + 'value': { + 'fields': {'superField': 'superField', 'field': 'field'}, + 'nullableFields': { + 'superField': 'superField', + 'field': 'field', + }, + }, + }, + output: { + 'fields': {'superField': 'superField', 'field': 'field'}, + 'nullableFields': { + 'superField': 'superField', + 'field': 'field', + }, + }, + ), + FunctionTestSuccess( + name: 'null', + input: { + 'value': { + 'fields': {'superField': 'superField', 'field': 'field'}, + }, + }, + output: { + 'fields': {'superField': 'superField', 'field': 'field'}, + }, + ), + ], + 'onlyFromJson': [ + FunctionTestSuccess( + name: 'onlyFromJson', + input: { + 'value': {'field': 'field'}, + }, + output: {'field': 'field'}, + ), + ], + 'asyncOnlyFromJson': [ + FunctionTestSuccess( + name: 'asyncOnlyFromJson', + input: { + 'value': {'field': 'field'}, + }, + output: {'field': 'field'}, + ), + ], + 'onlyToJson': [ + FunctionTestSuccess( + name: 'onlyToJson', + input: { + 'value': {'field': 'field'}, + }, + output: {'field': 'field'}, + ), + ], + 'asyncOnlyToJson': [ + FunctionTestSuccess( + name: 'asyncOnlyToJson', + input: { + 'value': {'field': 'field'}, + }, + output: {'field': 'field'}, + ), + ], + 'onlyToJsonWithDefaults': [ + FunctionTestSuccess( + name: 'present', + input: { + 'value': {'field': 'field'}, + }, + output: {'field': 'field'}, + ), + FunctionTestSuccess( + name: 'null', + input: {}, + output: {'field': 'default'}, + ), + ], + 'asyncOnlyToJsonWithDefaults': [ + FunctionTestSuccess( + name: 'present', + input: { + 'value': {'field': 'field'}, + }, + output: {'field': 'field'}, + ), + FunctionTestSuccess( + name: 'null', + input: {}, + output: {'field': 'default'}, + ), + ], + 'fromAndToJson': [ + FunctionTestSuccess( + name: 'fromAndToJson', + input: { + 'value': {'field': 'field'}, + }, + output: {'field': 'field'}, + ), + ], + 'asyncFromAndToJson': [ + FunctionTestSuccess( + name: 'asyncFromAndToJson', + input: { + 'value': {'field': 'field'}, + }, + output: {'field': 'field'}, + ), + ], + 'nonMapToJson': [ + FunctionTestSuccess( + name: 'nonMapToJson', + input: {'value': 'field'}, + output: 'field', + ), + ], + 'asyncNonMapToJson': [ + FunctionTestSuccess( + name: 'asyncNonMapToJson', + input: {'value': 'field'}, + output: 'field', + ), + ], + 'nonMapToJsonWithDefaults': [ + FunctionTestSuccess( + name: 'present', + input: {'value': 'field'}, + output: 'field', + ), + FunctionTestSuccess(name: 'null', input: {}, output: 'default'), + ], + 'asyncNonMapToJsonWithDefaults': [ + FunctionTestSuccess( + name: 'present', + input: {'value': 'field'}, + output: 'field', + ), + FunctionTestSuccess(name: 'null', input: {}, output: 'default'), + ], + 'nonMapFromAndToJson': [ + FunctionTestSuccess( + name: 'nonMapFromAndToJson', + input: {'value': 'field'}, + output: 'field', + ), + ], + 'asyncNonMapFromAndToJson': [ + FunctionTestSuccess( + name: 'asyncNonMapFromAndToJson', + input: {'value': 'field'}, + output: 'field', + ), + ], + 'fromJsonStatic': [ + FunctionTestSuccess( + name: 'fromJsonStatic', + input: {'value': 'field'}, + output: 'field', + ), + ], + }, + ), + 'records': ApiTest( + functionTests: { + 'nonAliasedNamedFields': [ + FunctionTestSuccess( + name: 'nonAliasedNamedFields', + input: { + 'value': {'field': 'field', 'anotherField': 'anotherField'}, + }, + output: {'field': 'field', 'anotherField': 'anotherField'}, + ), + ], + 'asyncNonAliasedNamedFields': [ + FunctionTestSuccess( + name: 'asyncNonAliasedNamedFields', + input: { + 'value': {'field': 'field', 'anotherField': 'anotherField'}, + }, + output: {'field': 'field', 'anotherField': 'anotherField'}, + ), + ], + 'aliasedNamedFields': [ + FunctionTestSuccess( + name: 'aliasedNamedFields', + input: { + 'value': {'field': 'field', 'anotherField': 'anotherField'}, + }, + output: {'field': 'field', 'anotherField': 'anotherField'}, + ), + ], + 'asyncAliasedNamedFields': [ + FunctionTestSuccess( + name: 'asyncAliasedNamedFields', + input: { + 'value': {'field': 'field', 'anotherField': 'anotherField'}, + }, + output: {'field': 'field', 'anotherField': 'anotherField'}, + ), + ], + 'namedFields': [ + FunctionTestSuccess( + name: 'namedFields', + input: { + 'nonAliased': { + 'field': 'field', + 'anotherField': 'anotherField', + }, + 'aliased': {'field': 'field', 'anotherField': 'anotherField'}, + }, + output: { + 'nonAliased': { + 'field': 'field', + 'anotherField': 'anotherField', + }, + 'aliased': {'field': 'field', 'anotherField': 'anotherField'}, + }, + ), + ], + 'asyncNamedFields': [ + FunctionTestSuccess( + name: 'namedFields', + input: { + 'nonAliased': { + 'field': 'field', + 'anotherField': 'anotherField', + }, + 'aliased': {'field': 'field', 'anotherField': 'anotherField'}, + }, + output: { + 'nonAliased': { + 'field': 'field', + 'anotherField': 'anotherField', + }, + 'aliased': {'field': 'field', 'anotherField': 'anotherField'}, + }, + ), + ], + 'nested': [ + FunctionTestSuccess( + name: 'nested', + input: { + 'value': { + 'namedFields': { + 'field': 'field', + 'anotherField': 'anotherField', + }, + }, + }, + output: { + 'namedFields': { + 'field': 'field', + 'anotherField': 'anotherField', + }, + }, + ), + ], + 'asyncNested': [ + FunctionTestSuccess( + name: 'asyncNested', + input: { + 'value': { + 'namedFields': { + 'field': 'field', + 'anotherField': 'anotherField', + }, + }, + }, + output: { + 'namedFields': { + 'field': 'field', + 'anotherField': 'anotherField', + }, + }, + ), + ], + 'nullableNested': [ + FunctionTestSuccess(name: 'null', input: {}, output: null), + FunctionTestSuccess( + name: 'no value', + input: { + 'value': {'namedFields': null}, + }, + output: {}, + ), + FunctionTestSuccess( + name: 'present', + input: { + 'value': { + 'namedFields': { + 'field': 'field', + 'anotherField': 'anotherField', + }, + }, + }, + output: { + 'namedFields': { + 'field': 'field', + 'anotherField': 'anotherField', + }, + }, + ), + ], + 'asyncNullableNested': [ + FunctionTestSuccess(name: 'null', input: {}, output: null), + FunctionTestSuccess( + name: 'no value', + input: { + 'value': {'namedFields': null}, + }, + output: {}, + ), + FunctionTestSuccess( + name: 'present', + input: { + 'value': { + 'namedFields': { + 'field': 'field', + 'anotherField': 'anotherField', + }, + }, + }, + output: { + 'namedFields': { + 'field': 'field', + 'anotherField': 'anotherField', + }, + }, + ), + ], + }, + ), + 'generic_wrappers': ApiTest( + functionTests: { + 'genericWrappers': [ + FunctionTestSuccess( + name: 'genericWrappers', + input: {'value': genericWrappers}, + output: genericWrappers, + ), + ], + 'genericWrappersAsync': [ + FunctionTestSuccess( + name: 'genericWrappers', + input: {'value': genericWrappers}, + output: genericWrappers, + ), + ], + 'genericWrapperParameters': [ + FunctionTestSuccess( + name: 'genericWrappers', + input: genericWrappers, + output: genericWrappers, + ), + ], + }, + ), + 'exceptions': const ApiTest( + functionTests: { + 'throwsException': [ + FunctionTestError( + name: 'deserializes std exception', + statusCode: 400, + input: {'type': 'Exception'}, + output: { + '@status': { + 'code': 400, + 'message': null, + 'details': [ + {'@type': 'dart.core.Exception', 'value': anything}, + {'@type': 'dart.core.StackTrace', 'value': anything}, + ], + }, + }, + ), + FunctionTestError( + name: 'deserializes format exception', + statusCode: 400, + input: {'type': 'FormatException'}, + output: { + '@status': { + 'code': 400, + 'message': 'Bad format', + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': {'message': 'Bad format', 'source': null}, + }, + {'@type': 'dart.core.StackTrace', 'value': anything}, + ], + }, + }, + ), + ], + 'throwsError': [ + FunctionTestError( + name: 'deserializes std error', + statusCode: 500, + input: {'type': 'Error'}, + output: { + '@status': { + 'code': 500, + 'message': null, + 'details': [ + {'@type': 'dart.core.Error', 'value': anything}, + {'@type': 'dart.core.StackTrace', 'value': anything}, + ], + }, + }, + ), + FunctionTestError( + name: 'deserializes argument error', + statusCode: 500, + input: {'type': 'ArgumentError'}, + output: { + '@status': { + 'code': 500, + // TODO(dnys1): This should be the custom message. + 'message': anything, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': { + 'name': 'someArg', + 'message': 'Bad argument', + 'invalidValue': null, + }, + }, + {'@type': 'dart.core.StackTrace', 'value': anything}, + ], + }, + }, + ), + ], + 'throwsCustomException': [ + FunctionTestError( + name: 'deserializes custom exception', + statusCode: 400, + input: {}, + output: { + '@status': { + 'code': 400, + // TODO(dnys1): This should be the custom message. + 'message': anything, + 'details': [ + { + '@type': 'api.v1.CustomException', + 'value': { + 'message': 'This is a custom exception', + 'additionalInfo': {'hello': 'world'}, + }, + }, + {'@type': 'dart.core.StackTrace', 'value': anything}, + ], + }, + }, + ), + ], + 'throwsCustomExceptionToFromJson': [ + FunctionTestError( + name: 'deserializes custom exception w/ custom serializer', + statusCode: 400, + input: {}, + output: { + '@status': { + 'code': 400, + // TODO(dnys1): This should be the custom message. + 'message': anything, + 'details': [ + { + '@type': 'api.v1.CustomExceptionToFromJson', + 'value': { + 'message': 'This is a custom exception', + 'hello': 'world', + 'another': 'value', + }, + }, + {'@type': 'dart.core.StackTrace', 'value': anything}, + ], + }, + }, + ), + ], + 'throwsCustomError': [ + FunctionTestError( + name: 'deserializes custom error', + statusCode: 500, + input: {}, + output: { + '@status': { + 'code': 500, + // TODO(dnys1): This should be the custom message. + 'message': anything, + 'details': [ + { + '@type': 'api.v1.CustomError', + 'value': { + 'message': 'This is a custom error', + 'additionalInfo': {'hello': 'world'}, + }, + }, + {'@type': 'dart.core.StackTrace', 'value': anything}, + ], + }, + }, + ), + ], + 'throwsCustomErrorToFromJson': [ + FunctionTestError( + name: 'deserializes custom error w/ custom serializer', + statusCode: 500, + input: {}, + output: { + '@status': { + 'code': 500, + // TODO(dnys1): This should be the custom message. + 'message': anything, + 'details': [ + { + '@type': 'api.v1.CustomErrorToFromJson', + 'value': { + 'message': 'This is a custom error', + 'hello': 'world', + 'another': 'value', + }, + }, + {'@type': 'dart.core.StackTrace', 'value': anything}, + ], + }, + }, + ), + ], + 'throwsCustomErrorWithStackTrace': [ + FunctionTestError( + name: 'deserializes custom error w/ stack traace', + statusCode: 500, + input: {}, + output: { + '@status': { + 'code': 500, + // TODO(dnys1): This should be the custom message. + 'message': anything, + 'details': [ + { + '@type': 'api.v1.CustomErrorWithStackTrace', + 'value': { + 'message': 'This is a custom error', + 'additionalInfo': {'hello': 'world'}, + 'stackTrace': '', + }, + }, + {'@type': 'dart.core.StackTrace', 'value': anything}, + ], + }, + }, + ), + ], + }, + ), + 'sealed_classes': ApiTest( + functionTests: { + 'sealedClass': [ + FunctionTestSuccess( + name: 'all shapes', + input: { + 'shapes': [ + {r'$type': 'Circle', 'radius': 5}, + {r'$type': 'Rectangle', 'width': 5, 'height': 5}, + ], + }, + output: [ + {r'$type': 'Circle', 'radius': 5, 'area': pi * 5 * 5}, + {r'$type': 'Rectangle', 'width': 5, 'height': 5, 'area': 25.0}, + ], + ), + ], + 'area': [ + FunctionTestSuccess( + name: 'circle', + input: { + 'shape': {r'$type': 'Circle', 'radius': 5}, + }, + output: pi * 5 * 5, + ), + FunctionTestSuccess( + name: 'rectangle', + input: { + 'shape': {r'$type': 'Rectangle', 'width': 5, 'height': 5}, + }, + output: 25, + ), + ], + 'rectangle': [ + FunctionTestSuccess( + name: 'rectangle', + input: { + 'rectangle': {'width': 5, 'height': 5}, + }, + output: {'width': 5.0, 'height': 5.0, 'area': 25.0}, + ), + ], + 'circle': [ + FunctionTestSuccess( + name: 'circle', + input: { + 'circle': {'radius': 5}, + }, + output: {'radius': 5.0, 'area': pi * 5 * 5}, + ), + ], + 'sealedClassWithInheritedCustomJson': [ + FunctionTestSuccess( + name: 'all shapes', + input: { + 'shapes': [ + { + r'$type': 'CircleWithInheritedCustomJson', + 'size': {'radius': 5}, + }, + { + r'$type': 'RectangleWithInheritedCustomJson', + 'size': {'width': 5, 'height': 5}, + }, + ], + }, + output: [ + { + r'$type': 'CircleWithInheritedCustomJson', + 'size': {'radius': 5}, + }, + { + r'$type': 'RectangleWithInheritedCustomJson', + 'size': {'width': 5, 'height': 5}, + }, + ], + ), + ], + 'sealedClassWithCustomJson': [ + FunctionTestSuccess( + name: 'all shapes', + input: { + 'shapes': [ + { + r'$type': 'CircleWithCustomJson', + 'size': {'radius': 5}, + }, + { + r'$type': 'RectangleWithCustomJson', + 'size': {'width': 5, 'height': 5}, + }, + ], + }, + output: [ + { + r'$type': 'CircleWithCustomJson', + 'size': {'radius': 5}, + }, + { + r'$type': 'RectangleWithCustomJson', + 'size': {'width': 5, 'height': 5}, + }, + ], + ), + ], + 'sealedClassWithOverriddenCustomJson': [ + FunctionTestSuccess( + name: 'all shapes', + input: { + // discriminator is not needed since it should be routed directly + // to the circle's fromJson ctor. + 'circle': { + 'size': {'radius': 5}, + }, + // discriminator is not needed since it should be routed directly + // to the rectangle's fromJson ctor. + 'rectangle': { + 'size': {'width': 5, 'height': 5}, + }, + // discriminator is needed when static type is the base class. + 'other': [ + { + r'$type': 'CircleWithOverriddenCustomJson', + 'size': {'radius': 5}, + }, + { + r'$type': 'RectangleWithOverriddenCustomJson', + 'size': {'width': 5, 'height': 5}, + }, + ], + }, + output: [ + { + r'$type': 'CircleWithOverriddenCustomJson', + 'size': {'radius': 5}, + }, + { + r'$type': 'RectangleWithOverriddenCustomJson', + 'size': {'width': 5, 'height': 5}, + }, + { + r'$type': 'CircleWithOverriddenCustomJson', + 'size': {'radius': 5}, + }, + { + r'$type': 'RectangleWithOverriddenCustomJson', + 'size': {'width': 5, 'height': 5}, + }, + ], + ), + ], + 'rectangleWithOverriddenCustomJson': [ + FunctionTestSuccess( + name: '', + input: { + 'rectangle': { + 'size': {'width': 5, 'height': 5}, + }, + }, + output: { + r'$type': 'RectangleWithOverriddenCustomJson', + 'size': {'width': 5, 'height': 5}, + }, + ), + ], + 'circleWithOverriddenCustomJson': [ + FunctionTestSuccess( + name: '', + input: { + 'circle': { + r'$type': 'CircleWithOverriddenCustomJson', + 'size': {'radius': 5}, + }, + }, + output: { + 'size': {'radius': 5}, + }, + ), + ], + 'shapeResults': [ + FunctionTestSuccess( + name: 'all shapes', + input: { + 'shapes': [ + {r'$type': 'Circle', 'radius': 5.0}, + {r'$type': 'Rectangle', 'width': 5.0, 'height': 5.0}, + ], + }, + output: [ + { + r'$type': 'OkResult', + 'data': { + r'$type': 'Circle', + 'radius': 5.0, + 'area': pi * 5.0 * 5.0, + }, + }, + { + r'$type': 'OkResult', + 'data': { + r'$type': 'Rectangle', + 'width': 5.0, + 'height': 5.0, + 'area': 25.0, + }, + }, + {r'$type': 'ErrResult', 'error': 'Bad shape: (Circle: 5.0)'}, + { + r'$type': 'ErrResult', + 'error': 'Bad shape: (Rectangle: 5.0 x 5.0)', + }, + ], + ), + ], + 'okShapeResults': [ + FunctionTestSuccess( + name: 'all shapes', + input: { + 'shapes': [ + {r'$type': 'Circle', 'radius': 5.0}, + {r'$type': 'Rectangle', 'width': 5.0, 'height': 5.0}, + ], + }, + output: [ + { + 'data': { + r'$type': 'Circle', + 'radius': 5.0, + 'area': pi * 5.0 * 5.0, + }, + }, + { + 'data': { + r'$type': 'Rectangle', + 'width': 5.0, + 'height': 5.0, + 'area': 25.0, + }, + }, + ], + ), + ], + 'errShapeResults': [ + FunctionTestSuccess( + name: 'all shapes', + input: { + 'shapes': [ + {r'$type': 'Circle', 'radius': 5.0}, + {r'$type': 'Rectangle', 'width': 5.0, 'height': 5.0}, + ], + }, + output: [ + {'error': 'Bad shape: (Circle: 5.0)'}, + {'error': 'Bad shape: (Rectangle: 5.0 x 5.0)'}, + ], + ), + ], + 'aliasedShapeResults': [ + FunctionTestSuccess( + name: 'all shapes', + input: { + 'shapes': [ + {r'$type': 'Circle', 'radius': 5.0}, + {r'$type': 'Rectangle', 'width': 5.0, 'height': 5.0}, + ], + }, + output: [ + { + r'$type': 'OkResult', + 'data': { + r'$type': 'Circle', + 'radius': 5.0, + 'area': pi * 5.0 * 5.0, + }, + }, + { + r'$type': 'OkResult', + 'data': { + r'$type': 'Rectangle', + 'width': 5.0, + 'height': 5.0, + 'area': 25.0, + }, + }, + {r'$type': 'ErrResult', 'error': 'Bad shape: (Circle: 5.0)'}, + { + r'$type': 'ErrResult', + 'error': 'Bad shape: (Rectangle: 5.0 x 5.0)', + }, + ], + ), + ], + 'aliasedOkShapeResults': [ + FunctionTestSuccess( + name: 'all shapes', + input: { + 'shapes': [ + {r'$type': 'Circle', 'radius': 5.0}, + {r'$type': 'Rectangle', 'width': 5.0, 'height': 5.0}, + ], + }, + output: [ + { + r'$type': 'OkResult', + 'data': { + r'$type': 'Circle', + 'radius': 5.0, + 'area': pi * 5.0 * 5.0, + }, + }, + { + r'$type': 'OkResult', + 'data': { + r'$type': 'Rectangle', + 'width': 5.0, + 'height': 5.0, + 'area': 25.0, + }, + }, + ], + ), + ], + 'aliasedErrShapeResults': [ + FunctionTestSuccess( + name: 'all shapes', + input: { + 'shapes': [ + {r'$type': 'Circle', 'radius': 5.0}, + {r'$type': 'Rectangle', 'width': 5.0, 'height': 5.0}, + ], + }, + output: [ + {r'$type': 'ErrResult', 'error': 'Bad shape: (Circle: 5.0)'}, + { + r'$type': 'ErrResult', + 'error': 'Bad shape: (Rectangle: 5.0 x 5.0)', + }, + ], + ), + ], + 'okShapeResult': [ + FunctionTestSuccess( + name: 'circle', + input: { + 'shape': {r'$type': 'Circle', 'radius': 5.0}, + }, + output: { + 'data': { + r'$type': 'Circle', + 'radius': 5.0, + 'area': pi * 5.0 * 5.0, + }, + }, + ), + FunctionTestSuccess( + name: 'rectangle', + input: { + 'shape': {r'$type': 'Rectangle', 'width': 5.0, 'height': 5.0}, + }, + output: { + 'data': { + r'$type': 'Rectangle', + 'width': 5.0, + 'height': 5.0, + 'area': 25.0, + }, + }, + ), + ], + 'swappedResult': [ + FunctionTestSuccess( + name: 'swappedResult', + input: { + 'result': { + r'$type': 'OkResult', + 'data': {r'$type': 'Circle', 'radius': 5.0}, + }, + }, + output: { + 'result': { + r'$type': 'OkResult', + 'data': { + r'$type': 'Circle', + 'radius': 5.0, + 'area': pi * 5.0 * 5.0, + }, + }, + }, + ), + ], + 'genericResult': [ + FunctionTestSuccess( + name: 'with type', + input: { + r'$T': 'Circle', + 'data': {'radius': 5.0}, + }, + output: { + 'data': {'radius': 5.0, 'area': pi * 5.0 * 5.0}, + }, + ), + FunctionTestSuccess( + name: 'without type', + input: { + 'data': {r'$type': 'Circle', 'radius': 5.0}, + }, + output: { + 'data': { + r'$type': 'Circle', + 'radius': 5.0, + 'area': pi * 5.0 * 5.0, + }, + }, + ), + ], + 'multipleGenericResult': [ + FunctionTestSuccess( + name: 'with types', + input: { + r'$T': 'Circle', + r'$E': 'BadShapeException', + 'data': {'radius': 5.0}, + 'error': { + 'shape': {r'$type': 'Circle', 'radius': 5.0}, + }, + }, + output: [ + { + r'$type': 'OkResult', + 'data': {'radius': 5.0, 'area': pi * 5.0 * 5.0}, + }, + { + r'$type': 'ErrResult', + 'error': { + 'shape': { + r'$type': 'Circle', + 'radius': 5.0, + 'area': pi * 5.0 * 5.0, + }, + }, + }, + ], + ), + FunctionTestSuccess( + name: 'without types', + input: { + 'data': {r'$type': 'Circle', 'radius': 5.0}, + 'error': { + r'$type': 'BadShapeException', + 'shape': {r'$type': 'Circle', 'radius': 5.0}, + }, + }, + output: [ + { + r'$type': 'OkResult', + 'data': { + r'$type': 'Circle', + 'radius': 5.0, + 'area': pi * 5.0 * 5.0, + }, + }, + { + r'$type': 'ErrResult', + 'error': { + r'$type': 'BadShapeException', + 'shape': { + r'$type': 'Circle', + 'radius': 5.0, + 'area': pi * 5.0 * 5.0, + }, + }, + }, + ], + ), + ], + }, + ), + 'cycles': ApiTest( + functionTests: { + 'createTree': [ + FunctionTestSuccess( + name: '', + input: {}, + output: { + r'$type': 'Parent', + 'name': 'root', + 'children': [ + { + r'$type': 'Parent', + 'name': 'parentA', + 'children': [ + { + r'$type': 'Child', + 'name': 'childA', + 'children': [], + }, + { + r'$type': 'Child', + 'name': 'childB', + 'children': [], + }, + ], + }, + { + r'$type': 'Parent', + 'name': 'parentB', + 'children': [ + { + r'$type': 'Child', + 'name': 'childC', + 'children': [], + }, + { + r'$type': 'Child', + 'name': 'childD', + 'children': [], + }, + ], + }, + ], + }, + ), + ], + 'printTree': [ + FunctionTestSuccess( + name: '', + input: { + 'node': { + r'$type': 'Parent', + 'name': 'root', + 'children': [ + { + r'$type': 'Parent', + 'name': 'parentA', + 'children': [ + {r'$type': 'Child', 'name': 'childA'}, + {r'$type': 'Child', 'name': 'childB'}, + ], + }, + { + r'$type': 'Parent', + 'name': 'parentB', + 'children': [ + {r'$type': 'Child', 'name': 'childC'}, + {r'$type': 'Child', 'name': 'childD'}, + ], + }, + ], + }, + }, + output: null, + logs: [ + 'root', + ' parentA', + ' childA', + ' childB', + ' parentB', + ' childC', + ' childD', + ], + ), + ], + 'combineTrees': [ + FunctionTestSuccess( + name: '', + input: { + 'tree1': { + r'$type': 'Parent', + 'name': 'parentA', + 'children': [ + {r'$type': 'Child', 'name': 'childA'}, + {r'$type': 'Child', 'name': 'childB'}, + ], + }, + 'tree2': { + 'name': 'parentB', + 'children': [ + {r'$type': 'Child', 'name': 'childC'}, + {r'$type': 'Child', 'name': 'childD'}, + ], + }, + 'additionalChildren': [ + null, + {r'$type': 'Child', 'name': 'childE'}, + {r'$type': 'Child', 'name': 'childF'}, + ], + }, + output: { + r'$type': 'Parent', + 'name': 'root', + 'children': [ + { + r'$type': 'Parent', + 'name': 'parentA', + 'children': [ + { + r'$type': 'Child', + 'name': 'childA', + 'children': [], + }, + { + r'$type': 'Child', + 'name': 'childB', + 'children': [], + }, + ], + }, + { + r'$type': 'Parent', + 'name': 'parentB', + 'children': [ + { + r'$type': 'Child', + 'name': 'childC', + 'children': [], + }, + { + r'$type': 'Child', + 'name': 'childD', + 'children': [], + }, + ], + }, + { + r'$type': 'Child', + 'name': 'childE', + 'children': [], + }, + { + r'$type': 'Child', + 'name': 'childF', + 'children': [], + }, + ], + }, + ), + ], + 'selfReferencing': [ + FunctionTestSuccess( + name: '', + input: { + 'selfReferencing': { + 'value': {'list': >[]}, + 'wrapper': { + 'value': { + 'value': {'list': >[]}, + 'list': >[], + }, + }, + 'list': [ + {'list': >[]}, + ], + }, + }, + output: { + 'value': {'list': >[]}, + 'wrapper': { + 'value': { + 'value': {'list': >[]}, + 'list': >[], + }, + }, + 'list': [ + {'list': >[]}, + ], + }, + ), + ], + }, + ), + 'metadata': ApiTest( + functionTests: { + // Tests that invoking methods with all default values + // should not result in any serialization errors. + 'positionalDefaultValues': [ + FunctionTestSuccess(name: '', input: {}, output: null), + ], + 'nullablePositionalDefaultValues': [ + FunctionTestSuccess(name: '', input: {}, output: null), + ], + 'namedDefaultValues': [ + FunctionTestSuccess(name: '', input: {}, output: null), + ], + 'nullableNamedDefaultValues': [ + FunctionTestSuccess(name: '', input: {}, output: null), + ], + 'positionalDefaultValueVars': [ + FunctionTestSuccess(name: '', input: {}, output: null), + ], + 'nullablePositionalDefaultValueVars': [ + FunctionTestSuccess(name: '', input: {}, output: null), + ], + 'namedDefaultValueVars': [ + FunctionTestSuccess(name: '', input: {}, output: null), + ], + 'nullableNamedDefaultValueVars': [ + FunctionTestSuccess(name: '', input: {}, output: null), + ], + 'positionalDefaultValueVarsPrivate': [ + FunctionTestSuccess(name: '', input: {}, output: null), + ], + 'nullablePositionalDefaultValueVarsPrivate': [ + FunctionTestSuccess(name: '', input: {}, output: null), + ], + 'namedDefaultValueVarsPrivate': [ + FunctionTestSuccess(name: '', input: {}, output: null), + ], + 'nullableNamedDefaultValueVarsPrivate': [ + FunctionTestSuccess(name: '', input: {}, output: null), + ], + }, + ), + 'typedefs': ApiTest( + functionTests: { + 'portfolio': [ + FunctionTestSuccess( + name: 'portfolio', + input: {'portfolio': {}}, + output: {}, + ), + ], + 'json': [ + FunctionTestSuccess( + name: 'json', + input: {'json': complexStruct}, + output: complexStruct, + ), + ], + 'nullableJson': [ + FunctionTestSuccess( + name: 'non-null', + input: {'json': complexStruct}, + output: complexStruct, + ), + FunctionTestSuccess( + name: 'null', + input: {'json': null}, + output: null, + ), + ], + 'mixedJson': [ + FunctionTestSuccess( + name: 'mixedJson', + input: {'json': complexStruct}, + output: complexStruct, + ), + ], + }, + ), + }, + ), + 'auth': Test( + apis: { + 'lib': ApiTest( + functionTests: { + 'sayHello': [ + FunctionTestSuccess( + name: 'sayHello', + input: {}, + output: 'Hello, anonymous!', + ), + ], + 'sayHelloPublic': [ + FunctionTestSuccess( + name: 'sayHelloPublic', + input: {}, + output: 'Hello, anonymous!', + ), + ], + }, + eventTests: { + 'streamHello': [ + EventTestSuccess( + name: 'streamHello', + input: {}, + events: ['Hello, anonymous!'], + ), + ], + 'streamHelloPublic': [ + EventTestSuccess( + name: 'streamHelloPublic', + input: {}, + events: ['Hello, anonymous!'], + ), + ], + }, + ), + 'public_lib': ApiTest( + functionTests: { + 'sayHello': [ + FunctionTestSuccess( + name: 'sayHello', + input: {}, + output: 'Hello, anonymous!', + ), + ], + }, + eventTests: { + 'streamHello': [ + EventTestSuccess( + name: 'streamHello', + input: {}, + events: ['Hello, anonymous!'], + ), + ], + }, + ), + }, + ), + 'data': Test( + apis: { + 'tasks': ApiTest( + functionTests: { + 'create': [ + FunctionTestSuccess( + name: 'creates a todo', + input: {'title': 'Ship V1'}, + output: { + 'id': 1, + 'title': 'Ship V1', + 'priority': 'high', + 'completed': false, + }, + ), + ], + }, + ), + }, + ), + 'env_vars': Test( + apis: { + 'injected': ApiTest( + functionTests: { + 'sayHello': [ + FunctionTestSuccess( + name: 'sayHello', + input: {}, + output: 'Hello, Dillon! I am 28 years old.', + ), + ], + 'sayHelloPerson': [ + FunctionTestSuccess( + name: 'sayHelloPerson', + input: {}, + output: { + 'name': 'Dillon', + 'age': 28, + 'height': 5.83, + 'weight': 130, + 'isCool': true, + 'website': 'https://dillonnys.com', + }, + logs: [ + '(local) Dillon is 28 years old, 5.83ft tall, 130 lbs, and is cool. ' + 'Find him at https://dillonnys.com.', + 'Super secret: Hi', + ], + ), + ], + }, + ), + }, + ), + 'exceptions': const Test( + apis: { + 'throwing': ApiTest( + functionTests: { + 'throwsBaseError': [ + FunctionTestError( + name: 'throwsBaseError', + statusCode: 500, + input: {}, + output: { + '@status': { + 'code': 500, + 'message': null, + 'details': [ + { + '@type': 'exceptions.v1.BaseError', + 'value': {'fault': 'base: message'}, + }, + {'@type': 'dart.core.StackTrace', 'value': anything}, + ], + }, + }, + ), + ], + 'throwsCustomError': [ + FunctionTestError( + name: 'throwsCustomError', + statusCode: 500, + input: {}, + output: { + '@status': { + 'code': 500, + 'message': null, + 'details': [ + { + '@type': 'exceptions.v1.CustomError', + 'value': {'fault': 'base: custom: message'}, + }, + {'@type': 'dart.core.StackTrace', 'value': anything}, + ], + }, + }, + ), + ], + 'throwsBaseException': [ + FunctionTestError( + name: 'throwsBaseException', + statusCode: 400, + input: {}, + output: { + '@status': { + 'code': 400, + 'message': null, + 'details': [ + { + '@type': 'exceptions.v1.BaseException', + 'value': {'fault': 'base: message'}, + }, + {'@type': 'dart.core.StackTrace', 'value': anything}, + ], + }, + }, + ), + ], + 'throwsCustomException': [ + FunctionTestError( + name: 'throwsCustomException', + statusCode: 400, + input: {}, + output: { + '@status': { + 'code': 400, + 'message': null, + 'details': [ + { + '@type': 'exceptions.v1.CustomException', + 'value': {'fault': 'base: custom: message'}, + }, + {'@type': 'dart.core.StackTrace', 'value': anything}, + ], + }, + }, + ), + ], + }, + ), + 'nonthrowing': ApiTest( + functionTests: { + 'callsThrowsBaseError': [ + FunctionTestError( + name: 'throwsBaseError', + statusCode: 500, + input: {}, + output: { + '@status': { + 'code': 500, + 'message': null, + 'details': [ + { + '@type': 'exceptions.v1.BaseError', + 'value': {'fault': 'base: message'}, + }, + {'@type': 'dart.core.StackTrace', 'value': anything}, + ], + }, + }, + ), + ], + 'callsThrowsCustomError': [ + FunctionTestError( + name: 'throwsCustomError', + statusCode: 500, + input: {}, + output: { + '@status': { + 'code': 500, + 'message': null, + 'details': [ + { + '@type': 'exceptions.v1.CustomError', + 'value': {'fault': 'base: custom: message'}, + }, + {'@type': 'dart.core.StackTrace', 'value': anything}, + ], + }, + }, + ), + ], + 'callsThrowsBaseException': [ + FunctionTestError( + name: 'throwsBaseException', + statusCode: 400, + input: {}, + output: { + '@status': { + 'code': 400, + 'message': null, + 'details': [ + { + '@type': 'exceptions.v1.BaseException', + 'value': {'fault': 'base: message'}, + }, + {'@type': 'dart.core.StackTrace', 'value': anything}, + ], + }, + }, + ), + ], + 'callsThrowsCustomException': [ + FunctionTestError( + name: 'throwsCustomException', + statusCode: 400, + input: {}, + output: { + '@status': { + 'code': 400, + 'message': null, + 'details': [ + { + '@type': 'exceptions.v1.CustomException', + 'value': {'fault': 'base: custom: message'}, + }, + {'@type': 'dart.core.StackTrace', 'value': anything}, + ], + }, + }, + ), + ], + }, + ), + 'external': ApiTest( + functionTests: { + 'callsThrowsCommonException': [ + FunctionTestError( + name: 'throwsCommonException', + statusCode: 400, + input: {}, + output: { + '@status': { + 'code': 400, + 'message': 'message', + 'details': [ + { + '@type': '_common.CommonException', + 'value': {'message': 'message'}, + }, + {'@type': 'dart.core.StackTrace', 'value': anything}, + ], + }, + }, + ), + ], + 'callsThrowsCustomException': [ + FunctionTestError( + name: 'throwsCustomException', + statusCode: 400, + input: {}, + output: { + '@status': { + 'code': 400, + 'message': 'message', + 'details': [ + { + '@type': '_common.CustomException', + 'value': {'message': 'message'}, + }, + {'@type': 'dart.core.StackTrace', 'value': anything}, + ], + }, + }, + ), + ], + }, + ), + }, + ), + 'flutter': Test( + apis: { + 'dart_ui': ApiTest( + functionTests: { + 'lerpColor': [ + FunctionTestSuccess( + name: 'lerpColor', + input: { + 'a': {'value': 0xFF000000}, + 'b': {'value': 0xFFFFFFFF}, + 't': 0.5, + }, + output: { + 'a': 1.0, + 'r': 0.5, + 'g': 0.5, + 'b': 0.5, + 'colorSpace': 'sRGB', + 'value': 4286611584, + 'alpha': 255, + 'opacity': 1.0, + 'red': 128, + 'green': 128, + 'blue': 128, + }, + ), + ], + 'addCountryCode': [ + FunctionTestSuccess( + name: 'addCountryCode', + input: { + 'locale': {'languageCode': 'en'}, + 'countryCode': 'US', + }, + output: {'languageCode': 'en', 'countryCode': 'US'}, + ), + ], + }, + ), + 'flutter': ApiTest( + functionTests: { + 'paintWidget': [ + FunctionTestSuccess( + name: 'paintImage', + input: {}, + output: startsWith('iVBORw0'), + ), + ], + 'helloWorld': [ + FunctionTestSuccess( + name: 'helloWorld', + method: 'GET', + input: {}, + output: {}, + ), + ], + }, + ), + }, + ), + 'http': Test( + apis: { + 'http_errors': const ApiTest( + functionTests: { + 'httpErrors': [ + FunctionTestError( + name: 'badRequest', + statusCode: 400, + input: {'type': 'badRequest'}, + output: { + '@status': { + 'code': 400, + 'message': '', + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': {'code': 400, 'message': ''}, + }, + {'@type': 'dart.core.StackTrace', 'value': anything}, + ], + }, + }, + ), + FunctionTestError( + name: 'customBadRequest', + statusCode: 412, + input: {'type': 'customBadRequest'}, + output: { + '@status': { + 'code': 412, + 'message': '', + 'details': [ + { + '@type': 'api.v1.CustomBadRequestException', + 'value': {'code': 400, 'message': ''}, + }, + {'@type': 'dart.core.StackTrace', 'value': anything}, + ], + }, + }, + ), + FunctionTestError( + name: 'unauthorized', + statusCode: 401, + input: {'type': 'unauthorized'}, + output: { + '@status': { + 'code': 401, + 'message': '', + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': {'code': 401, 'message': ''}, + }, + {'@type': 'dart.core.StackTrace', 'value': anything}, + ], + }, + }, + ), + FunctionTestError( + name: 'forbidden', + statusCode: 403, + input: {'type': 'forbidden'}, + output: { + '@status': { + 'code': 403, + 'message': '', + 'details': [ + { + '@type': 'api.v1.ForbiddenException', + 'value': {'code': 400, 'message': ''}, + }, + {'@type': 'dart.core.StackTrace', 'value': anything}, + ], + }, + }, + ), + FunctionTestError( + name: 'notFound', + statusCode: 404, + input: {'type': 'notFound'}, + output: { + '@status': { + 'code': 404, + 'message': null, + 'details': [ + { + '@type': 'api.v1.NotFoundException', + 'value': {}, + }, + {'@type': 'dart.core.StackTrace', 'value': anything}, + ], + }, + }, + ), + FunctionTestError( + name: 'anotherNotFound', + statusCode: 404, + input: {'type': 'anotherNotFound'}, + output: { + '@status': { + 'code': 404, + 'message': null, + 'details': [ + { + '@type': 'api.v1.AnotherNotFoundException', + 'value': {}, + }, + {'@type': 'dart.core.StackTrace', 'value': anything}, + ], + }, + }, + ), + FunctionTestError( + name: 'internalServerError', + statusCode: 404, + input: {'type': 'internalServerError'}, + output: { + '@status': { + 'code': 404, + 'message': '', + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': {'code': 500, 'message': ''}, + }, + {'@type': 'dart.core.StackTrace', 'value': anything}, + ], + }, + }, + ), + FunctionTestError( + name: 'badGateway', + statusCode: 404, + input: {'type': 'badGateway'}, + output: { + '@status': { + 'code': 404, + 'message': '', + 'details': [ + { + '@type': 'api.v1.BadGatewayError', + 'value': {'code': 500, 'message': ''}, + }, + {'@type': 'dart.core.StackTrace', 'value': anything}, + ], + }, + }, + ), + ], + }, + ), + 'http_header': ApiTest( + functionTests: { + 'headers': [ + FunctionTestSuccess( + name: 'present', + headers: { + 'aString': 'aString', + 'anInt': '42', + 'aDouble': '3.14', + 'aNum': '42', + 'aBool': 'true', + 'aDateTime': '2021-07-01T00:00:00.000Z', + 'aNullableString': 'aNullableString', + 'aNullableInt': '42', + 'aNullableDouble': '3.14', + 'aNullableNum': '42', + 'aNullableBool': 'true', + 'aNullableDateTime': '2021-07-01T00:00:00.000Z', + }, + output: { + 'aString': 'aString', + 'anInt': 42, + 'aDouble': 3.14, + 'aNum': 42, + 'aBool': true, + 'aDateTime': '2021-07-01T00:00:00.000Z', + 'aNullableString': 'aNullableString', + 'aNullableInt': 42, + 'aNullableDouble': 3.14, + 'aNullableNum': 42, + 'aNullableBool': true, + 'aNullableDateTime': '2021-07-01T00:00:00.000Z', + }, + ), + FunctionTestSuccess( + name: 'partial', + headers: { + 'aString': 'aString', + 'anInt': '42', + 'aDouble': '3.14', + 'aNum': '42', + 'aBool': 'true', + 'aDateTime': '2021-07-01T00:00:00.000Z', + }, + output: { + 'aString': 'aString', + 'anInt': 42, + 'aDouble': 3.14, + 'aNum': 42, + 'aBool': true, + 'aDateTime': '2021-07-01T00:00:00.000Z', + }, + ), + ], + }, + ), + 'http_query': ApiTest( + functionTests: { + 'query': [ + FunctionTestSuccess( + name: 'present', + queryParameters: { + 'aString': ['aString'], + 'anInt': ['42'], + 'aDouble': ['3.14'], + 'aNum': ['42'], + 'aBool': ['true'], + 'aDateTime': ['2021-07-01T00:00:00.000Z'], + 'aNullableString': ['aNullableString'], + 'aNullableInt': ['42'], + 'aNullableDouble': ['3.14'], + 'aNullableNum': ['42'], + 'aNullableBool': ['true'], + 'aNullableDateTime': ['2021-07-01T00:00:00.000Z'], + 'aListOfString': ['a', 'b', 'c'], + 'aListOfInt': ['1', '2', '3'], + 'aListOfDouble': ['1.1', '2.2', '3.3'], + 'aListOfNum': ['1', '2.2', '3'], + 'aListOfBool': ['true', 'false', 'true'], + 'aListOfDateTime': [ + '2021-07-01T00:00:00.000Z', + '2021-07-01T00:00:00.000Z', + ], + 'aNullableListOfString': ['a', 'b', 'c'], + 'aNullableListOfInt': ['1', '2', '3'], + 'aNullableListOfDouble': ['1.1', '2.2', '3.3'], + 'aNullableListOfNum': ['1', '2.2', '3'], + 'aNullableListOfBool': ['true', 'false', 'true'], + 'aNullableListOfDateTime': [ + '2021-07-01T00:00:00.000Z', + '2021-07-01T00:00:00.000Z', + ], + }, + output: { + 'aString': 'aString', + 'anInt': 42, + 'aDouble': 3.14, + 'aNum': 42, + 'aBool': true, + 'aDateTime': '2021-07-01T00:00:00.000Z', + 'aNullableString': 'aNullableString', + 'aNullableInt': 42, + 'aNullableDouble': 3.14, + 'aNullableNum': 42, + 'aNullableBool': true, + 'aNullableDateTime': '2021-07-01T00:00:00.000Z', + 'aListOfString': ['a', 'b', 'c'], + 'aListOfInt': [1, 2, 3], + 'aListOfDouble': [1.1, 2.2, 3.3], + 'aListOfNum': [1, 2.2, 3], + 'aListOfBool': [true, false, true], + 'aListOfDateTime': [ + '2021-07-01T00:00:00.000Z', + '2021-07-01T00:00:00.000Z', + ], + 'aNullableListOfString': ['a', 'b', 'c'], + 'aNullableListOfInt': [1, 2, 3], + 'aNullableListOfDouble': [1.1, 2.2, 3.3], + 'aNullableListOfNum': [1, 2.2, 3], + 'aNullableListOfBool': [true, false, true], + 'aNullableListOfDateTime': [ + '2021-07-01T00:00:00.000Z', + '2021-07-01T00:00:00.000Z', + ], + }, + ), + FunctionTestSuccess( + name: 'partial', + queryParameters: { + 'aString': ['aString'], + 'anInt': ['42'], + 'aDouble': ['3.14'], + 'aNum': ['42'], + 'aBool': ['true'], + 'aDateTime': ['2021-07-01T00:00:00.000Z'], + 'aListOfString': ['a', 'b', 'c'], + 'aListOfInt': ['1', '2', '3'], + 'aListOfDouble': ['1.1', '2.2', '3.3'], + 'aListOfNum': ['1', '2.2', '3'], + 'aListOfBool': ['true', 'false', 'true'], + 'aListOfDateTime': [ + '2021-07-01T00:00:00.000Z', + '2021-07-01T00:00:00.000Z', + ], + }, + output: { + 'aString': 'aString', + 'anInt': 42, + 'aDouble': 3.14, + 'aNum': 42, + 'aBool': true, + 'aDateTime': '2021-07-01T00:00:00.000Z', + 'aListOfString': ['a', 'b', 'c'], + 'aListOfInt': [1, 2, 3], + 'aListOfDouble': [1.1, 2.2, 3.3], + 'aListOfNum': [1, 2.2, 3], + 'aListOfBool': [true, false, true], + 'aListOfDateTime': [ + '2021-07-01T00:00:00.000Z', + '2021-07-01T00:00:00.000Z', + ], + }, + ), + ], + }, + ), + 'http_method': ApiTest( + functionTests: { + 'get': [ + FunctionTestSuccess( + name: 'get', + method: 'GET', + input: {}, + output: null, + ), + ], + 'post': [ + FunctionTestSuccess( + name: 'post', + method: 'POST', + input: {}, + output: null, + ), + ], + 'put': [ + FunctionTestSuccess( + name: 'put', + method: 'PUT', + input: {}, + output: null, + ), + ], + 'delete': [ + FunctionTestSuccess( + name: 'delete', + method: 'DELETE', + input: {}, + output: null, + ), + ], + 'patch': [ + FunctionTestSuccess( + name: 'patch', + method: 'PATCH', + input: {}, + output: null, + ), + ], + // TODO: Needed? Can only really implement when return types can + // map to the http headers. + // 'head': [ + // FunctionTestSuccess( + // name: 'head', + // method: 'HEAD', + // input: {}, + // output: null, + // ), + // ], + // 'trace': [ + // FunctionTestSuccess( + // name: 'trace', + // method: 'TRACE', + // input: {}, + // output: null, + // ), + // ], + }, + ), + 'http_status': ApiTest( + functionTests: { + 'ok': [ + FunctionTestSuccess( + name: 'ok', + statusCode: 200, + input: {}, + output: null, + ), + ], + 'created': [ + FunctionTestSuccess( + name: 'created', + statusCode: 201, + input: {}, + output: null, + ), + ], + 'accepted': [ + FunctionTestSuccess( + name: 'accepted', + statusCode: 202, + input: {}, + output: null, + ), + ], + 'badRequest': [ + FunctionTestSuccess( + name: 'badRequest', + statusCode: 400, + input: {}, + output: null, + ), + ], + 'internalServerError': [ + FunctionTestSuccess( + name: 'internalServerError', + statusCode: 500, + input: {}, + output: null, + ), + ], + }, + ), + }, + ), + 'marcelo': Test( + apis: { + 'exceptions': const ApiTest( + functionTests: { + 'throwsUserException': [ + FunctionTestError( + name: 'no cause', + statusCode: 400, + input: {}, + output: { + '@status': { + 'code': 400, + 'message': null, + 'details': [ + { + '@type': '_common.UserException', + 'value': {'msg': 'message'}, + }, + {'@type': 'dart.core.StackTrace', 'value': anything}, + ], + }, + }, + ), + FunctionTestError( + name: 'with cause (string)', + statusCode: 400, + input: {'cause': 'Bad thing happened'}, + output: { + '@status': { + 'code': 400, + 'message': null, + 'details': [ + { + '@type': '_common.UserException', + 'value': { + 'msg': 'message', + 'cause': 'Bad thing happened', + }, + }, + {'@type': 'dart.core.StackTrace', 'value': anything}, + ], + }, + }, + ), + FunctionTestError( + name: 'with cause (map)', + statusCode: 400, + input: { + 'cause': {'reason': 'Bad thing happened'}, + }, + output: { + '@status': { + 'code': 400, + 'message': null, + 'details': [ + { + '@type': '_common.UserException', + 'value': { + 'msg': 'message', + 'cause': + '{reason: Bad thing happened}', // cause.toString() + }, + }, + {'@type': 'dart.core.StackTrace', 'value': anything}, + ], + }, + }, + ), + ], + 'callsThrowsUserException': [ + FunctionTestError( + name: 'no cause', + statusCode: 400, + input: {}, + output: { + '@status': { + 'code': 400, + 'message': null, + 'details': [ + { + '@type': '_common.UserException', + 'value': {'msg': 'message'}, + }, + {'@type': 'dart.core.StackTrace', 'value': anything}, + ], + }, + }, + ), + FunctionTestError( + name: 'with cause (string)', + statusCode: 400, + input: {'cause': 'Bad thing happened'}, + output: { + '@status': { + 'code': 400, + 'message': null, + 'details': [ + { + '@type': '_common.UserException', + 'value': { + 'msg': 'message', + 'cause': 'Bad thing happened', + }, + }, + {'@type': 'dart.core.StackTrace', 'value': anything}, + ], + }, + }, + ), + FunctionTestError( + name: 'with cause (map)', + statusCode: 400, + input: { + 'cause': {'reason': 'Bad thing happened'}, + }, + output: { + '@status': { + 'code': 400, + 'message': null, + 'details': [ + { + '@type': '_common.UserException', + 'value': { + 'msg': 'message', + 'cause': + '{reason: Bad thing happened}', // cause.toString() + }, + }, + {'@type': 'dart.core.StackTrace', 'value': anything}, + ], + }, + }, + ), + ], + 'throwsAppError': [ + FunctionTestError( + name: 'throwsAppError', + statusCode: 500, + input: {}, + output: { + '@status': { + 'code': 500, + 'message': null, + 'details': [ + { + '@type': 'marcelo.v1.AppError', + 'value': {'msg': 'message', 'error': null}, + }, + {'@type': 'dart.core.StackTrace', 'value': anything}, + ], + }, + }, + ), + FunctionTestError( + name: 'with params', + statusCode: 500, + input: {'message': 'test', 'error': 123}, + output: { + '@status': { + 'code': 500, + 'message': null, + 'details': [ + { + '@type': 'marcelo.v1.AppError', + 'value': {'msg': 'test', 'error': 123}, + }, + {'@type': 'dart.core.StackTrace', 'value': anything}, + ], + }, + }, + ), + ], + 'throwsAppException': [ + FunctionTestError( + name: 'throwsAppException', + statusCode: 400, + input: {}, + output: { + '@status': { + 'code': 400, + 'message': null, + 'details': [ + { + '@type': 'marcelo.v1.AppException', + 'value': {'msg': 'message', 'error': 'error'}, + }, + {'@type': 'dart.core.StackTrace', 'value': anything}, + ], + }, + }, + ), + ], + 'throwsNotYetImplementedError': [ + FunctionTestError( + name: 'throwsNotYetImplementedError', + statusCode: 500, + input: {}, + output: { + '@status': { + 'code': 500, + 'message': null, + 'details': [ + { + '@type': 'marcelo.v1.NotYetImplementedError', + 'value': {'msg': 'message'}, + }, + {'@type': 'dart.core.StackTrace', 'value': anything}, + ], + }, + }, + ), + ], + 'throwsValidateError': [ + FunctionTestError( + name: 'throwsValidateError', + statusCode: 500, + input: {}, + output: { + '@status': { + 'code': 500, + 'message': null, + 'details': [ + { + '@type': '_common.ValidateError', + 'value': {'msg': 'message'}, + }, + {'@type': 'dart.core.StackTrace', 'value': anything}, + ], + }, + }, + ), + ], + 'throwsUserException_ShowInConsole': [ + FunctionTestError( + name: 'throwsUserException_ShowInConsole', + statusCode: 400, + input: {}, + output: { + '@status': { + 'code': 400, + 'message': null, + 'details': [ + { + '@type': 'marcelo.v1.UserException_ShowInConsole', + 'value': {'msg': 'message'}, + }, + {'@type': 'dart.core.StackTrace', 'value': anything}, + ], + }, + }, + ), + FunctionTestError( + name: 'with params', + statusCode: 400, + input: {'message': 'test', 'cause': 123}, + output: { + '@status': { + 'code': 400, + 'message': null, + 'details': [ + { + '@type': 'marcelo.v1.UserException_ShowInConsole', + 'value': {'msg': 'test', 'cause': 123}, + }, + {'@type': 'dart.core.StackTrace', 'value': anything}, + ], + }, + }, + ), + ], + }, + ), + 'models': ApiTest( + functionTests: { + 'availableStock': [ + FunctionTestSuccess( + name: 'availableStock', + input: { + 'availableStock': { + 'ticker': 'ABC', + 'name': 'Acme', + 'currentPrice': 123.45, + }, + }, + output: { + 'ticker': 'ABC', + 'name': 'Acme', + 'currentPrice': 123.45, + 'currentPriceStr': r'US$ 123.45', + }, + ), + ], + 'availableStocks': [ + FunctionTestSuccess( + name: 'availableStocks', + input: { + 'availableStocks': { + 'list': [ + {'ticker': 'ABC', 'name': 'Acme', 'currentPrice': 123.45}, + {'ticker': 'ABC', 'name': 'Acme', 'currentPrice': 123.45}, + ], + }, + }, + output: { + 'list': [ + { + 'ticker': 'ABC', + 'name': 'Acme', + 'currentPrice': 123.45, + 'currentPriceStr': r'US$ 123.45', + }, + { + 'ticker': 'ABC', + 'name': 'Acme', + 'currentPrice': 123.45, + 'currentPriceStr': r'US$ 123.45', + }, + ], + }, + ), + ], + 'cashBalance': [ + FunctionTestSuccess( + name: 'cashBalance', + input: { + 'cashBalance': {'amount': 123.45}, + }, + output: {'amount': 123.45}, + ), + ], + 'portfolio': [ + FunctionTestSuccess( + name: 'portfolio', + input: { + 'portfolio': { + 'stocks': [ + { + 'ticker': 'ABC', + 'howManyShares': 1000, + 'averagePrice': 123.45, + }, + { + 'ticker': 'ABC', + 'howManyShares': 1000, + 'averagePrice': 123.45, + }, + ], + 'cashBalance': {'amount': 123.45}, + }, + }, + output: { + 'stocks': [ + { + 'ticker': 'ABC', + 'howManyShares': 1000, + 'averagePrice': 123.45, + 'costBasis': 123450.0, + 'averagePriceStr': r'US$ 123.45', + }, + { + 'ticker': 'ABC', + 'howManyShares': 1000, + 'averagePrice': 123.45, + 'costBasis': 123450.0, + 'averagePriceStr': r'US$ 123.45', + }, + ], + 'cashBalance': {'amount': 123.45}, + 'isEmpty': false, + 'totalCostBasis': 247023.45, + }, + ), + ], + 'stock': [ + FunctionTestSuccess( + name: 'stock', + input: { + 'stock': { + 'ticker': 'ABC', + 'howManyShares': 1000, + 'averagePrice': 123.45, + }, + }, + output: { + 'ticker': 'ABC', + 'howManyShares': 1000, + 'averagePrice': 123.45, + 'costBasis': 123450.0, + 'averagePriceStr': r'US$ 123.45', + }, + ), + ], + 'ui': [ + FunctionTestSuccess( + name: 'ui', + input: { + 'ui': {'isDarkMode': true, 'screenChoice': 'signup'}, + }, + output: {'isDarkMode': true, 'screenChoice': 'signup'}, + ), + ], + }, + ), + }, + ), + 'streaming': Test( + apis: { + 'server_side': ApiTest( + eventTests: { + 'hello': [ + EventTestSuccess( + name: 'hello', + input: { + 'names': ['Amy', 'Bob', 'Charlie'], + }, + events: ['Hello, Amy!', 'Hello, Bob!', 'Hello, Charlie!'], + ), + ], + 'stockTicker': [ + EventTestSuccess( + name: 'stockTicker', + queryParameters: { + 'symbol': ['AAPL'], + }, + events: [ + { + 'ticker': 'AAPL', + 'name': 'AAPL', + 'currentPrice': 100.0, + 'currentPriceStr': r'US$ 100.00', + }, + { + 'ticker': 'AAPL', + 'name': 'AAPL', + 'currentPrice': 101.0, + 'currentPriceStr': r'US$ 101.00', + }, + { + 'ticker': 'AAPL', + 'name': 'AAPL', + 'currentPrice': 102.0, + 'currentPriceStr': r'US$ 102.00', + }, + ], + ), + ], + 'jsonValues': [ + EventTestSuccess( + name: 'jsonValues', + events: [ + true, + 42, + 'hello', + [false, 42, 42.0], + {'key': true}, + ], + ), + ], + }, + ), + }, + ), + 'supabase': Test( + apis: { + 'auth': ApiTest( + functionTests: { + 'currentUser': [ + FunctionTestSuccess( + name: 'currentUser', + method: 'GET', + setup: (request) async { + final jwt = JWT( + { + 'aud': 'authenticated', + 'exp': + DateTime.now() + .add(const Duration(days: 1)) + .millisecondsSinceEpoch ~/ + 1000, + 'sub': '123', + 'email': 'someone@email.com', + 'app_metadata': {'provider': 'email'}, + 'user_metadata': null, + 'role': 'authenticated', + }, + header: {'alg': 'HS256', 'typ': 'JWT'}, + ); + final jwk = SecretKey( + 'super-secret-jwt-token-with-at-least-32-characters-long', + ); + final token = jwt.sign(jwk); + request.headers['Authorization'] = 'Bearer $token'; + }, + input: {}, + output: { + 'userId': '123', + 'emails': [ + { + 'email': 'someone@email.com', + 'isVerified': false, + 'isPrimary': false, + }, + ], + 'roles': [ + {'type': 'Celest::Role', 'id': 'authenticated'}, + ], + }, + ), + ], + }, + ), + }, + ), +}; + +const genericWrappers = { + 'listOfString': ['one', 'two', 'three'], + 'listOfUri': ['https://google.com', 'https://example.com'], + 'listOfSimpleClass': [simpleStruct, simpleStruct], + 'listOfListOfString': [ + ['one', 'two', 'three'], + ['four', 'five', 'six'], + ], + 'listOfListOfUri': [ + ['https://google.com', 'https://example.com'], + ['https://dart.dev', 'https://pub.dev'], + ], + 'listOfListOfSimpleClass': [ + [simpleStruct, simpleStruct], + [simpleStruct, simpleStruct], + ], + 'mapOfString': {'one': 'one', 'two': 'two', 'three': 'three'}, + 'mapOfUri': {'one': 'https://google.com', 'two': 'https://example.com'}, + 'mapOfSimpleClass': { + 'one': simpleStruct, + 'two': simpleStruct, + 'three': simpleStruct, + }, + 'mapOfListOfString': { + 'one': ['one', 'two', 'three'], + 'two': ['four', 'five', 'six'], + }, + 'mapOfListOfUri': { + 'one': ['https://google.com', 'https://example.com'], + 'two': ['https://dart.dev', 'https://pub.dev'], + }, + 'mapOfListOfSimpleClass': { + 'one': [simpleStruct, simpleStruct], + 'two': [simpleStruct, simpleStruct], + }, + 'mapOfMapOfString': { + 'a': {'a': 'a', 'b': 'b', 'c': 'c'}, + 'b': {'a': 'a', 'b': 'b', 'c': 'c'}, + }, + 'mapOfMapOfUri': { + 'one': {'one': 'https://google.com', 'two': 'https://example.com'}, + 'two': {'one': 'https://dart.dev', 'two': 'https://pub.dev'}, + }, + 'mapOfMapOfSimpleClass': { + 'one': {'one': simpleStruct, 'two': simpleStruct, 'three': simpleStruct}, + 'two': {'one': simpleStruct, 'two': simpleStruct, 'three': simpleStruct}, + }, +}; diff --git a/apps/cli/fixtures/legacy/flutter/client/lib/flutter_client.dart b/apps/cli/fixtures/legacy/flutter/client/lib/flutter_client.dart new file mode 100644 index 000000000..cb162abfd --- /dev/null +++ b/apps/cli/fixtures/legacy/flutter/client/lib/flutter_client.dart @@ -0,0 +1,80 @@ +// Generated by Celest. This file should not be modified manually, but +// it can be checked into version control. +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +library; // ignore_for_file: no_leading_underscores_for_library_prefixes + +import 'dart:io'; + +import 'package:celest_core/_internal.dart' as _$celest; +import 'package:celest_core/celest_core.dart' as _$celest; +import 'package:celest_core/src/util/globals.dart' as _$celest; +import 'package:flutter_client/src/functions.dart'; +import 'package:flutter_client/src/serializers.dart'; +import 'package:http/http.dart' as _$http_http; +import 'package:native_storage/native_storage.dart' + as _$native_storage_native_storage; + +export 'package:celest_backend/src/functions/flutter.dart' show HelloWorld; + +final Celest celest = Celest(); + +enum CelestEnvironment { + local, + production; + + Uri get baseUri => switch (this) { + local => + _$celest.kIsWeb || !Platform.isAndroid + ? Uri.parse('http://localhost:7777') + : Uri.parse('http://10.0.2.2:7777'), + production => Uri.parse('https://example.celest.run'), + }; +} + +class Celest with _$celest.CelestBase { + var _initialized = false; + + late CelestEnvironment _currentEnvironment; + + late final _$native_storage_native_storage.NativeStorage nativeStorage = + _$native_storage_native_storage.NativeStorage(scope: 'celest'); + + @override + late _$http_http.Client httpClient = _$celest.CelestHttpClient( + secureStorage: nativeStorage.secure, + ); + + late Uri _baseUri; + + final _functions = CelestFunctions(); + + T _checkInitialized(T Function() value) { + if (!_initialized) { + throw StateError( + 'Celest has not been initialized. Make sure to call `celest.init()` at the start of your `main` method.', + ); + } + return value(); + } + + CelestEnvironment get currentEnvironment => + _checkInitialized(() => _currentEnvironment); + + @override + Uri get baseUri => _checkInitialized(() => _baseUri); + + CelestFunctions get functions => _checkInitialized(() => _functions); + + void init({ + CelestEnvironment environment = CelestEnvironment.local, + _$celest.Serializers? serializers, + }) { + _currentEnvironment = environment; + _baseUri = environment.baseUri; + if (!_initialized) { + initSerializers(serializers: serializers); + } + _initialized = true; + } +} diff --git a/apps/cli/fixtures/legacy/flutter/client/lib/src/functions.dart b/apps/cli/fixtures/legacy/flutter/client/lib/src/functions.dart new file mode 100644 index 000000000..d7e236113 --- /dev/null +++ b/apps/cli/fixtures/legacy/flutter/client/lib/src/functions.dart @@ -0,0 +1,839 @@ +// Generated by Celest. This file should not be modified manually, but +// it can be checked into version control. +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +library; // ignore_for_file: no_leading_underscores_for_library_prefixes + +import 'dart:async'; +import 'dart:convert'; +import 'dart:io'; +import 'dart:isolate'; +import 'dart:typed_data'; +import 'dart:ui'; + +import 'package:celest/celest.dart' as _$celest; +import 'package:celest_backend/src/functions/flutter.dart'; +import 'package:celest_core/celest_core.dart' as _$celest; +import 'package:celest_core/src/exception/cloud_exception.dart' as _$celest; +import 'package:celest_core/src/exception/serialization_exception.dart' + as _$celest; +import 'package:flutter/src/painting/image_provider.dart' + as _$flutter_image_provider; +import 'package:flutter_client/flutter_client.dart'; + +class CelestFunctions { + /// Tests that dart:ui types can be used as inputs/outputs in functions. + final dartUi = CelestFunctionsDartUi(); + + final flutter = CelestFunctionsFlutter(); +} + +/// Tests that dart:ui types can be used as inputs/outputs in functions. +class CelestFunctionsDartUi { + Never _throwError({int? code, required Map body}) { + final status = body['@status'] as Map?; + final message = status?['message'] as String?; + final details = status?['details'] as _$celest.JsonList?; + final (errorType, errorValue, stackTrace) = switch (details) { + null || [] => const (null, null, StackTrace.empty), + [ + final errorDetails as Map, + { + '@type': 'dart.core.StackTrace', + 'value': final stackTraceValue as String, + }, + ..., + ] => + ( + errorDetails['@type'], + errorDetails['value'], + StackTrace.fromString(stackTraceValue), + ), + [final errorDetails as Map, ...] => ( + errorDetails['@type'], + errorDetails['value'], + StackTrace.empty, + ), + }; + + switch (errorType) { + case 'dart.async.AsyncError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.async.TimeoutException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.convert.JsonUnsupportedObjectError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.Error': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.AssertionError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.TypeError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.ArgumentError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.RangeError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.IndexError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.UnsupportedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.UnimplementedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.StateError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.ConcurrentModificationError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.core.OutOfMemoryError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.StackOverflowError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.Exception': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.FormatException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.IntegerDivisionByZeroException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.isolate.IsolateSpawnException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.io.OSError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.io.FileSystemException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.io.PathAccessException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.io.PathExistsException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.io.PathNotFoundException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.io.SignalException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.io.ProcessException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.io.TlsException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.io.HandshakeException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.io.CertificateException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.io.StdoutException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.io.StdinException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart._http.HttpException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart._http.WebSocketException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.CloudException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.CloudException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.CancelledException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.CancelledException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnknownError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.UnknownError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.BadRequestException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.BadRequestException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnauthorizedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.UnauthorizedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.NotFoundException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.NotFoundException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.AlreadyExistsException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.AlreadyExistsException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.PermissionDeniedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.PermissionDeniedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.ResourceExhaustedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.ResourceExhaustedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.FailedPreconditionException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.FailedPreconditionException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.AbortedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.AbortedException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.OutOfRangeException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.OutOfRangeException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnimplementedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.UnimplementedError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.InternalServerError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.InternalServerError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnavailableError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.UnavailableError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.DataLossError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.DataLossError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.DeadlineExceededError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.DeadlineExceededError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.SerializationException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.SerializationException>(errorValue), + stackTrace, + ); + default: + Error.throwWithStackTrace( + _$celest.CloudException.http( + code: code, + message: message, + details: ((details ?? body) as _$celest.JsonValue), + ), + StackTrace.empty, + ); + } + } + + @_$celest.CloudFunction(api: 'dart_ui', function: 'lerpColor') + Future lerpColor(Color a, Color b, double t) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/dart-ui/lerp-color'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'a': _$celest.Serializers.instance.serialize(a), + r'b': _$celest.Serializers.instance.serialize(b), + r't': t, + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize($body); + } + + @_$celest.CloudFunction(api: 'dart_ui', function: 'addCountryCode') + Future addCountryCode(Locale locale, String countryCode) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/dart-ui/add-country-code'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'locale': _$celest.Serializers.instance.serialize(locale), + r'countryCode': countryCode, + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize($body); + } +} + +class CelestFunctionsFlutter { + Never _throwError({int? code, required Map body}) { + final status = body['@status'] as Map?; + final message = status?['message'] as String?; + final details = status?['details'] as _$celest.JsonList?; + final (errorType, errorValue, stackTrace) = switch (details) { + null || [] => const (null, null, StackTrace.empty), + [ + final errorDetails as Map, + { + '@type': 'dart.core.StackTrace', + 'value': final stackTraceValue as String, + }, + ..., + ] => + ( + errorDetails['@type'], + errorDetails['value'], + StackTrace.fromString(stackTraceValue), + ), + [final errorDetails as Map, ...] => ( + errorDetails['@type'], + errorDetails['value'], + StackTrace.empty, + ), + }; + + switch (errorType) { + case 'dart.async.AsyncError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.async.TimeoutException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.convert.JsonUnsupportedObjectError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.Error': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.AssertionError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.TypeError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.ArgumentError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.RangeError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.IndexError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.UnsupportedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.UnimplementedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.StateError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.ConcurrentModificationError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.core.OutOfMemoryError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.StackOverflowError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.Exception': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.FormatException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.IntegerDivisionByZeroException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.isolate.IsolateSpawnException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.io.OSError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.io.FileSystemException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.io.PathAccessException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.io.PathExistsException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.io.PathNotFoundException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.io.SignalException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.io.ProcessException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.io.TlsException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.io.HandshakeException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.io.CertificateException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.io.StdoutException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.io.StdinException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart._http.HttpException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart._http.WebSocketException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.CloudException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.CloudException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.CancelledException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.CancelledException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnknownError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.UnknownError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.BadRequestException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.BadRequestException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnauthorizedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.UnauthorizedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.NotFoundException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.NotFoundException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.AlreadyExistsException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.AlreadyExistsException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.PermissionDeniedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.PermissionDeniedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.ResourceExhaustedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.ResourceExhaustedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.FailedPreconditionException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.FailedPreconditionException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.AbortedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.AbortedException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.OutOfRangeException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.OutOfRangeException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnimplementedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.UnimplementedError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.InternalServerError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.InternalServerError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnavailableError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.UnavailableError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.DataLossError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.DataLossError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.DeadlineExceededError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.DeadlineExceededError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.SerializationException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.SerializationException>(errorValue), + stackTrace, + ); + case 'flutter.NetworkImageLoadException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$flutter_image_provider.NetworkImageLoadException>( + errorValue, + ), + stackTrace, + ); + default: + Error.throwWithStackTrace( + _$celest.CloudException.http( + code: code, + message: message, + details: ((details ?? body) as _$celest.JsonValue), + ), + StackTrace.empty, + ); + } + } + + @_$celest.CloudFunction(api: 'flutter', function: 'paintWidget') + Future paintWidget() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/flutter/paint-widget'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize($body); + } + + @_$celest.CloudFunction(api: 'flutter', function: 'helloWorld') + Future helloWorld() async { + final $response = await celest.httpClient.get( + celest.baseUri.resolve('/flutter/hello-world'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize($body); + } +} diff --git a/apps/cli/fixtures/legacy/flutter/client/lib/src/serializers.dart b/apps/cli/fixtures/legacy/flutter/client/lib/src/serializers.dart new file mode 100644 index 000000000..45091f3d4 --- /dev/null +++ b/apps/cli/fixtures/legacy/flutter/client/lib/src/serializers.dart @@ -0,0 +1,1148 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async'; +import 'dart:convert'; +import 'dart:io'; +import 'dart:isolate'; +import 'dart:ui'; + +import 'package:celest_backend/src/functions/flutter.dart'; +import 'package:celest_core/celest_core.dart' as _$celest; +import 'package:celest_core/src/exception/cloud_exception.dart' as _$celest; +import 'package:celest_core/src/exception/serialization_exception.dart' + as _$celest; +import 'package:celest_core/src/serialization/json_value.dart' as _$celest; +import 'package:flutter/src/foundation/key.dart' as _$flutter_key; +import 'package:flutter/src/painting/image_provider.dart' + as _$flutter_image_provider; + +void initSerializers({_$celest.Serializers? serializers}) { + return runZoned(() { + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _$celest.Serializers.instance + .serialize($value.stackTrace), + }, + deserialize: ($serialized) { + return AsyncError( + $serialized[r'error']!, + _$celest.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_$celest.Serializers.instance.serialize( + $value.duration, + ) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return TimeoutException( + ($serialized[r'message'] as String?), + _$celest.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest + .Serializer.define>( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + ConcurrentModificationError, + Map? + >( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: + ($value) => { + if (_$celest.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: + ($value) => { + r'type': $value.type, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize( + $value.osError, + ) + case final osError?) + r'osError': osError, + }, + deserialize: ($serialized) { + return CertificateException( + (($serialized?[r'message'] as String?)) ?? '', + _$celest.Serializers.instance.deserialize( + $serialized?[r'osError'], + ), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + if ($value.path case final path?) r'path': path, + if (_$celest.Serializers.instance.serialize( + $value.osError, + ) + case final osError?) + r'osError': osError, + }, + deserialize: ($serialized) { + return FileSystemException( + (($serialized?[r'message'] as String?)) ?? '', + (($serialized?[r'path'] as String?)) ?? '', + _$celest.Serializers.instance.deserialize( + $serialized?[r'osError'], + ), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: + ($value) => { + r'type': $value.type, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize( + $value.osError, + ) + case final osError?) + r'osError': osError, + }, + deserialize: ($serialized) { + return HandshakeException( + (($serialized?[r'message'] as String?)) ?? '', + _$celest.Serializers.instance.deserialize( + $serialized?[r'osError'], + ), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + r'message': $value.message, + if (_$celest.Serializers.instance.serialize($value.uri) + case final uri?) + r'uri': uri, + }, + deserialize: ($serialized) { + return HttpException( + ($serialized[r'message'] as String), + uri: _$celest.Serializers.instance.deserialize( + $serialized[r'uri'], + ), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'errorCode': $value.errorCode, + }, + deserialize: ($serialized) { + return OSError( + (($serialized?[r'message'] as String?)) ?? '', + (($serialized?[r'errorCode'] as num?)?.toInt()) ?? + OSError.noErrorCode, + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + r'message': $value.message, + if ($value.path case final path?) r'path': path, + if (_$celest.Serializers.instance.serialize( + $value.osError, + ) + case final osError?) + r'osError': osError, + }, + deserialize: ($serialized) { + return PathAccessException( + ($serialized[r'path'] as String), + _$celest.Serializers.instance.deserialize( + $serialized[r'osError'], + ), + (($serialized[r'message'] as String?)) ?? '', + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + r'message': $value.message, + if ($value.path case final path?) r'path': path, + if (_$celest.Serializers.instance.serialize( + $value.osError, + ) + case final osError?) + r'osError': osError, + }, + deserialize: ($serialized) { + return PathExistsException( + ($serialized[r'path'] as String), + _$celest.Serializers.instance.deserialize( + $serialized[r'osError'], + ), + (($serialized[r'message'] as String?)) ?? '', + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + r'message': $value.message, + if ($value.path case final path?) r'path': path, + if (_$celest.Serializers.instance.serialize( + $value.osError, + ) + case final osError?) + r'osError': osError, + }, + deserialize: ($serialized) { + return PathNotFoundException( + ($serialized[r'path'] as String), + _$celest.Serializers.instance.deserialize( + $serialized[r'osError'], + ), + (($serialized[r'message'] as String?)) ?? '', + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + r'executable': $value.executable, + r'arguments': $value.arguments, + r'message': $value.message, + r'errorCode': $value.errorCode, + }, + deserialize: ($serialized) { + return ProcessException( + ($serialized[r'executable'] as String), + ($serialized[r'arguments'] as Iterable) + .map((el) => (el as String)) + .toList(), + (($serialized[r'message'] as String?)) ?? '', + (($serialized[r'errorCode'] as num?)?.toInt()) ?? 0, + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + r'message': $value.message, + r'osError': $value.osError, + }, + deserialize: ($serialized) { + return SignalException( + ($serialized[r'message'] as String), + $serialized[r'osError'], + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + r'message': $value.message, + if (_$celest.Serializers.instance.serialize( + $value.osError, + ) + case final osError?) + r'osError': osError, + }, + deserialize: ($serialized) { + return StdinException( + ($serialized[r'message'] as String), + _$celest.Serializers.instance.deserialize( + $serialized[r'osError'], + ), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + r'message': $value.message, + if (_$celest.Serializers.instance.serialize( + $value.osError, + ) + case final osError?) + r'osError': osError, + }, + deserialize: ($serialized) { + return StdoutException( + ($serialized[r'message'] as String), + _$celest.Serializers.instance.deserialize( + $serialized[r'osError'], + ), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: + ($value) => { + r'type': $value.type, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize( + $value.osError, + ) + case final osError?) + r'osError': osError, + }, + deserialize: ($serialized) { + return TlsException( + (($serialized?[r'message'] as String?)) ?? '', + _$celest.Serializers.instance.deserialize( + $serialized?[r'osError'], + ), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + if ($value.httpStatusCode case final httpStatusCode?) + r'httpStatusCode': httpStatusCode, + }, + deserialize: ($serialized) { + return WebSocketException( + (($serialized?[r'message'] as String?)) ?? '', + ($serialized?[r'httpStatusCode'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return IsolateSpawnException(($serialized[r'message'] as String)); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + r'a': $value.a, + r'r': $value.r, + r'g': $value.g, + r'b': $value.b, + r'colorSpace': _$celest.Serializers.instance + .serialize($value.colorSpace), + r'value': $value.value, + r'alpha': $value.alpha, + r'opacity': $value.opacity, + r'red': $value.red, + r'green': $value.green, + r'blue': $value.blue, + }, + deserialize: ($serialized) { + return Color(($serialized[r'value'] as num).toInt()); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define( + serialize: ($value) => $value.name, + deserialize: ($serialized) { + return ColorSpace.values.byName($serialized); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + r'languageCode': $value.languageCode, + if ($value.scriptCode case final scriptCode?) + r'scriptCode': scriptCode, + if ($value.countryCode case final countryCode?) + r'countryCode': countryCode, + }, + deserialize: ($serialized) { + return Locale( + ($serialized[r'languageCode'] as String), + ($serialized[r'countryCode'] as String?), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: + ($value) => { + if (_$celest.Serializers.instance.serialize<_$flutter_key.Key?>( + $value.key, + ) + case final key?) + r'key': key, + }, + deserialize: ($serialized) { + return HelloWorld( + key: _$celest.Serializers.instance.deserialize<_$flutter_key.Key?>( + $serialized?[r'key'], + ), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest + .Serializer.define<_$celest.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.AbortedException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.AlreadyExistsException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.BadRequestException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.BadRequestException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.CancelledException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.CancelledException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define<_$celest.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.CloudException.fromJson($serialized); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define<_$celest.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.DataLossError( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.DeadlineExceededError, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.InternalServerError, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.InternalServerError( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest + .Serializer.define<_$celest.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.NotFoundException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.OutOfRangeException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.OutOfRangeException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.UnauthorizedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.UnauthorizedException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest + .Serializer.define<_$celest.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.UnavailableError( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.UnimplementedError, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.UnimplementedError( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define<_$celest.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.UnknownError( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.SerializationException, + Map + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define<_$celest.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _$celest.JsonValue($serialized); + }, + ), + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define<_$flutter_key.Key, Map>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return _$flutter_key.Key(($serialized[r'value'] as String)); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$flutter_image_provider.NetworkImageLoadException, + Map + >( + serialize: + ($value) => { + r'statusCode': $value.statusCode, + r'uri': _$celest.Serializers.instance.serialize($value.uri), + }, + deserialize: ($serialized) { + return _$flutter_image_provider.NetworkImageLoadException( + statusCode: ($serialized[r'statusCode'] as num).toInt(), + uri: _$celest.Serializers.instance.deserialize( + $serialized[r'uri'], + ), + ); + }, + ), + ); + }, zoneValues: {_$celest.Serializers: serializers}); +} diff --git a/apps/cli/fixtures/legacy/flutter/client/pubspec.yaml b/apps/cli/fixtures/legacy/flutter/client/pubspec.yaml new file mode 100644 index 000000000..f8953ca45 --- /dev/null +++ b/apps/cli/fixtures/legacy/flutter/client/pubspec.yaml @@ -0,0 +1,29 @@ +name: flutter_client +description: The Celest client for flutter. +publish_to: none + +environment: + sdk: ^3.4.0 + +dependencies: + celest: ^1.0.0 + celest_backend: + path: .. + celest_core: ^1.0.0 + http: ^1.0.0 + native_storage: ^0.2.2 + +dependency_overrides: + celest: + path: ../../../../../../celest/packages/celest + celest_ast: + path: ../../../../../../celest/packages/celest_ast + celest_auth: + path: ../../../../../../celest/packages/celest_auth + celest_cloud: + path: ../../../../../../celest/packages/celest_cloud + celest_cloud_auth: + path: ../../../../../../celest/services/celest_cloud_auth + celest_core: + path: ../../../../../../celest/packages/celest_core +dev_dependencies: {} diff --git a/apps/cli/fixtures/legacy/flutter/goldens/api.local.dart b/apps/cli/fixtures/legacy/flutter/goldens/api.local.dart new file mode 100644 index 000000000..bba72e8ed --- /dev/null +++ b/apps/cli/fixtures/legacy/flutter/goldens/api.local.dart @@ -0,0 +1,26 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; + +import 'functions/dart_ui/addCountryCode.dart' as _i2; +import 'functions/dart_ui/lerpColor.dart' as _i3; +import 'functions/flutter/helloWorld.dart' as _i4; +import 'functions/flutter/paintWidget.dart' as _i5; + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: { + '/dart-ui/add-country-code': _i2.AddCountryCodeTarget(), + '/dart-ui/lerp-color': _i3.LerpColorTarget(), + '/flutter/hello-world': _i4.HelloWorldTarget(), + '/flutter/paint-widget': _i5.PaintWidgetTarget(), + }, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/flutter/goldens/ast.json b/apps/cli/fixtures/legacy/flutter/goldens/ast.json new file mode 100644 index 000000000..fb7ab5c3c --- /dev/null +++ b/apps/cli/fixtures/legacy/flutter/goldens/ast.json @@ -0,0 +1,1139 @@ +{ + "name": "flutter", + "environment": "local", + "reference": { + "$": "Reference", + "symbol": "project", + "url": "package:celest_backend/src/project.dart" + }, + "apis": { + "dart_ui": { + "name": "dart_ui", + "metadata": [], + "functions": { + "lerpColor": { + "name": "lerpColor", + "apiName": "dart_ui", + "typeParameters": [], + "parameters": [ + { + "name": "a", + "type": { + "$": "TypeReference", + "symbol": "Color", + "url": "dart:ui", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 189, + "uri": "package:celest_backend/src/functions/dart_ui.dart", + "line": 8, + "column": 36 + }, + "end": { + "offset": 190, + "uri": "package:celest_backend/src/functions/dart_ui.dart", + "line": 8, + "column": 37 + }, + "text": "a" + } + }, + { + "name": "b", + "type": { + "$": "TypeReference", + "symbol": "Color", + "url": "dart:ui", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 201, + "uri": "package:celest_backend/src/functions/dart_ui.dart", + "line": 8, + "column": 48 + }, + "end": { + "offset": 202, + "uri": "package:celest_backend/src/functions/dart_ui.dart", + "line": 8, + "column": 49 + }, + "text": "b" + } + }, + { + "name": "t", + "type": { + "$": "TypeReference", + "symbol": "double", + "url": "dart:core", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 211, + "uri": "package:celest_backend/src/functions/dart_ui.dart", + "line": 8, + "column": 58 + }, + "end": { + "offset": 212, + "uri": "package:celest_backend/src/functions/dart_ui.dart", + "line": 8, + "column": 59 + }, + "text": "t" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "Future", + "url": "dart:async", + "types": [ + { + "$": "TypeReference", + "symbol": "Color", + "url": "dart:ui", + "isNullable": false + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "Color", + "url": "dart:ui", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 170, + "uri": "package:celest_backend/src/functions/dart_ui.dart", + "line": 8, + "column": 17 + }, + "end": { + "offset": 179, + "uri": "package:celest_backend/src/functions/dart_ui.dart", + "line": 8, + "column": 26 + }, + "text": "lerpColor" + } + }, + "addCountryCode": { + "name": "addCountryCode", + "apiName": "dart_ui", + "typeParameters": [], + "parameters": [ + { + "name": "locale", + "type": { + "$": "TypeReference", + "symbol": "Locale", + "url": "dart:ui", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 309, + "uri": "package:celest_backend/src/functions/dart_ui.dart", + "line": 13, + "column": 43 + }, + "end": { + "offset": 315, + "uri": "package:celest_backend/src/functions/dart_ui.dart", + "line": 13, + "column": 49 + }, + "text": "locale" + } + }, + { + "name": "countryCode", + "type": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 324, + "uri": "package:celest_backend/src/functions/dart_ui.dart", + "line": 13, + "column": 58 + }, + "end": { + "offset": 335, + "uri": "package:celest_backend/src/functions/dart_ui.dart", + "line": 13, + "column": 69 + }, + "text": "countryCode" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "Future", + "url": "dart:async", + "types": [ + { + "$": "TypeReference", + "symbol": "Locale", + "url": "dart:ui", + "isNullable": false + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "Locale", + "url": "dart:ui", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 284, + "uri": "package:celest_backend/src/functions/dart_ui.dart", + "line": 13, + "column": 18 + }, + "end": { + "offset": 298, + "uri": "package:celest_backend/src/functions/dart_ui.dart", + "line": 13, + "column": 32 + }, + "text": "addCountryCode" + } + } + }, + "docs": [ + "/// Tests that dart:ui types can be used as inputs/outputs in functions." + ], + "exceptionTypes": [ + { + "$": "TypeReference", + "symbol": "AsyncError", + "url": "dart:async", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "TimeoutException", + "url": "dart:async", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "JsonUnsupportedObjectError", + "url": "dart:convert", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "Error", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AssertionError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "TypeError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ArgumentError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "RangeError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "IndexError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnsupportedError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnimplementedError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "StateError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ConcurrentModificationError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "OutOfMemoryError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "StackOverflowError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "Exception", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "FormatException", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "IntegerDivisionByZeroException", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "IsolateSpawnException", + "url": "dart:isolate", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "OSError", + "url": "dart:io", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "FileSystemException", + "url": "dart:io", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "PathAccessException", + "url": "dart:io", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "PathExistsException", + "url": "dart:io", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "PathNotFoundException", + "url": "dart:io", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "SignalException", + "url": "dart:io", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ProcessException", + "url": "dart:io", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "TlsException", + "url": "dart:io", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "HandshakeException", + "url": "dart:io", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "CertificateException", + "url": "dart:io", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "StdoutException", + "url": "dart:io", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "StdinException", + "url": "dart:io", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "HttpException", + "url": "dart:io", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "WebSocketException", + "url": "dart:io", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "CloudException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "CancelledException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnknownError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "BadRequestException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnauthorizedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "NotFoundException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AlreadyExistsException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "PermissionDeniedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ResourceExhaustedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "FailedPreconditionException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AbortedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "OutOfRangeException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnimplementedError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "InternalServerError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnavailableError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "DataLossError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "DeadlineExceededError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "SerializationException", + "url": "package:celest_core/src/exception/serialization_exception.dart", + "isNullable": false + } + ], + "location": { + "start": { + "offset": 0, + "uri": "package:celest_backend/src/functions/dart_ui.dart", + "line": 0, + "column": 0 + }, + "end": { + "offset": 0, + "uri": "package:celest_backend/src/functions/dart_ui.dart", + "line": 0, + "column": 0 + }, + "text": "" + } + }, + "flutter": { + "name": "flutter", + "metadata": [], + "functions": { + "paintWidget": { + "name": "paintWidget", + "apiName": "flutter", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "TypeReference", + "symbol": "Future", + "url": "dart:async", + "types": [ + { + "$": "Reference", + "symbol": "Uint8List", + "url": "dart:typed_data" + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "Reference", + "symbol": "Uint8List", + "url": "dart:typed_data" + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 286, + "uri": "package:celest_backend/src/functions/flutter.dart", + "line": 11, + "column": 18 + }, + "end": { + "offset": 297, + "uri": "package:celest_backend/src/functions/flutter.dart", + "line": 11, + "column": 29 + }, + "text": "paintWidget" + } + }, + "helloWorld": { + "name": "helloWorld", + "apiName": "flutter", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "TypeReference", + "symbol": "Future", + "url": "dart:async", + "types": [ + { + "$": "TypeReference", + "symbol": "HelloWorld", + "url": "package:celest_backend/src/functions/flutter.dart", + "isNullable": false + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "HelloWorld", + "url": "package:celest_backend/src/functions/flutter.dart", + "isNullable": false + }, + "metadata": [ + { + "$": "ApiHttpConfig", + "method": "GET", + "statusCode": 200, + "location": { + "start": { + "offset": 1001, + "uri": "package:celest_backend/src/functions/flutter.dart", + "line": 33, + "column": 0 + }, + "end": { + "offset": 1030, + "uri": "package:celest_backend/src/functions/flutter.dart", + "line": 33, + "column": 29 + }, + "text": "@http(method: HttpMethod.get)" + } + } + ], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + }, + { + "$": "DartInstance", + "classRef": { + "symbol": "http", + "url": "package:celest/src/functions/http/http.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": { + "method": { + "$": "DartString", + "value": "GET", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "staticType": { + "symbol": "http", + "url": "package:celest/src/functions/http/http.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 1050, + "uri": "package:celest_backend/src/functions/flutter.dart", + "line": 34, + "column": 19 + }, + "end": { + "offset": 1060, + "uri": "package:celest_backend/src/functions/flutter.dart", + "line": 34, + "column": 29 + }, + "text": "helloWorld" + } + } + }, + "docs": [], + "exceptionTypes": [ + { + "$": "TypeReference", + "symbol": "AsyncError", + "url": "dart:async", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "TimeoutException", + "url": "dart:async", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "JsonUnsupportedObjectError", + "url": "dart:convert", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "Error", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AssertionError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "TypeError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ArgumentError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "RangeError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "IndexError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnsupportedError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnimplementedError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "StateError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ConcurrentModificationError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "OutOfMemoryError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "StackOverflowError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "Exception", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "FormatException", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "IntegerDivisionByZeroException", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "IsolateSpawnException", + "url": "dart:isolate", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "OSError", + "url": "dart:io", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "FileSystemException", + "url": "dart:io", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "PathAccessException", + "url": "dart:io", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "PathExistsException", + "url": "dart:io", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "PathNotFoundException", + "url": "dart:io", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "SignalException", + "url": "dart:io", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ProcessException", + "url": "dart:io", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "TlsException", + "url": "dart:io", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "HandshakeException", + "url": "dart:io", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "CertificateException", + "url": "dart:io", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "StdoutException", + "url": "dart:io", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "StdinException", + "url": "dart:io", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "HttpException", + "url": "dart:io", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "WebSocketException", + "url": "dart:io", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "CloudException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "CancelledException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnknownError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "BadRequestException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnauthorizedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "NotFoundException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AlreadyExistsException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "PermissionDeniedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ResourceExhaustedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "FailedPreconditionException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AbortedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "OutOfRangeException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnimplementedError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "InternalServerError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnavailableError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "DataLossError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "DeadlineExceededError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "SerializationException", + "url": "package:celest_core/src/exception/serialization_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "NetworkImageLoadException", + "url": "package:flutter/src/painting/image_provider.dart", + "isNullable": false + } + ], + "location": { + "start": { + "offset": 0, + "uri": "package:celest_backend/src/functions/flutter.dart", + "line": 0, + "column": 0 + }, + "end": { + "offset": 0, + "uri": "package:celest_backend/src/functions/flutter.dart", + "line": 0, + "column": 0 + }, + "text": "" + } + } + }, + "variables": [], + "secrets": [], + "databases": {}, + "sdkConfig": { + "celest": "1.0.6+2", + "dart": { + "type": "dart", + "version": "3.29.0", + "enabledExperiments": [] + }, + "targetSdk": "flutter", + "featureFlags": [ + "streaming" + ], + "flutter": { + "type": "flutter", + "version": "3.29.0", + "enabledExperiments": [] + } + }, + "location": { + "start": { + "offset": 44, + "uri": "project.dart", + "line": 2, + "column": 6 + }, + "end": { + "offset": 78, + "uri": "project.dart", + "line": 2, + "column": 40 + }, + "text": "project = Project(name: 'flutter')" + } +} \ No newline at end of file diff --git a/apps/cli/fixtures/legacy/flutter/goldens/ast.resolved.json b/apps/cli/fixtures/legacy/flutter/goldens/ast.resolved.json new file mode 100644 index 000000000..bb984867e --- /dev/null +++ b/apps/cli/fixtures/legacy/flutter/goldens/ast.resolved.json @@ -0,0 +1,105 @@ +{ + "projectId": "flutter", + "environmentId": "local", + "apis": { + "dart_ui": { + "apiId": "dart_ui", + "functions": { + "lerpColor": { + "functionId": "lerpColor", + "apiId": "dart_ui", + "httpConfig": { + "route": { + "method": "POST", + "path": "/dart-ui/lerp-color" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "addCountryCode": { + "functionId": "addCountryCode", + "apiId": "dart_ui", + "httpConfig": { + "route": { + "method": "POST", + "path": "/dart-ui/add-country-code" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + } + } + }, + "flutter": { + "apiId": "flutter", + "functions": { + "paintWidget": { + "functionId": "paintWidget", + "apiId": "flutter", + "httpConfig": { + "route": { + "method": "POST", + "path": "/flutter/paint-widget" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "helloWorld": { + "functionId": "helloWorld", + "apiId": "flutter", + "httpConfig": { + "route": { + "method": "GET", + "path": "/flutter/hello-world" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + } + } + } + }, + "variables": [ + { + "name": "CELEST_ENVIRONMENT", + "value": "local" + } + ], + "secrets": [], + "databases": {}, + "sdkConfig": { + "celest": "1.0.6+2", + "dart": { + "type": "dart", + "version": "3.29.0", + "enabledExperiments": [] + }, + "targetSdk": "flutter", + "featureFlags": [ + "streaming" + ], + "flutter": { + "type": "flutter", + "version": "3.29.0", + "enabledExperiments": [] + } + } +} \ No newline at end of file diff --git a/apps/cli/fixtures/legacy/flutter/goldens/celest.json b/apps/cli/fixtures/legacy/flutter/goldens/celest.json new file mode 100644 index 000000000..39d0d1e67 --- /dev/null +++ b/apps/cli/fixtures/legacy/flutter/goldens/celest.json @@ -0,0 +1,116 @@ +{ + "projectId": "flutter", + "environmentId": "local", + "apis": { + "dart_ui": { + "apiId": "dart_ui", + "functions": { + "lerpColor": { + "functionId": "lerpColor", + "parentId": "dart_ui", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/dart-ui/lerp-color" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "addCountryCode": { + "functionId": "addCountryCode", + "parentId": "dart_ui", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/dart-ui/add-country-code" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + } + } + }, + "flutter": { + "apiId": "flutter", + "functions": { + "paintWidget": { + "functionId": "paintWidget", + "parentId": "flutter", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/flutter/paint-widget" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "helloWorld": { + "functionId": "helloWorld", + "parentId": "flutter", + "httpConfig": { + "status": 200, + "route": { + "method": "GET", + "path": "/flutter/hello-world" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + } + } + } + }, + "variables": [ + { + "name": "CELEST_ENVIRONMENT", + "value": "local" + } + ], + "databases": {}, + "sdkConfig": { + "celest": { + "major": 1, + "minor": 0, + "patch": 6, + "build": [ + 2.0 + ], + "canonicalizedVersion": "1.0.6+2" + }, + "dart": { + "type": "DART", + "version": { + "major": 3, + "minor": 29, + "patch": 0, + "canonicalizedVersion": "3.29.0" + } + }, + "flutter": { + "type": "FLUTTER", + "version": { + "major": 3, + "minor": 29, + "patch": 0, + "canonicalizedVersion": "3.29.0" + } + }, + "targetSdk": "FLUTTER", + "featureFlags": [ + "STREAMING" + ] + } +} \ No newline at end of file diff --git a/apps/cli/fixtures/legacy/flutter/goldens/functions/dart_ui/addCountryCode.dart b/apps/cli/fixtures/legacy/flutter/goldens/functions/dart_ui/addCountryCode.dart new file mode 100644 index 000000000..826135934 --- /dev/null +++ b/apps/cli/fixtures/legacy/flutter/goldens/functions/dart_ui/addCountryCode.dart @@ -0,0 +1,2400 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i12; +import 'dart:io' as _i10; +import 'dart:isolate' as _i11; +import 'dart:ui' as _i5; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/dart_ui.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i13; +import 'package:celest_core/src/serialization/json_value.dart' as _i14; +import 'package:shelf/shelf.dart' as _i2; + +final class AddCountryCodeTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'addCountryCode'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = await _i3.addCountryCode( + _i4.Serializers.instance.deserialize<_i5.Locale>(request[r'locale']), + (request[r'countryCode'] as String), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.Locale>(response), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CertificateException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.io.CertificateException', + 'value': _i4.Serializers.instance + .serialize<_i10.CertificateException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.HandshakeException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.io.HandshakeException', + 'value': _i4.Serializers.instance + .serialize<_i10.HandshakeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.HttpException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart._http.HttpException', + 'value': _i4.Serializers.instance.serialize<_i10.HttpException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.IsolateSpawnException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.isolate.IsolateSpawnException', + 'value': _i4.Serializers.instance + .serialize<_i11.IsolateSpawnException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i12.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i12.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.OSError catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.io.OSError', + 'value': _i4.Serializers.instance.serialize<_i10.OSError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.PathAccessException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.io.PathAccessException', + 'value': _i4.Serializers.instance + .serialize<_i10.PathAccessException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.PathExistsException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.io.PathExistsException', + 'value': _i4.Serializers.instance + .serialize<_i10.PathExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.PathNotFoundException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.io.PathNotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i10.PathNotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.FileSystemException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.io.FileSystemException', + 'value': _i4.Serializers.instance + .serialize<_i10.FileSystemException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.ProcessException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.io.ProcessException', + 'value': _i4.Serializers.instance + .serialize<_i10.ProcessException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i13.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i13.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.SignalException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.io.SignalException', + 'value': _i4.Serializers.instance.serialize<_i10.SignalException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.StdinException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.io.StdinException', + 'value': _i4.Serializers.instance.serialize<_i10.StdinException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.StdoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.io.StdoutException', + 'value': _i4.Serializers.instance.serialize<_i10.StdoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.TlsException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.io.TlsException', + 'value': _i4.Serializers.instance.serialize<_i10.TlsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.WebSocketException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart._http.WebSocketException', + 'value': _i4.Serializers.instance + .serialize<_i10.WebSocketException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i12.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i12.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.CertificateException, Map?>( + serialize: + ($value) => { + r'type': $value.type, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i10.OSError?>( + $value.osError, + ) + case final osError?) + r'osError': osError, + }, + deserialize: ($serialized) { + return _i10.CertificateException( + (($serialized?[r'message'] as String?)) ?? '', + _i4.Serializers.instance.deserialize<_i10.OSError?>( + $serialized?[r'osError'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.FileSystemException, Map?>( + serialize: + ($value) => { + r'message': $value.message, + if ($value.path case final path?) r'path': path, + if (_i4.Serializers.instance.serialize<_i10.OSError?>( + $value.osError, + ) + case final osError?) + r'osError': osError, + }, + deserialize: ($serialized) { + return _i10.FileSystemException( + (($serialized?[r'message'] as String?)) ?? '', + (($serialized?[r'path'] as String?)) ?? '', + _i4.Serializers.instance.deserialize<_i10.OSError?>( + $serialized?[r'osError'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.HandshakeException, Map?>( + serialize: + ($value) => { + r'type': $value.type, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i10.OSError?>( + $value.osError, + ) + case final osError?) + r'osError': osError, + }, + deserialize: ($serialized) { + return _i10.HandshakeException( + (($serialized?[r'message'] as String?)) ?? '', + _i4.Serializers.instance.deserialize<_i10.OSError?>( + $serialized?[r'osError'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.HttpException, Map>( + serialize: + ($value) => { + r'message': $value.message, + if (_i4.Serializers.instance.serialize($value.uri) + case final uri?) + r'uri': uri, + }, + deserialize: ($serialized) { + return _i10.HttpException( + ($serialized[r'message'] as String), + uri: _i4.Serializers.instance.deserialize( + $serialized[r'uri'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.OSError, Map?>( + serialize: + ($value) => { + r'message': $value.message, + r'errorCode': $value.errorCode, + }, + deserialize: ($serialized) { + return _i10.OSError( + (($serialized?[r'message'] as String?)) ?? '', + (($serialized?[r'errorCode'] as num?)?.toInt()) ?? + _i10.OSError.noErrorCode, + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.PathAccessException, Map>( + serialize: + ($value) => { + r'message': $value.message, + if ($value.path case final path?) r'path': path, + if (_i4.Serializers.instance.serialize<_i10.OSError?>( + $value.osError, + ) + case final osError?) + r'osError': osError, + }, + deserialize: ($serialized) { + return _i10.PathAccessException( + ($serialized[r'path'] as String), + _i4.Serializers.instance.deserialize<_i10.OSError>( + $serialized[r'osError'], + ), + (($serialized[r'message'] as String?)) ?? '', + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.PathExistsException, Map>( + serialize: + ($value) => { + r'message': $value.message, + if ($value.path case final path?) r'path': path, + if (_i4.Serializers.instance.serialize<_i10.OSError?>( + $value.osError, + ) + case final osError?) + r'osError': osError, + }, + deserialize: ($serialized) { + return _i10.PathExistsException( + ($serialized[r'path'] as String), + _i4.Serializers.instance.deserialize<_i10.OSError>( + $serialized[r'osError'], + ), + (($serialized[r'message'] as String?)) ?? '', + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.PathNotFoundException, Map>( + serialize: + ($value) => { + r'message': $value.message, + if ($value.path case final path?) r'path': path, + if (_i4.Serializers.instance.serialize<_i10.OSError?>( + $value.osError, + ) + case final osError?) + r'osError': osError, + }, + deserialize: ($serialized) { + return _i10.PathNotFoundException( + ($serialized[r'path'] as String), + _i4.Serializers.instance.deserialize<_i10.OSError>( + $serialized[r'osError'], + ), + (($serialized[r'message'] as String?)) ?? '', + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.ProcessException, Map>( + serialize: + ($value) => { + r'executable': $value.executable, + r'arguments': $value.arguments, + r'message': $value.message, + r'errorCode': $value.errorCode, + }, + deserialize: ($serialized) { + return _i10.ProcessException( + ($serialized[r'executable'] as String), + ($serialized[r'arguments'] as Iterable) + .map((el) => (el as String)) + .toList(), + (($serialized[r'message'] as String?)) ?? '', + (($serialized[r'errorCode'] as num?)?.toInt()) ?? 0, + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.SignalException, Map>( + serialize: + ($value) => { + r'message': $value.message, + r'osError': $value.osError, + }, + deserialize: ($serialized) { + return _i10.SignalException( + ($serialized[r'message'] as String), + $serialized[r'osError'], + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.StdinException, Map>( + serialize: + ($value) => { + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i10.OSError?>( + $value.osError, + ) + case final osError?) + r'osError': osError, + }, + deserialize: ($serialized) { + return _i10.StdinException( + ($serialized[r'message'] as String), + _i4.Serializers.instance.deserialize<_i10.OSError?>( + $serialized[r'osError'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.StdoutException, Map>( + serialize: + ($value) => { + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i10.OSError?>( + $value.osError, + ) + case final osError?) + r'osError': osError, + }, + deserialize: ($serialized) { + return _i10.StdoutException( + ($serialized[r'message'] as String), + _i4.Serializers.instance.deserialize<_i10.OSError?>( + $serialized[r'osError'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.TlsException, Map?>( + serialize: + ($value) => { + r'type': $value.type, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i10.OSError?>( + $value.osError, + ) + case final osError?) + r'osError': osError, + }, + deserialize: ($serialized) { + return _i10.TlsException( + (($serialized?[r'message'] as String?)) ?? '', + _i4.Serializers.instance.deserialize<_i10.OSError?>( + $serialized?[r'osError'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.WebSocketException, Map?>( + serialize: + ($value) => { + r'message': $value.message, + if ($value.httpStatusCode case final httpStatusCode?) + r'httpStatusCode': httpStatusCode, + }, + deserialize: ($serialized) { + return _i10.WebSocketException( + (($serialized?[r'message'] as String?)) ?? '', + ($serialized?[r'httpStatusCode'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.IsolateSpawnException, Map>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return _i11.IsolateSpawnException( + ($serialized[r'message'] as String), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.Locale, Map>( + serialize: + ($value) => { + r'languageCode': $value.languageCode, + if ($value.scriptCode case final scriptCode?) + r'scriptCode': scriptCode, + if ($value.countryCode case final countryCode?) + r'countryCode': countryCode, + }, + deserialize: ($serialized) { + return _i5.Locale( + ($serialized[r'languageCode'] as String), + ($serialized[r'countryCode'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i13.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i14.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i14.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': AddCountryCodeTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/flutter/goldens/functions/dart_ui/lerpColor.dart b/apps/cli/fixtures/legacy/flutter/goldens/functions/dart_ui/lerpColor.dart new file mode 100644 index 000000000..4f4fe6d56 --- /dev/null +++ b/apps/cli/fixtures/legacy/flutter/goldens/functions/dart_ui/lerpColor.dart @@ -0,0 +1,2414 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i12; +import 'dart:io' as _i10; +import 'dart:isolate' as _i11; +import 'dart:ui' as _i5; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/dart_ui.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i13; +import 'package:celest_core/src/serialization/json_value.dart' as _i14; +import 'package:shelf/shelf.dart' as _i2; + +final class LerpColorTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'lerpColor'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = await _i3.lerpColor( + _i4.Serializers.instance.deserialize<_i5.Color>(request[r'a']), + _i4.Serializers.instance.deserialize<_i5.Color>(request[r'b']), + (request[r't'] as num).toDouble(), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.Color>(response), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CertificateException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.io.CertificateException', + 'value': _i4.Serializers.instance + .serialize<_i10.CertificateException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.HandshakeException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.io.HandshakeException', + 'value': _i4.Serializers.instance + .serialize<_i10.HandshakeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.HttpException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart._http.HttpException', + 'value': _i4.Serializers.instance.serialize<_i10.HttpException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.IsolateSpawnException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.isolate.IsolateSpawnException', + 'value': _i4.Serializers.instance + .serialize<_i11.IsolateSpawnException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i12.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i12.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.OSError catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.io.OSError', + 'value': _i4.Serializers.instance.serialize<_i10.OSError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.PathAccessException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.io.PathAccessException', + 'value': _i4.Serializers.instance + .serialize<_i10.PathAccessException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.PathExistsException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.io.PathExistsException', + 'value': _i4.Serializers.instance + .serialize<_i10.PathExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.PathNotFoundException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.io.PathNotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i10.PathNotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.FileSystemException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.io.FileSystemException', + 'value': _i4.Serializers.instance + .serialize<_i10.FileSystemException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.ProcessException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.io.ProcessException', + 'value': _i4.Serializers.instance + .serialize<_i10.ProcessException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i13.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i13.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.SignalException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.io.SignalException', + 'value': _i4.Serializers.instance.serialize<_i10.SignalException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.StdinException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.io.StdinException', + 'value': _i4.Serializers.instance.serialize<_i10.StdinException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.StdoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.io.StdoutException', + 'value': _i4.Serializers.instance.serialize<_i10.StdoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.TlsException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.io.TlsException', + 'value': _i4.Serializers.instance.serialize<_i10.TlsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.WebSocketException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart._http.WebSocketException', + 'value': _i4.Serializers.instance + .serialize<_i10.WebSocketException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i12.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i12.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.CertificateException, Map?>( + serialize: + ($value) => { + r'type': $value.type, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i10.OSError?>( + $value.osError, + ) + case final osError?) + r'osError': osError, + }, + deserialize: ($serialized) { + return _i10.CertificateException( + (($serialized?[r'message'] as String?)) ?? '', + _i4.Serializers.instance.deserialize<_i10.OSError?>( + $serialized?[r'osError'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.FileSystemException, Map?>( + serialize: + ($value) => { + r'message': $value.message, + if ($value.path case final path?) r'path': path, + if (_i4.Serializers.instance.serialize<_i10.OSError?>( + $value.osError, + ) + case final osError?) + r'osError': osError, + }, + deserialize: ($serialized) { + return _i10.FileSystemException( + (($serialized?[r'message'] as String?)) ?? '', + (($serialized?[r'path'] as String?)) ?? '', + _i4.Serializers.instance.deserialize<_i10.OSError?>( + $serialized?[r'osError'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.HandshakeException, Map?>( + serialize: + ($value) => { + r'type': $value.type, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i10.OSError?>( + $value.osError, + ) + case final osError?) + r'osError': osError, + }, + deserialize: ($serialized) { + return _i10.HandshakeException( + (($serialized?[r'message'] as String?)) ?? '', + _i4.Serializers.instance.deserialize<_i10.OSError?>( + $serialized?[r'osError'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.HttpException, Map>( + serialize: + ($value) => { + r'message': $value.message, + if (_i4.Serializers.instance.serialize($value.uri) + case final uri?) + r'uri': uri, + }, + deserialize: ($serialized) { + return _i10.HttpException( + ($serialized[r'message'] as String), + uri: _i4.Serializers.instance.deserialize( + $serialized[r'uri'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.OSError, Map?>( + serialize: + ($value) => { + r'message': $value.message, + r'errorCode': $value.errorCode, + }, + deserialize: ($serialized) { + return _i10.OSError( + (($serialized?[r'message'] as String?)) ?? '', + (($serialized?[r'errorCode'] as num?)?.toInt()) ?? + _i10.OSError.noErrorCode, + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.PathAccessException, Map>( + serialize: + ($value) => { + r'message': $value.message, + if ($value.path case final path?) r'path': path, + if (_i4.Serializers.instance.serialize<_i10.OSError?>( + $value.osError, + ) + case final osError?) + r'osError': osError, + }, + deserialize: ($serialized) { + return _i10.PathAccessException( + ($serialized[r'path'] as String), + _i4.Serializers.instance.deserialize<_i10.OSError>( + $serialized[r'osError'], + ), + (($serialized[r'message'] as String?)) ?? '', + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.PathExistsException, Map>( + serialize: + ($value) => { + r'message': $value.message, + if ($value.path case final path?) r'path': path, + if (_i4.Serializers.instance.serialize<_i10.OSError?>( + $value.osError, + ) + case final osError?) + r'osError': osError, + }, + deserialize: ($serialized) { + return _i10.PathExistsException( + ($serialized[r'path'] as String), + _i4.Serializers.instance.deserialize<_i10.OSError>( + $serialized[r'osError'], + ), + (($serialized[r'message'] as String?)) ?? '', + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.PathNotFoundException, Map>( + serialize: + ($value) => { + r'message': $value.message, + if ($value.path case final path?) r'path': path, + if (_i4.Serializers.instance.serialize<_i10.OSError?>( + $value.osError, + ) + case final osError?) + r'osError': osError, + }, + deserialize: ($serialized) { + return _i10.PathNotFoundException( + ($serialized[r'path'] as String), + _i4.Serializers.instance.deserialize<_i10.OSError>( + $serialized[r'osError'], + ), + (($serialized[r'message'] as String?)) ?? '', + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.ProcessException, Map>( + serialize: + ($value) => { + r'executable': $value.executable, + r'arguments': $value.arguments, + r'message': $value.message, + r'errorCode': $value.errorCode, + }, + deserialize: ($serialized) { + return _i10.ProcessException( + ($serialized[r'executable'] as String), + ($serialized[r'arguments'] as Iterable) + .map((el) => (el as String)) + .toList(), + (($serialized[r'message'] as String?)) ?? '', + (($serialized[r'errorCode'] as num?)?.toInt()) ?? 0, + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.SignalException, Map>( + serialize: + ($value) => { + r'message': $value.message, + r'osError': $value.osError, + }, + deserialize: ($serialized) { + return _i10.SignalException( + ($serialized[r'message'] as String), + $serialized[r'osError'], + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.StdinException, Map>( + serialize: + ($value) => { + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i10.OSError?>( + $value.osError, + ) + case final osError?) + r'osError': osError, + }, + deserialize: ($serialized) { + return _i10.StdinException( + ($serialized[r'message'] as String), + _i4.Serializers.instance.deserialize<_i10.OSError?>( + $serialized[r'osError'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.StdoutException, Map>( + serialize: + ($value) => { + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i10.OSError?>( + $value.osError, + ) + case final osError?) + r'osError': osError, + }, + deserialize: ($serialized) { + return _i10.StdoutException( + ($serialized[r'message'] as String), + _i4.Serializers.instance.deserialize<_i10.OSError?>( + $serialized[r'osError'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.TlsException, Map?>( + serialize: + ($value) => { + r'type': $value.type, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i10.OSError?>( + $value.osError, + ) + case final osError?) + r'osError': osError, + }, + deserialize: ($serialized) { + return _i10.TlsException( + (($serialized?[r'message'] as String?)) ?? '', + _i4.Serializers.instance.deserialize<_i10.OSError?>( + $serialized?[r'osError'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.WebSocketException, Map?>( + serialize: + ($value) => { + r'message': $value.message, + if ($value.httpStatusCode case final httpStatusCode?) + r'httpStatusCode': httpStatusCode, + }, + deserialize: ($serialized) { + return _i10.WebSocketException( + (($serialized?[r'message'] as String?)) ?? '', + ($serialized?[r'httpStatusCode'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.IsolateSpawnException, Map>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return _i11.IsolateSpawnException( + ($serialized[r'message'] as String), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.Color, Map>( + serialize: + ($value) => { + r'a': $value.a, + r'r': $value.r, + r'g': $value.g, + r'b': $value.b, + r'colorSpace': _i4.Serializers.instance.serialize<_i5.ColorSpace>( + $value.colorSpace, + ), + r'value': $value.value, + r'alpha': $value.alpha, + r'opacity': $value.opacity, + r'red': $value.red, + r'green': $value.green, + r'blue': $value.blue, + }, + deserialize: ($serialized) { + return _i5.Color(($serialized[r'value'] as num).toInt()); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.ColorSpace, String>( + serialize: ($value) => $value.name, + deserialize: ($serialized) { + return _i5.ColorSpace.values.byName($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i13.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i14.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i14.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': LerpColorTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/flutter/goldens/functions/flutter/helloWorld.dart b/apps/cli/fixtures/legacy/flutter/goldens/functions/flutter/helloWorld.dart new file mode 100644 index 000000000..3492b799e --- /dev/null +++ b/apps/cli/fixtures/legacy/flutter/goldens/functions/flutter/helloWorld.dart @@ -0,0 +1,2448 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i11; +import 'dart:io' as _i9; +import 'dart:isolate' as _i10; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/flutter.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i13; +import 'package:celest_core/src/serialization/json_value.dart' as _i15; +import 'package:flutter/src/foundation/key.dart' as _i14; +import 'package:flutter/src/painting/image_provider.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class HelloWorldTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'helloWorld'; + + @override + String get method => 'GET'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = await _i3.helloWorld(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i3.HelloWorld>(response), + ), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.CertificateException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.io.CertificateException', + 'value': _i4.Serializers.instance + .serialize<_i9.CertificateException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.HandshakeException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.io.HandshakeException', + 'value': _i4.Serializers.instance + .serialize<_i9.HandshakeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.HttpException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart._http.HttpException', + 'value': _i4.Serializers.instance.serialize<_i9.HttpException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.IsolateSpawnException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.isolate.IsolateSpawnException', + 'value': _i4.Serializers.instance + .serialize<_i10.IsolateSpawnException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i11.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i12.NetworkImageLoadException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'flutter.NetworkImageLoadException', + 'value': _i4.Serializers.instance + .serialize<_i12.NetworkImageLoadException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.OSError catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.io.OSError', + 'value': _i4.Serializers.instance.serialize<_i9.OSError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.PathAccessException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.io.PathAccessException', + 'value': _i4.Serializers.instance + .serialize<_i9.PathAccessException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.PathExistsException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.io.PathExistsException', + 'value': _i4.Serializers.instance + .serialize<_i9.PathExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.PathNotFoundException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.io.PathNotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i9.PathNotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.FileSystemException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.io.FileSystemException', + 'value': _i4.Serializers.instance + .serialize<_i9.FileSystemException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.ProcessException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.io.ProcessException', + 'value': _i4.Serializers.instance.serialize<_i9.ProcessException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i13.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i13.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.SignalException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.io.SignalException', + 'value': _i4.Serializers.instance.serialize<_i9.SignalException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.StdinException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.io.StdinException', + 'value': _i4.Serializers.instance.serialize<_i9.StdinException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.StdoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.io.StdoutException', + 'value': _i4.Serializers.instance.serialize<_i9.StdoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TlsException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.io.TlsException', + 'value': _i4.Serializers.instance.serialize<_i9.TlsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.WebSocketException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart._http.WebSocketException', + 'value': _i4.Serializers.instance + .serialize<_i9.WebSocketException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i11.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i11.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.CertificateException, Map?>( + serialize: + ($value) => { + r'type': $value.type, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i9.OSError?>( + $value.osError, + ) + case final osError?) + r'osError': osError, + }, + deserialize: ($serialized) { + return _i9.CertificateException( + (($serialized?[r'message'] as String?)) ?? '', + _i4.Serializers.instance.deserialize<_i9.OSError?>( + $serialized?[r'osError'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.FileSystemException, Map?>( + serialize: + ($value) => { + r'message': $value.message, + if ($value.path case final path?) r'path': path, + if (_i4.Serializers.instance.serialize<_i9.OSError?>( + $value.osError, + ) + case final osError?) + r'osError': osError, + }, + deserialize: ($serialized) { + return _i9.FileSystemException( + (($serialized?[r'message'] as String?)) ?? '', + (($serialized?[r'path'] as String?)) ?? '', + _i4.Serializers.instance.deserialize<_i9.OSError?>( + $serialized?[r'osError'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.HandshakeException, Map?>( + serialize: + ($value) => { + r'type': $value.type, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i9.OSError?>( + $value.osError, + ) + case final osError?) + r'osError': osError, + }, + deserialize: ($serialized) { + return _i9.HandshakeException( + (($serialized?[r'message'] as String?)) ?? '', + _i4.Serializers.instance.deserialize<_i9.OSError?>( + $serialized?[r'osError'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.HttpException, Map>( + serialize: + ($value) => { + r'message': $value.message, + if (_i4.Serializers.instance.serialize($value.uri) + case final uri?) + r'uri': uri, + }, + deserialize: ($serialized) { + return _i9.HttpException( + ($serialized[r'message'] as String), + uri: _i4.Serializers.instance.deserialize( + $serialized[r'uri'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.OSError, Map?>( + serialize: + ($value) => { + r'message': $value.message, + r'errorCode': $value.errorCode, + }, + deserialize: ($serialized) { + return _i9.OSError( + (($serialized?[r'message'] as String?)) ?? '', + (($serialized?[r'errorCode'] as num?)?.toInt()) ?? + _i9.OSError.noErrorCode, + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.PathAccessException, Map>( + serialize: + ($value) => { + r'message': $value.message, + if ($value.path case final path?) r'path': path, + if (_i4.Serializers.instance.serialize<_i9.OSError?>( + $value.osError, + ) + case final osError?) + r'osError': osError, + }, + deserialize: ($serialized) { + return _i9.PathAccessException( + ($serialized[r'path'] as String), + _i4.Serializers.instance.deserialize<_i9.OSError>( + $serialized[r'osError'], + ), + (($serialized[r'message'] as String?)) ?? '', + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.PathExistsException, Map>( + serialize: + ($value) => { + r'message': $value.message, + if ($value.path case final path?) r'path': path, + if (_i4.Serializers.instance.serialize<_i9.OSError?>( + $value.osError, + ) + case final osError?) + r'osError': osError, + }, + deserialize: ($serialized) { + return _i9.PathExistsException( + ($serialized[r'path'] as String), + _i4.Serializers.instance.deserialize<_i9.OSError>( + $serialized[r'osError'], + ), + (($serialized[r'message'] as String?)) ?? '', + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.PathNotFoundException, Map>( + serialize: + ($value) => { + r'message': $value.message, + if ($value.path case final path?) r'path': path, + if (_i4.Serializers.instance.serialize<_i9.OSError?>( + $value.osError, + ) + case final osError?) + r'osError': osError, + }, + deserialize: ($serialized) { + return _i9.PathNotFoundException( + ($serialized[r'path'] as String), + _i4.Serializers.instance.deserialize<_i9.OSError>( + $serialized[r'osError'], + ), + (($serialized[r'message'] as String?)) ?? '', + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.ProcessException, Map>( + serialize: + ($value) => { + r'executable': $value.executable, + r'arguments': $value.arguments, + r'message': $value.message, + r'errorCode': $value.errorCode, + }, + deserialize: ($serialized) { + return _i9.ProcessException( + ($serialized[r'executable'] as String), + ($serialized[r'arguments'] as Iterable) + .map((el) => (el as String)) + .toList(), + (($serialized[r'message'] as String?)) ?? '', + (($serialized[r'errorCode'] as num?)?.toInt()) ?? 0, + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.SignalException, Map>( + serialize: + ($value) => { + r'message': $value.message, + r'osError': $value.osError, + }, + deserialize: ($serialized) { + return _i9.SignalException( + ($serialized[r'message'] as String), + $serialized[r'osError'], + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.StdinException, Map>( + serialize: + ($value) => { + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i9.OSError?>( + $value.osError, + ) + case final osError?) + r'osError': osError, + }, + deserialize: ($serialized) { + return _i9.StdinException( + ($serialized[r'message'] as String), + _i4.Serializers.instance.deserialize<_i9.OSError?>( + $serialized[r'osError'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.StdoutException, Map>( + serialize: + ($value) => { + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i9.OSError?>( + $value.osError, + ) + case final osError?) + r'osError': osError, + }, + deserialize: ($serialized) { + return _i9.StdoutException( + ($serialized[r'message'] as String), + _i4.Serializers.instance.deserialize<_i9.OSError?>( + $serialized[r'osError'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TlsException, Map?>( + serialize: + ($value) => { + r'type': $value.type, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i9.OSError?>( + $value.osError, + ) + case final osError?) + r'osError': osError, + }, + deserialize: ($serialized) { + return _i9.TlsException( + (($serialized?[r'message'] as String?)) ?? '', + _i4.Serializers.instance.deserialize<_i9.OSError?>( + $serialized?[r'osError'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.WebSocketException, Map?>( + serialize: + ($value) => { + r'message': $value.message, + if ($value.httpStatusCode case final httpStatusCode?) + r'httpStatusCode': httpStatusCode, + }, + deserialize: ($serialized) { + return _i9.WebSocketException( + (($serialized?[r'message'] as String?)) ?? '', + ($serialized?[r'httpStatusCode'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.IsolateSpawnException, Map>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return _i10.IsolateSpawnException( + ($serialized[r'message'] as String), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i3.HelloWorld, Map?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize<_i14.Key?>($value.key) + case final key?) + r'key': key, + }, + deserialize: ($serialized) { + return _i3.HelloWorld( + key: _i4.Serializers.instance.deserialize<_i14.Key?>( + $serialized?[r'key'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i15.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i15.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i15.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i15.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i15.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i15.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i15.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i15.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i15.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i15.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i15.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i15.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i15.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i15.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i15.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i15.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i13.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i15.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i15.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i14.Key, Map>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return _i14.Key(($serialized[r'value'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i12.NetworkImageLoadException, + Map + >( + serialize: + ($value) => { + r'statusCode': $value.statusCode, + r'uri': _i4.Serializers.instance.serialize($value.uri), + }, + deserialize: ($serialized) { + return _i12.NetworkImageLoadException( + statusCode: ($serialized[r'statusCode'] as num).toInt(), + uri: _i4.Serializers.instance.deserialize($serialized[r'uri']), + ); + }, + ), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': HelloWorldTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/flutter/goldens/functions/flutter/paintWidget.dart b/apps/cli/fixtures/legacy/flutter/goldens/functions/flutter/paintWidget.dart new file mode 100644 index 000000000..24c7ca848 --- /dev/null +++ b/apps/cli/fixtures/legacy/flutter/goldens/functions/flutter/paintWidget.dart @@ -0,0 +1,2424 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i12; +import 'dart:io' as _i10; +import 'dart:isolate' as _i11; +import 'dart:typed_data' as _i5; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/flutter.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i14; +import 'package:celest_core/src/serialization/json_value.dart' as _i15; +import 'package:flutter/src/painting/image_provider.dart' as _i13; +import 'package:shelf/shelf.dart' as _i2; + +final class PaintWidgetTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'paintWidget'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = await _i3.paintWidget(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.Uint8List>(response), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.CertificateException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.io.CertificateException', + 'value': _i4.Serializers.instance + .serialize<_i10.CertificateException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.HandshakeException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.io.HandshakeException', + 'value': _i4.Serializers.instance + .serialize<_i10.HandshakeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.HttpException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart._http.HttpException', + 'value': _i4.Serializers.instance.serialize<_i10.HttpException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.IsolateSpawnException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.isolate.IsolateSpawnException', + 'value': _i4.Serializers.instance + .serialize<_i11.IsolateSpawnException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i12.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i12.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i13.NetworkImageLoadException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'flutter.NetworkImageLoadException', + 'value': _i4.Serializers.instance + .serialize<_i13.NetworkImageLoadException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.OSError catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.io.OSError', + 'value': _i4.Serializers.instance.serialize<_i10.OSError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.PathAccessException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.io.PathAccessException', + 'value': _i4.Serializers.instance + .serialize<_i10.PathAccessException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.PathExistsException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.io.PathExistsException', + 'value': _i4.Serializers.instance + .serialize<_i10.PathExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.PathNotFoundException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.io.PathNotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i10.PathNotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.FileSystemException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.io.FileSystemException', + 'value': _i4.Serializers.instance + .serialize<_i10.FileSystemException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.ProcessException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.io.ProcessException', + 'value': _i4.Serializers.instance + .serialize<_i10.ProcessException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i14.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i14.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.SignalException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.io.SignalException', + 'value': _i4.Serializers.instance.serialize<_i10.SignalException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.StdinException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.io.StdinException', + 'value': _i4.Serializers.instance.serialize<_i10.StdinException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.StdoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.io.StdoutException', + 'value': _i4.Serializers.instance.serialize<_i10.StdoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.TlsException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.io.TlsException', + 'value': _i4.Serializers.instance.serialize<_i10.TlsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.WebSocketException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart._http.WebSocketException', + 'value': _i4.Serializers.instance + .serialize<_i10.WebSocketException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i12.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i12.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.CertificateException, Map?>( + serialize: + ($value) => { + r'type': $value.type, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i10.OSError?>( + $value.osError, + ) + case final osError?) + r'osError': osError, + }, + deserialize: ($serialized) { + return _i10.CertificateException( + (($serialized?[r'message'] as String?)) ?? '', + _i4.Serializers.instance.deserialize<_i10.OSError?>( + $serialized?[r'osError'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.FileSystemException, Map?>( + serialize: + ($value) => { + r'message': $value.message, + if ($value.path case final path?) r'path': path, + if (_i4.Serializers.instance.serialize<_i10.OSError?>( + $value.osError, + ) + case final osError?) + r'osError': osError, + }, + deserialize: ($serialized) { + return _i10.FileSystemException( + (($serialized?[r'message'] as String?)) ?? '', + (($serialized?[r'path'] as String?)) ?? '', + _i4.Serializers.instance.deserialize<_i10.OSError?>( + $serialized?[r'osError'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.HandshakeException, Map?>( + serialize: + ($value) => { + r'type': $value.type, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i10.OSError?>( + $value.osError, + ) + case final osError?) + r'osError': osError, + }, + deserialize: ($serialized) { + return _i10.HandshakeException( + (($serialized?[r'message'] as String?)) ?? '', + _i4.Serializers.instance.deserialize<_i10.OSError?>( + $serialized?[r'osError'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.HttpException, Map>( + serialize: + ($value) => { + r'message': $value.message, + if (_i4.Serializers.instance.serialize($value.uri) + case final uri?) + r'uri': uri, + }, + deserialize: ($serialized) { + return _i10.HttpException( + ($serialized[r'message'] as String), + uri: _i4.Serializers.instance.deserialize( + $serialized[r'uri'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.OSError, Map?>( + serialize: + ($value) => { + r'message': $value.message, + r'errorCode': $value.errorCode, + }, + deserialize: ($serialized) { + return _i10.OSError( + (($serialized?[r'message'] as String?)) ?? '', + (($serialized?[r'errorCode'] as num?)?.toInt()) ?? + _i10.OSError.noErrorCode, + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.PathAccessException, Map>( + serialize: + ($value) => { + r'message': $value.message, + if ($value.path case final path?) r'path': path, + if (_i4.Serializers.instance.serialize<_i10.OSError?>( + $value.osError, + ) + case final osError?) + r'osError': osError, + }, + deserialize: ($serialized) { + return _i10.PathAccessException( + ($serialized[r'path'] as String), + _i4.Serializers.instance.deserialize<_i10.OSError>( + $serialized[r'osError'], + ), + (($serialized[r'message'] as String?)) ?? '', + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.PathExistsException, Map>( + serialize: + ($value) => { + r'message': $value.message, + if ($value.path case final path?) r'path': path, + if (_i4.Serializers.instance.serialize<_i10.OSError?>( + $value.osError, + ) + case final osError?) + r'osError': osError, + }, + deserialize: ($serialized) { + return _i10.PathExistsException( + ($serialized[r'path'] as String), + _i4.Serializers.instance.deserialize<_i10.OSError>( + $serialized[r'osError'], + ), + (($serialized[r'message'] as String?)) ?? '', + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.PathNotFoundException, Map>( + serialize: + ($value) => { + r'message': $value.message, + if ($value.path case final path?) r'path': path, + if (_i4.Serializers.instance.serialize<_i10.OSError?>( + $value.osError, + ) + case final osError?) + r'osError': osError, + }, + deserialize: ($serialized) { + return _i10.PathNotFoundException( + ($serialized[r'path'] as String), + _i4.Serializers.instance.deserialize<_i10.OSError>( + $serialized[r'osError'], + ), + (($serialized[r'message'] as String?)) ?? '', + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.ProcessException, Map>( + serialize: + ($value) => { + r'executable': $value.executable, + r'arguments': $value.arguments, + r'message': $value.message, + r'errorCode': $value.errorCode, + }, + deserialize: ($serialized) { + return _i10.ProcessException( + ($serialized[r'executable'] as String), + ($serialized[r'arguments'] as Iterable) + .map((el) => (el as String)) + .toList(), + (($serialized[r'message'] as String?)) ?? '', + (($serialized[r'errorCode'] as num?)?.toInt()) ?? 0, + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.SignalException, Map>( + serialize: + ($value) => { + r'message': $value.message, + r'osError': $value.osError, + }, + deserialize: ($serialized) { + return _i10.SignalException( + ($serialized[r'message'] as String), + $serialized[r'osError'], + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.StdinException, Map>( + serialize: + ($value) => { + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i10.OSError?>( + $value.osError, + ) + case final osError?) + r'osError': osError, + }, + deserialize: ($serialized) { + return _i10.StdinException( + ($serialized[r'message'] as String), + _i4.Serializers.instance.deserialize<_i10.OSError?>( + $serialized[r'osError'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.StdoutException, Map>( + serialize: + ($value) => { + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i10.OSError?>( + $value.osError, + ) + case final osError?) + r'osError': osError, + }, + deserialize: ($serialized) { + return _i10.StdoutException( + ($serialized[r'message'] as String), + _i4.Serializers.instance.deserialize<_i10.OSError?>( + $serialized[r'osError'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.TlsException, Map?>( + serialize: + ($value) => { + r'type': $value.type, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i10.OSError?>( + $value.osError, + ) + case final osError?) + r'osError': osError, + }, + deserialize: ($serialized) { + return _i10.TlsException( + (($serialized?[r'message'] as String?)) ?? '', + _i4.Serializers.instance.deserialize<_i10.OSError?>( + $serialized?[r'osError'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.WebSocketException, Map?>( + serialize: + ($value) => { + r'message': $value.message, + if ($value.httpStatusCode case final httpStatusCode?) + r'httpStatusCode': httpStatusCode, + }, + deserialize: ($serialized) { + return _i10.WebSocketException( + (($serialized?[r'message'] as String?)) ?? '', + ($serialized?[r'httpStatusCode'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.IsolateSpawnException, Map>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return _i11.IsolateSpawnException( + ($serialized[r'message'] as String), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i15.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i15.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i15.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i15.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i15.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i15.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i15.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i15.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i15.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i15.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i15.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i15.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i15.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i15.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i15.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i15.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i14.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i15.JsonValue?>( + $value.details, + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i14.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i15.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i15.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i15.JsonValue?>('JsonValue'), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i13.NetworkImageLoadException, + Map + >( + serialize: + ($value) => { + r'statusCode': $value.statusCode, + r'uri': _i4.Serializers.instance.serialize($value.uri), + }, + deserialize: ($serialized) { + return _i13.NetworkImageLoadException( + statusCode: ($serialized[r'statusCode'] as num).toInt(), + uri: _i4.Serializers.instance.deserialize($serialized[r'uri']), + ); + }, + ), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': PaintWidgetTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/flutter/lib/fix_data/v1_migration.yaml b/apps/cli/fixtures/legacy/flutter/lib/fix_data/v1_migration.yaml new file mode 100644 index 000000000..d4e3bbc10 --- /dev/null +++ b/apps/cli/fixtures/legacy/flutter/lib/fix_data/v1_migration.yaml @@ -0,0 +1,13 @@ +# Generated by Celest. Do not modify. +version: 1 +transforms: + - title: "Updates the import of the Celest client" + date: 2024-10-06 + element: + uris: ["client.dart"] + variable: celest + changes: + - kind: replacedBy + newElement: + uris: ["package:flutter_client/flutter_client.dart"] + variable: celest diff --git a/apps/cli/fixtures/legacy/flutter/lib/models/_overrides.dart b/apps/cli/fixtures/legacy/flutter/lib/models/_overrides.dart new file mode 100644 index 000000000..a4734955b --- /dev/null +++ b/apps/cli/fixtures/legacy/flutter/lib/models/_overrides.dart @@ -0,0 +1,74 @@ +// import 'dart:ui' as ui; + +// import 'package:celest/celest.dart'; +// import 'package:flutter/material.dart' as flutter; + +// @customOverride +// extension type const MyTextDecoration(ui.TextDecoration decoration) +// implements ui.TextDecoration { +// factory MyTextDecoration.fromJson(String value) { +// return const TextDecorationSerializer().deserialize(value) +// as MyTextDecoration; +// } + +// String toJson() { +// return const TextDecorationSerializer().serialize(this) as String; +// } +// } + +// final class TextDecorationSerializer extends Serializer { +// const TextDecorationSerializer(); + +// static const Map _values = { +// 'none': ui.TextDecoration.none, +// 'underline': ui.TextDecoration.underline, +// 'overline': ui.TextDecoration.overline, +// 'lineThrough': ui.TextDecoration.lineThrough, +// }; + +// @override +// ui.TextDecoration deserialize(Object? value) { +// final serialized = assertWireType(value); +// const prefix = 'TextDecoration.'; +// final decoration = serialized.substring(prefix.length); + +// // e.g. TextDecoration.none +// if (_values[decoration] case final decoration?) { +// return decoration; +// } + +// // e.g. TextDecoration.combine([underline, overline]) +// final combination = decoration +// .substring( +// 'combine(['.length, +// decoration.length - '])'.length, +// ) +// .split(', '); +// if (combination.length < 2) { +// throw SerializationException( +// 'Invalid TextDecoration: $value', +// ); +// } +// return ui.TextDecoration.combine( +// combination.map((decoration) { +// return _values[decoration] ?? +// (throw SerializationException( +// 'Invalid TextDecoration: $decoration', +// )); +// }).toList(), +// ); +// } + +// @override +// Object? serialize(ui.TextDecoration value) { +// return value.toString(); +// } +// } + +// @customOverride +// extension type const Text(flutter.Text _) implements flutter.Text { +// Null get textSpan => null; +// Null get style => null; +// Null get strutStyle => null; +// Null get textScaler => null; +// } diff --git a/apps/cli/fixtures/legacy/flutter/lib/src/functions/dart_ui.dart b/apps/cli/fixtures/legacy/flutter/lib/src/functions/dart_ui.dart new file mode 100644 index 000000000..de56a025c --- /dev/null +++ b/apps/cli/fixtures/legacy/flutter/lib/src/functions/dart_ui.dart @@ -0,0 +1,16 @@ +/// Tests that dart:ui types can be used as inputs/outputs in functions. +library; + +import 'dart:ui' as ui; + +import 'package:celest/celest.dart'; + +@cloud +Future lerpColor(ui.Color a, ui.Color b, double t) async { + return ui.Color.lerp(a, b, t)!; +} + +@cloud +Future addCountryCode(ui.Locale locale, String countryCode) async { + return ui.Locale(locale.languageCode, countryCode); +} diff --git a/apps/cli/fixtures/legacy/flutter/lib/src/functions/flutter.dart b/apps/cli/fixtures/legacy/flutter/lib/src/functions/flutter.dart new file mode 100644 index 000000000..a286b6313 --- /dev/null +++ b/apps/cli/fixtures/legacy/flutter/lib/src/functions/flutter.dart @@ -0,0 +1,52 @@ +import 'dart:async'; +import 'dart:typed_data'; +import 'dart:ui'; + +import 'package:celest/celest.dart'; +import 'package:celest/http.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/rendering.dart'; +import 'package:flutter/scheduler.dart'; + +@cloud +Future paintWidget() async { + WidgetsFlutterBinding.ensureInitialized(); + final firstFrame = Completer(); + SchedulerBinding.instance.addPostFrameCallback(firstFrame.complete); + + runApp(const HelloWorld()); + await firstFrame.future; + + final element = WidgetsBinding.instance.rootElement!; + final renderObject = element.renderObject!; + // ignore: invalid_use_of_protected_member + final layer = renderObject.layer! as OffsetLayer; + final image = await layer.toImage(renderObject.paintBounds); + final imageBytes = await image.toByteData(format: ImageByteFormat.png); + if (imageBytes == null) { + throw InternalServerError('Failed to encode image'); + } + + return imageBytes.buffer.asUint8List(); +} + +@cloud +@http(method: HttpMethod.get) +Future helloWorld() async { + return const HelloWorld(); +} + +class HelloWorld extends StatelessWidget { + const HelloWorld({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: Scaffold( + body: Center( + child: Text('Hello, World!'), + ), + ), + ); + } +} diff --git a/apps/cli/fixtures/legacy/flutter/lib/src/generated/README.md b/apps/cli/fixtures/legacy/flutter/lib/src/generated/README.md new file mode 100644 index 000000000..a5b5cb795 --- /dev/null +++ b/apps/cli/fixtures/legacy/flutter/lib/src/generated/README.md @@ -0,0 +1,9 @@ +# Generated Celest code + +This directory contains code generated by the Celest CLI to assist in building +your backend. + +This code can be safely checked into version control, but it should not be +modified directly. + +It is planned to replace this directory with macros when they become stable. diff --git a/apps/cli/fixtures/legacy/flutter/lib/src/generated/cloud.celest.dart b/apps/cli/fixtures/legacy/flutter/lib/src/generated/cloud.celest.dart new file mode 100644 index 000000000..f1a89c399 --- /dev/null +++ b/apps/cli/fixtures/legacy/flutter/lib/src/generated/cloud.celest.dart @@ -0,0 +1,45 @@ +// Generated by Celest. This file should not be modified manually, but +// it can be checked into version control. +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +library; + +import 'package:celest/src/core/context.dart'; +import 'package:celest_backend/src/generated/config.celest.dart'; + +/// The interface to your Celest backend. +/// +/// Similar to the `celest` global in the frontend, this +/// provides access to the backend environment and services +/// configured for your project. +const CelestCloud celest = CelestCloud._(); + +/// A per-request context object which propogates request information and common +/// accessors to the Celest server environment. +CelestContext get context => CelestContext._(context); + +/// The interface to your Celest backend. +/// +/// Similar to the `Celest` class in the frontend, this class +/// provides access to the backend environment and services +/// configured for your project. +class CelestCloud { + const CelestCloud._(); + + /// The current environment of the Celest service. + /// + /// This is determined by the `CELEST_ENVIRONMENT` variable + /// which is set for you by the deployment environment. + CelestEnvironment get currentEnvironment => + (variables.currentEnvironment as CelestEnvironment); + + /// The variables of the Celest service. + /// + /// This class provides access to the values configured for the + /// [currentEnvironment]. + CelestVariables get variables => const CelestVariables(); +} + +/// A per-request context object which propogates request information and common +/// accessors to the Celest server environment. +extension type CelestContext._(Context _context) implements Context {} diff --git a/apps/cli/fixtures/legacy/flutter/lib/src/generated/config.celest.dart b/apps/cli/fixtures/legacy/flutter/lib/src/generated/config.celest.dart new file mode 100644 index 000000000..687b9f186 --- /dev/null +++ b/apps/cli/fixtures/legacy/flutter/lib/src/generated/config.celest.dart @@ -0,0 +1,45 @@ +// Generated by Celest. This file should not be modified manually, but +// it can be checked into version control. +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +library; + +import 'package:celest/celest.dart'; +import 'package:celest/src/core/context.dart'; + +/// An environment of a deployed Celest service. +/// +/// Celest services can have multiple isolated branches, for example +/// a `development` and `production` environment. +extension type const CelestEnvironment._(String _env) + implements Environment, String { + /// The local Celest environment, used to delineate when a + /// Celest service is running on a developer machine as opposed + /// to the cloud. + static const CelestEnvironment local = CelestEnvironment._('local'); + + /// The production Celest environment which is common to all + /// Celest projects and labels the environment which is considered + /// live and served to end-users. + static const CelestEnvironment production = CelestEnvironment._('production'); + + /// Whether `this` represents the [local] environment. + bool get isLocal => this == local; + + /// Whether `this` represents the [production] environment. + bool get isProduction => this == production; +} + +/// The environment variables for the Celest service. +/// +/// This class provides access to the environment variable values +/// that are configured for the current [CelestEnvironment]. +class CelestVariables { + const CelestVariables(); + + /// The environment variable that determines the current environment. + /// + /// This is set by the deployment environment and is used to + /// determine the current environment of the Celest service. + String get currentEnvironment => context.expect(env.environment); +} diff --git a/apps/cli/fixtures/legacy/flutter/lib/src/project.dart b/apps/cli/fixtures/legacy/flutter/lib/src/project.dart new file mode 100644 index 000000000..b138b1e1b --- /dev/null +++ b/apps/cli/fixtures/legacy/flutter/lib/src/project.dart @@ -0,0 +1,3 @@ +import 'package:celest/celest.dart'; + +const project = Project(name: 'flutter'); diff --git a/apps/cli/fixtures/legacy/flutter/pubspec.yaml b/apps/cli/fixtures/legacy/flutter/pubspec.yaml new file mode 100644 index 000000000..e77c4a247 --- /dev/null +++ b/apps/cli/fixtures/legacy/flutter/pubspec.yaml @@ -0,0 +1,34 @@ +name: celest_backend +publish_to: none + +environment: + sdk: ^3.4.0 + +dependencies: + celest: ^1.0.0 + celest_core: ^1.0.0 + flutter: + sdk: flutter + meta: ^1.12.0 + +dependency_overrides: + cedar: + path: ../../../../../cedar/packages/cedar + celest: + path: ../../../../../celest/packages/celest + celest_ast: + path: ../../../../../celest/packages/celest_ast + celest_auth: + path: ../../../../../celest/packages/celest_auth + celest_cloud: + path: ../../../../../celest/packages/celest_cloud + celest_cloud_auth: + path: ../../../../../celest/services/celest_cloud_auth + celest_core: + path: ../../../../../celest/packages/celest_core +celest: + project: + id: project_01hymks1f3faqyz4sgk3ac2y9k +dev_dependencies: + lints: ^4.0.0 + test: ^1.25.0 diff --git a/apps/cli/fixtures/legacy/flutter/test/golden_image.dart b/apps/cli/fixtures/legacy/flutter/test/golden_image.dart new file mode 100644 index 000000000..535d7a81c --- /dev/null +++ b/apps/cli/fixtures/legacy/flutter/test/golden_image.dart @@ -0,0 +1,11 @@ +import 'dart:io'; + +import 'package:celest_backend/src/functions/flutter.dart'; + +Future main() async { + final golden = await paintWidget(); + final output = File.fromUri( + Directory.current.uri.resolve('test/golden_image.png'), + ); + await output.writeAsBytes(golden); +} diff --git a/apps/cli/fixtures/legacy/flutter/test/golden_image.png b/apps/cli/fixtures/legacy/flutter/test/golden_image.png new file mode 100644 index 000000000..4d523e83c Binary files /dev/null and b/apps/cli/fixtures/legacy/flutter/test/golden_image.png differ diff --git a/apps/cli/fixtures/legacy/http/analysis_options.yaml b/apps/cli/fixtures/legacy/http/analysis_options.yaml new file mode 100644 index 000000000..cef4bc91f --- /dev/null +++ b/apps/cli/fixtures/legacy/http/analysis_options.yaml @@ -0,0 +1,4 @@ +analyzer: + errors: + deprecated_member_use_from_same_package: ignore + unused_element: ignore diff --git a/apps/cli/fixtures/legacy/http/client/lib/api_client.dart b/apps/cli/fixtures/legacy/http/client/lib/api_client.dart new file mode 100644 index 000000000..40a717f18 --- /dev/null +++ b/apps/cli/fixtures/legacy/http/client/lib/api_client.dart @@ -0,0 +1,89 @@ +// Generated by Celest. This file should not be modified manually, but +// it can be checked into version control. +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +library; // ignore_for_file: no_leading_underscores_for_library_prefixes + +import 'dart:io'; + +import 'package:api_client/src/functions.dart'; +import 'package:api_client/src/serializers.dart'; +import 'package:celest_core/_internal.dart' as _$celest; +import 'package:celest_core/celest_core.dart' as _$celest; +import 'package:celest_core/src/util/globals.dart' as _$celest; +import 'package:http/http.dart' as _$http_http; +import 'package:native_storage/native_storage.dart' + as _$native_storage_native_storage; + +export 'package:celest_backend/exceptions/http_errors.dart' + show + CustomBadRequestException, + ForbiddenException, + NotFoundException, + AnotherNotFoundException, + BadGatewayError; +export 'package:celest_backend/models/http_errors.dart' show ExceptionType; +export 'package:celest_backend/models/http_header_query.dart' + show HttpQueryParams, HttpHeaderParams; + +final Celest celest = Celest(); + +enum CelestEnvironment { + local, + production; + + Uri get baseUri => switch (this) { + local => + _$celest.kIsWeb || !Platform.isAndroid + ? Uri.parse('http://localhost:7777') + : Uri.parse('http://10.0.2.2:7777'), + production => Uri.parse('https://example.celest.run'), + }; +} + +class Celest with _$celest.CelestBase { + var _initialized = false; + + late CelestEnvironment _currentEnvironment; + + late final _$native_storage_native_storage.NativeStorage nativeStorage = + _$native_storage_native_storage.NativeStorage(scope: 'celest'); + + @override + late _$http_http.Client httpClient = _$celest.CelestHttpClient( + secureStorage: nativeStorage.secure, + ); + + late Uri _baseUri; + + final _functions = CelestFunctions(); + + T _checkInitialized(T Function() value) { + if (!_initialized) { + throw StateError( + 'Celest has not been initialized. Make sure to call `celest.init()` at the start of your `main` method.', + ); + } + return value(); + } + + CelestEnvironment get currentEnvironment => + _checkInitialized(() => _currentEnvironment); + + @override + Uri get baseUri => _checkInitialized(() => _baseUri); + + CelestFunctions get functions => _checkInitialized(() => _functions); + + void init({ + CelestEnvironment environment = CelestEnvironment.local, + _$celest.Serializers? serializers, + }) { + _currentEnvironment = environment; + _baseUri = environment.baseUri; + if (!_initialized) { + initSerializers(serializers: serializers); + } + _initialized = true; + } +} diff --git a/apps/cli/fixtures/legacy/http/client/lib/src/functions.dart b/apps/cli/fixtures/legacy/http/client/lib/src/functions.dart new file mode 100644 index 000000000..a3fc787bb --- /dev/null +++ b/apps/cli/fixtures/legacy/http/client/lib/src/functions.dart @@ -0,0 +1,1721 @@ +// Generated by Celest. This file should not be modified manually, but +// it can be checked into version control. +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +library; // ignore_for_file: no_leading_underscores_for_library_prefixes + +import 'dart:async'; +import 'dart:convert'; + +import 'package:api_client/api_client.dart'; +import 'package:celest/celest.dart' as _$celest; +import 'package:celest_backend/exceptions/http_errors.dart'; +import 'package:celest_backend/models/http_errors.dart'; +import 'package:celest_backend/models/http_header_query.dart'; +import 'package:celest_core/celest_core.dart' as _$celest; +import 'package:celest_core/src/exception/cloud_exception.dart' as _$celest; +import 'package:celest_core/src/exception/serialization_exception.dart' + as _$celest; + +class CelestFunctions { + final httpErrors = CelestFunctionsHttpErrors(); + + final httpHeader = CelestFunctionsHttpHeader(); + + final httpMethod = CelestFunctionsHttpMethod(); + + final httpQuery = CelestFunctionsHttpQuery(); + + final httpStatus = CelestFunctionsHttpStatus(); +} + +class CelestFunctionsHttpErrors { + Never _throwError({int? code, required Map body}) { + final status = body['@status'] as Map?; + final message = status?['message'] as String?; + final details = status?['details'] as _$celest.JsonList?; + final (errorType, errorValue, stackTrace) = switch (details) { + null || [] => const (null, null, StackTrace.empty), + [ + final errorDetails as Map, + { + '@type': 'dart.core.StackTrace', + 'value': final stackTraceValue as String, + }, + ..., + ] => + ( + errorDetails['@type'], + errorDetails['value'], + StackTrace.fromString(stackTraceValue), + ), + [final errorDetails as Map, ...] => ( + errorDetails['@type'], + errorDetails['value'], + StackTrace.empty, + ), + }; + + switch (errorType) { + case 'celest.core.v1.CloudException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.CloudException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.CancelledException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.CancelledException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnknownError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.UnknownError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.BadRequestException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.BadRequestException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnauthorizedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.UnauthorizedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.NotFoundException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.NotFoundException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.AlreadyExistsException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.AlreadyExistsException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.PermissionDeniedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.PermissionDeniedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.ResourceExhaustedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.ResourceExhaustedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.FailedPreconditionException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.FailedPreconditionException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.AbortedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.AbortedException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.OutOfRangeException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.OutOfRangeException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnimplementedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.UnimplementedError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.InternalServerError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.InternalServerError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnavailableError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.UnavailableError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.DataLossError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.DataLossError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.DeadlineExceededError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.DeadlineExceededError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.SerializationException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.SerializationException>(errorValue), + stackTrace, + ); + case 'dart.core.Error': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.AssertionError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.TypeError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.ArgumentError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.RangeError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.IndexError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.UnsupportedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.UnimplementedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.StateError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.ConcurrentModificationError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.core.OutOfMemoryError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.StackOverflowError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.Exception': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.FormatException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.IntegerDivisionByZeroException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.async.AsyncError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.async.TimeoutException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.convert.JsonUnsupportedObjectError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'api.v1.CustomBadRequestException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'api.v1.ForbiddenException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'api.v1.NotFoundException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'api.v1.AnotherNotFoundException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'api.v1.BadGatewayError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + default: + Error.throwWithStackTrace( + _$celest.CloudException.http( + code: code, + message: message, + details: ((details ?? body) as _$celest.JsonValue), + ), + StackTrace.empty, + ); + } + } + + @_$celest.CloudFunction(api: 'http_errors', function: 'httpErrors') + Future httpErrors(ExceptionType type) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/http-errors/http-errors'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'type': _$celest.Serializers.instance.serialize(type), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return; + } +} + +class CelestFunctionsHttpHeader { + Never _throwError({int? code, required Map body}) { + final status = body['@status'] as Map?; + final message = status?['message'] as String?; + final details = status?['details'] as _$celest.JsonList?; + final (errorType, errorValue, stackTrace) = switch (details) { + null || [] => const (null, null, StackTrace.empty), + [ + final errorDetails as Map, + { + '@type': 'dart.core.StackTrace', + 'value': final stackTraceValue as String, + }, + ..., + ] => + ( + errorDetails['@type'], + errorDetails['value'], + StackTrace.fromString(stackTraceValue), + ), + [final errorDetails as Map, ...] => ( + errorDetails['@type'], + errorDetails['value'], + StackTrace.empty, + ), + }; + + switch (errorType) { + case 'celest.core.v1.CloudException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.CloudException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.CancelledException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.CancelledException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnknownError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.UnknownError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.BadRequestException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.BadRequestException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnauthorizedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.UnauthorizedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.NotFoundException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.NotFoundException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.AlreadyExistsException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.AlreadyExistsException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.PermissionDeniedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.PermissionDeniedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.ResourceExhaustedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.ResourceExhaustedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.FailedPreconditionException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.FailedPreconditionException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.AbortedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.AbortedException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.OutOfRangeException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.OutOfRangeException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnimplementedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.UnimplementedError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.InternalServerError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.InternalServerError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnavailableError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.UnavailableError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.DataLossError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.DataLossError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.DeadlineExceededError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.DeadlineExceededError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.SerializationException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.SerializationException>(errorValue), + stackTrace, + ); + case 'dart.core.Error': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.AssertionError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.TypeError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.ArgumentError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.RangeError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.IndexError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.UnsupportedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.UnimplementedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.StateError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.ConcurrentModificationError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.core.OutOfMemoryError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.StackOverflowError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.Exception': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.FormatException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.IntegerDivisionByZeroException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.async.AsyncError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.async.TimeoutException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.convert.JsonUnsupportedObjectError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + default: + Error.throwWithStackTrace( + _$celest.CloudException.http( + code: code, + message: message, + details: ((details ?? body) as _$celest.JsonValue), + ), + StackTrace.empty, + ); + } + } + + @_$celest.CloudFunction(api: 'http_header', function: 'headers') + Future headers( + String aString, + int anInt, + double aDouble, + num aNum, + bool aBool, + DateTime aDateTime, + String? aNullableString, + int? aNullableInt, + double? aNullableDouble, + num? aNullableNum, + bool? aNullableBool, + DateTime? aNullableDateTime, + ) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/http-header/headers'), + headers: { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + r'aString': aString, + r'anInt': anInt.toString(), + r'aDouble': aDouble.toString(), + r'aNum': aNum.toString(), + r'aBool': aBool.toString(), + r'aDateTime': aDateTime.toIso8601String(), + if (aNullableString != null) r'aNullableString': aNullableString, + if (aNullableInt != null) r'aNullableInt': aNullableInt.toString(), + if (aNullableDouble != null) + r'aNullableDouble': aNullableDouble.toString(), + if (aNullableNum != null) r'aNullableNum': aNullableNum.toString(), + if (aNullableBool != null) r'aNullableBool': aNullableBool.toString(), + if (aNullableDateTime != null) + r'aNullableDateTime': aNullableDateTime.toIso8601String(), + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize($body); + } +} + +class CelestFunctionsHttpMethod { + Never _throwError({int? code, required Map body}) { + final status = body['@status'] as Map?; + final message = status?['message'] as String?; + final details = status?['details'] as _$celest.JsonList?; + final (errorType, errorValue, stackTrace) = switch (details) { + null || [] => const (null, null, StackTrace.empty), + [ + final errorDetails as Map, + { + '@type': 'dart.core.StackTrace', + 'value': final stackTraceValue as String, + }, + ..., + ] => + ( + errorDetails['@type'], + errorDetails['value'], + StackTrace.fromString(stackTraceValue), + ), + [final errorDetails as Map, ...] => ( + errorDetails['@type'], + errorDetails['value'], + StackTrace.empty, + ), + }; + + switch (errorType) { + case 'celest.core.v1.CloudException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.CloudException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.CancelledException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.CancelledException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnknownError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.UnknownError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.BadRequestException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.BadRequestException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnauthorizedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.UnauthorizedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.NotFoundException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.NotFoundException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.AlreadyExistsException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.AlreadyExistsException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.PermissionDeniedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.PermissionDeniedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.ResourceExhaustedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.ResourceExhaustedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.FailedPreconditionException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.FailedPreconditionException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.AbortedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.AbortedException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.OutOfRangeException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.OutOfRangeException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnimplementedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.UnimplementedError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.InternalServerError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.InternalServerError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnavailableError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.UnavailableError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.DataLossError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.DataLossError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.DeadlineExceededError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.DeadlineExceededError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.SerializationException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.SerializationException>(errorValue), + stackTrace, + ); + case 'dart.core.Error': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.AssertionError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.TypeError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.ArgumentError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.RangeError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.IndexError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.UnsupportedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.UnimplementedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.StateError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.ConcurrentModificationError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.core.OutOfMemoryError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.StackOverflowError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.Exception': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.FormatException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.IntegerDivisionByZeroException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.async.AsyncError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.async.TimeoutException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.convert.JsonUnsupportedObjectError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + default: + Error.throwWithStackTrace( + _$celest.CloudException.http( + code: code, + message: message, + details: ((details ?? body) as _$celest.JsonValue), + ), + StackTrace.empty, + ); + } + } + + @_$celest.CloudFunction(api: 'http_method', function: 'get') + Future get() async { + final $response = await celest.httpClient.get( + celest.baseUri.resolve('/http-method/get'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return; + } + + @_$celest.CloudFunction(api: 'http_method', function: 'post') + Future post() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/http-method/post'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return; + } + + @_$celest.CloudFunction(api: 'http_method', function: 'put') + Future put() async { + final $response = await celest.httpClient.put( + celest.baseUri.resolve('/http-method/put'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return; + } + + @_$celest.CloudFunction(api: 'http_method', function: 'delete') + Future delete() async { + final $response = await celest.httpClient.delete( + celest.baseUri.resolve('/http-method/delete'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return; + } + + @_$celest.CloudFunction(api: 'http_method', function: 'patch') + Future patch() async { + final $response = await celest.httpClient.patch( + celest.baseUri.resolve('/http-method/patch'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return; + } +} + +class CelestFunctionsHttpQuery { + Never _throwError({int? code, required Map body}) { + final status = body['@status'] as Map?; + final message = status?['message'] as String?; + final details = status?['details'] as _$celest.JsonList?; + final (errorType, errorValue, stackTrace) = switch (details) { + null || [] => const (null, null, StackTrace.empty), + [ + final errorDetails as Map, + { + '@type': 'dart.core.StackTrace', + 'value': final stackTraceValue as String, + }, + ..., + ] => + ( + errorDetails['@type'], + errorDetails['value'], + StackTrace.fromString(stackTraceValue), + ), + [final errorDetails as Map, ...] => ( + errorDetails['@type'], + errorDetails['value'], + StackTrace.empty, + ), + }; + + switch (errorType) { + case 'celest.core.v1.CloudException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.CloudException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.CancelledException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.CancelledException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnknownError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.UnknownError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.BadRequestException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.BadRequestException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnauthorizedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.UnauthorizedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.NotFoundException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.NotFoundException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.AlreadyExistsException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.AlreadyExistsException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.PermissionDeniedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.PermissionDeniedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.ResourceExhaustedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.ResourceExhaustedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.FailedPreconditionException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.FailedPreconditionException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.AbortedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.AbortedException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.OutOfRangeException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.OutOfRangeException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnimplementedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.UnimplementedError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.InternalServerError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.InternalServerError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnavailableError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.UnavailableError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.DataLossError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.DataLossError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.DeadlineExceededError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.DeadlineExceededError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.SerializationException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.SerializationException>(errorValue), + stackTrace, + ); + case 'dart.core.Error': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.AssertionError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.TypeError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.ArgumentError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.RangeError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.IndexError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.UnsupportedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.UnimplementedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.StateError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.ConcurrentModificationError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.core.OutOfMemoryError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.StackOverflowError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.Exception': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.FormatException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.IntegerDivisionByZeroException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.async.AsyncError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.async.TimeoutException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.convert.JsonUnsupportedObjectError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + default: + Error.throwWithStackTrace( + _$celest.CloudException.http( + code: code, + message: message, + details: ((details ?? body) as _$celest.JsonValue), + ), + StackTrace.empty, + ); + } + } + + @_$celest.CloudFunction(api: 'http_query', function: 'query') + Future query( + String aString, + int anInt, + double aDouble, + num aNum, + bool aBool, + DateTime aDateTime, + String? aNullableString, + int? aNullableInt, + double? aNullableDouble, + num? aNullableNum, + bool? aNullableBool, + DateTime? aNullableDateTime, + List aListOfString, + List aListOfInt, + List aListOfDouble, + List aListOfNum, + List aListOfBool, + List aListOfDateTime, + List? aNullableListOfString, + List? aNullableListOfInt, + List? aNullableListOfDouble, + List? aNullableListOfNum, + List? aNullableListOfBool, + List? aNullableListOfDateTime, + ) async { + final $response = await celest.httpClient.post( + celest.baseUri + .resolve('/http-query/query') + .replace( + queryParameters: { + r'aString': aString, + r'anInt': anInt.toString(), + r'aDouble': aDouble.toString(), + r'aNum': aNum.toString(), + r'aBool': aBool.toString(), + r'aDateTime': aDateTime.toIso8601String(), + if (aNullableString != null) r'aNullableString': aNullableString, + if (aNullableInt != null) + r'aNullableInt': aNullableInt.toString(), + if (aNullableDouble != null) + r'aNullableDouble': aNullableDouble.toString(), + if (aNullableNum != null) + r'aNullableNum': aNullableNum.toString(), + if (aNullableBool != null) + r'aNullableBool': aNullableBool.toString(), + if (aNullableDateTime != null) + r'aNullableDateTime': aNullableDateTime.toIso8601String(), + r'aListOfString': aListOfString, + r'aListOfInt': aListOfInt.map((el) => el.toString()).toList(), + r'aListOfDouble': + aListOfDouble.map((el) => el.toString()).toList(), + r'aListOfNum': aListOfNum.map((el) => el.toString()).toList(), + r'aListOfBool': aListOfBool.map((el) => el.toString()).toList(), + r'aListOfDateTime': + aListOfDateTime.map((el) => el.toIso8601String()).toList(), + if (aNullableListOfString != null) + r'aNullableListOfString': aNullableListOfString, + if (aNullableListOfInt != null) + r'aNullableListOfInt': + aNullableListOfInt.map((el) => el.toString()).toList(), + if (aNullableListOfDouble != null) + r'aNullableListOfDouble': + aNullableListOfDouble.map((el) => el.toString()).toList(), + if (aNullableListOfNum != null) + r'aNullableListOfNum': + aNullableListOfNum.map((el) => el.toString()).toList(), + if (aNullableListOfBool != null) + r'aNullableListOfBool': + aNullableListOfBool.map((el) => el.toString()).toList(), + if (aNullableListOfDateTime != null) + r'aNullableListOfDateTime': + aNullableListOfDateTime + .map((el) => el.toIso8601String()) + .toList(), + }, + ), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize($body); + } +} + +class CelestFunctionsHttpStatus { + Never _throwError({int? code, required Map body}) { + final status = body['@status'] as Map?; + final message = status?['message'] as String?; + final details = status?['details'] as _$celest.JsonList?; + final (errorType, errorValue, stackTrace) = switch (details) { + null || [] => const (null, null, StackTrace.empty), + [ + final errorDetails as Map, + { + '@type': 'dart.core.StackTrace', + 'value': final stackTraceValue as String, + }, + ..., + ] => + ( + errorDetails['@type'], + errorDetails['value'], + StackTrace.fromString(stackTraceValue), + ), + [final errorDetails as Map, ...] => ( + errorDetails['@type'], + errorDetails['value'], + StackTrace.empty, + ), + }; + + switch (errorType) { + case 'celest.core.v1.CloudException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.CloudException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.CancelledException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.CancelledException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnknownError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.UnknownError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.BadRequestException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.BadRequestException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnauthorizedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.UnauthorizedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.NotFoundException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.NotFoundException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.AlreadyExistsException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.AlreadyExistsException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.PermissionDeniedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.PermissionDeniedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.ResourceExhaustedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.ResourceExhaustedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.FailedPreconditionException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.FailedPreconditionException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.AbortedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.AbortedException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.OutOfRangeException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.OutOfRangeException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnimplementedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.UnimplementedError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.InternalServerError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.InternalServerError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnavailableError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.UnavailableError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.DataLossError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.DataLossError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.DeadlineExceededError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.DeadlineExceededError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.SerializationException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.SerializationException>(errorValue), + stackTrace, + ); + case 'dart.core.Error': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.AssertionError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.TypeError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.ArgumentError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.RangeError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.IndexError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.UnsupportedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.UnimplementedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.StateError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.ConcurrentModificationError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.core.OutOfMemoryError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.StackOverflowError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.Exception': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.FormatException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.IntegerDivisionByZeroException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.async.AsyncError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.async.TimeoutException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.convert.JsonUnsupportedObjectError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + default: + Error.throwWithStackTrace( + _$celest.CloudException.http( + code: code, + message: message, + details: ((details ?? body) as _$celest.JsonValue), + ), + StackTrace.empty, + ); + } + } + + @_$celest.CloudFunction(api: 'http_status', function: 'ok') + Future ok() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/http-status/ok'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return; + } + + @_$celest.CloudFunction(api: 'http_status', function: 'created') + Future created() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/http-status/created'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return; + } + + @_$celest.CloudFunction(api: 'http_status', function: 'accepted') + Future accepted() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/http-status/accepted'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return; + } + + @_$celest.CloudFunction(api: 'http_status', function: 'badRequest') + Future badRequest() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/http-status/bad-request'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return; + } + + @_$celest.CloudFunction(api: 'http_status', function: 'internalServerError') + Future internalServerError() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/http-status/internal-server-error'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return; + } +} diff --git a/apps/cli/fixtures/legacy/http/client/lib/src/serializers.dart b/apps/cli/fixtures/legacy/http/client/lib/src/serializers.dart new file mode 100644 index 000000000..ce9966d45 --- /dev/null +++ b/apps/cli/fixtures/legacy/http/client/lib/src/serializers.dart @@ -0,0 +1,1024 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async'; +import 'dart:convert'; + +import 'package:celest_backend/exceptions/http_errors.dart'; +import 'package:celest_backend/models/http_errors.dart'; +import 'package:celest_backend/models/http_header_query.dart'; +import 'package:celest_core/celest_core.dart' as _$celest; +import 'package:celest_core/src/exception/cloud_exception.dart' as _$celest; +import 'package:celest_core/src/exception/serialization_exception.dart' + as _$celest; +import 'package:celest_core/src/serialization/json_value.dart' as _$celest; + +void initSerializers({_$celest.Serializers? serializers}) { + return runZoned(() { + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _$celest.Serializers.instance + .serialize($value.stackTrace), + }, + deserialize: ($serialized) { + return AsyncError( + $serialized[r'error']!, + _$celest.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_$celest.Serializers.instance.serialize( + $value.duration, + ) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return TimeoutException( + ($serialized[r'message'] as String?), + _$celest.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest + .Serializer.define>( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + ConcurrentModificationError, + Map? + >( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: + ($value) => { + if (_$celest.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest + .Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return AnotherNotFoundException(); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return BadGatewayError(($serialized[r'message'] as String?)); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest + .Serializer.define?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return CustomBadRequestException( + message: ($serialized?[r'message'] as String?), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return ForbiddenException( + message: ($serialized?[r'message'] as String?), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return NotFoundException(); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define( + serialize: ($value) => $value.name, + deserialize: ($serialized) { + return ExceptionType.values.byName($serialized); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + r'aString': $value.aString, + r'anInt': $value.anInt, + r'aDouble': $value.aDouble, + r'aNum': $value.aNum, + r'aBool': $value.aBool, + r'aDateTime': _$celest.Serializers.instance.serialize( + $value.aDateTime, + ), + if ($value.aNullableString case final aNullableString?) + r'aNullableString': aNullableString, + if ($value.aNullableInt case final aNullableInt?) + r'aNullableInt': aNullableInt, + if ($value.aNullableDouble case final aNullableDouble?) + r'aNullableDouble': aNullableDouble, + if ($value.aNullableNum case final aNullableNum?) + r'aNullableNum': aNullableNum, + if ($value.aNullableBool case final aNullableBool?) + r'aNullableBool': aNullableBool, + if (_$celest.Serializers.instance.serialize( + $value.aNullableDateTime, + ) + case final aNullableDateTime?) + r'aNullableDateTime': aNullableDateTime, + }, + deserialize: ($serialized) { + return HttpHeaderParams( + aString: ($serialized[r'aString'] as String), + anInt: ($serialized[r'anInt'] as num).toInt(), + aDouble: ($serialized[r'aDouble'] as num).toDouble(), + aNum: ($serialized[r'aNum'] as num), + aBool: ($serialized[r'aBool'] as bool), + aDateTime: _$celest.Serializers.instance.deserialize( + $serialized[r'aDateTime'], + ), + aNullableString: ($serialized[r'aNullableString'] as String?), + aNullableInt: ($serialized[r'aNullableInt'] as num?)?.toInt(), + aNullableDouble: + ($serialized[r'aNullableDouble'] as num?)?.toDouble(), + aNullableNum: ($serialized[r'aNullableNum'] as num?), + aNullableBool: ($serialized[r'aNullableBool'] as bool?), + aNullableDateTime: _$celest.Serializers.instance + .deserialize($serialized[r'aNullableDateTime']), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + r'aString': $value.aString, + r'anInt': $value.anInt, + r'aDouble': $value.aDouble, + r'aNum': $value.aNum, + r'aBool': $value.aBool, + r'aDateTime': _$celest.Serializers.instance.serialize( + $value.aDateTime, + ), + if ($value.aNullableString case final aNullableString?) + r'aNullableString': aNullableString, + if ($value.aNullableInt case final aNullableInt?) + r'aNullableInt': aNullableInt, + if ($value.aNullableDouble case final aNullableDouble?) + r'aNullableDouble': aNullableDouble, + if ($value.aNullableNum case final aNullableNum?) + r'aNullableNum': aNullableNum, + if ($value.aNullableBool case final aNullableBool?) + r'aNullableBool': aNullableBool, + if (_$celest.Serializers.instance.serialize( + $value.aNullableDateTime, + ) + case final aNullableDateTime?) + r'aNullableDateTime': aNullableDateTime, + r'aListOfString': $value.aListOfString, + r'aListOfInt': $value.aListOfInt, + r'aListOfDouble': $value.aListOfDouble, + r'aListOfNum': $value.aListOfNum, + r'aListOfBool': $value.aListOfBool, + r'aListOfDateTime': + $value.aListOfDateTime + .map( + (el) => _$celest.Serializers.instance + .serialize(el), + ) + .toList(), + if ($value.aNullableListOfString + case final aNullableListOfString?) + r'aNullableListOfString': aNullableListOfString, + if ($value.aNullableListOfInt case final aNullableListOfInt?) + r'aNullableListOfInt': aNullableListOfInt, + if ($value.aNullableListOfDouble + case final aNullableListOfDouble?) + r'aNullableListOfDouble': aNullableListOfDouble, + if ($value.aNullableListOfNum case final aNullableListOfNum?) + r'aNullableListOfNum': aNullableListOfNum, + if ($value.aNullableListOfBool case final aNullableListOfBool?) + r'aNullableListOfBool': aNullableListOfBool, + if ($value.aNullableListOfDateTime + ?.map( + (el) => _$celest.Serializers.instance + .serialize(el), + ) + .toList() + case final aNullableListOfDateTime?) + r'aNullableListOfDateTime': aNullableListOfDateTime, + }, + deserialize: ($serialized) { + return HttpQueryParams( + aString: ($serialized[r'aString'] as String), + anInt: ($serialized[r'anInt'] as num).toInt(), + aDouble: ($serialized[r'aDouble'] as num).toDouble(), + aNum: ($serialized[r'aNum'] as num), + aBool: ($serialized[r'aBool'] as bool), + aDateTime: _$celest.Serializers.instance.deserialize( + $serialized[r'aDateTime'], + ), + aNullableString: ($serialized[r'aNullableString'] as String?), + aNullableInt: ($serialized[r'aNullableInt'] as num?)?.toInt(), + aNullableDouble: + ($serialized[r'aNullableDouble'] as num?)?.toDouble(), + aNullableNum: ($serialized[r'aNullableNum'] as num?), + aNullableBool: ($serialized[r'aNullableBool'] as bool?), + aNullableDateTime: _$celest.Serializers.instance + .deserialize($serialized[r'aNullableDateTime']), + aListOfString: + ($serialized[r'aListOfString'] as Iterable) + .map((el) => (el as String)) + .toList(), + aListOfInt: + ($serialized[r'aListOfInt'] as Iterable) + .map((el) => (el as num).toInt()) + .toList(), + aListOfDouble: + ($serialized[r'aListOfDouble'] as Iterable) + .map((el) => (el as num).toDouble()) + .toList(), + aListOfNum: + ($serialized[r'aListOfNum'] as Iterable) + .map((el) => (el as num)) + .toList(), + aListOfBool: + ($serialized[r'aListOfBool'] as Iterable) + .map((el) => (el as bool)) + .toList(), + aListOfDateTime: + ($serialized[r'aListOfDateTime'] as Iterable) + .map( + (el) => _$celest.Serializers.instance + .deserialize(el), + ) + .toList(), + aNullableListOfString: + ($serialized[r'aNullableListOfString'] as Iterable?) + ?.map((el) => (el as String)) + .toList(), + aNullableListOfInt: + ($serialized[r'aNullableListOfInt'] as Iterable?) + ?.map((el) => (el as num).toInt()) + .toList(), + aNullableListOfDouble: + ($serialized[r'aNullableListOfDouble'] as Iterable?) + ?.map((el) => (el as num).toDouble()) + .toList(), + aNullableListOfNum: + ($serialized[r'aNullableListOfNum'] as Iterable?) + ?.map((el) => (el as num)) + .toList(), + aNullableListOfBool: + ($serialized[r'aNullableListOfBool'] as Iterable?) + ?.map((el) => (el as bool)) + .toList(), + aNullableListOfDateTime: + ($serialized[r'aNullableListOfDateTime'] as Iterable?) + ?.map( + (el) => _$celest.Serializers.instance + .deserialize(el), + ) + .toList(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest + .Serializer.define<_$celest.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.AbortedException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.AlreadyExistsException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.BadRequestException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.BadRequestException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.CancelledException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.CancelledException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define<_$celest.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.CloudException.fromJson($serialized); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define<_$celest.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.DataLossError( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.DeadlineExceededError, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.InternalServerError, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.InternalServerError( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest + .Serializer.define<_$celest.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.NotFoundException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.OutOfRangeException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.OutOfRangeException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.UnauthorizedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.UnauthorizedException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest + .Serializer.define<_$celest.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.UnavailableError( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.UnimplementedError, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.UnimplementedError( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define<_$celest.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.UnknownError( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.SerializationException, + Map + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define<_$celest.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _$celest.JsonValue($serialized); + }, + ), + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ); + }, zoneValues: {_$celest.Serializers: serializers}); +} diff --git a/apps/cli/fixtures/legacy/http/client/pubspec.yaml b/apps/cli/fixtures/legacy/http/client/pubspec.yaml new file mode 100644 index 000000000..8801b1840 --- /dev/null +++ b/apps/cli/fixtures/legacy/http/client/pubspec.yaml @@ -0,0 +1,29 @@ +name: api_client +description: The Celest client for api. +publish_to: none + +environment: + sdk: ^3.4.0 + +dependencies: + celest: ^1.0.0 + celest_backend: + path: .. + celest_core: ^1.0.0 + http: ^1.0.0 + native_storage: ^0.2.2 + +dependency_overrides: + celest: + path: ../../../../../../celest/packages/celest + celest_ast: + path: ../../../../../../celest/packages/celest_ast + celest_auth: + path: ../../../../../../celest/packages/celest_auth + celest_cloud: + path: ../../../../../../celest/packages/celest_cloud + celest_cloud_auth: + path: ../../../../../../celest/services/celest_cloud_auth + celest_core: + path: ../../../../../../celest/packages/celest_core +dev_dependencies: {} diff --git a/apps/cli/fixtures/legacy/http/goldens/api.local.dart b/apps/cli/fixtures/legacy/http/goldens/api.local.dart new file mode 100644 index 000000000..7f669105e --- /dev/null +++ b/apps/cli/fixtures/legacy/http/goldens/api.local.dart @@ -0,0 +1,44 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'package:celest/src/core/context.dart' as _i15; +import 'package:celest/src/runtime/serve.dart' as _i1; + +import 'functions/http_errors/httpErrors.dart' as _i2; +import 'functions/http_header/headers.dart' as _i3; +import 'functions/http_method/delete.dart' as _i4; +import 'functions/http_method/get.dart' as _i5; +import 'functions/http_method/patch.dart' as _i6; +import 'functions/http_method/post.dart' as _i7; +import 'functions/http_method/put.dart' as _i8; +import 'functions/http_query/query.dart' as _i9; +import 'functions/http_status/accepted.dart' as _i10; +import 'functions/http_status/badRequest.dart' as _i11; +import 'functions/http_status/created.dart' as _i12; +import 'functions/http_status/internalServerError.dart' as _i13; +import 'functions/http_status/ok.dart' as _i14; + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: { + '/http-errors/http-errors': _i2.HttpErrorsTarget(), + '/http-header/headers': _i3.HeadersTarget(), + '/http-method/delete': _i4.DeleteTarget(), + '/http-method/get': _i5.GetTarget(), + '/http-method/patch': _i6.PatchTarget(), + '/http-method/post': _i7.PostTarget(), + '/http-method/put': _i8.PutTarget(), + '/http-query/query': _i9.QueryTarget(), + '/http-status/accepted': _i10.AcceptedTarget(), + '/http-status/bad-request': _i11.BadRequestTarget(), + '/http-status/created': _i12.CreatedTarget(), + '/http-status/internal-server-error': _i13.InternalServerErrorTarget(), + '/http-status/ok': _i14.OkTarget(), + }, + setup: (_i15.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/http/goldens/ast.json b/apps/cli/fixtures/legacy/http/goldens/ast.json new file mode 100644 index 000000000..4521b668b --- /dev/null +++ b/apps/cli/fixtures/legacy/http/goldens/ast.json @@ -0,0 +1,4967 @@ +{ + "name": "api", + "environment": "local", + "reference": { + "$": "Reference", + "symbol": "project", + "url": "package:celest_backend/src/project.dart" + }, + "apis": { + "http_status": { + "name": "http_status", + "metadata": [], + "functions": { + "ok": { + "name": "ok", + "apiName": "http_status", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "TypeReference", + "symbol": "Future", + "url": "dart:async", + "types": [ + { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "metadata": [ + { + "$": "ApiHttpConfig", + "method": "POST", + "statusCode": 200, + "location": { + "start": { + "offset": 80, + "uri": "package:celest_backend/src/functions/http_status.dart", + "line": 4, + "column": 0 + }, + "end": { + "offset": 112, + "uri": "package:celest_backend/src/functions/http_status.dart", + "line": 4, + "column": 32 + }, + "text": "@http(statusCode: HttpStatus.ok)" + } + } + ], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + }, + { + "$": "DartInstance", + "classRef": { + "symbol": "http", + "url": "package:celest/src/functions/http/http.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": { + "statusCode": { + "$": "DartInt", + "value": 200, + "staticType": { + "symbol": "int", + "url": "dart:core" + } + } + }, + "staticType": { + "symbol": "http", + "url": "package:celest/src/functions/http/http.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 126, + "uri": "package:celest_backend/src/functions/http_status.dart", + "line": 5, + "column": 13 + }, + "end": { + "offset": 128, + "uri": "package:celest_backend/src/functions/http_status.dart", + "line": 5, + "column": 15 + }, + "text": "ok" + } + }, + "created": { + "name": "created", + "apiName": "http_status", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "TypeReference", + "symbol": "Future", + "url": "dart:async", + "types": [ + { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "metadata": [ + { + "$": "ApiHttpConfig", + "method": "POST", + "statusCode": 201, + "location": { + "start": { + "offset": 148, + "uri": "package:celest_backend/src/functions/http_status.dart", + "line": 8, + "column": 0 + }, + "end": { + "offset": 185, + "uri": "package:celest_backend/src/functions/http_status.dart", + "line": 8, + "column": 37 + }, + "text": "@http(statusCode: HttpStatus.created)" + } + } + ], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + }, + { + "$": "DartInstance", + "classRef": { + "symbol": "http", + "url": "package:celest/src/functions/http/http.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": { + "statusCode": { + "$": "DartInt", + "value": 201, + "staticType": { + "symbol": "int", + "url": "dart:core" + } + } + }, + "staticType": { + "symbol": "http", + "url": "package:celest/src/functions/http/http.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 199, + "uri": "package:celest_backend/src/functions/http_status.dart", + "line": 9, + "column": 13 + }, + "end": { + "offset": 206, + "uri": "package:celest_backend/src/functions/http_status.dart", + "line": 9, + "column": 20 + }, + "text": "created" + } + }, + "accepted": { + "name": "accepted", + "apiName": "http_status", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "TypeReference", + "symbol": "Future", + "url": "dart:async", + "types": [ + { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "metadata": [ + { + "$": "ApiHttpConfig", + "method": "POST", + "statusCode": 202, + "location": { + "start": { + "offset": 226, + "uri": "package:celest_backend/src/functions/http_status.dart", + "line": 12, + "column": 0 + }, + "end": { + "offset": 264, + "uri": "package:celest_backend/src/functions/http_status.dart", + "line": 12, + "column": 38 + }, + "text": "@http(statusCode: HttpStatus.accepted)" + } + } + ], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + }, + { + "$": "DartInstance", + "classRef": { + "symbol": "http", + "url": "package:celest/src/functions/http/http.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": { + "statusCode": { + "$": "DartInt", + "value": 202, + "staticType": { + "symbol": "int", + "url": "dart:core" + } + } + }, + "staticType": { + "symbol": "http", + "url": "package:celest/src/functions/http/http.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 278, + "uri": "package:celest_backend/src/functions/http_status.dart", + "line": 13, + "column": 13 + }, + "end": { + "offset": 286, + "uri": "package:celest_backend/src/functions/http_status.dart", + "line": 13, + "column": 21 + }, + "text": "accepted" + } + }, + "badRequest": { + "name": "badRequest", + "apiName": "http_status", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "TypeReference", + "symbol": "Future", + "url": "dart:async", + "types": [ + { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "metadata": [ + { + "$": "ApiHttpConfig", + "method": "POST", + "statusCode": 400, + "location": { + "start": { + "offset": 306, + "uri": "package:celest_backend/src/functions/http_status.dart", + "line": 16, + "column": 0 + }, + "end": { + "offset": 346, + "uri": "package:celest_backend/src/functions/http_status.dart", + "line": 16, + "column": 40 + }, + "text": "@http(statusCode: HttpStatus.badRequest)" + } + } + ], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + }, + { + "$": "DartInstance", + "classRef": { + "symbol": "http", + "url": "package:celest/src/functions/http/http.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": { + "statusCode": { + "$": "DartInt", + "value": 400, + "staticType": { + "symbol": "int", + "url": "dart:core" + } + } + }, + "staticType": { + "symbol": "http", + "url": "package:celest/src/functions/http/http.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 360, + "uri": "package:celest_backend/src/functions/http_status.dart", + "line": 17, + "column": 13 + }, + "end": { + "offset": 370, + "uri": "package:celest_backend/src/functions/http_status.dart", + "line": 17, + "column": 23 + }, + "text": "badRequest" + } + }, + "internalServerError": { + "name": "internalServerError", + "apiName": "http_status", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "TypeReference", + "symbol": "Future", + "url": "dart:async", + "types": [ + { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "metadata": [ + { + "$": "ApiHttpConfig", + "method": "POST", + "statusCode": 500, + "location": { + "start": { + "offset": 390, + "uri": "package:celest_backend/src/functions/http_status.dart", + "line": 20, + "column": 0 + }, + "end": { + "offset": 439, + "uri": "package:celest_backend/src/functions/http_status.dart", + "line": 20, + "column": 49 + }, + "text": "@http(statusCode: HttpStatus.internalServerError)" + } + } + ], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + }, + { + "$": "DartInstance", + "classRef": { + "symbol": "http", + "url": "package:celest/src/functions/http/http.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": { + "statusCode": { + "$": "DartInt", + "value": 500, + "staticType": { + "symbol": "int", + "url": "dart:core" + } + } + }, + "staticType": { + "symbol": "http", + "url": "package:celest/src/functions/http/http.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 453, + "uri": "package:celest_backend/src/functions/http_status.dart", + "line": 21, + "column": 13 + }, + "end": { + "offset": 472, + "uri": "package:celest_backend/src/functions/http_status.dart", + "line": 21, + "column": 32 + }, + "text": "internalServerError" + } + } + }, + "docs": [], + "exceptionTypes": [ + { + "$": "TypeReference", + "symbol": "CloudException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "CancelledException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnknownError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "BadRequestException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnauthorizedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "NotFoundException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AlreadyExistsException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "PermissionDeniedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ResourceExhaustedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "FailedPreconditionException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AbortedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "OutOfRangeException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnimplementedError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "InternalServerError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnavailableError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "DataLossError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "DeadlineExceededError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "SerializationException", + "url": "package:celest_core/src/exception/serialization_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "Error", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AssertionError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "TypeError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ArgumentError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "RangeError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "IndexError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnsupportedError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnimplementedError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "StateError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ConcurrentModificationError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "OutOfMemoryError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "StackOverflowError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "Exception", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "FormatException", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "IntegerDivisionByZeroException", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AsyncError", + "url": "dart:async", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "TimeoutException", + "url": "dart:async", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "JsonUnsupportedObjectError", + "url": "dart:convert", + "isNullable": false + } + ], + "location": { + "start": { + "offset": 0, + "uri": "package:celest_backend/src/functions/http_status.dart", + "line": 0, + "column": 0 + }, + "end": { + "offset": 0, + "uri": "package:celest_backend/src/functions/http_status.dart", + "line": 0, + "column": 0 + }, + "text": "" + } + }, + "http_method": { + "name": "http_method", + "metadata": [], + "functions": { + "get": { + "name": "get", + "apiName": "http_method", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "TypeReference", + "symbol": "Future", + "url": "dart:async", + "types": [ + { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "metadata": [ + { + "$": "ApiHttpConfig", + "method": "GET", + "statusCode": 200, + "location": { + "start": { + "offset": 80, + "uri": "package:celest_backend/src/functions/http_method.dart", + "line": 4, + "column": 0 + }, + "end": { + "offset": 109, + "uri": "package:celest_backend/src/functions/http_method.dart", + "line": 4, + "column": 29 + }, + "text": "@http(method: HttpMethod.get)" + } + } + ], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + }, + { + "$": "DartInstance", + "classRef": { + "symbol": "http", + "url": "package:celest/src/functions/http/http.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": { + "method": { + "$": "DartString", + "value": "GET", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "staticType": { + "symbol": "http", + "url": "package:celest/src/functions/http/http.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 123, + "uri": "package:celest_backend/src/functions/http_method.dart", + "line": 5, + "column": 13 + }, + "end": { + "offset": 126, + "uri": "package:celest_backend/src/functions/http_method.dart", + "line": 5, + "column": 16 + }, + "text": "get" + } + }, + "post": { + "name": "post", + "apiName": "http_method", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "TypeReference", + "symbol": "Future", + "url": "dart:async", + "types": [ + { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "metadata": [ + { + "$": "ApiHttpConfig", + "method": "POST", + "statusCode": 200, + "location": { + "start": { + "offset": 146, + "uri": "package:celest_backend/src/functions/http_method.dart", + "line": 8, + "column": 0 + }, + "end": { + "offset": 176, + "uri": "package:celest_backend/src/functions/http_method.dart", + "line": 8, + "column": 30 + }, + "text": "@http(method: HttpMethod.post)" + } + } + ], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + }, + { + "$": "DartInstance", + "classRef": { + "symbol": "http", + "url": "package:celest/src/functions/http/http.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": { + "method": { + "$": "DartString", + "value": "POST", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "staticType": { + "symbol": "http", + "url": "package:celest/src/functions/http/http.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 190, + "uri": "package:celest_backend/src/functions/http_method.dart", + "line": 9, + "column": 13 + }, + "end": { + "offset": 194, + "uri": "package:celest_backend/src/functions/http_method.dart", + "line": 9, + "column": 17 + }, + "text": "post" + } + }, + "put": { + "name": "put", + "apiName": "http_method", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "TypeReference", + "symbol": "Future", + "url": "dart:async", + "types": [ + { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "metadata": [ + { + "$": "ApiHttpConfig", + "method": "PUT", + "statusCode": 200, + "location": { + "start": { + "offset": 214, + "uri": "package:celest_backend/src/functions/http_method.dart", + "line": 12, + "column": 0 + }, + "end": { + "offset": 243, + "uri": "package:celest_backend/src/functions/http_method.dart", + "line": 12, + "column": 29 + }, + "text": "@http(method: HttpMethod.put)" + } + } + ], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + }, + { + "$": "DartInstance", + "classRef": { + "symbol": "http", + "url": "package:celest/src/functions/http/http.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": { + "method": { + "$": "DartString", + "value": "PUT", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "staticType": { + "symbol": "http", + "url": "package:celest/src/functions/http/http.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 257, + "uri": "package:celest_backend/src/functions/http_method.dart", + "line": 13, + "column": 13 + }, + "end": { + "offset": 260, + "uri": "package:celest_backend/src/functions/http_method.dart", + "line": 13, + "column": 16 + }, + "text": "put" + } + }, + "delete": { + "name": "delete", + "apiName": "http_method", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "TypeReference", + "symbol": "Future", + "url": "dart:async", + "types": [ + { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "metadata": [ + { + "$": "ApiHttpConfig", + "method": "DELETE", + "statusCode": 200, + "location": { + "start": { + "offset": 280, + "uri": "package:celest_backend/src/functions/http_method.dart", + "line": 16, + "column": 0 + }, + "end": { + "offset": 312, + "uri": "package:celest_backend/src/functions/http_method.dart", + "line": 16, + "column": 32 + }, + "text": "@http(method: HttpMethod.delete)" + } + } + ], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + }, + { + "$": "DartInstance", + "classRef": { + "symbol": "http", + "url": "package:celest/src/functions/http/http.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": { + "method": { + "$": "DartString", + "value": "DELETE", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "staticType": { + "symbol": "http", + "url": "package:celest/src/functions/http/http.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 326, + "uri": "package:celest_backend/src/functions/http_method.dart", + "line": 17, + "column": 13 + }, + "end": { + "offset": 332, + "uri": "package:celest_backend/src/functions/http_method.dart", + "line": 17, + "column": 19 + }, + "text": "delete" + } + }, + "patch": { + "name": "patch", + "apiName": "http_method", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "TypeReference", + "symbol": "Future", + "url": "dart:async", + "types": [ + { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "metadata": [ + { + "$": "ApiHttpConfig", + "method": "PATCH", + "statusCode": 200, + "location": { + "start": { + "offset": 352, + "uri": "package:celest_backend/src/functions/http_method.dart", + "line": 20, + "column": 0 + }, + "end": { + "offset": 383, + "uri": "package:celest_backend/src/functions/http_method.dart", + "line": 20, + "column": 31 + }, + "text": "@http(method: HttpMethod.patch)" + } + } + ], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + }, + { + "$": "DartInstance", + "classRef": { + "symbol": "http", + "url": "package:celest/src/functions/http/http.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": { + "method": { + "$": "DartString", + "value": "PATCH", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "staticType": { + "symbol": "http", + "url": "package:celest/src/functions/http/http.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 397, + "uri": "package:celest_backend/src/functions/http_method.dart", + "line": 21, + "column": 13 + }, + "end": { + "offset": 402, + "uri": "package:celest_backend/src/functions/http_method.dart", + "line": 21, + "column": 18 + }, + "text": "patch" + } + } + }, + "docs": [], + "exceptionTypes": [ + { + "$": "TypeReference", + "symbol": "CloudException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "CancelledException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnknownError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "BadRequestException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnauthorizedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "NotFoundException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AlreadyExistsException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "PermissionDeniedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ResourceExhaustedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "FailedPreconditionException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AbortedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "OutOfRangeException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnimplementedError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "InternalServerError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnavailableError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "DataLossError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "DeadlineExceededError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "SerializationException", + "url": "package:celest_core/src/exception/serialization_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "Error", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AssertionError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "TypeError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ArgumentError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "RangeError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "IndexError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnsupportedError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnimplementedError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "StateError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ConcurrentModificationError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "OutOfMemoryError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "StackOverflowError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "Exception", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "FormatException", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "IntegerDivisionByZeroException", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AsyncError", + "url": "dart:async", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "TimeoutException", + "url": "dart:async", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "JsonUnsupportedObjectError", + "url": "dart:convert", + "isNullable": false + } + ], + "location": { + "start": { + "offset": 0, + "uri": "package:celest_backend/src/functions/http_method.dart", + "line": 0, + "column": 0 + }, + "end": { + "offset": 0, + "uri": "package:celest_backend/src/functions/http_method.dart", + "line": 0, + "column": 0 + }, + "text": "" + } + }, + "http_query": { + "name": "http_query", + "metadata": [], + "functions": { + "query": { + "name": "query", + "apiName": "http_query", + "typeParameters": [], + "parameters": [ + { + "name": "aString", + "type": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "httpQuery", + "url": "package:celest/src/functions/http/http_query.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": { + "name": { + "$": "DartString", + "value": "aString", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "namedArguments": {}, + "staticType": { + "symbol": "httpQuery", + "url": "package:celest/src/functions/http/http_query.dart", + "isNullable": false + } + } + ], + "location": { + "start": { + "offset": 205, + "uri": "package:celest_backend/src/functions/http_query.dart", + "line": 6, + "column": 31 + }, + "end": { + "offset": 212, + "uri": "package:celest_backend/src/functions/http_query.dart", + "line": 6, + "column": 38 + }, + "text": "aString" + }, + "references": { + "name": "aString", + "type": "httpQuery" + } + }, + { + "name": "anInt", + "type": { + "$": "TypeReference", + "symbol": "int", + "url": "dart:core", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "httpQuery", + "url": "package:celest/src/functions/http/http_query.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": { + "name": { + "$": "DartString", + "value": "anInt", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "namedArguments": {}, + "staticType": { + "symbol": "httpQuery", + "url": "package:celest/src/functions/http/http_query.dart", + "isNullable": false + } + } + ], + "location": { + "start": { + "offset": 240, + "uri": "package:celest_backend/src/functions/http_query.dart", + "line": 7, + "column": 26 + }, + "end": { + "offset": 245, + "uri": "package:celest_backend/src/functions/http_query.dart", + "line": 7, + "column": 31 + }, + "text": "anInt" + }, + "references": { + "name": "anInt", + "type": "httpQuery" + } + }, + { + "name": "aDouble", + "type": { + "$": "TypeReference", + "symbol": "double", + "url": "dart:core", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "httpQuery", + "url": "package:celest/src/functions/http/http_query.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": { + "name": { + "$": "DartString", + "value": "aDouble", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "namedArguments": {}, + "staticType": { + "symbol": "httpQuery", + "url": "package:celest/src/functions/http/http_query.dart", + "isNullable": false + } + } + ], + "location": { + "start": { + "offset": 278, + "uri": "package:celest_backend/src/functions/http_query.dart", + "line": 8, + "column": 31 + }, + "end": { + "offset": 285, + "uri": "package:celest_backend/src/functions/http_query.dart", + "line": 8, + "column": 38 + }, + "text": "aDouble" + }, + "references": { + "name": "aDouble", + "type": "httpQuery" + } + }, + { + "name": "aNum", + "type": { + "$": "TypeReference", + "symbol": "num", + "url": "dart:core", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "httpQuery", + "url": "package:celest/src/functions/http/http_query.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": { + "name": { + "$": "DartString", + "value": "aNum", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "namedArguments": {}, + "staticType": { + "symbol": "httpQuery", + "url": "package:celest/src/functions/http/http_query.dart", + "isNullable": false + } + } + ], + "location": { + "start": { + "offset": 312, + "uri": "package:celest_backend/src/functions/http_query.dart", + "line": 9, + "column": 25 + }, + "end": { + "offset": 316, + "uri": "package:celest_backend/src/functions/http_query.dart", + "line": 9, + "column": 29 + }, + "text": "aNum" + }, + "references": { + "name": "aNum", + "type": "httpQuery" + } + }, + { + "name": "aBool", + "type": { + "$": "TypeReference", + "symbol": "bool", + "url": "dart:core", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "httpQuery", + "url": "package:celest/src/functions/http/http_query.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": { + "name": { + "$": "DartString", + "value": "aBool", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "namedArguments": {}, + "staticType": { + "symbol": "httpQuery", + "url": "package:celest/src/functions/http/http_query.dart", + "isNullable": false + } + } + ], + "location": { + "start": { + "offset": 345, + "uri": "package:celest_backend/src/functions/http_query.dart", + "line": 10, + "column": 27 + }, + "end": { + "offset": 350, + "uri": "package:celest_backend/src/functions/http_query.dart", + "line": 10, + "column": 32 + }, + "text": "aBool" + }, + "references": { + "name": "aBool", + "type": "httpQuery" + } + }, + { + "name": "aDateTime", + "type": { + "$": "Reference", + "symbol": "DateTime", + "url": "dart:core" + }, + "required": true, + "named": false, + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "httpQuery", + "url": "package:celest/src/functions/http/http_query.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": { + "name": { + "$": "DartString", + "value": "aDateTime", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "namedArguments": {}, + "staticType": { + "symbol": "httpQuery", + "url": "package:celest/src/functions/http/http_query.dart", + "isNullable": false + } + } + ], + "location": { + "start": { + "offset": 387, + "uri": "package:celest_backend/src/functions/http_query.dart", + "line": 11, + "column": 35 + }, + "end": { + "offset": 396, + "uri": "package:celest_backend/src/functions/http_query.dart", + "line": 11, + "column": 44 + }, + "text": "aDateTime" + }, + "references": { + "name": "aDateTime", + "type": "httpQuery" + } + }, + { + "name": "aNullableString", + "type": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": true + }, + "required": true, + "named": false, + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "httpQuery", + "url": "package:celest/src/functions/http/http_query.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": { + "name": { + "$": "DartString", + "value": "aNullableString", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "namedArguments": {}, + "staticType": { + "symbol": "httpQuery", + "url": "package:celest/src/functions/http/http_query.dart", + "isNullable": false + } + } + ], + "location": { + "start": { + "offset": 438, + "uri": "package:celest_backend/src/functions/http_query.dart", + "line": 12, + "column": 40 + }, + "end": { + "offset": 453, + "uri": "package:celest_backend/src/functions/http_query.dart", + "line": 12, + "column": 55 + }, + "text": "aNullableString" + }, + "references": { + "name": "aNullableString", + "type": "httpQuery" + } + }, + { + "name": "aNullableInt", + "type": { + "$": "TypeReference", + "symbol": "int", + "url": "dart:core", + "isNullable": true + }, + "required": true, + "named": false, + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "httpQuery", + "url": "package:celest/src/functions/http/http_query.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": { + "name": { + "$": "DartString", + "value": "aNullableInt", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "namedArguments": {}, + "staticType": { + "symbol": "httpQuery", + "url": "package:celest/src/functions/http/http_query.dart", + "isNullable": false + } + } + ], + "location": { + "start": { + "offset": 489, + "uri": "package:celest_backend/src/functions/http_query.dart", + "line": 13, + "column": 34 + }, + "end": { + "offset": 501, + "uri": "package:celest_backend/src/functions/http_query.dart", + "line": 13, + "column": 46 + }, + "text": "aNullableInt" + }, + "references": { + "name": "aNullableInt", + "type": "httpQuery" + } + }, + { + "name": "aNullableDouble", + "type": { + "$": "TypeReference", + "symbol": "double", + "url": "dart:core", + "isNullable": true + }, + "required": true, + "named": false, + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "httpQuery", + "url": "package:celest/src/functions/http/http_query.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": { + "name": { + "$": "DartString", + "value": "aNullableDouble", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "namedArguments": {}, + "staticType": { + "symbol": "httpQuery", + "url": "package:celest/src/functions/http/http_query.dart", + "isNullable": false + } + } + ], + "location": { + "start": { + "offset": 543, + "uri": "package:celest_backend/src/functions/http_query.dart", + "line": 14, + "column": 40 + }, + "end": { + "offset": 558, + "uri": "package:celest_backend/src/functions/http_query.dart", + "line": 14, + "column": 55 + }, + "text": "aNullableDouble" + }, + "references": { + "name": "aNullableDouble", + "type": "httpQuery" + } + }, + { + "name": "aNullableNum", + "type": { + "$": "TypeReference", + "symbol": "num", + "url": "dart:core", + "isNullable": true + }, + "required": true, + "named": false, + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "httpQuery", + "url": "package:celest/src/functions/http/http_query.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": { + "name": { + "$": "DartString", + "value": "aNullableNum", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "namedArguments": {}, + "staticType": { + "symbol": "httpQuery", + "url": "package:celest/src/functions/http/http_query.dart", + "isNullable": false + } + } + ], + "location": { + "start": { + "offset": 594, + "uri": "package:celest_backend/src/functions/http_query.dart", + "line": 15, + "column": 34 + }, + "end": { + "offset": 606, + "uri": "package:celest_backend/src/functions/http_query.dart", + "line": 15, + "column": 46 + }, + "text": "aNullableNum" + }, + "references": { + "name": "aNullableNum", + "type": "httpQuery" + } + }, + { + "name": "aNullableBool", + "type": { + "$": "TypeReference", + "symbol": "bool", + "url": "dart:core", + "isNullable": true + }, + "required": true, + "named": false, + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "httpQuery", + "url": "package:celest/src/functions/http/http_query.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": { + "name": { + "$": "DartString", + "value": "aNullableBool", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "namedArguments": {}, + "staticType": { + "symbol": "httpQuery", + "url": "package:celest/src/functions/http/http_query.dart", + "isNullable": false + } + } + ], + "location": { + "start": { + "offset": 644, + "uri": "package:celest_backend/src/functions/http_query.dart", + "line": 16, + "column": 36 + }, + "end": { + "offset": 657, + "uri": "package:celest_backend/src/functions/http_query.dart", + "line": 16, + "column": 49 + }, + "text": "aNullableBool" + }, + "references": { + "name": "aNullableBool", + "type": "httpQuery" + } + }, + { + "name": "aNullableDateTime", + "type": { + "$": "TypeReference", + "symbol": "DateTime", + "url": "dart:core", + "isNullable": true + }, + "required": true, + "named": false, + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "httpQuery", + "url": "package:celest/src/functions/http/http_query.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": { + "name": { + "$": "DartString", + "value": "aNullableDateTime", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "namedArguments": {}, + "staticType": { + "symbol": "httpQuery", + "url": "package:celest/src/functions/http/http_query.dart", + "isNullable": false + } + } + ], + "location": { + "start": { + "offset": 703, + "uri": "package:celest_backend/src/functions/http_query.dart", + "line": 17, + "column": 44 + }, + "end": { + "offset": 720, + "uri": "package:celest_backend/src/functions/http_query.dart", + "line": 17, + "column": 61 + }, + "text": "aNullableDateTime" + }, + "references": { + "name": "aNullableDateTime", + "type": "httpQuery" + } + }, + { + "name": "aListOfString", + "type": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "httpQuery", + "url": "package:celest/src/functions/http/http_query.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": { + "name": { + "$": "DartString", + "value": "aListOfString", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "namedArguments": {}, + "staticType": { + "symbol": "httpQuery", + "url": "package:celest/src/functions/http/http_query.dart", + "isNullable": false + } + } + ], + "location": { + "start": { + "offset": 765, + "uri": "package:celest_backend/src/functions/http_query.dart", + "line": 18, + "column": 43 + }, + "end": { + "offset": 778, + "uri": "package:celest_backend/src/functions/http_query.dart", + "line": 18, + "column": 56 + }, + "text": "aListOfString" + }, + "references": { + "name": "aListOfString", + "type": "httpQuery" + } + }, + { + "name": "aListOfInt", + "type": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "int", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "httpQuery", + "url": "package:celest/src/functions/http/http_query.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": { + "name": { + "$": "DartString", + "value": "aListOfInt", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "namedArguments": {}, + "staticType": { + "symbol": "httpQuery", + "url": "package:celest/src/functions/http/http_query.dart", + "isNullable": false + } + } + ], + "location": { + "start": { + "offset": 817, + "uri": "package:celest_backend/src/functions/http_query.dart", + "line": 19, + "column": 37 + }, + "end": { + "offset": 827, + "uri": "package:celest_backend/src/functions/http_query.dart", + "line": 19, + "column": 47 + }, + "text": "aListOfInt" + }, + "references": { + "name": "aListOfInt", + "type": "httpQuery" + } + }, + { + "name": "aListOfDouble", + "type": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "double", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "httpQuery", + "url": "package:celest/src/functions/http/http_query.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": { + "name": { + "$": "DartString", + "value": "aListOfDouble", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "namedArguments": {}, + "staticType": { + "symbol": "httpQuery", + "url": "package:celest/src/functions/http/http_query.dart", + "isNullable": false + } + } + ], + "location": { + "start": { + "offset": 872, + "uri": "package:celest_backend/src/functions/http_query.dart", + "line": 20, + "column": 43 + }, + "end": { + "offset": 885, + "uri": "package:celest_backend/src/functions/http_query.dart", + "line": 20, + "column": 56 + }, + "text": "aListOfDouble" + }, + "references": { + "name": "aListOfDouble", + "type": "httpQuery" + } + }, + { + "name": "aListOfNum", + "type": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "num", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "httpQuery", + "url": "package:celest/src/functions/http/http_query.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": { + "name": { + "$": "DartString", + "value": "aListOfNum", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "namedArguments": {}, + "staticType": { + "symbol": "httpQuery", + "url": "package:celest/src/functions/http/http_query.dart", + "isNullable": false + } + } + ], + "location": { + "start": { + "offset": 924, + "uri": "package:celest_backend/src/functions/http_query.dart", + "line": 21, + "column": 37 + }, + "end": { + "offset": 934, + "uri": "package:celest_backend/src/functions/http_query.dart", + "line": 21, + "column": 47 + }, + "text": "aListOfNum" + }, + "references": { + "name": "aListOfNum", + "type": "httpQuery" + } + }, + { + "name": "aListOfBool", + "type": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "bool", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "httpQuery", + "url": "package:celest/src/functions/http/http_query.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": { + "name": { + "$": "DartString", + "value": "aListOfBool", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "namedArguments": {}, + "staticType": { + "symbol": "httpQuery", + "url": "package:celest/src/functions/http/http_query.dart", + "isNullable": false + } + } + ], + "location": { + "start": { + "offset": 975, + "uri": "package:celest_backend/src/functions/http_query.dart", + "line": 22, + "column": 39 + }, + "end": { + "offset": 986, + "uri": "package:celest_backend/src/functions/http_query.dart", + "line": 22, + "column": 50 + }, + "text": "aListOfBool" + }, + "references": { + "name": "aListOfBool", + "type": "httpQuery" + } + }, + { + "name": "aListOfDateTime", + "type": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "Reference", + "symbol": "DateTime", + "url": "dart:core" + } + ], + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "httpQuery", + "url": "package:celest/src/functions/http/http_query.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": { + "name": { + "$": "DartString", + "value": "aListOfDateTime", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "namedArguments": {}, + "staticType": { + "symbol": "httpQuery", + "url": "package:celest/src/functions/http/http_query.dart", + "isNullable": false + } + } + ], + "location": { + "start": { + "offset": 1035, + "uri": "package:celest_backend/src/functions/http_query.dart", + "line": 23, + "column": 47 + }, + "end": { + "offset": 1050, + "uri": "package:celest_backend/src/functions/http_query.dart", + "line": 23, + "column": 62 + }, + "text": "aListOfDateTime" + }, + "references": { + "name": "aListOfDateTime", + "type": "httpQuery" + } + }, + { + "name": "aNullableListOfString", + "type": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": true + }, + "required": true, + "named": false, + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "httpQuery", + "url": "package:celest/src/functions/http/http_query.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": { + "name": { + "$": "DartString", + "value": "aNullableListOfString", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "namedArguments": {}, + "staticType": { + "symbol": "httpQuery", + "url": "package:celest/src/functions/http/http_query.dart", + "isNullable": false + } + } + ], + "location": { + "start": { + "offset": 1104, + "uri": "package:celest_backend/src/functions/http_query.dart", + "line": 24, + "column": 52 + }, + "end": { + "offset": 1125, + "uri": "package:celest_backend/src/functions/http_query.dart", + "line": 24, + "column": 73 + }, + "text": "aNullableListOfString" + }, + "references": { + "name": "aNullableListOfString", + "type": "httpQuery" + } + }, + { + "name": "aNullableListOfInt", + "type": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "int", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": true + }, + "required": true, + "named": false, + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "httpQuery", + "url": "package:celest/src/functions/http/http_query.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": { + "name": { + "$": "DartString", + "value": "aNullableListOfInt", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "namedArguments": {}, + "staticType": { + "symbol": "httpQuery", + "url": "package:celest/src/functions/http/http_query.dart", + "isNullable": false + } + } + ], + "location": { + "start": { + "offset": 1173, + "uri": "package:celest_backend/src/functions/http_query.dart", + "line": 25, + "column": 46 + }, + "end": { + "offset": 1191, + "uri": "package:celest_backend/src/functions/http_query.dart", + "line": 25, + "column": 64 + }, + "text": "aNullableListOfInt" + }, + "references": { + "name": "aNullableListOfInt", + "type": "httpQuery" + } + }, + { + "name": "aNullableListOfDouble", + "type": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "double", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": true + }, + "required": true, + "named": false, + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "httpQuery", + "url": "package:celest/src/functions/http/http_query.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": { + "name": { + "$": "DartString", + "value": "aNullableListOfDouble", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "namedArguments": {}, + "staticType": { + "symbol": "httpQuery", + "url": "package:celest/src/functions/http/http_query.dart", + "isNullable": false + } + } + ], + "location": { + "start": { + "offset": 1245, + "uri": "package:celest_backend/src/functions/http_query.dart", + "line": 26, + "column": 52 + }, + "end": { + "offset": 1266, + "uri": "package:celest_backend/src/functions/http_query.dart", + "line": 26, + "column": 73 + }, + "text": "aNullableListOfDouble" + }, + "references": { + "name": "aNullableListOfDouble", + "type": "httpQuery" + } + }, + { + "name": "aNullableListOfNum", + "type": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "num", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": true + }, + "required": true, + "named": false, + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "httpQuery", + "url": "package:celest/src/functions/http/http_query.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": { + "name": { + "$": "DartString", + "value": "aNullableListOfNum", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "namedArguments": {}, + "staticType": { + "symbol": "httpQuery", + "url": "package:celest/src/functions/http/http_query.dart", + "isNullable": false + } + } + ], + "location": { + "start": { + "offset": 1314, + "uri": "package:celest_backend/src/functions/http_query.dart", + "line": 27, + "column": 46 + }, + "end": { + "offset": 1332, + "uri": "package:celest_backend/src/functions/http_query.dart", + "line": 27, + "column": 64 + }, + "text": "aNullableListOfNum" + }, + "references": { + "name": "aNullableListOfNum", + "type": "httpQuery" + } + }, + { + "name": "aNullableListOfBool", + "type": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "bool", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": true + }, + "required": true, + "named": false, + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "httpQuery", + "url": "package:celest/src/functions/http/http_query.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": { + "name": { + "$": "DartString", + "value": "aNullableListOfBool", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "namedArguments": {}, + "staticType": { + "symbol": "httpQuery", + "url": "package:celest/src/functions/http/http_query.dart", + "isNullable": false + } + } + ], + "location": { + "start": { + "offset": 1382, + "uri": "package:celest_backend/src/functions/http_query.dart", + "line": 28, + "column": 48 + }, + "end": { + "offset": 1401, + "uri": "package:celest_backend/src/functions/http_query.dart", + "line": 28, + "column": 67 + }, + "text": "aNullableListOfBool" + }, + "references": { + "name": "aNullableListOfBool", + "type": "httpQuery" + } + }, + { + "name": "aNullableListOfDateTime", + "type": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "Reference", + "symbol": "DateTime", + "url": "dart:core" + } + ], + "isNullable": true + }, + "required": true, + "named": false, + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "httpQuery", + "url": "package:celest/src/functions/http/http_query.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": { + "name": { + "$": "DartString", + "value": "aNullableListOfDateTime", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "namedArguments": {}, + "staticType": { + "symbol": "httpQuery", + "url": "package:celest/src/functions/http/http_query.dart", + "isNullable": false + } + } + ], + "location": { + "start": { + "offset": 1459, + "uri": "package:celest_backend/src/functions/http_query.dart", + "line": 29, + "column": 56 + }, + "end": { + "offset": 1482, + "uri": "package:celest_backend/src/functions/http_query.dart", + "line": 29, + "column": 79 + }, + "text": "aNullableListOfDateTime" + }, + "references": { + "name": "aNullableListOfDateTime", + "type": "httpQuery" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "Future", + "url": "dart:async", + "types": [ + { + "$": "TypeReference", + "symbol": "HttpQueryParams", + "url": "package:celest_backend/models/http_header_query.dart", + "isNullable": false + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "HttpQueryParams", + "url": "package:celest_backend/models/http_header_query.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 167, + "uri": "package:celest_backend/src/functions/http_query.dart", + "line": 5, + "column": 24 + }, + "end": { + "offset": 172, + "uri": "package:celest_backend/src/functions/http_query.dart", + "line": 5, + "column": 29 + }, + "text": "query" + } + } + }, + "docs": [], + "exceptionTypes": [ + { + "$": "TypeReference", + "symbol": "CloudException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "CancelledException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnknownError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "BadRequestException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnauthorizedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "NotFoundException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AlreadyExistsException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "PermissionDeniedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ResourceExhaustedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "FailedPreconditionException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AbortedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "OutOfRangeException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnimplementedError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "InternalServerError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnavailableError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "DataLossError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "DeadlineExceededError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "SerializationException", + "url": "package:celest_core/src/exception/serialization_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "Error", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AssertionError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "TypeError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ArgumentError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "RangeError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "IndexError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnsupportedError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnimplementedError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "StateError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ConcurrentModificationError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "OutOfMemoryError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "StackOverflowError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "Exception", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "FormatException", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "IntegerDivisionByZeroException", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AsyncError", + "url": "dart:async", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "TimeoutException", + "url": "dart:async", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "JsonUnsupportedObjectError", + "url": "dart:convert", + "isNullable": false + } + ], + "location": { + "start": { + "offset": 0, + "uri": "package:celest_backend/src/functions/http_query.dart", + "line": 0, + "column": 0 + }, + "end": { + "offset": 0, + "uri": "package:celest_backend/src/functions/http_query.dart", + "line": 0, + "column": 0 + }, + "text": "" + } + }, + "http_errors": { + "name": "http_errors", + "metadata": [], + "functions": { + "httpErrors": { + "name": "httpErrors", + "apiName": "http_errors", + "typeParameters": [], + "parameters": [ + { + "name": "type", + "type": { + "$": "TypeReference", + "symbol": "ExceptionType", + "url": "package:celest_backend/models/http_errors.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 512, + "uri": "package:celest_backend/src/functions/http_errors.dart", + "line": 10, + "column": 38 + }, + "end": { + "offset": 516, + "uri": "package:celest_backend/src/functions/http_errors.dart", + "line": 10, + "column": 42 + }, + "text": "type" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "Future", + "url": "dart:async", + "types": [ + { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "metadata": [ + { + "$": "ApiHttpError", + "type": { + "symbol": "ForbiddenException", + "url": "package:celest_backend/exceptions/http_errors.dart", + "isNullable": false + }, + "statusCode": 403, + "location": { + "start": { + "offset": 221, + "uri": "package:celest_backend/src/functions/http_errors.dart", + "line": 6, + "column": 0 + }, + "end": { + "offset": 273, + "uri": "package:celest_backend/src/functions/http_errors.dart", + "line": 6, + "column": 52 + }, + "text": "@httpError(HttpStatus.forbidden, ForbiddenException)" + } + }, + { + "$": "ApiHttpError", + "type": { + "symbol": "CustomBadRequestException", + "url": "package:celest_backend/exceptions/http_errors.dart", + "isNullable": false + }, + "statusCode": 412, + "location": { + "start": { + "offset": 274, + "uri": "package:celest_backend/src/functions/http_errors.dart", + "line": 7, + "column": 0 + }, + "end": { + "offset": 342, + "uri": "package:celest_backend/src/functions/http_errors.dart", + "line": 7, + "column": 68 + }, + "text": "@httpError(HttpStatus.preconditionFailed, CustomBadRequestException)" + } + }, + { + "$": "ApiHttpError", + "type": { + "symbol": "UnauthorizedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + "statusCode": 401, + "location": { + "start": { + "offset": 343, + "uri": "package:celest_backend/src/functions/http_errors.dart", + "line": 8, + "column": 0 + }, + "end": { + "offset": 401, + "uri": "package:celest_backend/src/functions/http_errors.dart", + "line": 8, + "column": 58 + }, + "text": "@httpError(HttpStatus.unauthorized, UnauthorizedException)" + } + }, + { + "$": "ApiHttpError", + "type": { + "symbol": "NotFoundException", + "url": "package:celest_backend/exceptions/http_errors.dart", + "isNullable": false + }, + "statusCode": 404, + "location": { + "start": { + "offset": 402, + "uri": "package:celest_backend/src/functions/http_errors.dart", + "line": 9, + "column": 0 + }, + "end": { + "offset": 473, + "uri": "package:celest_backend/src/functions/http_errors.dart", + "line": 9, + "column": 71 + }, + "text": "@httpError(HttpStatus.notFound, NotFoundException, InternalServerError)" + } + }, + { + "$": "ApiHttpError", + "type": { + "symbol": "InternalServerError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + "statusCode": 404, + "location": { + "start": { + "offset": 402, + "uri": "package:celest_backend/src/functions/http_errors.dart", + "line": 9, + "column": 0 + }, + "end": { + "offset": 473, + "uri": "package:celest_backend/src/functions/http_errors.dart", + "line": 9, + "column": 71 + }, + "text": "@httpError(HttpStatus.notFound, NotFoundException, InternalServerError)" + } + } + ], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + }, + { + "$": "DartInstance", + "classRef": { + "symbol": "httpError", + "url": "package:celest_core/src/http/http_error.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": { + "statusCode": { + "$": "DartInt", + "value": 403, + "staticType": { + "symbol": "int", + "url": "dart:core" + } + }, + "type": { + "$": "DartTypeLiteral", + "type": { + "symbol": "ForbiddenException", + "url": "package:celest_backend/exceptions/http_errors.dart", + "isNullable": false + }, + "staticType": { + "symbol": "ForbiddenException", + "url": "package:celest_backend/exceptions/http_errors.dart", + "isNullable": false + } + } + }, + "namedArguments": {}, + "staticType": { + "symbol": "httpError", + "url": "package:celest_core/src/http/http_error.dart", + "isNullable": false + } + }, + { + "$": "DartInstance", + "classRef": { + "symbol": "httpError", + "url": "package:celest_core/src/http/http_error.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": { + "statusCode": { + "$": "DartInt", + "value": 412, + "staticType": { + "symbol": "int", + "url": "dart:core" + } + }, + "type": { + "$": "DartTypeLiteral", + "type": { + "symbol": "CustomBadRequestException", + "url": "package:celest_backend/exceptions/http_errors.dart", + "isNullable": false + }, + "staticType": { + "symbol": "CustomBadRequestException", + "url": "package:celest_backend/exceptions/http_errors.dart", + "isNullable": false + } + } + }, + "namedArguments": {}, + "staticType": { + "symbol": "httpError", + "url": "package:celest_core/src/http/http_error.dart", + "isNullable": false + } + }, + { + "$": "DartInstance", + "classRef": { + "symbol": "httpError", + "url": "package:celest_core/src/http/http_error.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": { + "statusCode": { + "$": "DartInt", + "value": 401, + "staticType": { + "symbol": "int", + "url": "dart:core" + } + }, + "type": { + "$": "DartTypeLiteral", + "type": { + "symbol": "UnauthorizedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + "staticType": { + "symbol": "UnauthorizedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + } + } + }, + "namedArguments": {}, + "staticType": { + "symbol": "httpError", + "url": "package:celest_core/src/http/http_error.dart", + "isNullable": false + } + }, + { + "$": "DartInstance", + "classRef": { + "symbol": "httpError", + "url": "package:celest_core/src/http/http_error.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": { + "statusCode": { + "$": "DartInt", + "value": 404, + "staticType": { + "symbol": "int", + "url": "dart:core" + } + }, + "type": { + "$": "DartTypeLiteral", + "type": { + "symbol": "NotFoundException", + "url": "package:celest_backend/exceptions/http_errors.dart", + "isNullable": false + }, + "staticType": { + "symbol": "NotFoundException", + "url": "package:celest_backend/exceptions/http_errors.dart", + "isNullable": false + } + }, + "type1": { + "$": "DartTypeLiteral", + "type": { + "symbol": "InternalServerError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + "staticType": { + "symbol": "InternalServerError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + } + } + }, + "namedArguments": {}, + "staticType": { + "symbol": "httpError", + "url": "package:celest_core/src/http/http_error.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 487, + "uri": "package:celest_backend/src/functions/http_errors.dart", + "line": 10, + "column": 13 + }, + "end": { + "offset": 497, + "uri": "package:celest_backend/src/functions/http_errors.dart", + "line": 10, + "column": 23 + }, + "text": "httpErrors" + } + } + }, + "docs": [], + "exceptionTypes": [ + { + "$": "TypeReference", + "symbol": "CloudException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "CancelledException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnknownError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "BadRequestException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnauthorizedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "NotFoundException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AlreadyExistsException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "PermissionDeniedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ResourceExhaustedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "FailedPreconditionException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AbortedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "OutOfRangeException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnimplementedError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "InternalServerError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnavailableError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "DataLossError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "DeadlineExceededError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "SerializationException", + "url": "package:celest_core/src/exception/serialization_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "Error", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AssertionError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "TypeError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ArgumentError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "RangeError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "IndexError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnsupportedError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnimplementedError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "StateError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ConcurrentModificationError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "OutOfMemoryError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "StackOverflowError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "Exception", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "FormatException", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "IntegerDivisionByZeroException", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AsyncError", + "url": "dart:async", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "TimeoutException", + "url": "dart:async", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "JsonUnsupportedObjectError", + "url": "dart:convert", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "CustomBadRequestException", + "url": "package:celest_backend/exceptions/http_errors.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ForbiddenException", + "url": "package:celest_backend/exceptions/http_errors.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "NotFoundException", + "url": "package:celest_backend/exceptions/http_errors.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AnotherNotFoundException", + "url": "package:celest_backend/exceptions/http_errors.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "BadGatewayError", + "url": "package:celest_backend/exceptions/http_errors.dart", + "isNullable": false + } + ], + "location": { + "start": { + "offset": 0, + "uri": "package:celest_backend/src/functions/http_errors.dart", + "line": 0, + "column": 0 + }, + "end": { + "offset": 0, + "uri": "package:celest_backend/src/functions/http_errors.dart", + "line": 0, + "column": 0 + }, + "text": "" + } + }, + "http_header": { + "name": "http_header", + "metadata": [], + "functions": { + "headers": { + "name": "headers", + "apiName": "http_header", + "typeParameters": [], + "parameters": [ + { + "name": "aString", + "type": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "httpHeader", + "url": "package:celest/src/functions/http/http_header.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": { + "name": { + "$": "DartString", + "value": "aString", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "namedArguments": {}, + "staticType": { + "symbol": "httpHeader", + "url": "package:celest/src/functions/http/http_header.dart", + "isNullable": false + } + } + ], + "location": { + "start": { + "offset": 209, + "uri": "package:celest_backend/src/functions/http_header.dart", + "line": 6, + "column": 32 + }, + "end": { + "offset": 216, + "uri": "package:celest_backend/src/functions/http_header.dart", + "line": 6, + "column": 39 + }, + "text": "aString" + }, + "references": { + "name": "aString", + "type": "httpHeader" + } + }, + { + "name": "anInt", + "type": { + "$": "TypeReference", + "symbol": "int", + "url": "dart:core", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "httpHeader", + "url": "package:celest/src/functions/http/http_header.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": { + "name": { + "$": "DartString", + "value": "anInt", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "namedArguments": {}, + "staticType": { + "symbol": "httpHeader", + "url": "package:celest/src/functions/http/http_header.dart", + "isNullable": false + } + } + ], + "location": { + "start": { + "offset": 245, + "uri": "package:celest_backend/src/functions/http_header.dart", + "line": 7, + "column": 27 + }, + "end": { + "offset": 250, + "uri": "package:celest_backend/src/functions/http_header.dart", + "line": 7, + "column": 32 + }, + "text": "anInt" + }, + "references": { + "name": "anInt", + "type": "httpHeader" + } + }, + { + "name": "aDouble", + "type": { + "$": "TypeReference", + "symbol": "double", + "url": "dart:core", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "httpHeader", + "url": "package:celest/src/functions/http/http_header.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": { + "name": { + "$": "DartString", + "value": "aDouble", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "namedArguments": {}, + "staticType": { + "symbol": "httpHeader", + "url": "package:celest/src/functions/http/http_header.dart", + "isNullable": false + } + } + ], + "location": { + "start": { + "offset": 284, + "uri": "package:celest_backend/src/functions/http_header.dart", + "line": 8, + "column": 32 + }, + "end": { + "offset": 291, + "uri": "package:celest_backend/src/functions/http_header.dart", + "line": 8, + "column": 39 + }, + "text": "aDouble" + }, + "references": { + "name": "aDouble", + "type": "httpHeader" + } + }, + { + "name": "aNum", + "type": { + "$": "TypeReference", + "symbol": "num", + "url": "dart:core", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "httpHeader", + "url": "package:celest/src/functions/http/http_header.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": { + "name": { + "$": "DartString", + "value": "aNum", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "namedArguments": {}, + "staticType": { + "symbol": "httpHeader", + "url": "package:celest/src/functions/http/http_header.dart", + "isNullable": false + } + } + ], + "location": { + "start": { + "offset": 319, + "uri": "package:celest_backend/src/functions/http_header.dart", + "line": 9, + "column": 26 + }, + "end": { + "offset": 323, + "uri": "package:celest_backend/src/functions/http_header.dart", + "line": 9, + "column": 30 + }, + "text": "aNum" + }, + "references": { + "name": "aNum", + "type": "httpHeader" + } + }, + { + "name": "aBool", + "type": { + "$": "TypeReference", + "symbol": "bool", + "url": "dart:core", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "httpHeader", + "url": "package:celest/src/functions/http/http_header.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": { + "name": { + "$": "DartString", + "value": "aBool", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "namedArguments": {}, + "staticType": { + "symbol": "httpHeader", + "url": "package:celest/src/functions/http/http_header.dart", + "isNullable": false + } + } + ], + "location": { + "start": { + "offset": 353, + "uri": "package:celest_backend/src/functions/http_header.dart", + "line": 10, + "column": 28 + }, + "end": { + "offset": 358, + "uri": "package:celest_backend/src/functions/http_header.dart", + "line": 10, + "column": 33 + }, + "text": "aBool" + }, + "references": { + "name": "aBool", + "type": "httpHeader" + } + }, + { + "name": "aDateTime", + "type": { + "$": "Reference", + "symbol": "DateTime", + "url": "dart:core" + }, + "required": true, + "named": false, + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "httpHeader", + "url": "package:celest/src/functions/http/http_header.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": { + "name": { + "$": "DartString", + "value": "aDateTime", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "namedArguments": {}, + "staticType": { + "symbol": "httpHeader", + "url": "package:celest/src/functions/http/http_header.dart", + "isNullable": false + } + } + ], + "location": { + "start": { + "offset": 396, + "uri": "package:celest_backend/src/functions/http_header.dart", + "line": 11, + "column": 36 + }, + "end": { + "offset": 405, + "uri": "package:celest_backend/src/functions/http_header.dart", + "line": 11, + "column": 45 + }, + "text": "aDateTime" + }, + "references": { + "name": "aDateTime", + "type": "httpHeader" + } + }, + { + "name": "aNullableString", + "type": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": true + }, + "required": true, + "named": false, + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "httpHeader", + "url": "package:celest/src/functions/http/http_header.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": { + "name": { + "$": "DartString", + "value": "aNullableString", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "namedArguments": {}, + "staticType": { + "symbol": "httpHeader", + "url": "package:celest/src/functions/http/http_header.dart", + "isNullable": false + } + } + ], + "location": { + "start": { + "offset": 448, + "uri": "package:celest_backend/src/functions/http_header.dart", + "line": 12, + "column": 41 + }, + "end": { + "offset": 463, + "uri": "package:celest_backend/src/functions/http_header.dart", + "line": 12, + "column": 56 + }, + "text": "aNullableString" + }, + "references": { + "name": "aNullableString", + "type": "httpHeader" + } + }, + { + "name": "aNullableInt", + "type": { + "$": "TypeReference", + "symbol": "int", + "url": "dart:core", + "isNullable": true + }, + "required": true, + "named": false, + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "httpHeader", + "url": "package:celest/src/functions/http/http_header.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": { + "name": { + "$": "DartString", + "value": "aNullableInt", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "namedArguments": {}, + "staticType": { + "symbol": "httpHeader", + "url": "package:celest/src/functions/http/http_header.dart", + "isNullable": false + } + } + ], + "location": { + "start": { + "offset": 500, + "uri": "package:celest_backend/src/functions/http_header.dart", + "line": 13, + "column": 35 + }, + "end": { + "offset": 512, + "uri": "package:celest_backend/src/functions/http_header.dart", + "line": 13, + "column": 47 + }, + "text": "aNullableInt" + }, + "references": { + "name": "aNullableInt", + "type": "httpHeader" + } + }, + { + "name": "aNullableDouble", + "type": { + "$": "TypeReference", + "symbol": "double", + "url": "dart:core", + "isNullable": true + }, + "required": true, + "named": false, + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "httpHeader", + "url": "package:celest/src/functions/http/http_header.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": { + "name": { + "$": "DartString", + "value": "aNullableDouble", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "namedArguments": {}, + "staticType": { + "symbol": "httpHeader", + "url": "package:celest/src/functions/http/http_header.dart", + "isNullable": false + } + } + ], + "location": { + "start": { + "offset": 555, + "uri": "package:celest_backend/src/functions/http_header.dart", + "line": 14, + "column": 41 + }, + "end": { + "offset": 570, + "uri": "package:celest_backend/src/functions/http_header.dart", + "line": 14, + "column": 56 + }, + "text": "aNullableDouble" + }, + "references": { + "name": "aNullableDouble", + "type": "httpHeader" + } + }, + { + "name": "aNullableNum", + "type": { + "$": "TypeReference", + "symbol": "num", + "url": "dart:core", + "isNullable": true + }, + "required": true, + "named": false, + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "httpHeader", + "url": "package:celest/src/functions/http/http_header.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": { + "name": { + "$": "DartString", + "value": "aNullableNum", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "namedArguments": {}, + "staticType": { + "symbol": "httpHeader", + "url": "package:celest/src/functions/http/http_header.dart", + "isNullable": false + } + } + ], + "location": { + "start": { + "offset": 607, + "uri": "package:celest_backend/src/functions/http_header.dart", + "line": 15, + "column": 35 + }, + "end": { + "offset": 619, + "uri": "package:celest_backend/src/functions/http_header.dart", + "line": 15, + "column": 47 + }, + "text": "aNullableNum" + }, + "references": { + "name": "aNullableNum", + "type": "httpHeader" + } + }, + { + "name": "aNullableBool", + "type": { + "$": "TypeReference", + "symbol": "bool", + "url": "dart:core", + "isNullable": true + }, + "required": true, + "named": false, + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "httpHeader", + "url": "package:celest/src/functions/http/http_header.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": { + "name": { + "$": "DartString", + "value": "aNullableBool", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "namedArguments": {}, + "staticType": { + "symbol": "httpHeader", + "url": "package:celest/src/functions/http/http_header.dart", + "isNullable": false + } + } + ], + "location": { + "start": { + "offset": 658, + "uri": "package:celest_backend/src/functions/http_header.dart", + "line": 16, + "column": 37 + }, + "end": { + "offset": 671, + "uri": "package:celest_backend/src/functions/http_header.dart", + "line": 16, + "column": 50 + }, + "text": "aNullableBool" + }, + "references": { + "name": "aNullableBool", + "type": "httpHeader" + } + }, + { + "name": "aNullableDateTime", + "type": { + "$": "TypeReference", + "symbol": "DateTime", + "url": "dart:core", + "isNullable": true + }, + "required": true, + "named": false, + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "httpHeader", + "url": "package:celest/src/functions/http/http_header.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": { + "name": { + "$": "DartString", + "value": "aNullableDateTime", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "namedArguments": {}, + "staticType": { + "symbol": "httpHeader", + "url": "package:celest/src/functions/http/http_header.dart", + "isNullable": false + } + } + ], + "location": { + "start": { + "offset": 718, + "uri": "package:celest_backend/src/functions/http_header.dart", + "line": 17, + "column": 45 + }, + "end": { + "offset": 735, + "uri": "package:celest_backend/src/functions/http_header.dart", + "line": 17, + "column": 62 + }, + "text": "aNullableDateTime" + }, + "references": { + "name": "aNullableDateTime", + "type": "httpHeader" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "Future", + "url": "dart:async", + "types": [ + { + "$": "TypeReference", + "symbol": "HttpHeaderParams", + "url": "package:celest_backend/models/http_header_query.dart", + "isNullable": false + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "HttpHeaderParams", + "url": "package:celest_backend/models/http_header_query.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 168, + "uri": "package:celest_backend/src/functions/http_header.dart", + "line": 5, + "column": 25 + }, + "end": { + "offset": 175, + "uri": "package:celest_backend/src/functions/http_header.dart", + "line": 5, + "column": 32 + }, + "text": "headers" + } + } + }, + "docs": [], + "exceptionTypes": [ + { + "$": "TypeReference", + "symbol": "CloudException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "CancelledException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnknownError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "BadRequestException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnauthorizedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "NotFoundException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AlreadyExistsException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "PermissionDeniedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ResourceExhaustedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "FailedPreconditionException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AbortedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "OutOfRangeException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnimplementedError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "InternalServerError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnavailableError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "DataLossError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "DeadlineExceededError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "SerializationException", + "url": "package:celest_core/src/exception/serialization_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "Error", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AssertionError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "TypeError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ArgumentError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "RangeError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "IndexError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnsupportedError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnimplementedError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "StateError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ConcurrentModificationError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "OutOfMemoryError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "StackOverflowError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "Exception", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "FormatException", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "IntegerDivisionByZeroException", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AsyncError", + "url": "dart:async", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "TimeoutException", + "url": "dart:async", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "JsonUnsupportedObjectError", + "url": "dart:convert", + "isNullable": false + } + ], + "location": { + "start": { + "offset": 0, + "uri": "package:celest_backend/src/functions/http_header.dart", + "line": 0, + "column": 0 + }, + "end": { + "offset": 0, + "uri": "package:celest_backend/src/functions/http_header.dart", + "line": 0, + "column": 0 + }, + "text": "" + } + } + }, + "variables": [], + "secrets": [], + "databases": {}, + "sdkConfig": { + "celest": "1.0.6+2", + "dart": { + "type": "dart", + "version": "3.29.0", + "enabledExperiments": [] + }, + "targetSdk": "dart", + "featureFlags": [ + "streaming" + ], + "flutter": { + "type": "flutter", + "version": "3.29.0", + "enabledExperiments": [] + } + }, + "location": { + "start": { + "offset": 44, + "uri": "project.dart", + "line": 2, + "column": 6 + }, + "end": { + "offset": 74, + "uri": "project.dart", + "line": 2, + "column": 36 + }, + "text": "project = Project(name: 'api')" + } +} \ No newline at end of file diff --git a/apps/cli/fixtures/legacy/http/goldens/ast.resolved.json b/apps/cli/fixtures/legacy/http/goldens/ast.resolved.json new file mode 100644 index 000000000..218558070 --- /dev/null +++ b/apps/cli/fixtures/legacy/http/goldens/ast.resolved.json @@ -0,0 +1,270 @@ +{ + "projectId": "api", + "environmentId": "local", + "apis": { + "http_status": { + "apiId": "http_status", + "functions": { + "ok": { + "functionId": "ok", + "apiId": "http_status", + "httpConfig": { + "route": { + "method": "POST", + "path": "/http-status/ok" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "created": { + "functionId": "created", + "apiId": "http_status", + "httpConfig": { + "route": { + "method": "POST", + "path": "/http-status/created" + }, + "additionalRoutes": [], + "status": 201, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "accepted": { + "functionId": "accepted", + "apiId": "http_status", + "httpConfig": { + "route": { + "method": "POST", + "path": "/http-status/accepted" + }, + "additionalRoutes": [], + "status": 202, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "badRequest": { + "functionId": "badRequest", + "apiId": "http_status", + "httpConfig": { + "route": { + "method": "POST", + "path": "/http-status/bad-request" + }, + "additionalRoutes": [], + "status": 400, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "internalServerError": { + "functionId": "internalServerError", + "apiId": "http_status", + "httpConfig": { + "route": { + "method": "POST", + "path": "/http-status/internal-server-error" + }, + "additionalRoutes": [], + "status": 500, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + } + } + }, + "http_method": { + "apiId": "http_method", + "functions": { + "get": { + "functionId": "get", + "apiId": "http_method", + "httpConfig": { + "route": { + "method": "GET", + "path": "/http-method/get" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "post": { + "functionId": "post", + "apiId": "http_method", + "httpConfig": { + "route": { + "method": "POST", + "path": "/http-method/post" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "put": { + "functionId": "put", + "apiId": "http_method", + "httpConfig": { + "route": { + "method": "PUT", + "path": "/http-method/put" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "delete": { + "functionId": "delete", + "apiId": "http_method", + "httpConfig": { + "route": { + "method": "DELETE", + "path": "/http-method/delete" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "patch": { + "functionId": "patch", + "apiId": "http_method", + "httpConfig": { + "route": { + "method": "PATCH", + "path": "/http-method/patch" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + } + } + }, + "http_query": { + "apiId": "http_query", + "functions": { + "query": { + "functionId": "query", + "apiId": "http_query", + "httpConfig": { + "route": { + "method": "POST", + "path": "/http-query/query" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + } + } + }, + "http_errors": { + "apiId": "http_errors", + "functions": { + "httpErrors": { + "functionId": "httpErrors", + "apiId": "http_errors", + "httpConfig": { + "route": { + "method": "POST", + "path": "/http-errors/http-errors" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": { + "{\"symbol\":\"ForbiddenException\",\"url\":\"package:celest_backend/exceptions/http_errors.dart\",\"isNullable\":false}": 403, + "{\"symbol\":\"CustomBadRequestException\",\"url\":\"package:celest_backend/exceptions/http_errors.dart\",\"isNullable\":false}": 412, + "{\"symbol\":\"UnauthorizedException\",\"url\":\"package:celest_core/src/exception/cloud_exception.dart\",\"isNullable\":false}": 401, + "{\"symbol\":\"NotFoundException\",\"url\":\"package:celest_backend/exceptions/http_errors.dart\",\"isNullable\":false}": 404, + "{\"symbol\":\"InternalServerError\",\"url\":\"package:celest_core/src/exception/cloud_exception.dart\",\"isNullable\":false}": 404 + } + }, + "variables": [], + "secrets": [], + "streamConfig": {} + } + } + }, + "http_header": { + "apiId": "http_header", + "functions": { + "headers": { + "functionId": "headers", + "apiId": "http_header", + "httpConfig": { + "route": { + "method": "POST", + "path": "/http-header/headers" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + } + } + } + }, + "variables": [ + { + "name": "CELEST_ENVIRONMENT", + "value": "local" + } + ], + "secrets": [], + "databases": {}, + "sdkConfig": { + "celest": "1.0.6+2", + "dart": { + "type": "dart", + "version": "3.29.0", + "enabledExperiments": [] + }, + "targetSdk": "dart", + "featureFlags": [ + "streaming" + ], + "flutter": { + "type": "flutter", + "version": "3.29.0", + "enabledExperiments": [] + } + } +} \ No newline at end of file diff --git a/apps/cli/fixtures/legacy/http/goldens/celest.json b/apps/cli/fixtures/legacy/http/goldens/celest.json new file mode 100644 index 000000000..55d8bd88f --- /dev/null +++ b/apps/cli/fixtures/legacy/http/goldens/celest.json @@ -0,0 +1,272 @@ +{ + "projectId": "api", + "environmentId": "local", + "apis": { + "http_status": { + "apiId": "http_status", + "functions": { + "ok": { + "functionId": "ok", + "parentId": "http_status", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/http-status/ok" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "created": { + "functionId": "created", + "parentId": "http_status", + "httpConfig": { + "status": 201, + "route": { + "method": "POST", + "path": "/http-status/created" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "accepted": { + "functionId": "accepted", + "parentId": "http_status", + "httpConfig": { + "status": 202, + "route": { + "method": "POST", + "path": "/http-status/accepted" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "badRequest": { + "functionId": "badRequest", + "parentId": "http_status", + "httpConfig": { + "status": 400, + "route": { + "method": "POST", + "path": "/http-status/bad-request" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "internalServerError": { + "functionId": "internalServerError", + "parentId": "http_status", + "httpConfig": { + "status": 500, + "route": { + "method": "POST", + "path": "/http-status/internal-server-error" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + } + } + }, + "http_method": { + "apiId": "http_method", + "functions": { + "get": { + "functionId": "get", + "parentId": "http_method", + "httpConfig": { + "status": 200, + "route": { + "method": "GET", + "path": "/http-method/get" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "post": { + "functionId": "post", + "parentId": "http_method", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/http-method/post" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "put": { + "functionId": "put", + "parentId": "http_method", + "httpConfig": { + "status": 200, + "route": { + "method": "PUT", + "path": "/http-method/put" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "delete": { + "functionId": "delete", + "parentId": "http_method", + "httpConfig": { + "status": 200, + "route": { + "method": "DELETE", + "path": "/http-method/delete" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "patch": { + "functionId": "patch", + "parentId": "http_method", + "httpConfig": { + "status": 200, + "route": { + "method": "PATCH", + "path": "/http-method/patch" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + } + } + }, + "http_query": { + "apiId": "http_query", + "functions": { + "query": { + "functionId": "query", + "parentId": "http_query", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/http-query/query" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + } + } + }, + "http_errors": { + "apiId": "http_errors", + "functions": { + "httpErrors": { + "functionId": "httpErrors", + "parentId": "http_errors", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/http-errors/http-errors" + }, + "statusMappings": { + "package:celest_backend/exceptions/http_errors.dart#ForbiddenException": 403, + "package:celest_backend/exceptions/http_errors.dart#CustomBadRequestException": 412, + "package:celest_core/src/exception/cloud_exception.dart#UnauthorizedException": 401, + "package:celest_backend/exceptions/http_errors.dart#NotFoundException": 404, + "package:celest_core/src/exception/cloud_exception.dart#InternalServerError": 404 + } + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + } + } + }, + "http_header": { + "apiId": "http_header", + "functions": { + "headers": { + "functionId": "headers", + "parentId": "http_header", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/http-header/headers" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + } + } + } + }, + "variables": [ + { + "name": "CELEST_ENVIRONMENT", + "value": "local" + } + ], + "databases": {}, + "sdkConfig": { + "celest": { + "major": 1, + "minor": 0, + "patch": 6, + "build": [ + 2.0 + ], + "canonicalizedVersion": "1.0.6+2" + }, + "dart": { + "type": "DART", + "version": { + "major": 3, + "minor": 29, + "patch": 0, + "canonicalizedVersion": "3.29.0" + } + }, + "flutter": { + "type": "FLUTTER", + "version": { + "major": 3, + "minor": 29, + "patch": 0, + "canonicalizedVersion": "3.29.0" + } + }, + "targetSdk": "DART", + "featureFlags": [ + "STREAMING" + ] + } +} \ No newline at end of file diff --git a/apps/cli/fixtures/legacy/http/goldens/functions/http_errors/httpErrors.dart b/apps/cli/fixtures/legacy/http/goldens/functions/http_errors/httpErrors.dart new file mode 100644 index 000000000..59ad9e166 --- /dev/null +++ b/apps/cli/fixtures/legacy/http/goldens/functions/http_errors/httpErrors.dart @@ -0,0 +1,1909 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i10; +import 'dart:convert' as _i11; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/exceptions/http_errors.dart' as _i9; +import 'package:celest_backend/models/http_errors.dart' as _i5; +import 'package:celest_backend/src/functions/http_errors.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i12; +import 'package:celest_core/src/serialization/json_value.dart' as _i13; +import 'package:shelf/shelf.dart' as _i2; + +final class HttpErrorsTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'httpErrors'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + await _i3.httpErrors( + _i4.Serializers.instance.deserialize<_i5.ExceptionType>( + request[r'type'], + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(null), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AnotherNotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'api.v1.AnotherNotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i9.AnotherNotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i10.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.BadGatewayError catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'api.v1.BadGatewayError', + 'value': _i4.Serializers.instance.serialize<_i9.BadGatewayError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.CustomBadRequestException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'api.v1.CustomBadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i9.CustomBadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.ForbiddenException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'api.v1.ForbiddenException', + 'value': _i4.Serializers.instance + .serialize<_i9.ForbiddenException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i11.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'api.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i9.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i12.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i12.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance + .serialize<_i10.TimeoutException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i10.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i10.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i11.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i11.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.AnotherNotFoundException, + Map? + >( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return _i9.AnotherNotFoundException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.BadGatewayError, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i9.BadGatewayError(($serialized[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.CustomBadRequestException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i9.CustomBadRequestException( + message: ($serialized?[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.ForbiddenException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i9.ForbiddenException( + message: ($serialized?[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.NotFoundException, Map?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return _i9.NotFoundException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.ExceptionType, String>( + serialize: ($value) => $value.name, + deserialize: ($serialized) { + return _i5.ExceptionType.values.byName($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i12.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i13.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': HttpErrorsTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/http/goldens/functions/http_header/headers.dart b/apps/cli/fixtures/legacy/http/goldens/functions/http_header/headers.dart new file mode 100644 index 000000000..32d822411 --- /dev/null +++ b/apps/cli/fixtures/legacy/http/goldens/functions/http_header/headers.dart @@ -0,0 +1,1764 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/http_header_query.dart' as _i5; +import 'package:celest_backend/src/functions/http_header.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class HeadersTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'headers'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = await _i3.headers( + headers['aString']!.first, + int.parse(headers['anInt']!.first), + double.parse(headers['aDouble']!.first), + num.parse(headers['aNum']!.first), + bool.parse(headers['aBool']!.first), + DateTime.parse(headers['aDateTime']!.first), + headers['aNullableString'] == null + ? null + : headers['aNullableString']!.first, + headers['aNullableInt'] == null + ? null + : int.parse(headers['aNullableInt']!.first), + headers['aNullableDouble'] == null + ? null + : double.parse(headers['aNullableDouble']!.first), + headers['aNullableNum'] == null + ? null + : num.parse(headers['aNullableNum']!.first), + headers['aNullableBool'] == null + ? null + : bool.parse(headers['aNullableBool']!.first), + headers['aNullableDateTime'] == null + ? null + : DateTime.parse(headers['aNullableDateTime']!.first), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.HttpHeaderParams>(response), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.HttpHeaderParams, Map>( + serialize: + ($value) => { + r'aString': $value.aString, + r'anInt': $value.anInt, + r'aDouble': $value.aDouble, + r'aNum': $value.aNum, + r'aBool': $value.aBool, + r'aDateTime': _i4.Serializers.instance.serialize( + $value.aDateTime, + ), + if ($value.aNullableString case final aNullableString?) + r'aNullableString': aNullableString, + if ($value.aNullableInt case final aNullableInt?) + r'aNullableInt': aNullableInt, + if ($value.aNullableDouble case final aNullableDouble?) + r'aNullableDouble': aNullableDouble, + if ($value.aNullableNum case final aNullableNum?) + r'aNullableNum': aNullableNum, + if ($value.aNullableBool case final aNullableBool?) + r'aNullableBool': aNullableBool, + if (_i4.Serializers.instance.serialize( + $value.aNullableDateTime, + ) + case final aNullableDateTime?) + r'aNullableDateTime': aNullableDateTime, + }, + deserialize: ($serialized) { + return _i5.HttpHeaderParams( + aString: ($serialized[r'aString'] as String), + anInt: ($serialized[r'anInt'] as num).toInt(), + aDouble: ($serialized[r'aDouble'] as num).toDouble(), + aNum: ($serialized[r'aNum'] as num), + aBool: ($serialized[r'aBool'] as bool), + aDateTime: _i4.Serializers.instance.deserialize( + $serialized[r'aDateTime'], + ), + aNullableString: ($serialized[r'aNullableString'] as String?), + aNullableInt: ($serialized[r'aNullableInt'] as num?)?.toInt(), + aNullableDouble: + ($serialized[r'aNullableDouble'] as num?)?.toDouble(), + aNullableNum: ($serialized[r'aNullableNum'] as num?), + aNullableBool: ($serialized[r'aNullableBool'] as bool?), + aNullableDateTime: _i4.Serializers.instance.deserialize( + $serialized[r'aNullableDateTime'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': HeadersTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/http/goldens/functions/http_method/delete.dart b/apps/cli/fixtures/legacy/http/goldens/functions/http_method/delete.dart new file mode 100644 index 000000000..d39785ce8 --- /dev/null +++ b/apps/cli/fixtures/legacy/http/goldens/functions/http_method/delete.dart @@ -0,0 +1,1685 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i9; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/http_method.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i10; +import 'package:celest_core/src/serialization/json_value.dart' as _i11; +import 'package:shelf/shelf.dart' as _i2; + +final class DeleteTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'delete'; + + @override + String get method => 'DELETE'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + await _i3.delete(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(null), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i9.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i10.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i9.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i10.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i11.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': DeleteTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/http/goldens/functions/http_method/get.dart b/apps/cli/fixtures/legacy/http/goldens/functions/http_method/get.dart new file mode 100644 index 000000000..bbceba724 --- /dev/null +++ b/apps/cli/fixtures/legacy/http/goldens/functions/http_method/get.dart @@ -0,0 +1,1685 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i9; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/http_method.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i10; +import 'package:celest_core/src/serialization/json_value.dart' as _i11; +import 'package:shelf/shelf.dart' as _i2; + +final class GetTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'get'; + + @override + String get method => 'GET'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + await _i3.get(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(null), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i9.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i10.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i9.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i10.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i11.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': GetTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/http/goldens/functions/http_method/patch.dart b/apps/cli/fixtures/legacy/http/goldens/functions/http_method/patch.dart new file mode 100644 index 000000000..216bd7971 --- /dev/null +++ b/apps/cli/fixtures/legacy/http/goldens/functions/http_method/patch.dart @@ -0,0 +1,1685 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i9; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/http_method.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i10; +import 'package:celest_core/src/serialization/json_value.dart' as _i11; +import 'package:shelf/shelf.dart' as _i2; + +final class PatchTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'patch'; + + @override + String get method => 'PATCH'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + await _i3.patch(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(null), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i9.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i10.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i9.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i10.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i11.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': PatchTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/http/goldens/functions/http_method/post.dart b/apps/cli/fixtures/legacy/http/goldens/functions/http_method/post.dart new file mode 100644 index 000000000..17bad969d --- /dev/null +++ b/apps/cli/fixtures/legacy/http/goldens/functions/http_method/post.dart @@ -0,0 +1,1685 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i9; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/http_method.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i10; +import 'package:celest_core/src/serialization/json_value.dart' as _i11; +import 'package:shelf/shelf.dart' as _i2; + +final class PostTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'post'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + await _i3.post(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(null), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i9.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i10.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i9.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i10.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i11.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': PostTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/http/goldens/functions/http_method/put.dart b/apps/cli/fixtures/legacy/http/goldens/functions/http_method/put.dart new file mode 100644 index 000000000..dafe28497 --- /dev/null +++ b/apps/cli/fixtures/legacy/http/goldens/functions/http_method/put.dart @@ -0,0 +1,1685 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i9; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/http_method.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i10; +import 'package:celest_core/src/serialization/json_value.dart' as _i11; +import 'package:shelf/shelf.dart' as _i2; + +final class PutTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'put'; + + @override + String get method => 'PUT'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + await _i3.put(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(null), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i9.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i10.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i9.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i10.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i11.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': PutTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/http/goldens/functions/http_query/query.dart b/apps/cli/fixtures/legacy/http/goldens/functions/http_query/query.dart new file mode 100644 index 000000000..c8ad0e6f1 --- /dev/null +++ b/apps/cli/fixtures/legacy/http/goldens/functions/http_query/query.dart @@ -0,0 +1,1884 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/models/http_header_query.dart' as _i5; +import 'package:celest_backend/src/functions/http_query.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i2; + +final class QueryTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'query'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = await _i3.query( + queryParameters['aString']!.first, + int.parse(queryParameters['anInt']!.first), + double.parse(queryParameters['aDouble']!.first), + num.parse(queryParameters['aNum']!.first), + bool.parse(queryParameters['aBool']!.first), + DateTime.parse(queryParameters['aDateTime']!.first), + queryParameters['aNullableString'] == null + ? null + : queryParameters['aNullableString']!.first, + queryParameters['aNullableInt'] == null + ? null + : int.parse(queryParameters['aNullableInt']!.first), + queryParameters['aNullableDouble'] == null + ? null + : double.parse(queryParameters['aNullableDouble']!.first), + queryParameters['aNullableNum'] == null + ? null + : num.parse(queryParameters['aNullableNum']!.first), + queryParameters['aNullableBool'] == null + ? null + : bool.parse(queryParameters['aNullableBool']!.first), + queryParameters['aNullableDateTime'] == null + ? null + : DateTime.parse(queryParameters['aNullableDateTime']!.first), + queryParameters['aListOfString']!.map((String el) => el).toList(), + queryParameters['aListOfInt']! + .map((String el) => int.parse(el)) + .toList(), + queryParameters['aListOfDouble']! + .map((String el) => double.parse(el)) + .toList(), + queryParameters['aListOfNum']! + .map((String el) => num.parse(el)) + .toList(), + queryParameters['aListOfBool']! + .map((String el) => bool.parse(el)) + .toList(), + queryParameters['aListOfDateTime']! + .map((String el) => DateTime.parse(el)) + .toList(), + queryParameters['aNullableListOfString'] + ?.map((String el) => el) + .toList(), + queryParameters['aNullableListOfInt'] + ?.map((String el) => int.parse(el)) + .toList(), + queryParameters['aNullableListOfDouble'] + ?.map((String el) => double.parse(el)) + .toList(), + queryParameters['aNullableListOfNum'] + ?.map((String el) => num.parse(el)) + .toList(), + queryParameters['aNullableListOfBool'] + ?.map((String el) => bool.parse(el)) + .toList(), + queryParameters['aNullableListOfDateTime'] + ?.map((String el) => DateTime.parse(el)) + .toList(), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.HttpQueryParams>(response), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.HttpQueryParams, Map>( + serialize: + ($value) => { + r'aString': $value.aString, + r'anInt': $value.anInt, + r'aDouble': $value.aDouble, + r'aNum': $value.aNum, + r'aBool': $value.aBool, + r'aDateTime': _i4.Serializers.instance.serialize( + $value.aDateTime, + ), + if ($value.aNullableString case final aNullableString?) + r'aNullableString': aNullableString, + if ($value.aNullableInt case final aNullableInt?) + r'aNullableInt': aNullableInt, + if ($value.aNullableDouble case final aNullableDouble?) + r'aNullableDouble': aNullableDouble, + if ($value.aNullableNum case final aNullableNum?) + r'aNullableNum': aNullableNum, + if ($value.aNullableBool case final aNullableBool?) + r'aNullableBool': aNullableBool, + if (_i4.Serializers.instance.serialize( + $value.aNullableDateTime, + ) + case final aNullableDateTime?) + r'aNullableDateTime': aNullableDateTime, + r'aListOfString': $value.aListOfString, + r'aListOfInt': $value.aListOfInt, + r'aListOfDouble': $value.aListOfDouble, + r'aListOfNum': $value.aListOfNum, + r'aListOfBool': $value.aListOfBool, + r'aListOfDateTime': + $value.aListOfDateTime + .map( + (el) => + _i4.Serializers.instance.serialize(el), + ) + .toList(), + if ($value.aNullableListOfString + case final aNullableListOfString?) + r'aNullableListOfString': aNullableListOfString, + if ($value.aNullableListOfInt case final aNullableListOfInt?) + r'aNullableListOfInt': aNullableListOfInt, + if ($value.aNullableListOfDouble + case final aNullableListOfDouble?) + r'aNullableListOfDouble': aNullableListOfDouble, + if ($value.aNullableListOfNum case final aNullableListOfNum?) + r'aNullableListOfNum': aNullableListOfNum, + if ($value.aNullableListOfBool case final aNullableListOfBool?) + r'aNullableListOfBool': aNullableListOfBool, + if ($value.aNullableListOfDateTime + ?.map( + (el) => + _i4.Serializers.instance.serialize(el), + ) + .toList() + case final aNullableListOfDateTime?) + r'aNullableListOfDateTime': aNullableListOfDateTime, + }, + deserialize: ($serialized) { + return _i5.HttpQueryParams( + aString: ($serialized[r'aString'] as String), + anInt: ($serialized[r'anInt'] as num).toInt(), + aDouble: ($serialized[r'aDouble'] as num).toDouble(), + aNum: ($serialized[r'aNum'] as num), + aBool: ($serialized[r'aBool'] as bool), + aDateTime: _i4.Serializers.instance.deserialize( + $serialized[r'aDateTime'], + ), + aNullableString: ($serialized[r'aNullableString'] as String?), + aNullableInt: ($serialized[r'aNullableInt'] as num?)?.toInt(), + aNullableDouble: + ($serialized[r'aNullableDouble'] as num?)?.toDouble(), + aNullableNum: ($serialized[r'aNullableNum'] as num?), + aNullableBool: ($serialized[r'aNullableBool'] as bool?), + aNullableDateTime: _i4.Serializers.instance.deserialize( + $serialized[r'aNullableDateTime'], + ), + aListOfString: + ($serialized[r'aListOfString'] as Iterable) + .map((el) => (el as String)) + .toList(), + aListOfInt: + ($serialized[r'aListOfInt'] as Iterable) + .map((el) => (el as num).toInt()) + .toList(), + aListOfDouble: + ($serialized[r'aListOfDouble'] as Iterable) + .map((el) => (el as num).toDouble()) + .toList(), + aListOfNum: + ($serialized[r'aListOfNum'] as Iterable) + .map((el) => (el as num)) + .toList(), + aListOfBool: + ($serialized[r'aListOfBool'] as Iterable) + .map((el) => (el as bool)) + .toList(), + aListOfDateTime: + ($serialized[r'aListOfDateTime'] as Iterable) + .map( + (el) => + _i4.Serializers.instance.deserialize(el), + ) + .toList(), + aNullableListOfString: + ($serialized[r'aNullableListOfString'] as Iterable?) + ?.map((el) => (el as String)) + .toList(), + aNullableListOfInt: + ($serialized[r'aNullableListOfInt'] as Iterable?) + ?.map((el) => (el as num).toInt()) + .toList(), + aNullableListOfDouble: + ($serialized[r'aNullableListOfDouble'] as Iterable?) + ?.map((el) => (el as num).toDouble()) + .toList(), + aNullableListOfNum: + ($serialized[r'aNullableListOfNum'] as Iterable?) + ?.map((el) => (el as num)) + .toList(), + aNullableListOfBool: + ($serialized[r'aNullableListOfBool'] as Iterable?) + ?.map((el) => (el as bool)) + .toList(), + aNullableListOfDateTime: + ($serialized[r'aNullableListOfDateTime'] as Iterable?) + ?.map( + (el) => + _i4.Serializers.instance.deserialize(el), + ) + .toList(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': QueryTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/http/goldens/functions/http_status/accepted.dart b/apps/cli/fixtures/legacy/http/goldens/functions/http_status/accepted.dart new file mode 100644 index 000000000..d3acc2c55 --- /dev/null +++ b/apps/cli/fixtures/legacy/http/goldens/functions/http_status/accepted.dart @@ -0,0 +1,1685 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i9; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/http_status.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i10; +import 'package:celest_core/src/serialization/json_value.dart' as _i11; +import 'package:shelf/shelf.dart' as _i2; + +final class AcceptedTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'accepted'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + await _i3.accepted(); + return _i2.Response( + 202, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(null), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i9.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i10.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i9.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i10.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i11.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': AcceptedTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/http/goldens/functions/http_status/badRequest.dart b/apps/cli/fixtures/legacy/http/goldens/functions/http_status/badRequest.dart new file mode 100644 index 000000000..19e13c357 --- /dev/null +++ b/apps/cli/fixtures/legacy/http/goldens/functions/http_status/badRequest.dart @@ -0,0 +1,1685 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i9; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/http_status.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i10; +import 'package:celest_core/src/serialization/json_value.dart' as _i11; +import 'package:shelf/shelf.dart' as _i2; + +final class BadRequestTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'badRequest'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + await _i3.badRequest(); + return _i2.Response( + 400, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(null), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i9.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i10.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i9.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i10.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i11.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': BadRequestTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/http/goldens/functions/http_status/created.dart b/apps/cli/fixtures/legacy/http/goldens/functions/http_status/created.dart new file mode 100644 index 000000000..2d8138d97 --- /dev/null +++ b/apps/cli/fixtures/legacy/http/goldens/functions/http_status/created.dart @@ -0,0 +1,1685 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i9; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/http_status.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i10; +import 'package:celest_core/src/serialization/json_value.dart' as _i11; +import 'package:shelf/shelf.dart' as _i2; + +final class CreatedTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'created'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + await _i3.created(); + return _i2.Response( + 201, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(null), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i9.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i10.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i9.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i10.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i11.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': CreatedTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/http/goldens/functions/http_status/internalServerError.dart b/apps/cli/fixtures/legacy/http/goldens/functions/http_status/internalServerError.dart new file mode 100644 index 000000000..1fa0986a3 --- /dev/null +++ b/apps/cli/fixtures/legacy/http/goldens/functions/http_status/internalServerError.dart @@ -0,0 +1,1685 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i9; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/http_status.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i10; +import 'package:celest_core/src/serialization/json_value.dart' as _i11; +import 'package:shelf/shelf.dart' as _i2; + +final class InternalServerErrorTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'internalServerError'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + await _i3.internalServerError(); + return _i2.Response( + 500, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(null), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i9.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i10.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i9.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i10.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i11.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': InternalServerErrorTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/http/goldens/functions/http_status/ok.dart b/apps/cli/fixtures/legacy/http/goldens/functions/http_status/ok.dart new file mode 100644 index 000000000..911b6292e --- /dev/null +++ b/apps/cli/fixtures/legacy/http/goldens/functions/http_status/ok.dart @@ -0,0 +1,1685 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i9; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/http_status.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i10; +import 'package:celest_core/src/serialization/json_value.dart' as _i11; +import 'package:shelf/shelf.dart' as _i2; + +final class OkTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'ok'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + await _i3.ok(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(null), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i9.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i10.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i9.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i10.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i11.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i11.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': OkTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/http/lib/exceptions/http_errors.dart b/apps/cli/fixtures/legacy/http/lib/exceptions/http_errors.dart new file mode 100644 index 000000000..045721971 --- /dev/null +++ b/apps/cli/fixtures/legacy/http/lib/exceptions/http_errors.dart @@ -0,0 +1,17 @@ +import 'package:celest/celest.dart'; + +final class CustomBadRequestException extends BadRequestException { + CustomBadRequestException({super.message}) : super.base(); +} + +final class ForbiddenException extends BadRequestException { + ForbiddenException({super.message}) : super.base(); +} + +class NotFoundException implements Exception {} + +class AnotherNotFoundException implements NotFoundException {} + +class BadGatewayError extends InternalServerError { + BadGatewayError(super.message); +} diff --git a/apps/cli/fixtures/legacy/http/lib/fix_data/v1_migration.yaml b/apps/cli/fixtures/legacy/http/lib/fix_data/v1_migration.yaml new file mode 100644 index 000000000..84cb5da56 --- /dev/null +++ b/apps/cli/fixtures/legacy/http/lib/fix_data/v1_migration.yaml @@ -0,0 +1,13 @@ +# Generated by Celest. Do not modify. +version: 1 +transforms: + - title: "Updates the import of the Celest client" + date: 2024-10-06 + element: + uris: ["client.dart"] + variable: celest + changes: + - kind: replacedBy + newElement: + uris: ["package:api_client/api_client.dart"] + variable: celest diff --git a/apps/cli/fixtures/legacy/http/lib/models/http_errors.dart b/apps/cli/fixtures/legacy/http/lib/models/http_errors.dart new file mode 100644 index 000000000..c9ab981ff --- /dev/null +++ b/apps/cli/fixtures/legacy/http/lib/models/http_errors.dart @@ -0,0 +1,10 @@ +enum ExceptionType { + badRequest, + customBadRequest, + unauthorized, + forbidden, + notFound, + anotherNotFound, + internalServerError, + badGateway, +} diff --git a/apps/cli/fixtures/legacy/http/lib/models/http_header_query.dart b/apps/cli/fixtures/legacy/http/lib/models/http_header_query.dart new file mode 100644 index 000000000..bb88a3f95 --- /dev/null +++ b/apps/cli/fixtures/legacy/http/lib/models/http_header_query.dart @@ -0,0 +1,83 @@ +final class HttpQueryParams { + const HttpQueryParams({ + required this.aString, + required this.anInt, + required this.aDouble, + required this.aNum, + required this.aBool, + required this.aDateTime, + required this.aNullableString, + required this.aNullableInt, + required this.aNullableDouble, + required this.aNullableNum, + required this.aNullableBool, + required this.aNullableDateTime, + required this.aListOfString, + required this.aListOfInt, + required this.aListOfDouble, + required this.aListOfNum, + required this.aListOfBool, + required this.aListOfDateTime, + required this.aNullableListOfString, + required this.aNullableListOfInt, + required this.aNullableListOfDouble, + required this.aNullableListOfNum, + required this.aNullableListOfBool, + required this.aNullableListOfDateTime, + }); + + final String aString; + final int anInt; + final double aDouble; + final num aNum; + final bool aBool; + final DateTime aDateTime; + final String? aNullableString; + final int? aNullableInt; + final double? aNullableDouble; + final num? aNullableNum; + final bool? aNullableBool; + final DateTime? aNullableDateTime; + final List aListOfString; + final List aListOfInt; + final List aListOfDouble; + final List aListOfNum; + final List aListOfBool; + final List aListOfDateTime; + final List? aNullableListOfString; + final List? aNullableListOfInt; + final List? aNullableListOfDouble; + final List? aNullableListOfNum; + final List? aNullableListOfBool; + final List? aNullableListOfDateTime; +} + +final class HttpHeaderParams { + const HttpHeaderParams({ + required this.aString, + required this.anInt, + required this.aDouble, + required this.aNum, + required this.aBool, + required this.aDateTime, + required this.aNullableString, + required this.aNullableInt, + required this.aNullableDouble, + required this.aNullableNum, + required this.aNullableBool, + required this.aNullableDateTime, + }); + + final String aString; + final int anInt; + final double aDouble; + final num aNum; + final bool aBool; + final DateTime aDateTime; + final String? aNullableString; + final int? aNullableInt; + final double? aNullableDouble; + final num? aNullableNum; + final bool? aNullableBool; + final DateTime? aNullableDateTime; +} diff --git a/apps/cli/fixtures/legacy/http/lib/src/functions/http_errors.dart b/apps/cli/fixtures/legacy/http/lib/src/functions/http_errors.dart new file mode 100644 index 000000000..25b6120a9 --- /dev/null +++ b/apps/cli/fixtures/legacy/http/lib/src/functions/http_errors.dart @@ -0,0 +1,45 @@ +import 'package:celest/celest.dart' hide NotFoundException; +import 'package:celest/http.dart'; +import 'package:celest_backend/exceptions/http_errors.dart'; +import 'package:celest_backend/models/http_errors.dart'; + +@cloud +@httpError(HttpStatus.forbidden, ForbiddenException) +@httpError(HttpStatus.preconditionFailed, CustomBadRequestException) +@httpError(HttpStatus.unauthorized, UnauthorizedException) +@httpError(HttpStatus.notFound, NotFoundException, InternalServerError) +Future httpErrors(ExceptionType type) async { + switch (type) { + // Should return 400 even when not overridden. + case ExceptionType.badRequest: + throw BadRequestException(''); + + // Should return 412 + case ExceptionType.customBadRequest: + throw CustomBadRequestException(message: ''); + + // Should return 401 + case ExceptionType.unauthorized: + throw UnauthorizedException(''); + + // Should return 403 + case ExceptionType.forbidden: + throw ForbiddenException(message: ''); + + // Should return 404 + case ExceptionType.notFound: + throw NotFoundException(); + + // Should return 404 since it subtypes NotFoundException + case ExceptionType.anotherNotFound: + throw AnotherNotFoundException(); + + // Should return 404 + case ExceptionType.internalServerError: + throw InternalServerError(''); + + // Should return 404 since it subtypes InternalServerError + case ExceptionType.badGateway: + throw BadGatewayError(''); + } +} diff --git a/apps/cli/fixtures/legacy/http/lib/src/functions/http_header.dart b/apps/cli/fixtures/legacy/http/lib/src/functions/http_header.dart new file mode 100644 index 000000000..98f5dacab --- /dev/null +++ b/apps/cli/fixtures/legacy/http/lib/src/functions/http_header.dart @@ -0,0 +1,34 @@ +import 'package:celest/celest.dart'; +import 'package:celest/http.dart'; +import 'package:celest_backend/models/http_header_query.dart'; + +@cloud +Future headers( + @httpHeader('aString') String aString, + @httpHeader('anInt') int anInt, + @httpHeader('aDouble') double aDouble, + @httpHeader('aNum') num aNum, + @httpHeader('aBool') bool aBool, + @httpHeader('aDateTime') DateTime aDateTime, + @httpHeader('aNullableString') String? aNullableString, + @httpHeader('aNullableInt') int? aNullableInt, + @httpHeader('aNullableDouble') double? aNullableDouble, + @httpHeader('aNullableNum') num? aNullableNum, + @httpHeader('aNullableBool') bool? aNullableBool, + @httpHeader('aNullableDateTime') DateTime? aNullableDateTime, +) async { + return HttpHeaderParams( + aString: aString, + anInt: anInt, + aDouble: aDouble, + aNum: aNum, + aBool: aBool, + aDateTime: aDateTime, + aNullableString: aNullableString, + aNullableInt: aNullableInt, + aNullableDouble: aNullableDouble, + aNullableNum: aNullableNum, + aNullableBool: aNullableBool, + aNullableDateTime: aNullableDateTime, + ); +} diff --git a/apps/cli/fixtures/legacy/http/lib/src/functions/http_method.dart b/apps/cli/fixtures/legacy/http/lib/src/functions/http_method.dart new file mode 100644 index 000000000..8ecb7a1bf --- /dev/null +++ b/apps/cli/fixtures/legacy/http/lib/src/functions/http_method.dart @@ -0,0 +1,22 @@ +import 'package:celest/celest.dart'; +import 'package:celest/http.dart'; + +@cloud +@http(method: HttpMethod.get) +Future get() async {} + +@cloud +@http(method: HttpMethod.post) +Future post() async {} + +@cloud +@http(method: HttpMethod.put) +Future put() async {} + +@cloud +@http(method: HttpMethod.delete) +Future delete() async {} + +@cloud +@http(method: HttpMethod.patch) +Future patch() async {} diff --git a/apps/cli/fixtures/legacy/http/lib/src/functions/http_query.dart b/apps/cli/fixtures/legacy/http/lib/src/functions/http_query.dart new file mode 100644 index 000000000..bb13209e4 --- /dev/null +++ b/apps/cli/fixtures/legacy/http/lib/src/functions/http_query.dart @@ -0,0 +1,58 @@ +import 'package:celest/celest.dart'; +import 'package:celest/http.dart'; +import 'package:celest_backend/models/http_header_query.dart'; + +@cloud +Future query( + @httpQuery('aString') String aString, + @httpQuery('anInt') int anInt, + @httpQuery('aDouble') double aDouble, + @httpQuery('aNum') num aNum, + @httpQuery('aBool') bool aBool, + @httpQuery('aDateTime') DateTime aDateTime, + @httpQuery('aNullableString') String? aNullableString, + @httpQuery('aNullableInt') int? aNullableInt, + @httpQuery('aNullableDouble') double? aNullableDouble, + @httpQuery('aNullableNum') num? aNullableNum, + @httpQuery('aNullableBool') bool? aNullableBool, + @httpQuery('aNullableDateTime') DateTime? aNullableDateTime, + @httpQuery('aListOfString') List aListOfString, + @httpQuery('aListOfInt') List aListOfInt, + @httpQuery('aListOfDouble') List aListOfDouble, + @httpQuery('aListOfNum') List aListOfNum, + @httpQuery('aListOfBool') List aListOfBool, + @httpQuery('aListOfDateTime') List aListOfDateTime, + @httpQuery('aNullableListOfString') List? aNullableListOfString, + @httpQuery('aNullableListOfInt') List? aNullableListOfInt, + @httpQuery('aNullableListOfDouble') List? aNullableListOfDouble, + @httpQuery('aNullableListOfNum') List? aNullableListOfNum, + @httpQuery('aNullableListOfBool') List? aNullableListOfBool, + @httpQuery('aNullableListOfDateTime') List? aNullableListOfDateTime, +) async { + return HttpQueryParams( + aString: aString, + anInt: anInt, + aDouble: aDouble, + aNum: aNum, + aBool: aBool, + aDateTime: aDateTime, + aListOfString: aListOfString, + aListOfInt: aListOfInt, + aListOfDouble: aListOfDouble, + aListOfNum: aListOfNum, + aListOfBool: aListOfBool, + aListOfDateTime: aListOfDateTime, + aNullableString: aNullableString, + aNullableInt: aNullableInt, + aNullableDouble: aNullableDouble, + aNullableNum: aNullableNum, + aNullableBool: aNullableBool, + aNullableDateTime: aNullableDateTime, + aNullableListOfString: aNullableListOfString, + aNullableListOfInt: aNullableListOfInt, + aNullableListOfDouble: aNullableListOfDouble, + aNullableListOfNum: aNullableListOfNum, + aNullableListOfBool: aNullableListOfBool, + aNullableListOfDateTime: aNullableListOfDateTime, + ); +} diff --git a/apps/cli/fixtures/legacy/http/lib/src/functions/http_status.dart b/apps/cli/fixtures/legacy/http/lib/src/functions/http_status.dart new file mode 100644 index 000000000..889d30a7c --- /dev/null +++ b/apps/cli/fixtures/legacy/http/lib/src/functions/http_status.dart @@ -0,0 +1,22 @@ +import 'package:celest/celest.dart'; +import 'package:celest/http.dart'; + +@cloud +@http(statusCode: HttpStatus.ok) +Future ok() async {} + +@cloud +@http(statusCode: HttpStatus.created) +Future created() async {} + +@cloud +@http(statusCode: HttpStatus.accepted) +Future accepted() async {} + +@cloud +@http(statusCode: HttpStatus.badRequest) +Future badRequest() async {} + +@cloud +@http(statusCode: HttpStatus.internalServerError) +Future internalServerError() async {} diff --git a/apps/cli/fixtures/legacy/http/lib/src/generated/cloud.celest.dart b/apps/cli/fixtures/legacy/http/lib/src/generated/cloud.celest.dart new file mode 100644 index 000000000..f1a89c399 --- /dev/null +++ b/apps/cli/fixtures/legacy/http/lib/src/generated/cloud.celest.dart @@ -0,0 +1,45 @@ +// Generated by Celest. This file should not be modified manually, but +// it can be checked into version control. +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +library; + +import 'package:celest/src/core/context.dart'; +import 'package:celest_backend/src/generated/config.celest.dart'; + +/// The interface to your Celest backend. +/// +/// Similar to the `celest` global in the frontend, this +/// provides access to the backend environment and services +/// configured for your project. +const CelestCloud celest = CelestCloud._(); + +/// A per-request context object which propogates request information and common +/// accessors to the Celest server environment. +CelestContext get context => CelestContext._(context); + +/// The interface to your Celest backend. +/// +/// Similar to the `Celest` class in the frontend, this class +/// provides access to the backend environment and services +/// configured for your project. +class CelestCloud { + const CelestCloud._(); + + /// The current environment of the Celest service. + /// + /// This is determined by the `CELEST_ENVIRONMENT` variable + /// which is set for you by the deployment environment. + CelestEnvironment get currentEnvironment => + (variables.currentEnvironment as CelestEnvironment); + + /// The variables of the Celest service. + /// + /// This class provides access to the values configured for the + /// [currentEnvironment]. + CelestVariables get variables => const CelestVariables(); +} + +/// A per-request context object which propogates request information and common +/// accessors to the Celest server environment. +extension type CelestContext._(Context _context) implements Context {} diff --git a/apps/cli/fixtures/legacy/http/lib/src/generated/config.celest.dart b/apps/cli/fixtures/legacy/http/lib/src/generated/config.celest.dart new file mode 100644 index 000000000..687b9f186 --- /dev/null +++ b/apps/cli/fixtures/legacy/http/lib/src/generated/config.celest.dart @@ -0,0 +1,45 @@ +// Generated by Celest. This file should not be modified manually, but +// it can be checked into version control. +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +library; + +import 'package:celest/celest.dart'; +import 'package:celest/src/core/context.dart'; + +/// An environment of a deployed Celest service. +/// +/// Celest services can have multiple isolated branches, for example +/// a `development` and `production` environment. +extension type const CelestEnvironment._(String _env) + implements Environment, String { + /// The local Celest environment, used to delineate when a + /// Celest service is running on a developer machine as opposed + /// to the cloud. + static const CelestEnvironment local = CelestEnvironment._('local'); + + /// The production Celest environment which is common to all + /// Celest projects and labels the environment which is considered + /// live and served to end-users. + static const CelestEnvironment production = CelestEnvironment._('production'); + + /// Whether `this` represents the [local] environment. + bool get isLocal => this == local; + + /// Whether `this` represents the [production] environment. + bool get isProduction => this == production; +} + +/// The environment variables for the Celest service. +/// +/// This class provides access to the environment variable values +/// that are configured for the current [CelestEnvironment]. +class CelestVariables { + const CelestVariables(); + + /// The environment variable that determines the current environment. + /// + /// This is set by the deployment environment and is used to + /// determine the current environment of the Celest service. + String get currentEnvironment => context.expect(env.environment); +} diff --git a/apps/cli/fixtures/legacy/http/lib/src/project.dart b/apps/cli/fixtures/legacy/http/lib/src/project.dart new file mode 100644 index 000000000..c436b9732 --- /dev/null +++ b/apps/cli/fixtures/legacy/http/lib/src/project.dart @@ -0,0 +1,3 @@ +import 'package:celest/celest.dart'; + +const project = Project(name: 'api'); diff --git a/apps/cli/fixtures/legacy/http/pubspec.yaml b/apps/cli/fixtures/legacy/http/pubspec.yaml new file mode 100644 index 000000000..bec67c0b5 --- /dev/null +++ b/apps/cli/fixtures/legacy/http/pubspec.yaml @@ -0,0 +1,32 @@ +name: celest_backend +publish_to: none + +environment: + sdk: ^3.4.0 + +dependencies: + _common: + path: ../_common + celest: ^1.0.0 + celest_core: ^1.0.0 + meta: ^1.12.0 + +dependency_overrides: + cedar: + path: ../../../../../cedar/packages/cedar + celest: + path: ../../../../../celest/packages/celest + celest_ast: + path: ../../../../../celest/packages/celest_ast + celest_auth: + path: ../../../../../celest/packages/celest_auth + celest_cloud: + path: ../../../../../celest/packages/celest_cloud + celest_cloud_auth: + path: ../../../../../celest/services/celest_cloud_auth + celest_core: + path: ../../../../../celest/packages/celest_core + +dev_dependencies: + lints: ^4.0.0 + test: ^1.25.0 diff --git a/apps/cli/fixtures/legacy/marcelo/client/lib/marcelo_client.dart b/apps/cli/fixtures/legacy/marcelo/client/lib/marcelo_client.dart new file mode 100644 index 000000000..4e9e156eb --- /dev/null +++ b/apps/cli/fixtures/legacy/marcelo/client/lib/marcelo_client.dart @@ -0,0 +1,85 @@ +// Generated by Celest. This file should not be modified manually, but +// it can be checked into version control. +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +library; // ignore_for_file: no_leading_underscores_for_library_prefixes + +import 'dart:io'; + +import 'package:celest_core/_internal.dart' as _$celest; +import 'package:celest_core/celest_core.dart' as _$celest; +import 'package:celest_core/src/util/globals.dart' as _$celest; +import 'package:http/http.dart' as _$http_http; +import 'package:marcelo_client/src/functions.dart'; +import 'package:marcelo_client/src/serializers.dart'; +import 'package:native_storage/native_storage.dart' + as _$native_storage_native_storage; + +export 'package:celest_backend/exceptions/overrides.dart' + show + AppError, + AppException, + NotYetImplementedError, + UserException_ShowInConsole; + +final Celest celest = Celest(); + +enum CelestEnvironment { + local, + production; + + Uri get baseUri => switch (this) { + local => + _$celest.kIsWeb || !Platform.isAndroid + ? Uri.parse('http://localhost:7777') + : Uri.parse('http://10.0.2.2:7777'), + production => Uri.parse('https://example.celest.run'), + }; +} + +class Celest with _$celest.CelestBase { + var _initialized = false; + + late CelestEnvironment _currentEnvironment; + + late final _$native_storage_native_storage.NativeStorage nativeStorage = + _$native_storage_native_storage.NativeStorage(scope: 'celest'); + + @override + late _$http_http.Client httpClient = _$celest.CelestHttpClient( + secureStorage: nativeStorage.secure, + ); + + late Uri _baseUri; + + final _functions = CelestFunctions(); + + T _checkInitialized(T Function() value) { + if (!_initialized) { + throw StateError( + 'Celest has not been initialized. Make sure to call `celest.init()` at the start of your `main` method.', + ); + } + return value(); + } + + CelestEnvironment get currentEnvironment => + _checkInitialized(() => _currentEnvironment); + + @override + Uri get baseUri => _checkInitialized(() => _baseUri); + + CelestFunctions get functions => _checkInitialized(() => _functions); + + void init({ + CelestEnvironment environment = CelestEnvironment.local, + _$celest.Serializers? serializers, + }) { + _currentEnvironment = environment; + _baseUri = environment.baseUri; + if (!_initialized) { + initSerializers(serializers: serializers); + } + _initialized = true; + } +} diff --git a/apps/cli/fixtures/legacy/marcelo/client/lib/src/functions.dart b/apps/cli/fixtures/legacy/marcelo/client/lib/src/functions.dart new file mode 100644 index 000000000..d9a641d6a --- /dev/null +++ b/apps/cli/fixtures/legacy/marcelo/client/lib/src/functions.dart @@ -0,0 +1,964 @@ +// Generated by Celest. This file should not be modified manually, but +// it can be checked into version control. +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +library; // ignore_for_file: no_leading_underscores_for_library_prefixes + +import 'dart:async'; +import 'dart:convert'; + +import 'package:_common/src/models/available_stock.dart' + as _$_common_available_stock; +import 'package:_common/src/models/available_stocks.dart' + as _$_common_available_stocks; +import 'package:_common/src/models/cash_balance.dart' as _$_common_cash_balance; +import 'package:_common/src/models/errors_and_exceptions.dart' + as _$_common_errors_and_exceptions; +import 'package:_common/src/models/portfolio.dart' as _$_common_portfolio; +import 'package:_common/src/models/stock.dart' as _$_common_stock; +import 'package:_common/src/models/ui.dart' as _$_common_ui; +import 'package:celest/celest.dart' as _$celest; +import 'package:celest_backend/exceptions/overrides.dart'; +import 'package:celest_core/celest_core.dart' as _$celest; +import 'package:celest_core/src/exception/cloud_exception.dart' as _$celest; +import 'package:celest_core/src/exception/serialization_exception.dart' + as _$celest; +import 'package:celest_core/src/serialization/json_value.dart' as _$celest; +import 'package:marcelo_client/marcelo_client.dart'; + +class CelestFunctions { + final exceptions = CelestFunctionsExceptions(); + + final models = CelestFunctionsModels(); +} + +class CelestFunctionsExceptions { + Never _throwError({int? code, required Map body}) { + final status = body['@status'] as Map?; + final message = status?['message'] as String?; + final details = status?['details'] as _$celest.JsonList?; + final (errorType, errorValue, stackTrace) = switch (details) { + null || [] => const (null, null, StackTrace.empty), + [ + final errorDetails as Map, + { + '@type': 'dart.core.StackTrace', + 'value': final stackTraceValue as String, + }, + ..., + ] => + ( + errorDetails['@type'], + errorDetails['value'], + StackTrace.fromString(stackTraceValue), + ), + [final errorDetails as Map, ...] => ( + errorDetails['@type'], + errorDetails['value'], + StackTrace.empty, + ), + }; + + switch (errorType) { + case '_common.UserException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$_common_errors_and_exceptions.UserException>( + errorValue, + ), + stackTrace, + ); + case 'marcelo.v1.AppError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'marcelo.v1.AppException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'marcelo.v1.NotYetImplementedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case '_common.ValidateError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$_common_errors_and_exceptions.ValidateError>( + errorValue, + ), + stackTrace, + ); + case 'marcelo.v1.UserException_ShowInConsole': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.core.Error': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.AssertionError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.TypeError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.ArgumentError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.RangeError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.IndexError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.UnsupportedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.UnimplementedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.StateError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.ConcurrentModificationError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.core.OutOfMemoryError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.StackOverflowError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.Exception': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.FormatException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.IntegerDivisionByZeroException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.async.AsyncError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.async.TimeoutException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.convert.JsonUnsupportedObjectError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.CloudException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.CloudException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.CancelledException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.CancelledException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnknownError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.UnknownError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.BadRequestException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.BadRequestException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnauthorizedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.UnauthorizedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.NotFoundException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.NotFoundException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.AlreadyExistsException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.AlreadyExistsException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.PermissionDeniedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.PermissionDeniedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.ResourceExhaustedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.ResourceExhaustedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.FailedPreconditionException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.FailedPreconditionException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.AbortedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.AbortedException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.OutOfRangeException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.OutOfRangeException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnimplementedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.UnimplementedError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.InternalServerError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.InternalServerError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnavailableError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.UnavailableError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.DataLossError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.DataLossError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.DeadlineExceededError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.DeadlineExceededError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.SerializationException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.SerializationException>(errorValue), + stackTrace, + ); + default: + Error.throwWithStackTrace( + _$celest.CloudException.http( + code: code, + message: message, + details: ((details ?? body) as _$celest.JsonValue), + ), + StackTrace.empty, + ); + } + } + + @_$celest.CloudFunction(api: 'exceptions', function: 'throwsUserException') + Future throwsUserException({_$celest.JsonValue? cause}) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/exceptions/throws-user-exception'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'cause': _$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + cause, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return; + } + + @_$celest.CloudFunction( + api: 'exceptions', + function: 'callsThrowsUserException', + ) + Future callsThrowsUserException({_$celest.JsonValue? cause}) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/exceptions/calls-throws-user-exception'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'cause': _$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + cause, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return; + } + + @_$celest.CloudFunction(api: 'exceptions', function: 'throwsAppError') + Future throwsAppError({ + String message = 'message', + _$celest.JsonValue? error, + }) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/exceptions/throws-app-error'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'message': message, + r'error': _$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + error, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return; + } + + @_$celest.CloudFunction(api: 'exceptions', function: 'throwsAppException') + Future throwsAppException() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/exceptions/throws-app-exception'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return; + } + + @_$celest.CloudFunction( + api: 'exceptions', + function: 'throwsNotYetImplementedError', + ) + Future throwsNotYetImplementedError() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/exceptions/throws-not-yet-implemented-error'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return; + } + + @_$celest.CloudFunction(api: 'exceptions', function: 'throwsValidateError') + Future throwsValidateError() async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/exceptions/throws-validate-error'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return; + } + + @_$celest.CloudFunction( + api: 'exceptions', + function: 'throwsUserException_ShowInConsole', + ) + Future throwsUserExceptionShowInConsole({ + String message = 'message', + _$celest.JsonValue? cause, + }) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve( + '/exceptions/throws-user-exception-show-in-console', + ), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'message': message, + r'cause': _$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + cause, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return; + } +} + +class CelestFunctionsModels { + Never _throwError({int? code, required Map body}) { + final status = body['@status'] as Map?; + final message = status?['message'] as String?; + final details = status?['details'] as _$celest.JsonList?; + final (errorType, errorValue, stackTrace) = switch (details) { + null || [] => const (null, null, StackTrace.empty), + [ + final errorDetails as Map, + { + '@type': 'dart.core.StackTrace', + 'value': final stackTraceValue as String, + }, + ..., + ] => + ( + errorDetails['@type'], + errorDetails['value'], + StackTrace.fromString(stackTraceValue), + ), + [final errorDetails as Map, ...] => ( + errorDetails['@type'], + errorDetails['value'], + StackTrace.empty, + ), + }; + + switch (errorType) { + case '_common.UserException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$_common_errors_and_exceptions.UserException>( + errorValue, + ), + stackTrace, + ); + case 'marcelo.v1.AppError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'marcelo.v1.AppException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'marcelo.v1.NotYetImplementedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case '_common.ValidateError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$_common_errors_and_exceptions.ValidateError>( + errorValue, + ), + stackTrace, + ); + case 'marcelo.v1.UserException_ShowInConsole': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.core.Error': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.AssertionError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.TypeError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.ArgumentError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.RangeError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.IndexError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.UnsupportedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.UnimplementedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.StateError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.ConcurrentModificationError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.core.OutOfMemoryError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.StackOverflowError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.Exception': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.FormatException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.IntegerDivisionByZeroException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.async.AsyncError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.async.TimeoutException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.convert.JsonUnsupportedObjectError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.CloudException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.CloudException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.CancelledException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.CancelledException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnknownError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.UnknownError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.BadRequestException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.BadRequestException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnauthorizedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.UnauthorizedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.NotFoundException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.NotFoundException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.AlreadyExistsException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.AlreadyExistsException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.PermissionDeniedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.PermissionDeniedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.ResourceExhaustedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.ResourceExhaustedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.FailedPreconditionException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.FailedPreconditionException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.AbortedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.AbortedException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.OutOfRangeException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.OutOfRangeException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnimplementedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.UnimplementedError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.InternalServerError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.InternalServerError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnavailableError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.UnavailableError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.DataLossError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.DataLossError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.DeadlineExceededError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.DeadlineExceededError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.SerializationException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.SerializationException>(errorValue), + stackTrace, + ); + default: + Error.throwWithStackTrace( + _$celest.CloudException.http( + code: code, + message: message, + details: ((details ?? body) as _$celest.JsonValue), + ), + StackTrace.empty, + ); + } + } + + @_$celest.CloudFunction(api: 'models', function: 'availableStock') + Future<_$_common_available_stock.AvailableStock> availableStock( + _$_common_available_stock.AvailableStock availableStock, + ) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/models/available-stock'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'availableStock': _$celest.Serializers.instance + .serialize<_$_common_available_stock.AvailableStock>( + availableStock, + ), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance + .deserialize<_$_common_available_stock.AvailableStock>($body); + } + + @_$celest.CloudFunction(api: 'models', function: 'availableStocks') + Future<_$_common_available_stocks.AvailableStocks> availableStocks( + _$_common_available_stocks.AvailableStocks availableStocks, + ) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/models/available-stocks'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'availableStocks': _$celest.Serializers.instance + .serialize<_$_common_available_stocks.AvailableStocks>( + availableStocks, + ), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance + .deserialize<_$_common_available_stocks.AvailableStocks>($body); + } + + @_$celest.CloudFunction(api: 'models', function: 'cashBalance') + Future<_$_common_cash_balance.CashBalance> cashBalance( + _$_common_cash_balance.CashBalance cashBalance, + ) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/models/cash-balance'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'cashBalance': _$celest.Serializers.instance + .serialize<_$_common_cash_balance.CashBalance>(cashBalance), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance + .deserialize<_$_common_cash_balance.CashBalance>($body); + } + + @_$celest.CloudFunction(api: 'models', function: 'portfolio') + Future<_$_common_portfolio.Portfolio> portfolio( + _$_common_portfolio.Portfolio portfolio, + ) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/models/portfolio'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'portfolio': _$celest.Serializers.instance + .serialize<_$_common_portfolio.Portfolio>(portfolio), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance + .deserialize<_$_common_portfolio.Portfolio>($body); + } + + @_$celest.CloudFunction(api: 'models', function: 'stock') + Future<_$_common_stock.Stock> stock(_$_common_stock.Stock stock) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/models/stock'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'stock': _$celest.Serializers.instance + .serialize<_$_common_stock.Stock>(stock), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize<_$_common_stock.Stock>( + $body, + ); + } + + @_$celest.CloudFunction(api: 'models', function: 'ui') + Future<_$_common_ui.Ui> ui(_$_common_ui.Ui ui) async { + final $response = await celest.httpClient.post( + celest.baseUri.resolve('/models/ui'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode({ + r'ui': _$celest.Serializers.instance.serialize<_$_common_ui.Ui>(ui), + }), + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize<_$_common_ui.Ui>($body); + } +} diff --git a/apps/cli/fixtures/legacy/marcelo/client/lib/src/serializers.dart b/apps/cli/fixtures/legacy/marcelo/client/lib/src/serializers.dart new file mode 100644 index 000000000..c19ef155f --- /dev/null +++ b/apps/cli/fixtures/legacy/marcelo/client/lib/src/serializers.dart @@ -0,0 +1,1057 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async'; +import 'dart:convert'; + +import 'package:_common/src/models/available_stock.dart' + as _$_common_available_stock; +import 'package:_common/src/models/available_stocks.dart' + as _$_common_available_stocks; +import 'package:_common/src/models/cash_balance.dart' as _$_common_cash_balance; +import 'package:_common/src/models/errors_and_exceptions.dart' + as _$_common_errors_and_exceptions; +import 'package:_common/src/models/portfolio.dart' as _$_common_portfolio; +import 'package:_common/src/models/stock.dart' as _$_common_stock; +import 'package:_common/src/models/ui.dart' as _$_common_ui; +import 'package:celest_backend/exceptions/overrides.dart'; +import 'package:celest_backend/models/overrides.dart'; +import 'package:celest_core/celest_core.dart' as _$celest; +import 'package:celest_core/src/exception/cloud_exception.dart' as _$celest; +import 'package:celest_core/src/exception/serialization_exception.dart' + as _$celest; +import 'package:celest_core/src/serialization/json_value.dart' as _$celest; +import 'package:fast_immutable_collections/src/ilist/ilist.dart' + as _$fast_immutable_collections_ilist; + +void initSerializers({_$celest.Serializers? serializers}) { + return runZoned(() { + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _$celest.Serializers.instance + .serialize($value.stackTrace), + }, + deserialize: ($serialized) { + return AsyncError( + $serialized[r'error']!, + _$celest.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_$celest.Serializers.instance.serialize( + $value.duration, + ) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return TimeoutException( + ($serialized[r'message'] as String?), + _$celest.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest + .Serializer.define>( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + ConcurrentModificationError, + Map? + >( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: + ($value) => { + if (_$celest.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$_common_available_stocks.AvailableStocks, + Map + >( + serialize: + ($value) => { + r'list': _$celest.Serializers.instance.serialize< + _$fast_immutable_collections_ilist.IList< + _$_common_available_stock.AvailableStock + > + >($value.list), + }, + deserialize: ($serialized) { + return _$_common_available_stocks.AvailableStocks( + ($serialized[r'list'] as Iterable) + .map( + (el) => _$celest.Serializers.instance + .deserialize<_$_common_available_stock.AvailableStock>( + el, + ), + ) + .toList(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$_common_errors_and_exceptions.UserException, + Map + >( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _$_common_errors_and_exceptions.UserException.fromJson( + $serialized, + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$_common_errors_and_exceptions.ValidateError, + Map + >( + serialize: ($value) => {r'msg': $value.msg}, + deserialize: ($serialized) { + return _$_common_errors_and_exceptions.ValidateError( + ($serialized[r'msg'] as String), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define<_$_common_ui.ScreenChoice, String>( + serialize: ($value) => $value.name, + deserialize: ($serialized) { + return _$_common_ui.ScreenChoice.values.byName($serialized); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return AppError.fromJson($serialized); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: + ($value) => { + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.error, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final error?) + r'error': error, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.msg, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final msg?) + r'msg': msg, + }, + deserialize: ($serialized) { + return (_$_common_errors_and_exceptions.AppException( + $serialized?[r'msg'], + $serialized?[r'error'], + ) + as AppException); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: + ($value) => { + r'msg': $value.msg, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.message, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final message?) + r'message': message, + }, + deserialize: ($serialized) { + return NotYetImplementedError( + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'message'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest + .Serializer.define>( + serialize: + ($value) => { + if ($value.msg case final msg?) r'msg': msg, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.cause, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final cause?) + r'cause': cause, + }, + deserialize: ($serialized) { + return UserException_ShowInConsole( + msg: ($serialized[r'msg'] as String), + cause: _$celest.Serializers.instance + .deserialize<_$celest.JsonValue?>( + $serialized[r'cause'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + r'ticker': $value.ticker, + r'name': $value.name, + r'currentPrice': $value.currentPrice, + r'currentPriceStr': $value.currentPriceStr, + }, + deserialize: ($serialized) { + return (_$_common_available_stock.AvailableStock( + ($serialized[r'ticker'] as String), + name: ($serialized[r'name'] as String), + currentPrice: ($serialized[r'currentPrice'] as num).toDouble(), + ) + as AvailableStock); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: ($value) => {r'amount': $value.amount}, + deserialize: ($serialized) { + return (_$_common_cash_balance.CashBalance( + ($serialized[r'amount'] as num).toDouble(), + ) + as CashBalance); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: + ($value) => { + r'stocks': _$celest.Serializers.instance.serialize< + _$fast_immutable_collections_ilist.IList<_$_common_stock.Stock> + >($value.stocks), + r'cashBalance': _$celest.Serializers.instance + .serialize<_$_common_cash_balance.CashBalance>( + $value.cashBalance, + ), + r'isEmpty': $value.isEmpty, + r'totalCostBasis': $value.totalCostBasis, + }, + deserialize: ($serialized) { + return (_$_common_portfolio.Portfolio( + stocks: + ($serialized?[r'stocks'] as Iterable?) + ?.map( + (el) => _$celest.Serializers.instance + .deserialize<_$_common_stock.Stock>(el), + ) + .toList(), + cashBalance: + (_$celest.Serializers.instance + .deserialize<_$_common_cash_balance.CashBalance?>( + $serialized?[r'cashBalance'], + )) ?? + _$_common_cash_balance.CashBalance.ZERO, + ) + as Portfolio); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + r'ticker': $value.ticker, + r'howManyShares': $value.howManyShares, + r'averagePrice': $value.averagePrice, + r'costBasis': $value.costBasis, + r'averagePriceStr': $value.averagePriceStr, + }, + deserialize: ($serialized) { + return (_$_common_stock.Stock( + ($serialized[r'ticker'] as String), + howManyShares: ($serialized[r'howManyShares'] as num).toInt(), + averagePrice: ($serialized[r'averagePrice'] as num).toDouble(), + ) + as Stock); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + r'isDarkMode': $value.isDarkMode, + r'screenChoice': _$celest.Serializers.instance + .serialize<_$_common_ui.ScreenChoice>($value.screenChoice), + }, + deserialize: ($serialized) { + return (_$_common_ui.Ui( + isDarkMode: ($serialized[r'isDarkMode'] as bool), + screenChoice: + (_$celest.Serializers.instance + .deserialize<_$_common_ui.ScreenChoice?>( + $serialized[r'screenChoice'], + )) ?? + _$_common_ui.ScreenChoice.portfolioAndCashBalance, + ) + as Ui); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest + .Serializer.define<_$celest.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.AbortedException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.AlreadyExistsException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.BadRequestException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.BadRequestException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.CancelledException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.CancelledException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define<_$celest.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.CloudException.fromJson($serialized); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define<_$celest.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.DataLossError( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.DeadlineExceededError, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.InternalServerError, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.InternalServerError( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest + .Serializer.define<_$celest.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.NotFoundException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.OutOfRangeException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.OutOfRangeException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.UnauthorizedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.UnauthorizedException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest + .Serializer.define<_$celest.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.UnavailableError( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.UnimplementedError, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.UnimplementedError( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define<_$celest.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.UnknownError( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.SerializationException, + Map + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define<_$celest.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _$celest.JsonValue($serialized); + }, + ), + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$fast_immutable_collections_ilist.IList< + _$_common_available_stock.AvailableStock + >, + dynamic + >( + serialize: + ($value) => $value.toJson( + (value) => _$celest.Serializers.instance + .serialize<_$_common_available_stock.AvailableStock>(value), + ), + deserialize: ($serialized) { + return _$fast_immutable_collections_ilist.IList< + _$_common_available_stock.AvailableStock + >.fromJson( + $serialized, + (value) => _$celest.Serializers.instance + .deserialize<_$_common_available_stock.AvailableStock>(value), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$fast_immutable_collections_ilist.IList<_$_common_stock.Stock>, + dynamic + >( + serialize: + ($value) => $value.toJson( + (value) => _$celest.Serializers.instance + .serialize<_$_common_stock.Stock>(value), + ), + deserialize: ($serialized) { + return _$fast_immutable_collections_ilist.IList< + _$_common_stock.Stock + >.fromJson( + $serialized, + (value) => _$celest.Serializers.instance + .deserialize<_$_common_stock.Stock>(value), + ); + }, + ), + ); + }, zoneValues: {_$celest.Serializers: serializers}); +} diff --git a/apps/cli/fixtures/legacy/marcelo/client/pubspec.yaml b/apps/cli/fixtures/legacy/marcelo/client/pubspec.yaml new file mode 100644 index 000000000..7d22dea06 --- /dev/null +++ b/apps/cli/fixtures/legacy/marcelo/client/pubspec.yaml @@ -0,0 +1,29 @@ +name: marcelo_client +description: The Celest client for marcelo. +publish_to: none + +environment: + sdk: ^3.4.0 + +dependencies: + celest: ^1.0.0 + celest_backend: + path: .. + celest_core: ^1.0.0 + http: ^1.0.0 + native_storage: ^0.2.2 + +dependency_overrides: + celest: + path: ../../../../../../celest/packages/celest + celest_ast: + path: ../../../../../../celest/packages/celest_ast + celest_auth: + path: ../../../../../../celest/packages/celest_auth + celest_cloud: + path: ../../../../../../celest/packages/celest_cloud + celest_cloud_auth: + path: ../../../../../../celest/services/celest_cloud_auth + celest_core: + path: ../../../../../../celest/packages/celest_core +dev_dependencies: {} diff --git a/apps/cli/fixtures/legacy/marcelo/goldens/api.local.dart b/apps/cli/fixtures/legacy/marcelo/goldens/api.local.dart new file mode 100644 index 000000000..40b9c3b04 --- /dev/null +++ b/apps/cli/fixtures/legacy/marcelo/goldens/api.local.dart @@ -0,0 +1,47 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'package:celest/src/core/context.dart' as _i15; +import 'package:celest/src/runtime/serve.dart' as _i1; + +import 'functions/exceptions/callsThrowsUserException.dart' as _i2; +import 'functions/exceptions/throwsAppError.dart' as _i3; +import 'functions/exceptions/throwsAppException.dart' as _i4; +import 'functions/exceptions/throwsNotYetImplementedError.dart' as _i5; +import 'functions/exceptions/throwsUserException.dart' as _i6; +import 'functions/exceptions/throwsUserException_ShowInConsole.dart' as _i7; +import 'functions/exceptions/throwsValidateError.dart' as _i8; +import 'functions/models/availableStock.dart' as _i9; +import 'functions/models/availableStocks.dart' as _i10; +import 'functions/models/cashBalance.dart' as _i11; +import 'functions/models/portfolio.dart' as _i12; +import 'functions/models/stock.dart' as _i13; +import 'functions/models/ui.dart' as _i14; + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: { + '/exceptions/calls-throws-user-exception': + _i2.CallsThrowsUserExceptionTarget(), + '/exceptions/throws-app-error': _i3.ThrowsAppErrorTarget(), + '/exceptions/throws-app-exception': _i4.ThrowsAppExceptionTarget(), + '/exceptions/throws-not-yet-implemented-error': + _i5.ThrowsNotYetImplementedErrorTarget(), + '/exceptions/throws-user-exception': _i6.ThrowsUserExceptionTarget(), + '/exceptions/throws-user-exception-show-in-console': + _i7.ThrowsUserExceptionShowInConsoleTarget(), + '/exceptions/throws-validate-error': _i8.ThrowsValidateErrorTarget(), + '/models/available-stock': _i9.AvailableStockTarget(), + '/models/available-stocks': _i10.AvailableStocksTarget(), + '/models/cash-balance': _i11.CashBalanceTarget(), + '/models/portfolio': _i12.PortfolioTarget(), + '/models/stock': _i13.StockTarget(), + '/models/ui': _i14.UiTarget(), + }, + setup: (_i15.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/marcelo/goldens/ast.json b/apps/cli/fixtures/legacy/marcelo/goldens/ast.json new file mode 100644 index 000000000..9ae45d8b1 --- /dev/null +++ b/apps/cli/fixtures/legacy/marcelo/goldens/ast.json @@ -0,0 +1,1651 @@ +{ + "name": "marcelo", + "environment": "local", + "reference": { + "$": "Reference", + "symbol": "project", + "url": "package:celest_backend/src/project.dart" + }, + "apis": { + "exceptions": { + "name": "exceptions", + "metadata": [], + "functions": { + "throwsUserException": { + "name": "throwsUserException", + "apiName": "exceptions", + "typeParameters": [], + "parameters": [ + { + "name": "cause", + "type": { + "$": "TypeReference", + "symbol": "JsonValue", + "url": "package:celest_core/src/serialization/json_value.dart", + "isNullable": true + }, + "required": false, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 312, + "uri": "package:celest_backend/src/functions/exceptions.dart", + "line": 8, + "column": 13 + }, + "end": { + "offset": 317, + "uri": "package:celest_backend/src/functions/exceptions.dart", + "line": 8, + "column": 18 + }, + "text": "cause" + }, + "defaultTo": { + "$": "DartNull", + "staticType": { + "symbol": "Null", + "url": "dart:core" + } + } + } + ], + "returnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "flattenedReturnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 277, + "uri": "package:celest_backend/src/functions/exceptions.dart", + "line": 7, + "column": 5 + }, + "end": { + "offset": 296, + "uri": "package:celest_backend/src/functions/exceptions.dart", + "line": 7, + "column": 24 + }, + "text": "throwsUserException" + } + }, + "callsThrowsUserException": { + "name": "callsThrowsUserException", + "apiName": "exceptions", + "typeParameters": [], + "parameters": [ + { + "name": "cause", + "type": { + "$": "TypeReference", + "symbol": "JsonValue", + "url": "package:celest_core/src/serialization/json_value.dart", + "isNullable": true + }, + "required": false, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 427, + "uri": "package:celest_backend/src/functions/exceptions.dart", + "line": 15, + "column": 13 + }, + "end": { + "offset": 432, + "uri": "package:celest_backend/src/functions/exceptions.dart", + "line": 15, + "column": 18 + }, + "text": "cause" + }, + "defaultTo": { + "$": "DartNull", + "staticType": { + "symbol": "Null", + "url": "dart:core" + } + } + } + ], + "returnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "flattenedReturnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 387, + "uri": "package:celest_backend/src/functions/exceptions.dart", + "line": 14, + "column": 5 + }, + "end": { + "offset": 411, + "uri": "package:celest_backend/src/functions/exceptions.dart", + "line": 14, + "column": 29 + }, + "text": "callsThrowsUserException" + } + }, + "throwsAppError": { + "name": "throwsAppError", + "apiName": "exceptions", + "typeParameters": [], + "parameters": [ + { + "name": "message", + "type": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + "required": false, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 517, + "uri": "package:celest_backend/src/functions/exceptions.dart", + "line": 22, + "column": 9 + }, + "end": { + "offset": 524, + "uri": "package:celest_backend/src/functions/exceptions.dart", + "line": 22, + "column": 16 + }, + "text": "message" + }, + "defaultTo": { + "$": "DartString", + "value": "message", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + { + "name": "error", + "type": { + "$": "TypeReference", + "symbol": "JsonValue", + "url": "package:celest_core/src/serialization/json_value.dart", + "isNullable": true + }, + "required": false, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 551, + "uri": "package:celest_backend/src/functions/exceptions.dart", + "line": 23, + "column": 13 + }, + "end": { + "offset": 556, + "uri": "package:celest_backend/src/functions/exceptions.dart", + "line": 23, + "column": 18 + }, + "text": "error" + }, + "defaultTo": { + "$": "DartNull", + "staticType": { + "symbol": "Null", + "url": "dart:core" + } + } + } + ], + "returnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "flattenedReturnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 491, + "uri": "package:celest_backend/src/functions/exceptions.dart", + "line": 21, + "column": 5 + }, + "end": { + "offset": 505, + "uri": "package:celest_backend/src/functions/exceptions.dart", + "line": 21, + "column": 19 + }, + "text": "throwsAppError" + } + }, + "throwsAppException": { + "name": "throwsAppException", + "apiName": "exceptions", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "flattenedReturnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 612, + "uri": "package:celest_backend/src/functions/exceptions.dart", + "line": 29, + "column": 5 + }, + "end": { + "offset": 630, + "uri": "package:celest_backend/src/functions/exceptions.dart", + "line": 29, + "column": 23 + }, + "text": "throwsAppException" + } + }, + "throwsNotYetImplementedError": { + "name": "throwsNotYetImplementedError", + "apiName": "exceptions", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "flattenedReturnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 715, + "uri": "package:celest_backend/src/functions/exceptions.dart", + "line": 34, + "column": 5 + }, + "end": { + "offset": 743, + "uri": "package:celest_backend/src/functions/exceptions.dart", + "line": 34, + "column": 33 + }, + "text": "throwsNotYetImplementedError" + } + }, + "throwsValidateError": { + "name": "throwsValidateError", + "apiName": "exceptions", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "flattenedReturnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 806, + "uri": "package:celest_backend/src/functions/exceptions.dart", + "line": 39, + "column": 5 + }, + "end": { + "offset": 825, + "uri": "package:celest_backend/src/functions/exceptions.dart", + "line": 39, + "column": 24 + }, + "text": "throwsValidateError" + } + }, + "throwsUserException_ShowInConsole": { + "name": "throwsUserException_ShowInConsole", + "apiName": "exceptions", + "typeParameters": [], + "parameters": [ + { + "name": "message", + "type": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + "required": false, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 924, + "uri": "package:celest_backend/src/functions/exceptions.dart", + "line": 45, + "column": 9 + }, + "end": { + "offset": 931, + "uri": "package:celest_backend/src/functions/exceptions.dart", + "line": 45, + "column": 16 + }, + "text": "message" + }, + "defaultTo": { + "$": "DartString", + "value": "message", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + { + "name": "cause", + "type": { + "$": "TypeReference", + "symbol": "JsonValue", + "url": "package:celest_core/src/serialization/json_value.dart", + "isNullable": true + }, + "required": false, + "named": true, + "annotations": [], + "location": { + "start": { + "offset": 958, + "uri": "package:celest_backend/src/functions/exceptions.dart", + "line": 46, + "column": 13 + }, + "end": { + "offset": 963, + "uri": "package:celest_backend/src/functions/exceptions.dart", + "line": 46, + "column": 18 + }, + "text": "cause" + }, + "defaultTo": { + "$": "DartNull", + "staticType": { + "symbol": "Null", + "url": "dart:core" + } + } + } + ], + "returnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "flattenedReturnType": { + "$": "Reference", + "symbol": "void", + "url": "dart:core" + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 879, + "uri": "package:celest_backend/src/functions/exceptions.dart", + "line": 44, + "column": 5 + }, + "end": { + "offset": 912, + "uri": "package:celest_backend/src/functions/exceptions.dart", + "line": 44, + "column": 38 + }, + "text": "throwsUserException_ShowInConsole" + } + } + }, + "docs": [], + "exceptionTypes": [ + { + "$": "TypeReference", + "symbol": "UserException", + "url": "package:_common/src/models/errors_and_exceptions.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AppError", + "url": "package:celest_backend/exceptions/overrides.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AppException", + "url": "package:celest_backend/exceptions/overrides.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "NotYetImplementedError", + "url": "package:celest_backend/exceptions/overrides.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ValidateError", + "url": "package:_common/src/models/errors_and_exceptions.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UserException_ShowInConsole", + "url": "package:celest_backend/exceptions/overrides.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "Error", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AssertionError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "TypeError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ArgumentError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "RangeError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "IndexError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnsupportedError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnimplementedError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "StateError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ConcurrentModificationError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "OutOfMemoryError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "StackOverflowError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "Exception", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "FormatException", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "IntegerDivisionByZeroException", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AsyncError", + "url": "dart:async", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "TimeoutException", + "url": "dart:async", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "JsonUnsupportedObjectError", + "url": "dart:convert", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "CloudException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "CancelledException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnknownError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "BadRequestException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnauthorizedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "NotFoundException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AlreadyExistsException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "PermissionDeniedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ResourceExhaustedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "FailedPreconditionException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AbortedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "OutOfRangeException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnimplementedError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "InternalServerError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnavailableError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "DataLossError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "DeadlineExceededError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "SerializationException", + "url": "package:celest_core/src/exception/serialization_exception.dart", + "isNullable": false + } + ], + "location": { + "start": { + "offset": 0, + "uri": "package:celest_backend/src/functions/exceptions.dart", + "line": 0, + "column": 0 + }, + "end": { + "offset": 0, + "uri": "package:celest_backend/src/functions/exceptions.dart", + "line": 0, + "column": 0 + }, + "text": "" + } + }, + "models": { + "name": "models", + "metadata": [], + "functions": { + "availableStock": { + "name": "availableStock", + "apiName": "models", + "typeParameters": [], + "parameters": [ + { + "name": "availableStock", + "type": { + "$": "TypeReference", + "symbol": "AvailableStock", + "url": "package:_common/src/models/available_stock.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 129, + "uri": "package:celest_backend/src/functions/models.dart", + "line": 4, + "column": 45 + }, + "end": { + "offset": 143, + "uri": "package:celest_backend/src/functions/models.dart", + "line": 4, + "column": 59 + }, + "text": "availableStock" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "AvailableStock", + "url": "package:_common/src/models/available_stock.dart", + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "AvailableStock", + "url": "package:_common/src/models/available_stock.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 99, + "uri": "package:celest_backend/src/functions/models.dart", + "line": 4, + "column": 15 + }, + "end": { + "offset": 113, + "uri": "package:celest_backend/src/functions/models.dart", + "line": 4, + "column": 29 + }, + "text": "availableStock" + } + }, + "availableStocks": { + "name": "availableStocks", + "apiName": "models", + "typeParameters": [], + "parameters": [ + { + "name": "availableStocks", + "type": { + "$": "TypeReference", + "symbol": "AvailableStocks", + "url": "package:_common/src/models/available_stocks.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 219, + "uri": "package:celest_backend/src/functions/models.dart", + "line": 6, + "column": 48 + }, + "end": { + "offset": 234, + "uri": "package:celest_backend/src/functions/models.dart", + "line": 6, + "column": 63 + }, + "text": "availableStocks" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "AvailableStocks", + "url": "package:_common/src/models/available_stocks.dart", + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "AvailableStocks", + "url": "package:_common/src/models/available_stocks.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 187, + "uri": "package:celest_backend/src/functions/models.dart", + "line": 6, + "column": 16 + }, + "end": { + "offset": 202, + "uri": "package:celest_backend/src/functions/models.dart", + "line": 6, + "column": 31 + }, + "text": "availableStocks" + } + }, + "cashBalance": { + "name": "cashBalance", + "apiName": "models", + "typeParameters": [], + "parameters": [ + { + "name": "cashBalance", + "type": { + "$": "TypeReference", + "symbol": "CashBalance", + "url": "package:_common/src/models/cash_balance.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 303, + "uri": "package:celest_backend/src/functions/models.dart", + "line": 9, + "column": 36 + }, + "end": { + "offset": 314, + "uri": "package:celest_backend/src/functions/models.dart", + "line": 9, + "column": 47 + }, + "text": "cashBalance" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "CashBalance", + "url": "package:_common/src/models/cash_balance.dart", + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "CashBalance", + "url": "package:_common/src/models/cash_balance.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 279, + "uri": "package:celest_backend/src/functions/models.dart", + "line": 9, + "column": 12 + }, + "end": { + "offset": 290, + "uri": "package:celest_backend/src/functions/models.dart", + "line": 9, + "column": 23 + }, + "text": "cashBalance" + } + }, + "portfolio": { + "name": "portfolio", + "apiName": "models", + "typeParameters": [], + "parameters": [ + { + "name": "portfolio", + "type": { + "$": "TypeReference", + "symbol": "Portfolio", + "url": "package:_common/src/models/portfolio.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 369, + "uri": "package:celest_backend/src/functions/models.dart", + "line": 11, + "column": 30 + }, + "end": { + "offset": 378, + "uri": "package:celest_backend/src/functions/models.dart", + "line": 11, + "column": 39 + }, + "text": "portfolio" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "Portfolio", + "url": "package:_common/src/models/portfolio.dart", + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "Portfolio", + "url": "package:_common/src/models/portfolio.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 349, + "uri": "package:celest_backend/src/functions/models.dart", + "line": 11, + "column": 10 + }, + "end": { + "offset": 358, + "uri": "package:celest_backend/src/functions/models.dart", + "line": 11, + "column": 19 + }, + "text": "portfolio" + } + }, + "stock": { + "name": "stock", + "apiName": "models", + "typeParameters": [], + "parameters": [ + { + "name": "stock", + "type": { + "$": "TypeReference", + "symbol": "Stock", + "url": "package:_common/src/models/stock.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 419, + "uri": "package:celest_backend/src/functions/models.dart", + "line": 13, + "column": 18 + }, + "end": { + "offset": 424, + "uri": "package:celest_backend/src/functions/models.dart", + "line": 13, + "column": 23 + }, + "text": "stock" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "Stock", + "url": "package:_common/src/models/stock.dart", + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "Stock", + "url": "package:_common/src/models/stock.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 407, + "uri": "package:celest_backend/src/functions/models.dart", + "line": 13, + "column": 6 + }, + "end": { + "offset": 412, + "uri": "package:celest_backend/src/functions/models.dart", + "line": 13, + "column": 11 + }, + "text": "stock" + } + }, + "ui": { + "name": "ui", + "apiName": "models", + "typeParameters": [], + "parameters": [ + { + "name": "ui", + "type": { + "$": "TypeReference", + "symbol": "Ui", + "url": "package:_common/src/models/ui.dart", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 452, + "uri": "package:celest_backend/src/functions/models.dart", + "line": 15, + "column": 9 + }, + "end": { + "offset": 454, + "uri": "package:celest_backend/src/functions/models.dart", + "line": 15, + "column": 11 + }, + "text": "ui" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "Ui", + "url": "package:_common/src/models/ui.dart", + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "Ui", + "url": "package:_common/src/models/ui.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 446, + "uri": "package:celest_backend/src/functions/models.dart", + "line": 15, + "column": 3 + }, + "end": { + "offset": 448, + "uri": "package:celest_backend/src/functions/models.dart", + "line": 15, + "column": 5 + }, + "text": "ui" + } + } + }, + "docs": [], + "exceptionTypes": [ + { + "$": "TypeReference", + "symbol": "UserException", + "url": "package:_common/src/models/errors_and_exceptions.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AppError", + "url": "package:celest_backend/exceptions/overrides.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AppException", + "url": "package:celest_backend/exceptions/overrides.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "NotYetImplementedError", + "url": "package:celest_backend/exceptions/overrides.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ValidateError", + "url": "package:_common/src/models/errors_and_exceptions.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UserException_ShowInConsole", + "url": "package:celest_backend/exceptions/overrides.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "Error", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AssertionError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "TypeError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ArgumentError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "RangeError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "IndexError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnsupportedError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnimplementedError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "StateError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ConcurrentModificationError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "OutOfMemoryError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "StackOverflowError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "Exception", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "FormatException", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "IntegerDivisionByZeroException", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AsyncError", + "url": "dart:async", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "TimeoutException", + "url": "dart:async", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "JsonUnsupportedObjectError", + "url": "dart:convert", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "CloudException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "CancelledException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnknownError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "BadRequestException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnauthorizedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "NotFoundException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AlreadyExistsException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "PermissionDeniedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ResourceExhaustedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "FailedPreconditionException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AbortedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "OutOfRangeException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnimplementedError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "InternalServerError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnavailableError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "DataLossError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "DeadlineExceededError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "SerializationException", + "url": "package:celest_core/src/exception/serialization_exception.dart", + "isNullable": false + } + ], + "location": { + "start": { + "offset": 0, + "uri": "package:celest_backend/src/functions/models.dart", + "line": 0, + "column": 0 + }, + "end": { + "offset": 0, + "uri": "package:celest_backend/src/functions/models.dart", + "line": 0, + "column": 0 + }, + "text": "" + } + } + }, + "variables": [], + "secrets": [], + "databases": {}, + "sdkConfig": { + "celest": "1.0.6+2", + "dart": { + "type": "dart", + "version": "3.29.0", + "enabledExperiments": [] + }, + "targetSdk": "dart", + "featureFlags": [ + "streaming" + ], + "flutter": { + "type": "flutter", + "version": "3.29.0", + "enabledExperiments": [] + } + }, + "location": { + "start": { + "offset": 44, + "uri": "project.dart", + "line": 2, + "column": 6 + }, + "end": { + "offset": 78, + "uri": "project.dart", + "line": 2, + "column": 40 + }, + "text": "project = Project(name: 'marcelo')" + } +} \ No newline at end of file diff --git a/apps/cli/fixtures/legacy/marcelo/goldens/ast.resolved.json b/apps/cli/fixtures/legacy/marcelo/goldens/ast.resolved.json new file mode 100644 index 000000000..6eb57e4e9 --- /dev/null +++ b/apps/cli/fixtures/legacy/marcelo/goldens/ast.resolved.json @@ -0,0 +1,249 @@ +{ + "projectId": "marcelo", + "environmentId": "local", + "apis": { + "exceptions": { + "apiId": "exceptions", + "functions": { + "throwsUserException": { + "functionId": "throwsUserException", + "apiId": "exceptions", + "httpConfig": { + "route": { + "method": "POST", + "path": "/exceptions/throws-user-exception" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "callsThrowsUserException": { + "functionId": "callsThrowsUserException", + "apiId": "exceptions", + "httpConfig": { + "route": { + "method": "POST", + "path": "/exceptions/calls-throws-user-exception" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "throwsAppError": { + "functionId": "throwsAppError", + "apiId": "exceptions", + "httpConfig": { + "route": { + "method": "POST", + "path": "/exceptions/throws-app-error" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "throwsAppException": { + "functionId": "throwsAppException", + "apiId": "exceptions", + "httpConfig": { + "route": { + "method": "POST", + "path": "/exceptions/throws-app-exception" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "throwsNotYetImplementedError": { + "functionId": "throwsNotYetImplementedError", + "apiId": "exceptions", + "httpConfig": { + "route": { + "method": "POST", + "path": "/exceptions/throws-not-yet-implemented-error" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "throwsValidateError": { + "functionId": "throwsValidateError", + "apiId": "exceptions", + "httpConfig": { + "route": { + "method": "POST", + "path": "/exceptions/throws-validate-error" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "throwsUserException_ShowInConsole": { + "functionId": "throwsUserException_ShowInConsole", + "apiId": "exceptions", + "httpConfig": { + "route": { + "method": "POST", + "path": "/exceptions/throws-user-exception-show-in-console" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + } + } + }, + "models": { + "apiId": "models", + "functions": { + "availableStock": { + "functionId": "availableStock", + "apiId": "models", + "httpConfig": { + "route": { + "method": "POST", + "path": "/models/available-stock" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "availableStocks": { + "functionId": "availableStocks", + "apiId": "models", + "httpConfig": { + "route": { + "method": "POST", + "path": "/models/available-stocks" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "cashBalance": { + "functionId": "cashBalance", + "apiId": "models", + "httpConfig": { + "route": { + "method": "POST", + "path": "/models/cash-balance" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "portfolio": { + "functionId": "portfolio", + "apiId": "models", + "httpConfig": { + "route": { + "method": "POST", + "path": "/models/portfolio" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "stock": { + "functionId": "stock", + "apiId": "models", + "httpConfig": { + "route": { + "method": "POST", + "path": "/models/stock" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + }, + "ui": { + "functionId": "ui", + "apiId": "models", + "httpConfig": { + "route": { + "method": "POST", + "path": "/models/ui" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {} + } + } + } + }, + "variables": [ + { + "name": "CELEST_ENVIRONMENT", + "value": "local" + } + ], + "secrets": [], + "databases": {}, + "sdkConfig": { + "celest": "1.0.6+2", + "dart": { + "type": "dart", + "version": "3.29.0", + "enabledExperiments": [] + }, + "targetSdk": "dart", + "featureFlags": [ + "streaming" + ], + "flutter": { + "type": "flutter", + "version": "3.29.0", + "enabledExperiments": [] + } + } +} \ No newline at end of file diff --git a/apps/cli/fixtures/legacy/marcelo/goldens/celest.json b/apps/cli/fixtures/legacy/marcelo/goldens/celest.json new file mode 100644 index 000000000..50751d6d1 --- /dev/null +++ b/apps/cli/fixtures/legacy/marcelo/goldens/celest.json @@ -0,0 +1,251 @@ +{ + "projectId": "marcelo", + "environmentId": "local", + "apis": { + "exceptions": { + "apiId": "exceptions", + "functions": { + "throwsUserException": { + "functionId": "throwsUserException", + "parentId": "exceptions", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/exceptions/throws-user-exception" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "callsThrowsUserException": { + "functionId": "callsThrowsUserException", + "parentId": "exceptions", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/exceptions/calls-throws-user-exception" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "throwsAppError": { + "functionId": "throwsAppError", + "parentId": "exceptions", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/exceptions/throws-app-error" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "throwsAppException": { + "functionId": "throwsAppException", + "parentId": "exceptions", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/exceptions/throws-app-exception" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "throwsNotYetImplementedError": { + "functionId": "throwsNotYetImplementedError", + "parentId": "exceptions", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/exceptions/throws-not-yet-implemented-error" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "throwsValidateError": { + "functionId": "throwsValidateError", + "parentId": "exceptions", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/exceptions/throws-validate-error" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "throwsUserException_ShowInConsole": { + "functionId": "throwsUserException_ShowInConsole", + "parentId": "exceptions", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/exceptions/throws-user-exception-show-in-console" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + } + } + }, + "models": { + "apiId": "models", + "functions": { + "availableStock": { + "functionId": "availableStock", + "parentId": "models", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/models/available-stock" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "availableStocks": { + "functionId": "availableStocks", + "parentId": "models", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/models/available-stocks" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "cashBalance": { + "functionId": "cashBalance", + "parentId": "models", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/models/cash-balance" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "portfolio": { + "functionId": "portfolio", + "parentId": "models", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/models/portfolio" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "stock": { + "functionId": "stock", + "parentId": "models", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/models/stock" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + }, + "ui": { + "functionId": "ui", + "parentId": "models", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/models/ui" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + } + } + } + } + }, + "variables": [ + { + "name": "CELEST_ENVIRONMENT", + "value": "local" + } + ], + "databases": {}, + "sdkConfig": { + "celest": { + "major": 1, + "minor": 0, + "patch": 6, + "build": [ + 2.0 + ], + "canonicalizedVersion": "1.0.6+2" + }, + "dart": { + "type": "DART", + "version": { + "major": 3, + "minor": 29, + "patch": 0, + "canonicalizedVersion": "3.29.0" + } + }, + "flutter": { + "type": "FLUTTER", + "version": { + "major": 3, + "minor": 29, + "patch": 0, + "canonicalizedVersion": "3.29.0" + } + }, + "targetSdk": "DART", + "featureFlags": [ + "STREAMING" + ] + } +} \ No newline at end of file diff --git a/apps/cli/fixtures/legacy/marcelo/goldens/functions/exceptions/callsThrowsUserException.dart b/apps/cli/fixtures/legacy/marcelo/goldens/functions/exceptions/callsThrowsUserException.dart new file mode 100644 index 000000000..e44447b24 --- /dev/null +++ b/apps/cli/fixtures/legacy/marcelo/goldens/functions/exceptions/callsThrowsUserException.dart @@ -0,0 +1,1945 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i10; +import 'dart:convert' as _i11; + +import 'package:_common/src/models/errors_and_exceptions.dart' as _i13; +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/exceptions/overrides.dart' as _i9; +import 'package:celest_backend/src/functions/exceptions.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i12; +import 'package:celest_core/src/serialization/json_value.dart' as _i5; +import 'package:shelf/shelf.dart' as _i2; + +final class CallsThrowsUserExceptionTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'callsThrowsUserException'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + _i3.callsThrowsUserException( + cause: _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + request[r'cause'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(null), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AppError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'marcelo.v1.AppError', + 'value': _i4.Serializers.instance.serialize<_i9.AppError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AppException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'marcelo.v1.AppException', + 'value': _i4.Serializers.instance.serialize<_i9.AppException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i10.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i11.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.NotYetImplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'marcelo.v1.NotYetImplementedError', + 'value': _i4.Serializers.instance + .serialize<_i9.NotYetImplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i12.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i12.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance + .serialize<_i10.TimeoutException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.UserException_ShowInConsole catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'marcelo.v1.UserException_ShowInConsole', + 'value': _i4.Serializers.instance + .serialize<_i9.UserException_ShowInConsole>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i13.UserException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': '_common.UserException', + 'value': _i4.Serializers.instance.serialize<_i13.UserException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i13.ValidateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': '_common.ValidateError', + 'value': _i4.Serializers.instance.serialize<_i13.ValidateError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i10.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i10.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i11.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i11.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.UserException, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i13.UserException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.ValidateError, Map>( + serialize: ($value) => {r'msg': $value.msg}, + deserialize: ($serialized) { + return _i13.ValidateError(($serialized[r'msg'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AppError, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i9.AppError.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AppException, Map?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.error, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final error?) + r'error': error, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.msg, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final msg?) + r'msg': msg, + }, + deserialize: ($serialized) { + return (_i13.AppException( + $serialized?[r'msg'], + $serialized?[r'error'], + ) + as _i9.AppException); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.NotYetImplementedError, Map?>( + serialize: + ($value) => { + r'msg': $value.msg, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.message, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final message?) + r'message': message, + }, + deserialize: ($serialized) { + return _i9.NotYetImplementedError( + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'message'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.UserException_ShowInConsole, + Map + >( + serialize: + ($value) => { + if ($value.msg case final msg?) r'msg': msg, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.cause, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final cause?) + r'cause': cause, + }, + deserialize: ($serialized) { + return _i9.UserException_ShowInConsole( + msg: ($serialized[r'msg'] as String), + cause: _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized[r'cause'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i12.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i5.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': CallsThrowsUserExceptionTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/marcelo/goldens/functions/exceptions/throwsAppError.dart b/apps/cli/fixtures/legacy/marcelo/goldens/functions/exceptions/throwsAppError.dart new file mode 100644 index 000000000..51f75908d --- /dev/null +++ b/apps/cli/fixtures/legacy/marcelo/goldens/functions/exceptions/throwsAppError.dart @@ -0,0 +1,1946 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i10; +import 'dart:convert' as _i11; + +import 'package:_common/src/models/errors_and_exceptions.dart' as _i13; +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/exceptions/overrides.dart' as _i9; +import 'package:celest_backend/src/functions/exceptions.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i12; +import 'package:celest_core/src/serialization/json_value.dart' as _i5; +import 'package:shelf/shelf.dart' as _i2; + +final class ThrowsAppErrorTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'throwsAppError'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + _i3.throwsAppError( + message: ((request[r'message'] as String?)) ?? 'message', + error: _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + request[r'error'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(null), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AppError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'marcelo.v1.AppError', + 'value': _i4.Serializers.instance.serialize<_i9.AppError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AppException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'marcelo.v1.AppException', + 'value': _i4.Serializers.instance.serialize<_i9.AppException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i10.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i11.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.NotYetImplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'marcelo.v1.NotYetImplementedError', + 'value': _i4.Serializers.instance + .serialize<_i9.NotYetImplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i12.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i12.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance + .serialize<_i10.TimeoutException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.UserException_ShowInConsole catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'marcelo.v1.UserException_ShowInConsole', + 'value': _i4.Serializers.instance + .serialize<_i9.UserException_ShowInConsole>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i13.UserException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': '_common.UserException', + 'value': _i4.Serializers.instance.serialize<_i13.UserException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i13.ValidateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': '_common.ValidateError', + 'value': _i4.Serializers.instance.serialize<_i13.ValidateError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i10.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i10.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i11.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i11.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.UserException, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i13.UserException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.ValidateError, Map>( + serialize: ($value) => {r'msg': $value.msg}, + deserialize: ($serialized) { + return _i13.ValidateError(($serialized[r'msg'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AppError, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i9.AppError.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AppException, Map?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.error, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final error?) + r'error': error, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.msg, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final msg?) + r'msg': msg, + }, + deserialize: ($serialized) { + return (_i13.AppException( + $serialized?[r'msg'], + $serialized?[r'error'], + ) + as _i9.AppException); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.NotYetImplementedError, Map?>( + serialize: + ($value) => { + r'msg': $value.msg, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.message, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final message?) + r'message': message, + }, + deserialize: ($serialized) { + return _i9.NotYetImplementedError( + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'message'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.UserException_ShowInConsole, + Map + >( + serialize: + ($value) => { + if ($value.msg case final msg?) r'msg': msg, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.cause, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final cause?) + r'cause': cause, + }, + deserialize: ($serialized) { + return _i9.UserException_ShowInConsole( + msg: ($serialized[r'msg'] as String), + cause: _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized[r'cause'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i12.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i5.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': ThrowsAppErrorTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/marcelo/goldens/functions/exceptions/throwsAppException.dart b/apps/cli/fixtures/legacy/marcelo/goldens/functions/exceptions/throwsAppException.dart new file mode 100644 index 000000000..750a183d6 --- /dev/null +++ b/apps/cli/fixtures/legacy/marcelo/goldens/functions/exceptions/throwsAppException.dart @@ -0,0 +1,1941 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:_common/src/models/errors_and_exceptions.dart' as _i12; +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/exceptions/overrides.dart' as _i8; +import 'package:celest_backend/src/functions/exceptions.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i13; +import 'package:shelf/shelf.dart' as _i2; + +final class ThrowsAppExceptionTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'throwsAppException'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + _i3.throwsAppException(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(null), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AppError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'marcelo.v1.AppError', + 'value': _i4.Serializers.instance.serialize<_i8.AppError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AppException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'marcelo.v1.AppException', + 'value': _i4.Serializers.instance.serialize<_i8.AppException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.NotYetImplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'marcelo.v1.NotYetImplementedError', + 'value': _i4.Serializers.instance + .serialize<_i8.NotYetImplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.UserException_ShowInConsole catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'marcelo.v1.UserException_ShowInConsole', + 'value': _i4.Serializers.instance + .serialize<_i8.UserException_ShowInConsole>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i12.UserException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': '_common.UserException', + 'value': _i4.Serializers.instance.serialize<_i12.UserException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i12.ValidateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': '_common.ValidateError', + 'value': _i4.Serializers.instance.serialize<_i12.ValidateError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.UserException, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i12.UserException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.ValidateError, Map>( + serialize: ($value) => {r'msg': $value.msg}, + deserialize: ($serialized) { + return _i12.ValidateError(($serialized[r'msg'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AppError, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i8.AppError.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AppException, Map?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.error, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final error?) + r'error': error, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.msg, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final msg?) + r'msg': msg, + }, + deserialize: ($serialized) { + return (_i12.AppException( + $serialized?[r'msg'], + $serialized?[r'error'], + ) + as _i8.AppException); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.NotYetImplementedError, Map?>( + serialize: + ($value) => { + r'msg': $value.msg, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.message, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final message?) + r'message': message, + }, + deserialize: ($serialized) { + return _i8.NotYetImplementedError( + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'message'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i8.UserException_ShowInConsole, + Map + >( + serialize: + ($value) => { + if ($value.msg case final msg?) r'msg': msg, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.cause, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final cause?) + r'cause': cause, + }, + deserialize: ($serialized) { + return _i8.UserException_ShowInConsole( + msg: ($serialized[r'msg'] as String), + cause: _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized[r'cause'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i13.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': ThrowsAppExceptionTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/marcelo/goldens/functions/exceptions/throwsNotYetImplementedError.dart b/apps/cli/fixtures/legacy/marcelo/goldens/functions/exceptions/throwsNotYetImplementedError.dart new file mode 100644 index 000000000..6bcc6f253 --- /dev/null +++ b/apps/cli/fixtures/legacy/marcelo/goldens/functions/exceptions/throwsNotYetImplementedError.dart @@ -0,0 +1,1942 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:_common/src/models/errors_and_exceptions.dart' as _i12; +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/exceptions/overrides.dart' as _i8; +import 'package:celest_backend/src/functions/exceptions.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i13; +import 'package:shelf/shelf.dart' as _i2; + +final class ThrowsNotYetImplementedErrorTarget + extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'throwsNotYetImplementedError'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + _i3.throwsNotYetImplementedError(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(null), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AppError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'marcelo.v1.AppError', + 'value': _i4.Serializers.instance.serialize<_i8.AppError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AppException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'marcelo.v1.AppException', + 'value': _i4.Serializers.instance.serialize<_i8.AppException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.NotYetImplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'marcelo.v1.NotYetImplementedError', + 'value': _i4.Serializers.instance + .serialize<_i8.NotYetImplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.UserException_ShowInConsole catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'marcelo.v1.UserException_ShowInConsole', + 'value': _i4.Serializers.instance + .serialize<_i8.UserException_ShowInConsole>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i12.UserException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': '_common.UserException', + 'value': _i4.Serializers.instance.serialize<_i12.UserException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i12.ValidateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': '_common.ValidateError', + 'value': _i4.Serializers.instance.serialize<_i12.ValidateError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.UserException, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i12.UserException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.ValidateError, Map>( + serialize: ($value) => {r'msg': $value.msg}, + deserialize: ($serialized) { + return _i12.ValidateError(($serialized[r'msg'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AppError, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i8.AppError.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AppException, Map?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.error, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final error?) + r'error': error, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.msg, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final msg?) + r'msg': msg, + }, + deserialize: ($serialized) { + return (_i12.AppException( + $serialized?[r'msg'], + $serialized?[r'error'], + ) + as _i8.AppException); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.NotYetImplementedError, Map?>( + serialize: + ($value) => { + r'msg': $value.msg, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.message, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final message?) + r'message': message, + }, + deserialize: ($serialized) { + return _i8.NotYetImplementedError( + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'message'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i8.UserException_ShowInConsole, + Map + >( + serialize: + ($value) => { + if ($value.msg case final msg?) r'msg': msg, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.cause, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final cause?) + r'cause': cause, + }, + deserialize: ($serialized) { + return _i8.UserException_ShowInConsole( + msg: ($serialized[r'msg'] as String), + cause: _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized[r'cause'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i13.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': ThrowsNotYetImplementedErrorTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/marcelo/goldens/functions/exceptions/throwsUserException.dart b/apps/cli/fixtures/legacy/marcelo/goldens/functions/exceptions/throwsUserException.dart new file mode 100644 index 000000000..b84ffc0fd --- /dev/null +++ b/apps/cli/fixtures/legacy/marcelo/goldens/functions/exceptions/throwsUserException.dart @@ -0,0 +1,1945 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i10; +import 'dart:convert' as _i11; + +import 'package:_common/src/models/errors_and_exceptions.dart' as _i13; +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/exceptions/overrides.dart' as _i9; +import 'package:celest_backend/src/functions/exceptions.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i12; +import 'package:celest_core/src/serialization/json_value.dart' as _i5; +import 'package:shelf/shelf.dart' as _i2; + +final class ThrowsUserExceptionTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'throwsUserException'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + _i3.throwsUserException( + cause: _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + request[r'cause'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(null), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AppError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'marcelo.v1.AppError', + 'value': _i4.Serializers.instance.serialize<_i9.AppError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AppException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'marcelo.v1.AppException', + 'value': _i4.Serializers.instance.serialize<_i9.AppException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i10.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i11.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.NotYetImplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'marcelo.v1.NotYetImplementedError', + 'value': _i4.Serializers.instance + .serialize<_i9.NotYetImplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i12.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i12.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance + .serialize<_i10.TimeoutException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.UserException_ShowInConsole catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'marcelo.v1.UserException_ShowInConsole', + 'value': _i4.Serializers.instance + .serialize<_i9.UserException_ShowInConsole>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i13.UserException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': '_common.UserException', + 'value': _i4.Serializers.instance.serialize<_i13.UserException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i13.ValidateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': '_common.ValidateError', + 'value': _i4.Serializers.instance.serialize<_i13.ValidateError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i10.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i10.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i11.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i11.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.UserException, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i13.UserException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.ValidateError, Map>( + serialize: ($value) => {r'msg': $value.msg}, + deserialize: ($serialized) { + return _i13.ValidateError(($serialized[r'msg'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AppError, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i9.AppError.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AppException, Map?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.error, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final error?) + r'error': error, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.msg, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final msg?) + r'msg': msg, + }, + deserialize: ($serialized) { + return (_i13.AppException( + $serialized?[r'msg'], + $serialized?[r'error'], + ) + as _i9.AppException); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.NotYetImplementedError, Map?>( + serialize: + ($value) => { + r'msg': $value.msg, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.message, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final message?) + r'message': message, + }, + deserialize: ($serialized) { + return _i9.NotYetImplementedError( + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'message'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.UserException_ShowInConsole, + Map + >( + serialize: + ($value) => { + if ($value.msg case final msg?) r'msg': msg, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.cause, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final cause?) + r'cause': cause, + }, + deserialize: ($serialized) { + return _i9.UserException_ShowInConsole( + msg: ($serialized[r'msg'] as String), + cause: _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized[r'cause'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i12.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i5.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': ThrowsUserExceptionTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/marcelo/goldens/functions/exceptions/throwsUserException_ShowInConsole.dart b/apps/cli/fixtures/legacy/marcelo/goldens/functions/exceptions/throwsUserException_ShowInConsole.dart new file mode 100644 index 000000000..761745a9e --- /dev/null +++ b/apps/cli/fixtures/legacy/marcelo/goldens/functions/exceptions/throwsUserException_ShowInConsole.dart @@ -0,0 +1,1947 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i10; +import 'dart:convert' as _i11; + +import 'package:_common/src/models/errors_and_exceptions.dart' as _i13; +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/exceptions/overrides.dart' as _i9; +import 'package:celest_backend/src/functions/exceptions.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i12; +import 'package:celest_core/src/serialization/json_value.dart' as _i5; +import 'package:shelf/shelf.dart' as _i2; + +final class ThrowsUserExceptionShowInConsoleTarget + extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'throwsUserException_ShowInConsole'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + _i3.throwsUserException_ShowInConsole( + message: ((request[r'message'] as String?)) ?? 'message', + cause: _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + request[r'cause'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(null), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AppError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'marcelo.v1.AppError', + 'value': _i4.Serializers.instance.serialize<_i9.AppError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AppException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'marcelo.v1.AppException', + 'value': _i4.Serializers.instance.serialize<_i9.AppException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i10.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i11.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.NotYetImplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'marcelo.v1.NotYetImplementedError', + 'value': _i4.Serializers.instance + .serialize<_i9.NotYetImplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i12.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i12.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance + .serialize<_i10.TimeoutException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.UserException_ShowInConsole catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'marcelo.v1.UserException_ShowInConsole', + 'value': _i4.Serializers.instance + .serialize<_i9.UserException_ShowInConsole>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i13.UserException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': '_common.UserException', + 'value': _i4.Serializers.instance.serialize<_i13.UserException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i13.ValidateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': '_common.ValidateError', + 'value': _i4.Serializers.instance.serialize<_i13.ValidateError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i10.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i10.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i11.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i11.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.UserException, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i13.UserException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.ValidateError, Map>( + serialize: ($value) => {r'msg': $value.msg}, + deserialize: ($serialized) { + return _i13.ValidateError(($serialized[r'msg'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AppError, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i9.AppError.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AppException, Map?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.error, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final error?) + r'error': error, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.msg, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final msg?) + r'msg': msg, + }, + deserialize: ($serialized) { + return (_i13.AppException( + $serialized?[r'msg'], + $serialized?[r'error'], + ) + as _i9.AppException); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.NotYetImplementedError, Map?>( + serialize: + ($value) => { + r'msg': $value.msg, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.message, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final message?) + r'message': message, + }, + deserialize: ($serialized) { + return _i9.NotYetImplementedError( + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'message'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.UserException_ShowInConsole, + Map + >( + serialize: + ($value) => { + if ($value.msg case final msg?) r'msg': msg, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.cause, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final cause?) + r'cause': cause, + }, + deserialize: ($serialized) { + return _i9.UserException_ShowInConsole( + msg: ($serialized[r'msg'] as String), + cause: _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized[r'cause'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i5.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i5.JsonValue?>( + $value.details, + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i12.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i5.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i5.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': ThrowsUserExceptionShowInConsoleTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/marcelo/goldens/functions/exceptions/throwsValidateError.dart b/apps/cli/fixtures/legacy/marcelo/goldens/functions/exceptions/throwsValidateError.dart new file mode 100644 index 000000000..da1560d24 --- /dev/null +++ b/apps/cli/fixtures/legacy/marcelo/goldens/functions/exceptions/throwsValidateError.dart @@ -0,0 +1,1941 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i9; +import 'dart:convert' as _i10; + +import 'package:_common/src/models/errors_and_exceptions.dart' as _i12; +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/exceptions/overrides.dart' as _i8; +import 'package:celest_backend/src/functions/exceptions.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i13; +import 'package:shelf/shelf.dart' as _i2; + +final class ThrowsValidateErrorTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'throwsValidateError'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + _i3.throwsValidateError(); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(null), + ); + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AppError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'marcelo.v1.AppError', + 'value': _i4.Serializers.instance.serialize<_i8.AppError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.AppException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'marcelo.v1.AppException', + 'value': _i4.Serializers.instance.serialize<_i8.AppException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i9.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i10.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.NotYetImplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'marcelo.v1.NotYetImplementedError', + 'value': _i4.Serializers.instance + .serialize<_i8.NotYetImplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance.serialize<_i9.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i8.UserException_ShowInConsole catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'marcelo.v1.UserException_ShowInConsole', + 'value': _i4.Serializers.instance + .serialize<_i8.UserException_ShowInConsole>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i12.UserException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': '_common.UserException', + 'value': _i4.Serializers.instance.serialize<_i12.UserException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i12.ValidateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': '_common.ValidateError', + 'value': _i4.Serializers.instance.serialize<_i12.ValidateError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i9.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i9.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i10.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i10.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.UserException, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i12.UserException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.ValidateError, Map>( + serialize: ($value) => {r'msg': $value.msg}, + deserialize: ($serialized) { + return _i12.ValidateError(($serialized[r'msg'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AppError, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i8.AppError.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.AppException, Map?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.error, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final error?) + r'error': error, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.msg, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final msg?) + r'msg': msg, + }, + deserialize: ($serialized) { + return (_i12.AppException( + $serialized?[r'msg'], + $serialized?[r'error'], + ) + as _i8.AppException); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i8.NotYetImplementedError, Map?>( + serialize: + ($value) => { + r'msg': $value.msg, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.message, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final message?) + r'message': message, + }, + deserialize: ($serialized) { + return _i8.NotYetImplementedError( + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'message'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i8.UserException_ShowInConsole, + Map + >( + serialize: + ($value) => { + if ($value.msg case final msg?) r'msg': msg, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.cause, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final cause?) + r'cause': cause, + }, + deserialize: ($serialized) { + return _i8.UserException_ShowInConsole( + msg: ($serialized[r'msg'] as String), + cause: _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized[r'cause'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i13.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i13.JsonValue?>( + $value.details, + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i13.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i13.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': ThrowsValidateErrorTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/marcelo/goldens/functions/models/availableStock.dart b/apps/cli/fixtures/legacy/marcelo/goldens/functions/models/availableStock.dart new file mode 100644 index 000000000..4cbb0dd2c --- /dev/null +++ b/apps/cli/fixtures/legacy/marcelo/goldens/functions/models/availableStock.dart @@ -0,0 +1,1967 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i10; +import 'dart:convert' as _i11; + +import 'package:_common/src/models/available_stock.dart' as _i5; +import 'package:_common/src/models/errors_and_exceptions.dart' as _i13; +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/exceptions/overrides.dart' as _i9; +import 'package:celest_backend/models/overrides.dart' as _i15; +import 'package:celest_backend/src/functions/models.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i12; +import 'package:celest_core/src/serialization/json_value.dart' as _i14; +import 'package:shelf/shelf.dart' as _i2; + +final class AvailableStockTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'availableStock'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.availableStock( + _i4.Serializers.instance.deserialize<_i5.AvailableStock>( + request[r'availableStock'], + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.AvailableStock>(response), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AppError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'marcelo.v1.AppError', + 'value': _i4.Serializers.instance.serialize<_i9.AppError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AppException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'marcelo.v1.AppException', + 'value': _i4.Serializers.instance.serialize<_i9.AppException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i10.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i11.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.NotYetImplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'marcelo.v1.NotYetImplementedError', + 'value': _i4.Serializers.instance + .serialize<_i9.NotYetImplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i12.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i12.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance + .serialize<_i10.TimeoutException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.UserException_ShowInConsole catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'marcelo.v1.UserException_ShowInConsole', + 'value': _i4.Serializers.instance + .serialize<_i9.UserException_ShowInConsole>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i13.UserException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': '_common.UserException', + 'value': _i4.Serializers.instance.serialize<_i13.UserException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i13.ValidateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': '_common.ValidateError', + 'value': _i4.Serializers.instance.serialize<_i13.ValidateError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i10.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i10.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i11.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i11.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.UserException, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i13.UserException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.ValidateError, Map>( + serialize: ($value) => {r'msg': $value.msg}, + deserialize: ($serialized) { + return _i13.ValidateError(($serialized[r'msg'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AppError, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i9.AppError.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AppException, Map?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.error, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final error?) + r'error': error, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.msg, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final msg?) + r'msg': msg, + }, + deserialize: ($serialized) { + return (_i13.AppException( + $serialized?[r'msg'], + $serialized?[r'error'], + ) + as _i9.AppException); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.NotYetImplementedError, Map?>( + serialize: + ($value) => { + r'msg': $value.msg, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.message, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final message?) + r'message': message, + }, + deserialize: ($serialized) { + return _i9.NotYetImplementedError( + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'message'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.UserException_ShowInConsole, + Map + >( + serialize: + ($value) => { + if ($value.msg case final msg?) r'msg': msg, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.cause, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final cause?) + r'cause': cause, + }, + deserialize: ($serialized) { + return _i9.UserException_ShowInConsole( + msg: ($serialized[r'msg'] as String), + cause: _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized[r'cause'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i15.AvailableStock, Map>( + serialize: + ($value) => { + r'ticker': $value.ticker, + r'name': $value.name, + r'currentPrice': $value.currentPrice, + r'currentPriceStr': $value.currentPriceStr, + }, + deserialize: ($serialized) { + return (_i5.AvailableStock( + ($serialized[r'ticker'] as String), + name: ($serialized[r'name'] as String), + currentPrice: ($serialized[r'currentPrice'] as num).toDouble(), + ) + as _i15.AvailableStock); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i12.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i14.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i14.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': AvailableStockTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/marcelo/goldens/functions/models/availableStocks.dart b/apps/cli/fixtures/legacy/marcelo/goldens/functions/models/availableStocks.dart new file mode 100644 index 000000000..f807ff942 --- /dev/null +++ b/apps/cli/fixtures/legacy/marcelo/goldens/functions/models/availableStocks.dart @@ -0,0 +1,2004 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i10; +import 'dart:convert' as _i11; + +import 'package:_common/src/models/available_stock.dart' as _i15; +import 'package:_common/src/models/available_stocks.dart' as _i5; +import 'package:_common/src/models/errors_and_exceptions.dart' as _i13; +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/exceptions/overrides.dart' as _i9; +import 'package:celest_backend/models/overrides.dart' as _i17; +import 'package:celest_backend/src/functions/models.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i12; +import 'package:celest_core/src/serialization/json_value.dart' as _i16; +import 'package:fast_immutable_collections/src/ilist/ilist.dart' as _i14; +import 'package:shelf/shelf.dart' as _i2; + +final class AvailableStocksTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'availableStocks'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.availableStocks( + _i4.Serializers.instance.deserialize<_i5.AvailableStocks>( + request[r'availableStocks'], + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.AvailableStocks>(response), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AppError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'marcelo.v1.AppError', + 'value': _i4.Serializers.instance.serialize<_i9.AppError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AppException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'marcelo.v1.AppException', + 'value': _i4.Serializers.instance.serialize<_i9.AppException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i10.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i11.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.NotYetImplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'marcelo.v1.NotYetImplementedError', + 'value': _i4.Serializers.instance + .serialize<_i9.NotYetImplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i12.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i12.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance + .serialize<_i10.TimeoutException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.UserException_ShowInConsole catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'marcelo.v1.UserException_ShowInConsole', + 'value': _i4.Serializers.instance + .serialize<_i9.UserException_ShowInConsole>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i13.UserException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': '_common.UserException', + 'value': _i4.Serializers.instance.serialize<_i13.UserException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i13.ValidateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': '_common.ValidateError', + 'value': _i4.Serializers.instance.serialize<_i13.ValidateError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i10.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i10.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i11.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i11.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.AvailableStocks, Map>( + serialize: + ($value) => { + r'list': _i4.Serializers.instance + .serialize<_i14.IList<_i15.AvailableStock>>($value.list), + }, + deserialize: ($serialized) { + return _i5.AvailableStocks( + ($serialized[r'list'] as Iterable) + .map( + (el) => _i4.Serializers.instance + .deserialize<_i15.AvailableStock>(el), + ) + .toList(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.UserException, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i13.UserException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.ValidateError, Map>( + serialize: ($value) => {r'msg': $value.msg}, + deserialize: ($serialized) { + return _i13.ValidateError(($serialized[r'msg'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AppError, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i9.AppError.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AppException, Map?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize<_i16.JsonValue?>( + $value.error, + const _i4.TypeToken<_i16.JsonValue?>('JsonValue'), + ) + case final error?) + r'error': error, + if (_i4.Serializers.instance.serialize<_i16.JsonValue?>( + $value.msg, + const _i4.TypeToken<_i16.JsonValue?>('JsonValue'), + ) + case final msg?) + r'msg': msg, + }, + deserialize: ($serialized) { + return (_i13.AppException( + $serialized?[r'msg'], + $serialized?[r'error'], + ) + as _i9.AppException); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.NotYetImplementedError, Map?>( + serialize: + ($value) => { + r'msg': $value.msg, + if (_i4.Serializers.instance.serialize<_i16.JsonValue?>( + $value.message, + const _i4.TypeToken<_i16.JsonValue?>('JsonValue'), + ) + case final message?) + r'message': message, + }, + deserialize: ($serialized) { + return _i9.NotYetImplementedError( + _i4.Serializers.instance.deserialize<_i16.JsonValue?>( + $serialized?[r'message'], + const _i4.TypeToken<_i16.JsonValue?>('JsonValue'), + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.UserException_ShowInConsole, + Map + >( + serialize: + ($value) => { + if ($value.msg case final msg?) r'msg': msg, + if (_i4.Serializers.instance.serialize<_i16.JsonValue?>( + $value.cause, + const _i4.TypeToken<_i16.JsonValue?>('JsonValue'), + ) + case final cause?) + r'cause': cause, + }, + deserialize: ($serialized) { + return _i9.UserException_ShowInConsole( + msg: ($serialized[r'msg'] as String), + cause: _i4.Serializers.instance.deserialize<_i16.JsonValue?>( + $serialized[r'cause'], + const _i4.TypeToken<_i16.JsonValue?>('JsonValue'), + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i17.AvailableStock, Map>( + serialize: + ($value) => { + r'ticker': $value.ticker, + r'name': $value.name, + r'currentPrice': $value.currentPrice, + r'currentPriceStr': $value.currentPriceStr, + }, + deserialize: ($serialized) { + return (_i15.AvailableStock( + ($serialized[r'ticker'] as String), + name: ($serialized[r'name'] as String), + currentPrice: ($serialized[r'currentPrice'] as num).toDouble(), + ) + as _i17.AvailableStock); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i16.JsonValue?>( + $value.details, + const _i4.TypeToken<_i16.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i16.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i16.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i16.JsonValue?>( + $value.details, + const _i4.TypeToken<_i16.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i16.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i16.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i16.JsonValue?>( + $value.details, + const _i4.TypeToken<_i16.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i16.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i16.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i16.JsonValue?>( + $value.details, + const _i4.TypeToken<_i16.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i16.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i16.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i16.JsonValue?>( + $value.details, + const _i4.TypeToken<_i16.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i16.JsonValue?>( + $value.details, + const _i4.TypeToken<_i16.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i16.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i16.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i16.JsonValue?>( + $value.details, + const _i4.TypeToken<_i16.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i16.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i16.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i16.JsonValue?>( + $value.details, + const _i4.TypeToken<_i16.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i16.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i16.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i16.JsonValue?>( + $value.details, + const _i4.TypeToken<_i16.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i16.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i16.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i16.JsonValue?>( + $value.details, + const _i4.TypeToken<_i16.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i16.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i16.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i16.JsonValue?>( + $value.details, + const _i4.TypeToken<_i16.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i16.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i16.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i16.JsonValue?>( + $value.details, + const _i4.TypeToken<_i16.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i16.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i16.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i16.JsonValue?>( + $value.details, + const _i4.TypeToken<_i16.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i16.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i16.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i16.JsonValue?>( + $value.details, + const _i4.TypeToken<_i16.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i16.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i16.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i16.JsonValue?>( + $value.details, + const _i4.TypeToken<_i16.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i16.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i16.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i16.JsonValue?>( + $value.details, + const _i4.TypeToken<_i16.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i16.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i16.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i16.JsonValue?>( + $value.details, + const _i4.TypeToken<_i16.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i16.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i16.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i16.JsonValue?>( + $value.details, + const _i4.TypeToken<_i16.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i12.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i16.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i16.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i16.JsonValue?>('JsonValue'), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i14.IList<_i15.AvailableStock>, dynamic>( + serialize: + ($value) => $value.toJson( + (value) => _i4.Serializers.instance + .serialize<_i15.AvailableStock>(value), + ), + deserialize: ($serialized) { + return _i14.IList<_i15.AvailableStock>.fromJson( + $serialized, + (value) => _i4.Serializers.instance + .deserialize<_i15.AvailableStock>(value), + ); + }, + ), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': AvailableStocksTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/marcelo/goldens/functions/models/cashBalance.dart b/apps/cli/fixtures/legacy/marcelo/goldens/functions/models/cashBalance.dart new file mode 100644 index 000000000..a58ce40b6 --- /dev/null +++ b/apps/cli/fixtures/legacy/marcelo/goldens/functions/models/cashBalance.dart @@ -0,0 +1,1957 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i10; +import 'dart:convert' as _i11; + +import 'package:_common/src/models/cash_balance.dart' as _i5; +import 'package:_common/src/models/errors_and_exceptions.dart' as _i13; +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/exceptions/overrides.dart' as _i9; +import 'package:celest_backend/models/overrides.dart' as _i15; +import 'package:celest_backend/src/functions/models.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i12; +import 'package:celest_core/src/serialization/json_value.dart' as _i14; +import 'package:shelf/shelf.dart' as _i2; + +final class CashBalanceTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'cashBalance'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.cashBalance( + _i4.Serializers.instance.deserialize<_i5.CashBalance>( + request[r'cashBalance'], + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.CashBalance>(response), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AppError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'marcelo.v1.AppError', + 'value': _i4.Serializers.instance.serialize<_i9.AppError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AppException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'marcelo.v1.AppException', + 'value': _i4.Serializers.instance.serialize<_i9.AppException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i10.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i11.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.NotYetImplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'marcelo.v1.NotYetImplementedError', + 'value': _i4.Serializers.instance + .serialize<_i9.NotYetImplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i12.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i12.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance + .serialize<_i10.TimeoutException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.UserException_ShowInConsole catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'marcelo.v1.UserException_ShowInConsole', + 'value': _i4.Serializers.instance + .serialize<_i9.UserException_ShowInConsole>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i13.UserException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': '_common.UserException', + 'value': _i4.Serializers.instance.serialize<_i13.UserException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i13.ValidateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': '_common.ValidateError', + 'value': _i4.Serializers.instance.serialize<_i13.ValidateError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i10.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i10.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i11.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i11.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.UserException, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i13.UserException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.ValidateError, Map>( + serialize: ($value) => {r'msg': $value.msg}, + deserialize: ($serialized) { + return _i13.ValidateError(($serialized[r'msg'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AppError, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i9.AppError.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AppException, Map?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.error, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final error?) + r'error': error, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.msg, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final msg?) + r'msg': msg, + }, + deserialize: ($serialized) { + return (_i13.AppException( + $serialized?[r'msg'], + $serialized?[r'error'], + ) + as _i9.AppException); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.NotYetImplementedError, Map?>( + serialize: + ($value) => { + r'msg': $value.msg, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.message, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final message?) + r'message': message, + }, + deserialize: ($serialized) { + return _i9.NotYetImplementedError( + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'message'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.UserException_ShowInConsole, + Map + >( + serialize: + ($value) => { + if ($value.msg case final msg?) r'msg': msg, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.cause, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final cause?) + r'cause': cause, + }, + deserialize: ($serialized) { + return _i9.UserException_ShowInConsole( + msg: ($serialized[r'msg'] as String), + cause: _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized[r'cause'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i15.CashBalance, Map>( + serialize: ($value) => {r'amount': $value.amount}, + deserialize: ($serialized) { + return (_i5.CashBalance(($serialized[r'amount'] as num).toDouble()) + as _i15.CashBalance); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i12.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i14.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i14.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': CashBalanceTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/marcelo/goldens/functions/models/portfolio.dart b/apps/cli/fixtures/legacy/marcelo/goldens/functions/models/portfolio.dart new file mode 100644 index 000000000..fb1025062 --- /dev/null +++ b/apps/cli/fixtures/legacy/marcelo/goldens/functions/models/portfolio.dart @@ -0,0 +1,2024 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i10; +import 'dart:convert' as _i11; + +import 'package:_common/src/models/cash_balance.dart' as _i16; +import 'package:_common/src/models/errors_and_exceptions.dart' as _i13; +import 'package:_common/src/models/portfolio.dart' as _i5; +import 'package:_common/src/models/stock.dart' as _i18; +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/exceptions/overrides.dart' as _i9; +import 'package:celest_backend/models/overrides.dart' as _i15; +import 'package:celest_backend/src/functions/models.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i12; +import 'package:celest_core/src/serialization/json_value.dart' as _i14; +import 'package:fast_immutable_collections/src/ilist/ilist.dart' as _i17; +import 'package:shelf/shelf.dart' as _i2; + +final class PortfolioTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'portfolio'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.portfolio( + _i4.Serializers.instance.deserialize<_i5.Portfolio>( + request[r'portfolio'], + ), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.Portfolio>(response), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AppError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'marcelo.v1.AppError', + 'value': _i4.Serializers.instance.serialize<_i9.AppError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AppException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'marcelo.v1.AppException', + 'value': _i4.Serializers.instance.serialize<_i9.AppException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i10.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i11.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.NotYetImplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'marcelo.v1.NotYetImplementedError', + 'value': _i4.Serializers.instance + .serialize<_i9.NotYetImplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i12.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i12.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance + .serialize<_i10.TimeoutException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.UserException_ShowInConsole catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'marcelo.v1.UserException_ShowInConsole', + 'value': _i4.Serializers.instance + .serialize<_i9.UserException_ShowInConsole>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i13.UserException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': '_common.UserException', + 'value': _i4.Serializers.instance.serialize<_i13.UserException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i13.ValidateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': '_common.ValidateError', + 'value': _i4.Serializers.instance.serialize<_i13.ValidateError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i10.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i10.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i11.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i11.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.UserException, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i13.UserException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.ValidateError, Map>( + serialize: ($value) => {r'msg': $value.msg}, + deserialize: ($serialized) { + return _i13.ValidateError(($serialized[r'msg'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AppError, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i9.AppError.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AppException, Map?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.error, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final error?) + r'error': error, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.msg, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final msg?) + r'msg': msg, + }, + deserialize: ($serialized) { + return (_i13.AppException( + $serialized?[r'msg'], + $serialized?[r'error'], + ) + as _i9.AppException); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.NotYetImplementedError, Map?>( + serialize: + ($value) => { + r'msg': $value.msg, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.message, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final message?) + r'message': message, + }, + deserialize: ($serialized) { + return _i9.NotYetImplementedError( + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'message'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.UserException_ShowInConsole, + Map + >( + serialize: + ($value) => { + if ($value.msg case final msg?) r'msg': msg, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.cause, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final cause?) + r'cause': cause, + }, + deserialize: ($serialized) { + return _i9.UserException_ShowInConsole( + msg: ($serialized[r'msg'] as String), + cause: _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized[r'cause'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i15.CashBalance, Map>( + serialize: ($value) => {r'amount': $value.amount}, + deserialize: ($serialized) { + return (_i16.CashBalance(($serialized[r'amount'] as num).toDouble()) + as _i15.CashBalance); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i15.Portfolio, Map?>( + serialize: + ($value) => { + r'stocks': _i4.Serializers.instance + .serialize<_i17.IList<_i18.Stock>>($value.stocks), + r'cashBalance': _i4.Serializers.instance + .serialize<_i16.CashBalance>($value.cashBalance), + r'isEmpty': $value.isEmpty, + r'totalCostBasis': $value.totalCostBasis, + }, + deserialize: ($serialized) { + return (_i5.Portfolio( + stocks: + ($serialized?[r'stocks'] as Iterable?) + ?.map( + (el) => _i4.Serializers.instance + .deserialize<_i18.Stock>(el), + ) + .toList(), + cashBalance: + (_i4.Serializers.instance.deserialize<_i16.CashBalance?>( + $serialized?[r'cashBalance'], + )) ?? + _i16.CashBalance.ZERO, + ) + as _i15.Portfolio); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i15.Stock, Map>( + serialize: + ($value) => { + r'ticker': $value.ticker, + r'howManyShares': $value.howManyShares, + r'averagePrice': $value.averagePrice, + r'costBasis': $value.costBasis, + r'averagePriceStr': $value.averagePriceStr, + }, + deserialize: ($serialized) { + return (_i18.Stock( + ($serialized[r'ticker'] as String), + howManyShares: ($serialized[r'howManyShares'] as num).toInt(), + averagePrice: ($serialized[r'averagePrice'] as num).toDouble(), + ) + as _i15.Stock); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i12.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i14.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i14.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i17.IList<_i18.Stock>, dynamic>( + serialize: + ($value) => $value.toJson( + (value) => _i4.Serializers.instance.serialize<_i18.Stock>(value), + ), + deserialize: ($serialized) { + return _i17.IList<_i18.Stock>.fromJson( + $serialized, + (value) => _i4.Serializers.instance.deserialize<_i18.Stock>(value), + ); + }, + ), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': PortfolioTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/marcelo/goldens/functions/models/stock.dart b/apps/cli/fixtures/legacy/marcelo/goldens/functions/models/stock.dart new file mode 100644 index 000000000..9dc329adf --- /dev/null +++ b/apps/cli/fixtures/legacy/marcelo/goldens/functions/models/stock.dart @@ -0,0 +1,1966 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i10; +import 'dart:convert' as _i11; + +import 'package:_common/src/models/errors_and_exceptions.dart' as _i13; +import 'package:_common/src/models/stock.dart' as _i5; +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/exceptions/overrides.dart' as _i9; +import 'package:celest_backend/models/overrides.dart' as _i15; +import 'package:celest_backend/src/functions/models.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i12; +import 'package:celest_core/src/serialization/json_value.dart' as _i14; +import 'package:shelf/shelf.dart' as _i2; + +final class StockTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'stock'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.stock( + _i4.Serializers.instance.deserialize<_i5.Stock>(request[r'stock']), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.Stock>(response), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AppError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'marcelo.v1.AppError', + 'value': _i4.Serializers.instance.serialize<_i9.AppError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AppException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'marcelo.v1.AppException', + 'value': _i4.Serializers.instance.serialize<_i9.AppException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i10.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i11.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.NotYetImplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'marcelo.v1.NotYetImplementedError', + 'value': _i4.Serializers.instance + .serialize<_i9.NotYetImplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i12.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i12.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance + .serialize<_i10.TimeoutException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.UserException_ShowInConsole catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'marcelo.v1.UserException_ShowInConsole', + 'value': _i4.Serializers.instance + .serialize<_i9.UserException_ShowInConsole>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i13.UserException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': '_common.UserException', + 'value': _i4.Serializers.instance.serialize<_i13.UserException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i13.ValidateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': '_common.ValidateError', + 'value': _i4.Serializers.instance.serialize<_i13.ValidateError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i10.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i10.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i11.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i11.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.UserException, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i13.UserException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.ValidateError, Map>( + serialize: ($value) => {r'msg': $value.msg}, + deserialize: ($serialized) { + return _i13.ValidateError(($serialized[r'msg'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AppError, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i9.AppError.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AppException, Map?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.error, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final error?) + r'error': error, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.msg, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final msg?) + r'msg': msg, + }, + deserialize: ($serialized) { + return (_i13.AppException( + $serialized?[r'msg'], + $serialized?[r'error'], + ) + as _i9.AppException); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.NotYetImplementedError, Map?>( + serialize: + ($value) => { + r'msg': $value.msg, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.message, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final message?) + r'message': message, + }, + deserialize: ($serialized) { + return _i9.NotYetImplementedError( + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'message'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.UserException_ShowInConsole, + Map + >( + serialize: + ($value) => { + if ($value.msg case final msg?) r'msg': msg, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.cause, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final cause?) + r'cause': cause, + }, + deserialize: ($serialized) { + return _i9.UserException_ShowInConsole( + msg: ($serialized[r'msg'] as String), + cause: _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized[r'cause'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i15.Stock, Map>( + serialize: + ($value) => { + r'ticker': $value.ticker, + r'howManyShares': $value.howManyShares, + r'averagePrice': $value.averagePrice, + r'costBasis': $value.costBasis, + r'averagePriceStr': $value.averagePriceStr, + }, + deserialize: ($serialized) { + return (_i5.Stock( + ($serialized[r'ticker'] as String), + howManyShares: ($serialized[r'howManyShares'] as num).toInt(), + averagePrice: ($serialized[r'averagePrice'] as num).toDouble(), + ) + as _i15.Stock); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i12.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i14.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i14.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': StockTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/marcelo/goldens/functions/models/ui.dart b/apps/cli/fixtures/legacy/marcelo/goldens/functions/models/ui.dart new file mode 100644 index 000000000..2fe8773da --- /dev/null +++ b/apps/cli/fixtures/legacy/marcelo/goldens/functions/models/ui.dart @@ -0,0 +1,1975 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i10; +import 'dart:convert' as _i11; + +import 'package:_common/src/models/errors_and_exceptions.dart' as _i13; +import 'package:_common/src/models/ui.dart' as _i5; +import 'package:celest/celest.dart' as _i8; +import 'package:celest/src/core/context.dart' as _i7; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/exceptions/overrides.dart' as _i9; +import 'package:celest_backend/models/overrides.dart' as _i15; +import 'package:celest_backend/src/functions/models.dart' as _i3; +import 'package:celest_core/celest_core.dart' as _i4; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i6; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i12; +import 'package:celest_core/src/serialization/json_value.dart' as _i14; +import 'package:shelf/shelf.dart' as _i2; + +final class UiTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'ui'; + + @override + String get method => 'POST'; + + @override + Future<_i2.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = _i3.ui( + _i4.Serializers.instance.deserialize<_i5.Ui>(request[r'ui']), + ); + return _i2.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode( + _i4.Serializers.instance.serialize<_i5.Ui>(response), + ), + ); + } on _i6.AbortedException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i4.Serializers.instance.serialize<_i6.AbortedException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i4.Serializers.instance + .serialize<_i6.AlreadyExistsException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AppError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'marcelo.v1.AppError', + 'value': _i4.Serializers.instance.serialize<_i9.AppError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.AppException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'marcelo.v1.AppException', + 'value': _i4.Serializers.instance.serialize<_i9.AppException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.AsyncError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i4.Serializers.instance.serialize<_i10.AsyncError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CancelledException catch (e, st) { + const statusCode = 499; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i4.Serializers.instance + .serialize<_i6.CancelledException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DataLossError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i4.Serializers.instance.serialize<_i6.DataLossError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i4.Serializers.instance + .serialize<_i6.DeadlineExceededError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i4.Serializers.instance + .serialize<_i6.FailedPreconditionException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i4.Serializers.instance + .serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.InternalServerError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i4.Serializers.instance + .serialize<_i6.InternalServerError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i11.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i4.Serializers.instance + .serialize<_i11.JsonUnsupportedObjectError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.NotFoundException catch (e, st) { + const statusCode = 404; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i4.Serializers.instance + .serialize<_i6.NotFoundException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.NotYetImplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'marcelo.v1.NotYetImplementedError', + 'value': _i4.Serializers.instance + .serialize<_i9.NotYetImplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i4.Serializers.instance + .serialize<_i6.OutOfRangeException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i4.Serializers.instance + .serialize<_i6.PermissionDeniedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i4.Serializers.instance + .serialize<_i6.ResourceExhaustedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i12.SerializationException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i4.Serializers.instance + .serialize<_i12.SerializationException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.BadRequestException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i4.Serializers.instance + .serialize<_i6.BadRequestException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i10.TimeoutException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i4.Serializers.instance + .serialize<_i10.TimeoutException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i4.Serializers.instance + .serialize<_i6.UnauthorizedException>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnavailableError catch (e, st) { + const statusCode = 503; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i4.Serializers.instance.serialize<_i6.UnavailableError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnimplementedError catch (e, st) { + const statusCode = 501; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i4.Serializers.instance + .serialize<_i6.UnimplementedError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i4.Serializers.instance.serialize( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.UnknownError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i4.Serializers.instance.serialize<_i6.UnknownError>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i6.CloudException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i4.Serializers.instance.serialize<_i6.CloudException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i9.UserException_ShowInConsole catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'marcelo.v1.UserException_ShowInConsole', + 'value': _i4.Serializers.instance + .serialize<_i9.UserException_ShowInConsole>(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i13.UserException catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': '_common.UserException', + 'value': _i4.Serializers.instance.serialize<_i13.UserException>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on _i13.ValidateError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': '_common.ValidateError', + 'value': _i4.Serializers.instance.serialize<_i13.ValidateError>( + e, + ), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i7.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i4.Serializers.instance.serialize(e), + }, + if (_i7.context.environment != _i8.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i4.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i2.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i4.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i4.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i10.AsyncError( + $serialized[r'error']!, + _i4.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i10.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i4.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i10.TimeoutException( + ($serialized[r'message'] as String?), + _i4.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i11.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i11.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.UserException, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i13.UserException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i13.ValidateError, Map>( + serialize: ($value) => {r'msg': $value.msg}, + deserialize: ($serialized) { + return _i13.ValidateError(($serialized[r'msg'] as String)); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i5.ScreenChoice, String>( + serialize: ($value) => $value.name, + deserialize: ($serialized) { + return _i5.ScreenChoice.values.byName($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AppError, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i9.AppError.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.AppException, Map?>( + serialize: + ($value) => { + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.error, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final error?) + r'error': error, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.msg, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final msg?) + r'msg': msg, + }, + deserialize: ($serialized) { + return (_i13.AppException( + $serialized?[r'msg'], + $serialized?[r'error'], + ) + as _i9.AppException); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i9.NotYetImplementedError, Map?>( + serialize: + ($value) => { + r'msg': $value.msg, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.message, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final message?) + r'message': message, + }, + deserialize: ($serialized) { + return _i9.NotYetImplementedError( + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'message'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i9.UserException_ShowInConsole, + Map + >( + serialize: + ($value) => { + if ($value.msg case final msg?) r'msg': msg, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.cause, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final cause?) + r'cause': cause, + }, + deserialize: ($serialized) { + return _i9.UserException_ShowInConsole( + msg: ($serialized[r'msg'] as String), + cause: _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized[r'cause'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i15.Ui, Map>( + serialize: + ($value) => { + r'isDarkMode': $value.isDarkMode, + r'screenChoice': _i4.Serializers.instance + .serialize<_i5.ScreenChoice>($value.screenChoice), + }, + deserialize: ($serialized) { + return (_i5.Ui( + isDarkMode: ($serialized[r'isDarkMode'] as bool), + screenChoice: + (_i4.Serializers.instance.deserialize<_i5.ScreenChoice?>( + $serialized[r'screenChoice'], + )) ?? + _i5.ScreenChoice.portfolioAndCashBalance, + ) + as _i15.Ui); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AbortedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.BadRequestException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CancelledException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.CloudException.fromJson($serialized); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DataLossError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.InternalServerError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.NotFoundException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define< + _i6.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnavailableError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnimplementedError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i6.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i6.UnknownError( + ($serialized?[r'message'] as String?), + _i4.Serializers.instance.deserialize<_i14.JsonValue?>( + $serialized?[r'details'], + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i12.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i4.Serializers.instance.serialize<_i14.JsonValue?>( + $value.details, + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i12.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i4.Serializers.instance.put( + _i4.Serializer.define<_i14.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i14.JsonValue($serialized); + }, + ), + const _i4.TypeToken<_i14.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': UiTarget()}, + setup: (_i7.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/marcelo/lib/exceptions/overrides.dart b/apps/cli/fixtures/legacy/marcelo/lib/exceptions/overrides.dart new file mode 100644 index 000000000..0caf1dca9 --- /dev/null +++ b/apps/cli/fixtures/legacy/marcelo/lib/exceptions/overrides.dart @@ -0,0 +1,40 @@ +import 'package:_common/marcelo.dart' as core; +import 'package:celest/celest.dart'; + +@customOverride +extension type AppError(core.AppError _err) implements core.AppError { + AppError.fromJson(Map json) + : _err = core.AppError(json['msg'], json['error']); + + Map toJson() => {'msg': _err.message, 'error': _err.error}; +} + +@customOverride +extension type AppException(core.AppException _ex) + implements core.AppException { + JsonValue? get error => _ex.error as JsonValue?; + JsonValue? get msg => _ex.msg as JsonValue?; +} + +@customOverride +extension type NotYetImplementedError._(core.NotYetImplementedError _err) + implements core.NotYetImplementedError { + NotYetImplementedError([JsonValue? message]) + : _err = core.NotYetImplementedError(message); + + String get msg => _err.msg.split('\n').first.trim(); + JsonValue? get message => _err.message as JsonValue?; +} + +@customOverride +extension type UserException_ShowInConsole._( + core.UserException_ShowInConsole _ex) + implements core.UserException_ShowInConsole { + UserException_ShowInConsole({ + required String msg, + JsonValue? cause, + }) : this._(core.UserException_ShowInConsole(msg, cause: cause)); + + Null get code => null; + JsonValue? get cause => _ex.cause as JsonValue?; +} diff --git a/apps/cli/fixtures/legacy/marcelo/lib/fix_data/v1_migration.yaml b/apps/cli/fixtures/legacy/marcelo/lib/fix_data/v1_migration.yaml new file mode 100644 index 000000000..5a1d3965a --- /dev/null +++ b/apps/cli/fixtures/legacy/marcelo/lib/fix_data/v1_migration.yaml @@ -0,0 +1,13 @@ +# Generated by Celest. Do not modify. +version: 1 +transforms: + - title: "Updates the import of the Celest client" + date: 2024-10-06 + element: + uris: ["client.dart"] + variable: celest + changes: + - kind: replacedBy + newElement: + uris: ["package:marcelo_client/marcelo_client.dart"] + variable: celest diff --git a/apps/cli/fixtures/legacy/marcelo/lib/models/overrides.dart b/apps/cli/fixtures/legacy/marcelo/lib/models/overrides.dart new file mode 100644 index 000000000..a49810fc1 --- /dev/null +++ b/apps/cli/fixtures/legacy/marcelo/lib/models/overrides.dart @@ -0,0 +1,23 @@ +import 'package:_common/marcelo.dart' as models; +import 'package:celest/celest.dart'; + +@customOverride +extension type AvailableStock(models.AvailableStock _) + implements models.AvailableStock {} + +// @customOverride +// extension type AvailableStocks(models.AvailableStocks _) +// implements models.AvailableStocks {} + +@customOverride +extension type CashBalance(models.CashBalance _) + implements models.CashBalance {} + +@customOverride +extension type Portfolio(models.Portfolio _) implements models.Portfolio {} + +@customOverride +extension type Stock(models.Stock _) implements models.Stock {} + +@customOverride +extension type Ui(models.Ui _) implements models.Ui {} diff --git a/apps/cli/fixtures/legacy/marcelo/lib/src/functions/exceptions.dart b/apps/cli/fixtures/legacy/marcelo/lib/src/functions/exceptions.dart new file mode 100644 index 000000000..42d7bae09 --- /dev/null +++ b/apps/cli/fixtures/legacy/marcelo/lib/src/functions/exceptions.dart @@ -0,0 +1,50 @@ +// ignore_for_file: deprecated_member_use_from_same_package, non_constant_identifier_names + +import 'package:_common/src/models/errors_and_exceptions.dart'; +import 'package:celest/celest.dart'; +import 'package:celest_backend/exceptions/overrides.dart' as override; + +@cloud +void throwsUserException({ + JsonValue? cause, +}) { + throw UserException('message', cause: cause); +} + +@cloud +void callsThrowsUserException({ + JsonValue? cause, +}) { + throwsUserException(cause: cause); +} + +@cloud +void throwsAppError({ + String message = 'message', + JsonValue? error, +}) { + throw AppError(message, error); +} + +@cloud +void throwsAppException() { + throw override.AppException(AppException('message', 'error')); +} + +@cloud +void throwsNotYetImplementedError() { + throw NotYetImplementedError('message'); +} + +@cloud +void throwsValidateError() { + throw ValidateError('message'); +} + +@cloud +void throwsUserException_ShowInConsole({ + String message = 'message', + JsonValue? cause, +}) { + throw UserException_ShowInConsole(message, cause: cause); +} diff --git a/apps/cli/fixtures/legacy/marcelo/lib/src/functions/models.dart b/apps/cli/fixtures/legacy/marcelo/lib/src/functions/models.dart new file mode 100644 index 000000000..79a90327f --- /dev/null +++ b/apps/cli/fixtures/legacy/marcelo/lib/src/functions/models.dart @@ -0,0 +1,16 @@ +import 'package:_common/marcelo.dart'; +import 'package:celest/celest.dart'; + +@cloud +AvailableStock availableStock(AvailableStock availableStock) => availableStock; +@cloud +AvailableStocks availableStocks(AvailableStocks availableStocks) => + availableStocks; +@cloud +CashBalance cashBalance(CashBalance cashBalance) => cashBalance; +@cloud +Portfolio portfolio(Portfolio portfolio) => portfolio; +@cloud +Stock stock(Stock stock) => stock; +@cloud +Ui ui(Ui ui) => ui; diff --git a/apps/cli/fixtures/legacy/marcelo/lib/src/generated/cloud.celest.dart b/apps/cli/fixtures/legacy/marcelo/lib/src/generated/cloud.celest.dart new file mode 100644 index 000000000..f1a89c399 --- /dev/null +++ b/apps/cli/fixtures/legacy/marcelo/lib/src/generated/cloud.celest.dart @@ -0,0 +1,45 @@ +// Generated by Celest. This file should not be modified manually, but +// it can be checked into version control. +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +library; + +import 'package:celest/src/core/context.dart'; +import 'package:celest_backend/src/generated/config.celest.dart'; + +/// The interface to your Celest backend. +/// +/// Similar to the `celest` global in the frontend, this +/// provides access to the backend environment and services +/// configured for your project. +const CelestCloud celest = CelestCloud._(); + +/// A per-request context object which propogates request information and common +/// accessors to the Celest server environment. +CelestContext get context => CelestContext._(context); + +/// The interface to your Celest backend. +/// +/// Similar to the `Celest` class in the frontend, this class +/// provides access to the backend environment and services +/// configured for your project. +class CelestCloud { + const CelestCloud._(); + + /// The current environment of the Celest service. + /// + /// This is determined by the `CELEST_ENVIRONMENT` variable + /// which is set for you by the deployment environment. + CelestEnvironment get currentEnvironment => + (variables.currentEnvironment as CelestEnvironment); + + /// The variables of the Celest service. + /// + /// This class provides access to the values configured for the + /// [currentEnvironment]. + CelestVariables get variables => const CelestVariables(); +} + +/// A per-request context object which propogates request information and common +/// accessors to the Celest server environment. +extension type CelestContext._(Context _context) implements Context {} diff --git a/apps/cli/fixtures/legacy/marcelo/lib/src/generated/config.celest.dart b/apps/cli/fixtures/legacy/marcelo/lib/src/generated/config.celest.dart new file mode 100644 index 000000000..687b9f186 --- /dev/null +++ b/apps/cli/fixtures/legacy/marcelo/lib/src/generated/config.celest.dart @@ -0,0 +1,45 @@ +// Generated by Celest. This file should not be modified manually, but +// it can be checked into version control. +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +library; + +import 'package:celest/celest.dart'; +import 'package:celest/src/core/context.dart'; + +/// An environment of a deployed Celest service. +/// +/// Celest services can have multiple isolated branches, for example +/// a `development` and `production` environment. +extension type const CelestEnvironment._(String _env) + implements Environment, String { + /// The local Celest environment, used to delineate when a + /// Celest service is running on a developer machine as opposed + /// to the cloud. + static const CelestEnvironment local = CelestEnvironment._('local'); + + /// The production Celest environment which is common to all + /// Celest projects and labels the environment which is considered + /// live and served to end-users. + static const CelestEnvironment production = CelestEnvironment._('production'); + + /// Whether `this` represents the [local] environment. + bool get isLocal => this == local; + + /// Whether `this` represents the [production] environment. + bool get isProduction => this == production; +} + +/// The environment variables for the Celest service. +/// +/// This class provides access to the environment variable values +/// that are configured for the current [CelestEnvironment]. +class CelestVariables { + const CelestVariables(); + + /// The environment variable that determines the current environment. + /// + /// This is set by the deployment environment and is used to + /// determine the current environment of the Celest service. + String get currentEnvironment => context.expect(env.environment); +} diff --git a/apps/cli/fixtures/legacy/marcelo/lib/src/project.dart b/apps/cli/fixtures/legacy/marcelo/lib/src/project.dart new file mode 100644 index 000000000..e4b7834ca --- /dev/null +++ b/apps/cli/fixtures/legacy/marcelo/lib/src/project.dart @@ -0,0 +1,3 @@ +import 'package:celest/celest.dart'; + +const project = Project(name: 'marcelo'); diff --git a/apps/cli/fixtures/legacy/marcelo/pubspec.yaml b/apps/cli/fixtures/legacy/marcelo/pubspec.yaml new file mode 100644 index 000000000..7d7b37f8f --- /dev/null +++ b/apps/cli/fixtures/legacy/marcelo/pubspec.yaml @@ -0,0 +1,31 @@ +name: celest_backend +publish_to: none + +environment: + sdk: ^3.4.0 + +dependencies: + _common: + path: ../_common + celest: ^1.0.0 + celest_core: ^1.0.0 + meta: ^1.12.0 + +dependency_overrides: + cedar: + path: ../../../../../cedar/packages/cedar + celest: + path: ../../../../../celest/packages/celest + celest_ast: + path: ../../../../../celest/packages/celest_ast + celest_auth: + path: ../../../../../celest/packages/celest_auth + celest_cloud: + path: ../../../../../celest/packages/celest_cloud + celest_cloud_auth: + path: ../../../../../celest/services/celest_cloud_auth + celest_core: + path: ../../../../../celest/packages/celest_core +dev_dependencies: + lints: ^4.0.0 + test: ^1.25.0 diff --git a/apps/cli/fixtures/legacy/simple/client/lib/simple_client.dart b/apps/cli/fixtures/legacy/simple/client/lib/simple_client.dart new file mode 100644 index 000000000..56c16d999 --- /dev/null +++ b/apps/cli/fixtures/legacy/simple/client/lib/simple_client.dart @@ -0,0 +1,51 @@ +// Generated by Celest. This file should not be modified manually, but +// it can be checked into version control. +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +library; // ignore_for_file: no_leading_underscores_for_library_prefixes + +import 'dart:io'; + +import 'package:celest_core/celest_core.dart' as _$celest; +import 'package:celest_core/src/util/globals.dart' as _$celest; + +final Celest celest = Celest(); + +enum CelestEnvironment { + local, + production; + + Uri get baseUri => switch (this) { + local => + _$celest.kIsWeb || !Platform.isAndroid + ? Uri.parse('http://localhost:7777') + : Uri.parse('http://10.0.2.2:7777'), + production => Uri.parse('https://example.celest.run'), + }; +} + +class Celest { + var _initialized = false; + + late CelestEnvironment _currentEnvironment; + + T _checkInitialized(T Function() value) { + if (!_initialized) { + throw StateError( + 'Celest has not been initialized. Make sure to call `celest.init()` at the start of your `main` method.', + ); + } + return value(); + } + + CelestEnvironment get currentEnvironment => + _checkInitialized(() => _currentEnvironment); + + void init({ + CelestEnvironment environment = CelestEnvironment.local, + _$celest.Serializers? serializers, + }) { + _currentEnvironment = environment; + _initialized = true; + } +} diff --git a/apps/cli/fixtures/legacy/simple/client/pubspec.yaml b/apps/cli/fixtures/legacy/simple/client/pubspec.yaml new file mode 100644 index 000000000..f45c3ac3d --- /dev/null +++ b/apps/cli/fixtures/legacy/simple/client/pubspec.yaml @@ -0,0 +1,29 @@ +name: simple_client +description: The Celest client for simple. +publish_to: none + +environment: + sdk: ^3.4.0 + +dependencies: + celest: ^1.0.0 + celest_backend: + path: .. + celest_core: ^1.0.0 + http: ^1.0.0 + native_storage: ^0.2.2 + +dependency_overrides: + celest: + path: ../../../../../../celest/packages/celest + celest_ast: + path: ../../../../../../celest/packages/celest_ast + celest_auth: + path: ../../../../../../celest/packages/celest_auth + celest_cloud: + path: ../../../../../../celest/packages/celest_cloud + celest_cloud_auth: + path: ../../../../../../celest/services/celest_cloud_auth + celest_core: + path: ../../../../../../celest/packages/celest_core +dev_dependencies: {} diff --git a/apps/cli/fixtures/legacy/simple/goldens/ast.json b/apps/cli/fixtures/legacy/simple/goldens/ast.json new file mode 100644 index 000000000..bd652ea01 --- /dev/null +++ b/apps/cli/fixtures/legacy/simple/goldens/ast.json @@ -0,0 +1,45 @@ +{ + "name": "simple", + "environment": "local", + "reference": { + "$": "Reference", + "symbol": "project", + "url": "package:celest_backend/src/project.dart" + }, + "apis": {}, + "variables": [], + "secrets": [], + "databases": {}, + "sdkConfig": { + "celest": "1.0.6+2", + "dart": { + "type": "dart", + "version": "3.29.0", + "enabledExperiments": [] + }, + "targetSdk": "dart", + "featureFlags": [ + "streaming" + ], + "flutter": { + "type": "flutter", + "version": "3.29.0", + "enabledExperiments": [] + } + }, + "location": { + "start": { + "offset": 44, + "uri": "project.dart", + "line": 2, + "column": 6 + }, + "end": { + "offset": 77, + "uri": "project.dart", + "line": 2, + "column": 39 + }, + "text": "project = Project(name: 'simple')" + } +} \ No newline at end of file diff --git a/apps/cli/fixtures/legacy/simple/goldens/ast.resolved.json b/apps/cli/fixtures/legacy/simple/goldens/ast.resolved.json new file mode 100644 index 000000000..fc642401f --- /dev/null +++ b/apps/cli/fixtures/legacy/simple/goldens/ast.resolved.json @@ -0,0 +1,30 @@ +{ + "projectId": "simple", + "environmentId": "local", + "apis": {}, + "variables": [ + { + "name": "CELEST_ENVIRONMENT", + "value": "local" + } + ], + "secrets": [], + "databases": {}, + "sdkConfig": { + "celest": "1.0.6+2", + "dart": { + "type": "dart", + "version": "3.29.0", + "enabledExperiments": [] + }, + "targetSdk": "dart", + "featureFlags": [ + "streaming" + ], + "flutter": { + "type": "flutter", + "version": "3.29.0", + "enabledExperiments": [] + } + } +} \ No newline at end of file diff --git a/apps/cli/fixtures/legacy/simple/lib/fix_data/v1_migration.yaml b/apps/cli/fixtures/legacy/simple/lib/fix_data/v1_migration.yaml new file mode 100644 index 000000000..63808355d --- /dev/null +++ b/apps/cli/fixtures/legacy/simple/lib/fix_data/v1_migration.yaml @@ -0,0 +1,13 @@ +# Generated by Celest. Do not modify. +version: 1 +transforms: + - title: "Updates the import of the Celest client" + date: 2024-10-06 + element: + uris: ["client.dart"] + variable: celest + changes: + - kind: replacedBy + newElement: + uris: ["package:simple_client/simple_client.dart"] + variable: celest diff --git a/apps/cli/fixtures/legacy/simple/lib/src/generated/cloud.celest.dart b/apps/cli/fixtures/legacy/simple/lib/src/generated/cloud.celest.dart new file mode 100644 index 000000000..f1a89c399 --- /dev/null +++ b/apps/cli/fixtures/legacy/simple/lib/src/generated/cloud.celest.dart @@ -0,0 +1,45 @@ +// Generated by Celest. This file should not be modified manually, but +// it can be checked into version control. +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +library; + +import 'package:celest/src/core/context.dart'; +import 'package:celest_backend/src/generated/config.celest.dart'; + +/// The interface to your Celest backend. +/// +/// Similar to the `celest` global in the frontend, this +/// provides access to the backend environment and services +/// configured for your project. +const CelestCloud celest = CelestCloud._(); + +/// A per-request context object which propogates request information and common +/// accessors to the Celest server environment. +CelestContext get context => CelestContext._(context); + +/// The interface to your Celest backend. +/// +/// Similar to the `Celest` class in the frontend, this class +/// provides access to the backend environment and services +/// configured for your project. +class CelestCloud { + const CelestCloud._(); + + /// The current environment of the Celest service. + /// + /// This is determined by the `CELEST_ENVIRONMENT` variable + /// which is set for you by the deployment environment. + CelestEnvironment get currentEnvironment => + (variables.currentEnvironment as CelestEnvironment); + + /// The variables of the Celest service. + /// + /// This class provides access to the values configured for the + /// [currentEnvironment]. + CelestVariables get variables => const CelestVariables(); +} + +/// A per-request context object which propogates request information and common +/// accessors to the Celest server environment. +extension type CelestContext._(Context _context) implements Context {} diff --git a/apps/cli/fixtures/legacy/simple/lib/src/generated/config.celest.dart b/apps/cli/fixtures/legacy/simple/lib/src/generated/config.celest.dart new file mode 100644 index 000000000..687b9f186 --- /dev/null +++ b/apps/cli/fixtures/legacy/simple/lib/src/generated/config.celest.dart @@ -0,0 +1,45 @@ +// Generated by Celest. This file should not be modified manually, but +// it can be checked into version control. +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +library; + +import 'package:celest/celest.dart'; +import 'package:celest/src/core/context.dart'; + +/// An environment of a deployed Celest service. +/// +/// Celest services can have multiple isolated branches, for example +/// a `development` and `production` environment. +extension type const CelestEnvironment._(String _env) + implements Environment, String { + /// The local Celest environment, used to delineate when a + /// Celest service is running on a developer machine as opposed + /// to the cloud. + static const CelestEnvironment local = CelestEnvironment._('local'); + + /// The production Celest environment which is common to all + /// Celest projects and labels the environment which is considered + /// live and served to end-users. + static const CelestEnvironment production = CelestEnvironment._('production'); + + /// Whether `this` represents the [local] environment. + bool get isLocal => this == local; + + /// Whether `this` represents the [production] environment. + bool get isProduction => this == production; +} + +/// The environment variables for the Celest service. +/// +/// This class provides access to the environment variable values +/// that are configured for the current [CelestEnvironment]. +class CelestVariables { + const CelestVariables(); + + /// The environment variable that determines the current environment. + /// + /// This is set by the deployment environment and is used to + /// determine the current environment of the Celest service. + String get currentEnvironment => context.expect(env.environment); +} diff --git a/apps/cli/fixtures/legacy/simple/lib/src/project.dart b/apps/cli/fixtures/legacy/simple/lib/src/project.dart new file mode 100644 index 000000000..bdaecffb5 --- /dev/null +++ b/apps/cli/fixtures/legacy/simple/lib/src/project.dart @@ -0,0 +1,3 @@ +import 'package:celest/celest.dart'; + +const project = Project(name: 'simple'); diff --git a/apps/cli/fixtures/legacy/simple/pubspec.yaml b/apps/cli/fixtures/legacy/simple/pubspec.yaml new file mode 100644 index 000000000..76787a958 --- /dev/null +++ b/apps/cli/fixtures/legacy/simple/pubspec.yaml @@ -0,0 +1,29 @@ +name: celest_backend +publish_to: none + +environment: + sdk: ^3.4.0 + +dependencies: + celest: ^1.0.0 + celest_core: ^1.0.0 + meta: ^1.12.0 + +dependency_overrides: + cedar: + path: ../../../../../cedar/packages/cedar + celest: + path: ../../../../../celest/packages/celest + celest_ast: + path: ../../../../../celest/packages/celest_ast + celest_auth: + path: ../../../../../celest/packages/celest_auth + celest_cloud: + path: ../../../../../celest/packages/celest_cloud + celest_cloud_auth: + path: ../../../../../celest/services/celest_cloud_auth + celest_core: + path: ../../../../../celest/packages/celest_core +dev_dependencies: + lints: ^4.0.0 + test: ^1.25.0 diff --git a/apps/cli/fixtures/legacy/simple/resources.dart b/apps/cli/fixtures/legacy/simple/resources.dart new file mode 100644 index 000000000..ffc4fd722 --- /dev/null +++ b/apps/cli/fixtures/legacy/simple/resources.dart @@ -0,0 +1,5 @@ +// Generated by Celest. This file should not be modified manually, but +// it can be checked into version control. +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import + +library; diff --git a/apps/cli/fixtures/legacy/streaming/analysis_options.yaml b/apps/cli/fixtures/legacy/streaming/analysis_options.yaml new file mode 100644 index 000000000..cef4bc91f --- /dev/null +++ b/apps/cli/fixtures/legacy/streaming/analysis_options.yaml @@ -0,0 +1,4 @@ +analyzer: + errors: + deprecated_member_use_from_same_package: ignore + unused_element: ignore diff --git a/apps/cli/fixtures/legacy/streaming/client/lib/src/functions.dart b/apps/cli/fixtures/legacy/streaming/client/lib/src/functions.dart new file mode 100644 index 000000000..f68d6695a --- /dev/null +++ b/apps/cli/fixtures/legacy/streaming/client/lib/src/functions.dart @@ -0,0 +1,331 @@ +// Generated by Celest. This file should not be modified manually, but +// it can be checked into version control. +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +library; // ignore_for_file: no_leading_underscores_for_library_prefixes + +import 'dart:async'; +import 'dart:convert'; + +import 'package:_common/src/models/available_stock.dart' + as _$_common_available_stock; +import 'package:celest/celest.dart' as _$celest; +import 'package:celest_core/celest_core.dart' as _$celest; +import 'package:celest_core/src/exception/cloud_exception.dart' as _$celest; +import 'package:celest_core/src/exception/serialization_exception.dart' + as _$celest; +import 'package:celest_core/src/serialization/json_value.dart' as _$celest; +import 'package:streaming_client/streaming_client.dart'; + +class CelestFunctions { + /// Tests the ability to use server-side streaming. + final serverSide = CelestFunctionsServerSide(); +} + +/// Tests the ability to use server-side streaming. +class CelestFunctionsServerSide { + Never _throwError({int? code, required Map body}) { + final status = body['@status'] as Map?; + final message = status?['message'] as String?; + final details = status?['details'] as _$celest.JsonList?; + final (errorType, errorValue, stackTrace) = switch (details) { + null || [] => const (null, null, StackTrace.empty), + [ + final errorDetails as Map, + { + '@type': 'dart.core.StackTrace', + 'value': final stackTraceValue as String, + }, + ..., + ] => + ( + errorDetails['@type'], + errorDetails['value'], + StackTrace.fromString(stackTraceValue), + ), + [final errorDetails as Map, ...] => ( + errorDetails['@type'], + errorDetails['value'], + StackTrace.empty, + ), + }; + + switch (errorType) { + case 'dart.core.Error': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.AssertionError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.TypeError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.ArgumentError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.RangeError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.IndexError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.UnsupportedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.UnimplementedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.StateError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.ConcurrentModificationError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.core.OutOfMemoryError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.StackOverflowError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.Exception': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.FormatException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.IntegerDivisionByZeroException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.async.AsyncError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.async.TimeoutException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.convert.JsonUnsupportedObjectError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.CloudException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.CloudException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.CancelledException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.CancelledException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnknownError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.UnknownError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.BadRequestException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.BadRequestException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnauthorizedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.UnauthorizedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.NotFoundException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.NotFoundException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.AlreadyExistsException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.AlreadyExistsException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.PermissionDeniedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.PermissionDeniedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.ResourceExhaustedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.ResourceExhaustedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.FailedPreconditionException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.FailedPreconditionException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.AbortedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.AbortedException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.OutOfRangeException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.OutOfRangeException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnimplementedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.UnimplementedError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.InternalServerError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.InternalServerError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnavailableError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.UnavailableError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.DataLossError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.DataLossError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.DeadlineExceededError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.DeadlineExceededError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.SerializationException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.SerializationException>(errorValue), + stackTrace, + ); + default: + Error.throwWithStackTrace( + _$celest.CloudException.http( + code: code, + message: message, + details: ((details ?? body) as _$celest.JsonValue), + ), + StackTrace.empty, + ); + } + } + + @_$celest.CloudFunction(api: 'server_side', function: 'hello') + Stream hello(List names) { + final $channel = celest.eventClient.connect( + celest.baseUri.resolve('/server-side/hello'), + ); + $channel.sink.add({r'names': names}); + return $channel.stream.map(($event) { + if ($event is Map && $event.containsKey('@error')) { + _throwError(body: $event); + } + return ($event as String); + }); + } + + @_$celest.CloudFunction(api: 'server_side', function: 'stockTicker') + Stream<_$_common_available_stock.AvailableStock> stockTicker(String symbol) { + final $channel = celest.eventClient.connect( + celest.baseUri + .resolve('/server-side/stock-ticker') + .replace(queryParameters: {r'symbol': symbol}), + ); + return $channel.stream.map(($event) { + if ($event is Map && $event.containsKey('@error')) { + _throwError(body: $event); + } + return _$celest.Serializers.instance + .deserialize<_$_common_available_stock.AvailableStock>($event); + }); + } + + @_$celest.CloudFunction(api: 'server_side', function: 'jsonValues') + Stream<_$celest.JsonValue> jsonValues() { + final $channel = celest.eventClient.connect( + celest.baseUri.resolve('/server-side/json-values'), + ); + return $channel.stream.map(($event) { + if ($event is Map && $event.containsKey('@error')) { + _throwError(body: $event); + } + return _$celest.Serializers.instance.deserialize<_$celest.JsonValue>( + $event, + const _$celest.TypeToken<_$celest.JsonValue>('JsonValue'), + ); + }); + } +} diff --git a/apps/cli/fixtures/legacy/streaming/client/lib/src/serializers.dart b/apps/cli/fixtures/legacy/streaming/client/lib/src/serializers.dart new file mode 100644 index 000000000..b2eb061bb --- /dev/null +++ b/apps/cli/fixtures/legacy/streaming/client/lib/src/serializers.dart @@ -0,0 +1,774 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async'; +import 'dart:convert'; + +import 'package:_common/src/models/available_stock.dart' + as _$_common_available_stock; +import 'package:celest_core/celest_core.dart' as _$celest; +import 'package:celest_core/src/exception/cloud_exception.dart' as _$celest; +import 'package:celest_core/src/exception/serialization_exception.dart' + as _$celest; +import 'package:celest_core/src/serialization/json_value.dart' as _$celest; + +void initSerializers({_$celest.Serializers? serializers}) { + return runZoned(() { + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _$celest.Serializers.instance + .serialize($value.stackTrace), + }, + deserialize: ($serialized) { + return AsyncError( + $serialized[r'error']!, + _$celest.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_$celest.Serializers.instance.serialize( + $value.duration, + ) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return TimeoutException( + ($serialized[r'message'] as String?), + _$celest.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest + .Serializer.define>( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + ConcurrentModificationError, + Map? + >( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: + ($value) => { + if (_$celest.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$_common_available_stock.AvailableStock, + Map + >( + serialize: + ($value) => { + r'ticker': $value.ticker, + r'name': $value.name, + r'currentPrice': $value.currentPrice, + r'currentPriceStr': $value.currentPriceStr, + }, + deserialize: ($serialized) { + return _$_common_available_stock.AvailableStock( + ($serialized[r'ticker'] as String), + name: ($serialized[r'name'] as String), + currentPrice: ($serialized[r'currentPrice'] as num).toDouble(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest + .Serializer.define<_$celest.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.AbortedException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.AlreadyExistsException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.BadRequestException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.BadRequestException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.CancelledException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.CancelledException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define<_$celest.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.CloudException.fromJson($serialized); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define<_$celest.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.DataLossError( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.DeadlineExceededError, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.InternalServerError, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.InternalServerError( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest + .Serializer.define<_$celest.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.NotFoundException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.OutOfRangeException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.OutOfRangeException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.UnauthorizedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.UnauthorizedException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest + .Serializer.define<_$celest.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.UnavailableError( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.UnimplementedError, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.UnimplementedError( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define<_$celest.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.UnknownError( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.SerializationException, + Map + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define<_$celest.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _$celest.JsonValue($serialized); + }, + ), + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ); + }, zoneValues: {_$celest.Serializers: serializers}); +} diff --git a/apps/cli/fixtures/legacy/streaming/client/lib/streaming_client.dart b/apps/cli/fixtures/legacy/streaming/client/lib/streaming_client.dart new file mode 100644 index 000000000..efa212cb6 --- /dev/null +++ b/apps/cli/fixtures/legacy/streaming/client/lib/streaming_client.dart @@ -0,0 +1,78 @@ +// Generated by Celest. This file should not be modified manually, but +// it can be checked into version control. +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +library; // ignore_for_file: no_leading_underscores_for_library_prefixes + +import 'dart:io'; + +import 'package:celest_core/_internal.dart' as _$celest; +import 'package:celest_core/celest_core.dart' as _$celest; +import 'package:celest_core/src/util/globals.dart' as _$celest; +import 'package:http/http.dart' as _$http_http; +import 'package:native_storage/native_storage.dart' + as _$native_storage_native_storage; +import 'package:streaming_client/src/functions.dart'; +import 'package:streaming_client/src/serializers.dart'; + +final Celest celest = Celest(); + +enum CelestEnvironment { + local, + production; + + Uri get baseUri => switch (this) { + local => + _$celest.kIsWeb || !Platform.isAndroid + ? Uri.parse('http://localhost:7777') + : Uri.parse('http://10.0.2.2:7777'), + production => Uri.parse('https://example.celest.run'), + }; +} + +class Celest with _$celest.CelestBase { + var _initialized = false; + + late CelestEnvironment _currentEnvironment; + + late final _$native_storage_native_storage.NativeStorage nativeStorage = + _$native_storage_native_storage.NativeStorage(scope: 'celest'); + + @override + late _$http_http.Client httpClient = _$celest.CelestHttpClient( + secureStorage: nativeStorage.secure, + ); + + late Uri _baseUri; + + final _functions = CelestFunctions(); + + T _checkInitialized(T Function() value) { + if (!_initialized) { + throw StateError( + 'Celest has not been initialized. Make sure to call `celest.init()` at the start of your `main` method.', + ); + } + return value(); + } + + CelestEnvironment get currentEnvironment => + _checkInitialized(() => _currentEnvironment); + + @override + Uri get baseUri => _checkInitialized(() => _baseUri); + + CelestFunctions get functions => _checkInitialized(() => _functions); + + void init({ + CelestEnvironment environment = CelestEnvironment.local, + _$celest.Serializers? serializers, + }) { + _currentEnvironment = environment; + _baseUri = environment.baseUri; + if (!_initialized) { + initSerializers(serializers: serializers); + } + _initialized = true; + } +} diff --git a/apps/cli/fixtures/legacy/streaming/client/pubspec.yaml b/apps/cli/fixtures/legacy/streaming/client/pubspec.yaml new file mode 100644 index 000000000..fc11ddfdd --- /dev/null +++ b/apps/cli/fixtures/legacy/streaming/client/pubspec.yaml @@ -0,0 +1,29 @@ +name: streaming_client +description: The Celest client for streaming. +publish_to: none + +environment: + sdk: ^3.4.0 + +dependencies: + celest: ^1.0.0 + celest_backend: + path: .. + celest_core: ^1.0.0 + http: ^1.0.0 + native_storage: ^0.2.2 + +dependency_overrides: + celest: + path: ../../../../../../celest/packages/celest + celest_ast: + path: ../../../../../../celest/packages/celest_ast + celest_auth: + path: ../../../../../../celest/packages/celest_auth + celest_cloud: + path: ../../../../../../celest/packages/celest_cloud + celest_cloud_auth: + path: ../../../../../../celest/services/celest_cloud_auth + celest_core: + path: ../../../../../../celest/packages/celest_core +dev_dependencies: {} diff --git a/apps/cli/fixtures/legacy/streaming/goldens/api.local.dart b/apps/cli/fixtures/legacy/streaming/goldens/api.local.dart new file mode 100644 index 000000000..8d1ab9f1d --- /dev/null +++ b/apps/cli/fixtures/legacy/streaming/goldens/api.local.dart @@ -0,0 +1,24 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'package:celest/src/core/context.dart' as _i5; +import 'package:celest/src/runtime/serve.dart' as _i1; + +import 'functions/server_side/hello.dart' as _i2; +import 'functions/server_side/jsonValues.dart' as _i3; +import 'functions/server_side/stockTicker.dart' as _i4; + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: { + '/server-side/hello': _i2.HelloTarget(), + '/server-side/json-values': _i3.JsonValuesTarget(), + '/server-side/stock-ticker': _i4.StockTickerTarget(), + }, + setup: (_i5.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/streaming/goldens/ast.json b/apps/cli/fixtures/legacy/streaming/goldens/ast.json new file mode 100644 index 000000000..b80f2a12c --- /dev/null +++ b/apps/cli/fixtures/legacy/streaming/goldens/ast.json @@ -0,0 +1,559 @@ +{ + "name": "streaming", + "environment": "local", + "reference": { + "$": "Reference", + "symbol": "project", + "url": "package:celest_backend/src/project.dart" + }, + "apis": { + "server_side": { + "name": "server_side", + "metadata": [], + "functions": { + "hello": { + "name": "hello", + "apiName": "server_side", + "typeParameters": [], + "parameters": [ + { + "name": "names", + "type": { + "$": "TypeReference", + "symbol": "List", + "url": "dart:core", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [], + "location": { + "start": { + "offset": 234, + "uri": "package:celest_backend/src/functions/server_side.dart", + "line": 8, + "column": 34 + }, + "end": { + "offset": 239, + "uri": "package:celest_backend/src/functions/server_side.dart", + "line": 8, + "column": 39 + }, + "text": "names" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "Stream", + "url": "dart:async", + "types": [ + { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 215, + "uri": "package:celest_backend/src/functions/server_side.dart", + "line": 8, + "column": 15 + }, + "end": { + "offset": 220, + "uri": "package:celest_backend/src/functions/server_side.dart", + "line": 8, + "column": 20 + }, + "text": "hello" + }, + "streamType": "unidirectionalServer" + }, + "stockTicker": { + "name": "stockTicker", + "apiName": "server_side", + "typeParameters": [], + "parameters": [ + { + "name": "symbol", + "type": { + "$": "TypeReference", + "symbol": "String", + "url": "dart:core", + "isNullable": false + }, + "required": true, + "named": false, + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "httpQuery", + "url": "package:celest/src/functions/http/http_query.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "httpQuery", + "url": "package:celest/src/functions/http/http_query.dart", + "isNullable": false + } + } + ], + "location": { + "start": { + "offset": 376, + "uri": "package:celest_backend/src/functions/server_side.dart", + "line": 15, + "column": 55 + }, + "end": { + "offset": 382, + "uri": "package:celest_backend/src/functions/server_side.dart", + "line": 15, + "column": 61 + }, + "text": "symbol" + }, + "references": { + "name": "symbol", + "type": "httpQuery" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "Stream", + "url": "dart:async", + "types": [ + { + "$": "TypeReference", + "symbol": "AvailableStock", + "url": "package:_common/src/models/available_stock.dart", + "isNullable": false + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "AvailableStock", + "url": "package:_common/src/models/available_stock.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 344, + "uri": "package:celest_backend/src/functions/server_side.dart", + "line": 15, + "column": 23 + }, + "end": { + "offset": 355, + "uri": "package:celest_backend/src/functions/server_side.dart", + "line": 15, + "column": 34 + }, + "text": "stockTicker" + }, + "streamType": "unidirectionalServer" + }, + "jsonValues": { + "name": "jsonValues", + "apiName": "server_side", + "typeParameters": [], + "parameters": [], + "returnType": { + "$": "TypeReference", + "symbol": "Stream", + "url": "dart:async", + "types": [ + { + "$": "TypeReference", + "symbol": "JsonValue", + "url": "package:celest_core/src/serialization/json_value.dart", + "isNullable": false + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "JsonValue", + "url": "package:celest_core/src/serialization/json_value.dart", + "isNullable": false + }, + "metadata": [], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 530, + "uri": "package:celest_backend/src/functions/server_side.dart", + "line": 22, + "column": 18 + }, + "end": { + "offset": 540, + "uri": "package:celest_backend/src/functions/server_side.dart", + "line": 22, + "column": 28 + }, + "text": "jsonValues" + }, + "streamType": "unidirectionalServer" + } + }, + "docs": [ + "/// Tests the ability to use server-side streaming." + ], + "exceptionTypes": [ + { + "$": "TypeReference", + "symbol": "Error", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AssertionError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "TypeError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ArgumentError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "RangeError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "IndexError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnsupportedError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnimplementedError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "StateError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ConcurrentModificationError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "OutOfMemoryError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "StackOverflowError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "Exception", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "FormatException", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "IntegerDivisionByZeroException", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AsyncError", + "url": "dart:async", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "TimeoutException", + "url": "dart:async", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "JsonUnsupportedObjectError", + "url": "dart:convert", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "CloudException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "CancelledException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnknownError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "BadRequestException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnauthorizedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "NotFoundException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AlreadyExistsException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "PermissionDeniedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ResourceExhaustedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "FailedPreconditionException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AbortedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "OutOfRangeException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnimplementedError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "InternalServerError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnavailableError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "DataLossError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "DeadlineExceededError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "SerializationException", + "url": "package:celest_core/src/exception/serialization_exception.dart", + "isNullable": false + } + ], + "location": { + "start": { + "offset": 0, + "uri": "package:celest_backend/src/functions/server_side.dart", + "line": 0, + "column": 0 + }, + "end": { + "offset": 0, + "uri": "package:celest_backend/src/functions/server_side.dart", + "line": 0, + "column": 0 + }, + "text": "" + } + } + }, + "variables": [], + "secrets": [], + "databases": {}, + "sdkConfig": { + "celest": "1.0.6+2", + "dart": { + "type": "dart", + "version": "3.29.0", + "enabledExperiments": [] + }, + "targetSdk": "dart", + "featureFlags": [ + "streaming" + ], + "flutter": { + "type": "flutter", + "version": "3.29.0", + "enabledExperiments": [] + } + }, + "location": { + "start": { + "offset": 44, + "uri": "project.dart", + "line": 2, + "column": 6 + }, + "end": { + "offset": 80, + "uri": "project.dart", + "line": 2, + "column": 42 + }, + "text": "project = Project(name: 'streaming')" + } +} \ No newline at end of file diff --git a/apps/cli/fixtures/legacy/streaming/goldens/ast.resolved.json b/apps/cli/fixtures/legacy/streaming/goldens/ast.resolved.json new file mode 100644 index 000000000..8c44f7140 --- /dev/null +++ b/apps/cli/fixtures/legacy/streaming/goldens/ast.resolved.json @@ -0,0 +1,90 @@ +{ + "projectId": "streaming", + "environmentId": "local", + "apis": { + "server_side": { + "apiId": "server_side", + "functions": { + "hello": { + "functionId": "hello", + "apiId": "server_side", + "httpConfig": { + "route": { + "method": "POST", + "path": "/server-side/hello" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": { + "type": "unidirectionalServer" + } + }, + "stockTicker": { + "functionId": "stockTicker", + "apiId": "server_side", + "httpConfig": { + "route": { + "method": "POST", + "path": "/server-side/stock-ticker" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": { + "type": "unidirectionalServer" + } + }, + "jsonValues": { + "functionId": "jsonValues", + "apiId": "server_side", + "httpConfig": { + "route": { + "method": "POST", + "path": "/server-side/json-values" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": { + "type": "unidirectionalServer" + } + } + } + } + }, + "variables": [ + { + "name": "CELEST_ENVIRONMENT", + "value": "local" + } + ], + "secrets": [], + "databases": {}, + "sdkConfig": { + "celest": "1.0.6+2", + "dart": { + "type": "dart", + "version": "3.29.0", + "enabledExperiments": [] + }, + "targetSdk": "dart", + "featureFlags": [ + "streaming" + ], + "flutter": { + "type": "flutter", + "version": "3.29.0", + "enabledExperiments": [] + } + } +} \ No newline at end of file diff --git a/apps/cli/fixtures/legacy/streaming/goldens/celest.json b/apps/cli/fixtures/legacy/streaming/goldens/celest.json new file mode 100644 index 000000000..a185d283f --- /dev/null +++ b/apps/cli/fixtures/legacy/streaming/goldens/celest.json @@ -0,0 +1,96 @@ +{ + "projectId": "streaming", + "environmentId": "local", + "apis": { + "server_side": { + "apiId": "server_side", + "functions": { + "hello": { + "functionId": "hello", + "parentId": "server_side", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/server-side/hello" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "UNIDIRECTIONAL_SERVER" + } + }, + "stockTicker": { + "functionId": "stockTicker", + "parentId": "server_side", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/server-side/stock-ticker" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "UNIDIRECTIONAL_SERVER" + } + }, + "jsonValues": { + "functionId": "jsonValues", + "parentId": "server_side", + "httpConfig": { + "status": 200, + "route": { + "method": "POST", + "path": "/server-side/json-values" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "UNIDIRECTIONAL_SERVER" + } + } + } + } + }, + "variables": [ + { + "name": "CELEST_ENVIRONMENT", + "value": "local" + } + ], + "databases": {}, + "sdkConfig": { + "celest": { + "major": 1, + "minor": 0, + "patch": 6, + "build": [ + 2.0 + ], + "canonicalizedVersion": "1.0.6+2" + }, + "dart": { + "type": "DART", + "version": { + "major": 3, + "minor": 29, + "patch": 0, + "canonicalizedVersion": "3.29.0" + } + }, + "flutter": { + "type": "FLUTTER", + "version": { + "major": 3, + "minor": 29, + "patch": 0, + "canonicalizedVersion": "3.29.0" + } + }, + "targetSdk": "DART", + "featureFlags": [ + "STREAMING" + ] + } +} \ No newline at end of file diff --git a/apps/cli/fixtures/legacy/streaming/goldens/functions/server_side/hello.dart b/apps/cli/fixtures/legacy/streaming/goldens/functions/server_side/hello.dart new file mode 100644 index 000000000..a99ac2453 --- /dev/null +++ b/apps/cli/fixtures/legacy/streaming/goldens/functions/server_side/hello.dart @@ -0,0 +1,1541 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i7; +import 'dart:convert' as _i8; + +import 'package:celest/celest.dart' as _i6; +import 'package:celest/src/core/context.dart' as _i4; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/server_side.dart' as _i2; +import 'package:celest_core/celest_core.dart' as _i5; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i3; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i9; +import 'package:celest_core/src/serialization/json_value.dart' as _i10; + +final class HelloTarget extends _i1.CloudEventSourceTarget { + @override + String get name => 'hello'; + + @override + bool get hasBody => true; + + @override + Stream handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async* { + try { + await for (final response in _i2.hello( + (request[r'names'] as Iterable) + .map((el) => (el as String)) + .toList(), + )) { + yield response; + } + } on _i3.AbortedException catch (e, st) { + const statusCode = 409; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i5.Serializers.instance.serialize<_i3.AbortedException>( + e, + ), + }, + if (_i4.context.environment != _i6.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i3.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i5.Serializers.instance + .serialize<_i3.AlreadyExistsException>(e), + }, + if (_i4.context.environment != _i6.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on AssertionError catch (e, st) { + const statusCode = 500; + _i4.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i5.Serializers.instance.serialize(e), + }, + if (_i4.context.environment != _i6.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i7.AsyncError catch (e, st) { + const statusCode = 500; + _i4.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i5.Serializers.instance.serialize<_i7.AsyncError>(e), + }, + if (_i4.context.environment != _i6.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i3.CancelledException catch (e, st) { + const statusCode = 499; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i5.Serializers.instance + .serialize<_i3.CancelledException>(e), + }, + if (_i4.context.environment != _i6.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i4.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i5.Serializers.instance + .serialize(e), + }, + if (_i4.context.environment != _i6.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i3.DataLossError catch (e, st) { + const statusCode = 500; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i5.Serializers.instance.serialize<_i3.DataLossError>(e), + }, + if (_i4.context.environment != _i6.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i3.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i5.Serializers.instance + .serialize<_i3.DeadlineExceededError>(e), + }, + if (_i4.context.environment != _i6.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i3.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i5.Serializers.instance + .serialize<_i3.FailedPreconditionException>(e), + }, + if (_i4.context.environment != _i6.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on IndexError catch (e, st) { + const statusCode = 500; + _i4.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i5.Serializers.instance.serialize(e), + }, + if (_i4.context.environment != _i6.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i5.Serializers.instance + .serialize(e), + }, + if (_i4.context.environment != _i6.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i3.InternalServerError catch (e, st) { + const statusCode = 500; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i5.Serializers.instance + .serialize<_i3.InternalServerError>(e), + }, + if (_i4.context.environment != _i6.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i8.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i4.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i5.Serializers.instance + .serialize<_i8.JsonUnsupportedObjectError>(e), + }, + if (_i4.context.environment != _i6.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i3.NotFoundException catch (e, st) { + const statusCode = 404; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i5.Serializers.instance + .serialize<_i3.NotFoundException>(e), + }, + if (_i4.context.environment != _i6.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i4.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i5.Serializers.instance.serialize(e), + }, + if (_i4.context.environment != _i6.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i3.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i5.Serializers.instance + .serialize<_i3.OutOfRangeException>(e), + }, + if (_i4.context.environment != _i6.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i3.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i5.Serializers.instance + .serialize<_i3.PermissionDeniedException>(e), + }, + if (_i4.context.environment != _i6.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on RangeError catch (e, st) { + const statusCode = 500; + _i4.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i5.Serializers.instance.serialize(e), + }, + if (_i4.context.environment != _i6.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i4.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i5.Serializers.instance.serialize(e), + }, + if (_i4.context.environment != _i6.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i3.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i5.Serializers.instance + .serialize<_i3.ResourceExhaustedException>(e), + }, + if (_i4.context.environment != _i6.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i9.SerializationException catch (e, st) { + const statusCode = 400; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i5.Serializers.instance + .serialize<_i9.SerializationException>(e), + }, + if (_i4.context.environment != _i6.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i3.BadRequestException catch (e, st) { + const statusCode = 400; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i5.Serializers.instance + .serialize<_i3.BadRequestException>(e), + }, + if (_i4.context.environment != _i6.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on FormatException catch (e, st) { + const statusCode = 400; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i5.Serializers.instance.serialize(e), + }, + if (_i4.context.environment != _i6.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i4.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i5.Serializers.instance.serialize( + e, + ), + }, + if (_i4.context.environment != _i6.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on StateError catch (e, st) { + const statusCode = 500; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i5.Serializers.instance.serialize(e), + }, + if (_i4.context.environment != _i6.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i7.TimeoutException catch (e, st) { + const statusCode = 400; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i5.Serializers.instance.serialize<_i7.TimeoutException>( + e, + ), + }, + if (_i4.context.environment != _i6.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on TypeError catch (e, st) { + const statusCode = 500; + _i4.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i5.Serializers.instance.serialize(e), + }, + if (_i4.context.environment != _i6.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i3.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i5.Serializers.instance + .serialize<_i3.UnauthorizedException>(e), + }, + if (_i4.context.environment != _i6.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i3.UnavailableError catch (e, st) { + const statusCode = 503; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i5.Serializers.instance.serialize<_i3.UnavailableError>( + e, + ), + }, + if (_i4.context.environment != _i6.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i3.UnimplementedError catch (e, st) { + const statusCode = 501; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i5.Serializers.instance + .serialize<_i3.UnimplementedError>(e), + }, + if (_i4.context.environment != _i6.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i5.Serializers.instance.serialize( + e, + ), + }, + if (_i4.context.environment != _i6.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i3.UnknownError catch (e, st) { + const statusCode = 500; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i5.Serializers.instance.serialize<_i3.UnknownError>(e), + }, + if (_i4.context.environment != _i6.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i3.CloudException catch (e, st) { + const statusCode = 400; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i5.Serializers.instance.serialize<_i3.CloudException>( + e, + ), + }, + if (_i4.context.environment != _i6.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on Exception catch (e, st) { + const statusCode = 400; + _i4.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i5.Serializers.instance.serialize(e), + }, + if (_i4.context.environment != _i6.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i4.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i5.Serializers.instance.serialize(e), + }, + if (_i4.context.environment != _i6.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on Error catch (e, st) { + const statusCode = 500; + _i4.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i5.Serializers.instance.serialize(e), + }, + if (_i4.context.environment != _i6.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i5.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } + } + + @override + void init() { + _i5.Serializers.instance.put( + _i5.Serializer.define<_i7.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i5.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i7.AsyncError( + $serialized[r'error']!, + _i5.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define<_i7.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i5.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i7.TimeoutException( + ($serialized[r'message'] as String?), + _i5.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define< + _i8.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i8.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define?>( + serialize: + ($value) => { + if (_i5.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define<_i3.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i5.Serializers.instance.serialize<_i10.JsonValue?>( + $value.details, + const _i5.TypeToken<_i10.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i3.AbortedException( + ($serialized?[r'message'] as String?), + _i5.Serializers.instance.deserialize<_i10.JsonValue?>( + $serialized?[r'details'], + const _i5.TypeToken<_i10.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define<_i3.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i5.Serializers.instance.serialize<_i10.JsonValue?>( + $value.details, + const _i5.TypeToken<_i10.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i3.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i5.Serializers.instance.deserialize<_i10.JsonValue?>( + $serialized?[r'details'], + const _i5.TypeToken<_i10.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define<_i3.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i5.Serializers.instance.serialize<_i10.JsonValue?>( + $value.details, + const _i5.TypeToken<_i10.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i3.BadRequestException( + ($serialized?[r'message'] as String?), + _i5.Serializers.instance.deserialize<_i10.JsonValue?>( + $serialized?[r'details'], + const _i5.TypeToken<_i10.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define<_i3.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i5.Serializers.instance.serialize<_i10.JsonValue?>( + $value.details, + const _i5.TypeToken<_i10.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i3.CancelledException( + ($serialized?[r'message'] as String?), + _i5.Serializers.instance.deserialize<_i10.JsonValue?>( + $serialized?[r'details'], + const _i5.TypeToken<_i10.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define<_i3.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i5.Serializers.instance.serialize<_i10.JsonValue?>( + $value.details, + const _i5.TypeToken<_i10.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i3.CloudException.fromJson($serialized); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define<_i3.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i5.Serializers.instance.serialize<_i10.JsonValue?>( + $value.details, + const _i5.TypeToken<_i10.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i3.DataLossError( + ($serialized?[r'message'] as String?), + _i5.Serializers.instance.deserialize<_i10.JsonValue?>( + $serialized?[r'details'], + const _i5.TypeToken<_i10.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define<_i3.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i5.Serializers.instance.serialize<_i10.JsonValue?>( + $value.details, + const _i5.TypeToken<_i10.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i3.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i5.Serializers.instance.deserialize<_i10.JsonValue?>( + $serialized?[r'details'], + const _i5.TypeToken<_i10.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define< + _i3.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i5.Serializers.instance.serialize<_i10.JsonValue?>( + $value.details, + const _i5.TypeToken<_i10.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i3.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i5.Serializers.instance.deserialize<_i10.JsonValue?>( + $serialized?[r'details'], + const _i5.TypeToken<_i10.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define<_i3.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i5.Serializers.instance.serialize<_i10.JsonValue?>( + $value.details, + const _i5.TypeToken<_i10.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i3.InternalServerError( + ($serialized?[r'message'] as String?), + _i5.Serializers.instance.deserialize<_i10.JsonValue?>( + $serialized?[r'details'], + const _i5.TypeToken<_i10.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define<_i3.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i5.Serializers.instance.serialize<_i10.JsonValue?>( + $value.details, + const _i5.TypeToken<_i10.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i3.NotFoundException( + ($serialized?[r'message'] as String?), + _i5.Serializers.instance.deserialize<_i10.JsonValue?>( + $serialized?[r'details'], + const _i5.TypeToken<_i10.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define<_i3.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i5.Serializers.instance.serialize<_i10.JsonValue?>( + $value.details, + const _i5.TypeToken<_i10.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i3.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i5.Serializers.instance.deserialize<_i10.JsonValue?>( + $serialized?[r'details'], + const _i5.TypeToken<_i10.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define< + _i3.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i5.Serializers.instance.serialize<_i10.JsonValue?>( + $value.details, + const _i5.TypeToken<_i10.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i3.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i5.Serializers.instance.deserialize<_i10.JsonValue?>( + $serialized?[r'details'], + const _i5.TypeToken<_i10.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define< + _i3.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i5.Serializers.instance.serialize<_i10.JsonValue?>( + $value.details, + const _i5.TypeToken<_i10.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i3.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i5.Serializers.instance.deserialize<_i10.JsonValue?>( + $serialized?[r'details'], + const _i5.TypeToken<_i10.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define<_i3.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i5.Serializers.instance.serialize<_i10.JsonValue?>( + $value.details, + const _i5.TypeToken<_i10.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i3.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i5.Serializers.instance.deserialize<_i10.JsonValue?>( + $serialized?[r'details'], + const _i5.TypeToken<_i10.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define<_i3.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i5.Serializers.instance.serialize<_i10.JsonValue?>( + $value.details, + const _i5.TypeToken<_i10.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i3.UnavailableError( + ($serialized?[r'message'] as String?), + _i5.Serializers.instance.deserialize<_i10.JsonValue?>( + $serialized?[r'details'], + const _i5.TypeToken<_i10.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define<_i3.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i5.Serializers.instance.serialize<_i10.JsonValue?>( + $value.details, + const _i5.TypeToken<_i10.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i3.UnimplementedError( + ($serialized?[r'message'] as String?), + _i5.Serializers.instance.deserialize<_i10.JsonValue?>( + $serialized?[r'details'], + const _i5.TypeToken<_i10.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define<_i3.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i5.Serializers.instance.serialize<_i10.JsonValue?>( + $value.details, + const _i5.TypeToken<_i10.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i3.UnknownError( + ($serialized?[r'message'] as String?), + _i5.Serializers.instance.deserialize<_i10.JsonValue?>( + $serialized?[r'details'], + const _i5.TypeToken<_i10.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define<_i9.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i5.Serializers.instance.serialize<_i10.JsonValue?>( + $value.details, + const _i5.TypeToken<_i10.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i9.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i5.Serializers.instance.put( + _i5.Serializer.define<_i10.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i10.JsonValue($serialized); + }, + ), + const _i5.TypeToken<_i10.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': HelloTarget()}, + setup: (_i4.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/streaming/goldens/functions/server_side/jsonValues.dart b/apps/cli/fixtures/legacy/streaming/goldens/functions/server_side/jsonValues.dart new file mode 100644 index 000000000..9fd89e880 --- /dev/null +++ b/apps/cli/fixtures/legacy/streaming/goldens/functions/server_side/jsonValues.dart @@ -0,0 +1,1540 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i9; + +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/server_side.dart' as _i2; +import 'package:celest_core/celest_core.dart' as _i3; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i10; +import 'package:celest_core/src/serialization/json_value.dart' as _i4; + +final class JsonValuesTarget extends _i1.CloudEventSourceTarget { + @override + String get name => 'jsonValues'; + + @override + bool get hasBody => false; + + @override + Stream handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async* { + try { + await for (final response in _i2.jsonValues()) { + yield _i3.Serializers.instance.serialize<_i4.JsonValue>( + response, + const _i3.TypeToken<_i4.JsonValue>('JsonValue'), + ); + } + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i3.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i3.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i3.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i3.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i3.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i3.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i3.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i3.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i3.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i3.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i3.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i3.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i3.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i3.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i3.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i3.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i3.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i3.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i3.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i3.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i3.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i3.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i3.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i3.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i9.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i3.Serializers.instance + .serialize<_i9.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i3.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i3.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i3.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i3.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i3.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i3.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i3.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i3.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i3.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i3.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i3.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i3.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i3.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i3.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i3.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i10.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i3.Serializers.instance + .serialize<_i10.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i3.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i3.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i3.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i3.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i3.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i3.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i3.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i3.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i3.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i3.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i3.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i3.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i3.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i3.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i3.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i3.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i3.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i3.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i3.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i3.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i3.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i3.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i3.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i3.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i3.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i3.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i3.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i3.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i3.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i3.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i3.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } + } + + @override + void init() { + _i3.Serializers.instance.put( + _i3.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i3.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i3.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i3.Serializers.instance.put( + _i3.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i3.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i3.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i3.Serializers.instance.put( + _i3.Serializer.define< + _i9.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i9.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i3.Serializers.instance.put( + _i3.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i3.Serializers.instance.put( + _i3.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i3.Serializers.instance.put( + _i3.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i3.Serializers.instance.put( + _i3.Serializer.define?>( + serialize: + ($value) => { + if (_i3.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i3.Serializers.instance.put( + _i3.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i3.Serializers.instance.put( + _i3.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i3.Serializers.instance.put( + _i3.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i3.Serializers.instance.put( + _i3.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i3.Serializers.instance.put( + _i3.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i3.Serializers.instance.put( + _i3.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i3.Serializers.instance.put( + _i3.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i3.Serializers.instance.put( + _i3.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i3.Serializers.instance.put( + _i3.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i3.Serializers.instance.put( + _i3.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i3.Serializers.instance.put( + _i3.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i3.Serializers.instance.put( + _i3.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i3.Serializers.instance.serialize<_i4.JsonValue?>( + $value.details, + const _i3.TypeToken<_i4.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i3.Serializers.instance.deserialize<_i4.JsonValue?>( + $serialized?[r'details'], + const _i3.TypeToken<_i4.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i3.Serializers.instance.put( + _i3.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i3.Serializers.instance.serialize<_i4.JsonValue?>( + $value.details, + const _i3.TypeToken<_i4.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i3.Serializers.instance.deserialize<_i4.JsonValue?>( + $serialized?[r'details'], + const _i3.TypeToken<_i4.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i3.Serializers.instance.put( + _i3.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i3.Serializers.instance.serialize<_i4.JsonValue?>( + $value.details, + const _i3.TypeToken<_i4.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i3.Serializers.instance.deserialize<_i4.JsonValue?>( + $serialized?[r'details'], + const _i3.TypeToken<_i4.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i3.Serializers.instance.put( + _i3.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i3.Serializers.instance.serialize<_i4.JsonValue?>( + $value.details, + const _i3.TypeToken<_i4.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i3.Serializers.instance.deserialize<_i4.JsonValue?>( + $serialized?[r'details'], + const _i3.TypeToken<_i4.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i3.Serializers.instance.put( + _i3.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i3.Serializers.instance.serialize<_i4.JsonValue?>( + $value.details, + const _i3.TypeToken<_i4.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i3.Serializers.instance.put( + _i3.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i3.Serializers.instance.serialize<_i4.JsonValue?>( + $value.details, + const _i3.TypeToken<_i4.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i3.Serializers.instance.deserialize<_i4.JsonValue?>( + $serialized?[r'details'], + const _i3.TypeToken<_i4.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i3.Serializers.instance.put( + _i3.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i3.Serializers.instance.serialize<_i4.JsonValue?>( + $value.details, + const _i3.TypeToken<_i4.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i3.Serializers.instance.deserialize<_i4.JsonValue?>( + $serialized?[r'details'], + const _i3.TypeToken<_i4.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i3.Serializers.instance.put( + _i3.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i3.Serializers.instance.serialize<_i4.JsonValue?>( + $value.details, + const _i3.TypeToken<_i4.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i3.Serializers.instance.deserialize<_i4.JsonValue?>( + $serialized?[r'details'], + const _i3.TypeToken<_i4.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i3.Serializers.instance.put( + _i3.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i3.Serializers.instance.serialize<_i4.JsonValue?>( + $value.details, + const _i3.TypeToken<_i4.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i3.Serializers.instance.deserialize<_i4.JsonValue?>( + $serialized?[r'details'], + const _i3.TypeToken<_i4.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i3.Serializers.instance.put( + _i3.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i3.Serializers.instance.serialize<_i4.JsonValue?>( + $value.details, + const _i3.TypeToken<_i4.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i3.Serializers.instance.deserialize<_i4.JsonValue?>( + $serialized?[r'details'], + const _i3.TypeToken<_i4.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i3.Serializers.instance.put( + _i3.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i3.Serializers.instance.serialize<_i4.JsonValue?>( + $value.details, + const _i3.TypeToken<_i4.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i3.Serializers.instance.deserialize<_i4.JsonValue?>( + $serialized?[r'details'], + const _i3.TypeToken<_i4.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i3.Serializers.instance.put( + _i3.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i3.Serializers.instance.serialize<_i4.JsonValue?>( + $value.details, + const _i3.TypeToken<_i4.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i3.Serializers.instance.deserialize<_i4.JsonValue?>( + $serialized?[r'details'], + const _i3.TypeToken<_i4.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i3.Serializers.instance.put( + _i3.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i3.Serializers.instance.serialize<_i4.JsonValue?>( + $value.details, + const _i3.TypeToken<_i4.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i3.Serializers.instance.deserialize<_i4.JsonValue?>( + $serialized?[r'details'], + const _i3.TypeToken<_i4.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i3.Serializers.instance.put( + _i3.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i3.Serializers.instance.serialize<_i4.JsonValue?>( + $value.details, + const _i3.TypeToken<_i4.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i3.Serializers.instance.deserialize<_i4.JsonValue?>( + $serialized?[r'details'], + const _i3.TypeToken<_i4.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i3.Serializers.instance.put( + _i3.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i3.Serializers.instance.serialize<_i4.JsonValue?>( + $value.details, + const _i3.TypeToken<_i4.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i3.Serializers.instance.deserialize<_i4.JsonValue?>( + $serialized?[r'details'], + const _i3.TypeToken<_i4.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i3.Serializers.instance.put( + _i3.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i3.Serializers.instance.serialize<_i4.JsonValue?>( + $value.details, + const _i3.TypeToken<_i4.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i3.Serializers.instance.deserialize<_i4.JsonValue?>( + $serialized?[r'details'], + const _i3.TypeToken<_i4.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i3.Serializers.instance.put( + _i3.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i3.Serializers.instance.serialize<_i4.JsonValue?>( + $value.details, + const _i3.TypeToken<_i4.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i3.Serializers.instance.deserialize<_i4.JsonValue?>( + $serialized?[r'details'], + const _i3.TypeToken<_i4.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i3.Serializers.instance.put( + _i3.Serializer.define<_i10.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i3.Serializers.instance.serialize<_i4.JsonValue?>( + $value.details, + const _i3.TypeToken<_i4.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i10.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i3.Serializers.instance.put( + _i3.Serializer.define<_i4.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i4.JsonValue($serialized); + }, + ), + const _i3.TypeToken<_i4.JsonValue>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': JsonValuesTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/streaming/goldens/functions/server_side/stockTicker.dart b/apps/cli/fixtures/legacy/streaming/goldens/functions/server_side/stockTicker.dart new file mode 100644 index 000000000..ed8b7895d --- /dev/null +++ b/apps/cli/fixtures/legacy/streaming/goldens/functions/server_side/stockTicker.dart @@ -0,0 +1,1558 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; +import 'dart:convert' as _i9; + +import 'package:_common/src/models/available_stock.dart' as _i4; +import 'package:celest/celest.dart' as _i7; +import 'package:celest/src/core/context.dart' as _i6; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/server_side.dart' as _i2; +import 'package:celest_core/celest_core.dart' as _i3; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i5; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i10; +import 'package:celest_core/src/serialization/json_value.dart' as _i11; + +final class StockTickerTarget extends _i1.CloudEventSourceTarget { + @override + String get name => 'stockTicker'; + + @override + bool get hasBody => false; + + @override + Stream handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async* { + try { + await for (final response in _i2.stockTicker( + queryParameters['symbol']!.first, + )) { + yield _i3.Serializers.instance.serialize<_i4.AvailableStock>(response); + } + } on _i5.AbortedException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i3.Serializers.instance.serialize<_i5.AbortedException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i3.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i3.Serializers.instance + .serialize<_i5.AlreadyExistsException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i3.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on AssertionError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i3.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i3.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i8.AsyncError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i3.Serializers.instance.serialize<_i8.AsyncError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i3.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.CancelledException catch (e, st) { + const statusCode = 499; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i3.Serializers.instance + .serialize<_i5.CancelledException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i3.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i3.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i3.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.DataLossError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i3.Serializers.instance.serialize<_i5.DataLossError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i3.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i3.Serializers.instance + .serialize<_i5.DeadlineExceededError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i3.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i3.Serializers.instance + .serialize<_i5.FailedPreconditionException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i3.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on IndexError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i3.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i3.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i3.Serializers.instance + .serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i3.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.InternalServerError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i3.Serializers.instance + .serialize<_i5.InternalServerError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i3.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i9.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i3.Serializers.instance + .serialize<_i9.JsonUnsupportedObjectError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i3.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.NotFoundException catch (e, st) { + const statusCode = 404; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i3.Serializers.instance + .serialize<_i5.NotFoundException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i3.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i3.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i3.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i3.Serializers.instance + .serialize<_i5.OutOfRangeException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i3.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i3.Serializers.instance + .serialize<_i5.PermissionDeniedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i3.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on RangeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i3.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i3.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i3.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i3.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i3.Serializers.instance + .serialize<_i5.ResourceExhaustedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i3.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i10.SerializationException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i3.Serializers.instance + .serialize<_i10.SerializationException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i3.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.BadRequestException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i3.Serializers.instance + .serialize<_i5.BadRequestException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i3.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on FormatException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i3.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i3.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i3.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i3.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on StateError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i3.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i3.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i8.TimeoutException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i3.Serializers.instance.serialize<_i8.TimeoutException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i3.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on TypeError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i3.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i3.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i3.Serializers.instance + .serialize<_i5.UnauthorizedException>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i3.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.UnavailableError catch (e, st) { + const statusCode = 503; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i3.Serializers.instance.serialize<_i5.UnavailableError>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i3.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.UnimplementedError catch (e, st) { + const statusCode = 501; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i3.Serializers.instance + .serialize<_i5.UnimplementedError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i3.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i3.Serializers.instance.serialize( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i3.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.UnknownError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i3.Serializers.instance.serialize<_i5.UnknownError>(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i3.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on _i5.CloudException catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i3.Serializers.instance.serialize<_i5.CloudException>( + e, + ), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i3.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on Exception catch (e, st) { + const statusCode = 400; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i3.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i3.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i3.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i3.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } on Error catch (e, st) { + const statusCode = 500; + _i6.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i3.Serializers.instance.serialize(e), + }, + if (_i6.context.environment != _i7.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i3.Serializers.instance.serialize(st), + }, + ], + }, + }; + yield status; + } + } + + @override + void init() { + _i3.Serializers.instance.put( + _i3.Serializer.define<_i8.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i3.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i8.AsyncError( + $serialized[r'error']!, + _i3.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i3.Serializers.instance.put( + _i3.Serializer.define<_i8.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i3.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i8.TimeoutException( + ($serialized[r'message'] as String?), + _i3.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i3.Serializers.instance.put( + _i3.Serializer.define< + _i9.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i9.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i3.Serializers.instance.put( + _i3.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i3.Serializers.instance.put( + _i3.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i3.Serializers.instance.put( + _i3.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i3.Serializers.instance.put( + _i3.Serializer.define?>( + serialize: + ($value) => { + if (_i3.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i3.Serializers.instance.put( + _i3.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i3.Serializers.instance.put( + _i3.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i3.Serializers.instance.put( + _i3.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i3.Serializers.instance.put( + _i3.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i3.Serializers.instance.put( + _i3.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i3.Serializers.instance.put( + _i3.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i3.Serializers.instance.put( + _i3.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i3.Serializers.instance.put( + _i3.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i3.Serializers.instance.put( + _i3.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i3.Serializers.instance.put( + _i3.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i3.Serializers.instance.put( + _i3.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i3.Serializers.instance.put( + _i3.Serializer.define<_i4.AvailableStock, Map>( + serialize: + ($value) => { + r'ticker': $value.ticker, + r'name': $value.name, + r'currentPrice': $value.currentPrice, + r'currentPriceStr': $value.currentPriceStr, + }, + deserialize: ($serialized) { + return _i4.AvailableStock( + ($serialized[r'ticker'] as String), + name: ($serialized[r'name'] as String), + currentPrice: ($serialized[r'currentPrice'] as num).toDouble(), + ); + }, + ), + ); + _i3.Serializers.instance.put( + _i3.Serializer.define<_i5.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i3.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i3.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AbortedException( + ($serialized?[r'message'] as String?), + _i3.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i3.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i3.Serializers.instance.put( + _i3.Serializer.define<_i5.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i3.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i3.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i3.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i3.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i3.Serializers.instance.put( + _i3.Serializer.define<_i5.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i3.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i3.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.BadRequestException( + ($serialized?[r'message'] as String?), + _i3.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i3.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i3.Serializers.instance.put( + _i3.Serializer.define<_i5.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i3.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i3.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CancelledException( + ($serialized?[r'message'] as String?), + _i3.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i3.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i3.Serializers.instance.put( + _i3.Serializer.define<_i5.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i3.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i3.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.CloudException.fromJson($serialized); + }, + ), + ); + _i3.Serializers.instance.put( + _i3.Serializer.define<_i5.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i3.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i3.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DataLossError( + ($serialized?[r'message'] as String?), + _i3.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i3.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i3.Serializers.instance.put( + _i3.Serializer.define<_i5.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i3.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i3.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i3.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i3.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i3.Serializers.instance.put( + _i3.Serializer.define< + _i5.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i3.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i3.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i3.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i3.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i3.Serializers.instance.put( + _i3.Serializer.define<_i5.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i3.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i3.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.InternalServerError( + ($serialized?[r'message'] as String?), + _i3.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i3.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i3.Serializers.instance.put( + _i3.Serializer.define<_i5.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i3.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i3.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.NotFoundException( + ($serialized?[r'message'] as String?), + _i3.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i3.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i3.Serializers.instance.put( + _i3.Serializer.define<_i5.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i3.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i3.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i3.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i3.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i3.Serializers.instance.put( + _i3.Serializer.define< + _i5.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i3.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i3.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i3.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i3.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i3.Serializers.instance.put( + _i3.Serializer.define< + _i5.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i3.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i3.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i3.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i3.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i3.Serializers.instance.put( + _i3.Serializer.define<_i5.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i3.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i3.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i3.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i3.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i3.Serializers.instance.put( + _i3.Serializer.define<_i5.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i3.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i3.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnavailableError( + ($serialized?[r'message'] as String?), + _i3.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i3.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i3.Serializers.instance.put( + _i3.Serializer.define<_i5.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i3.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i3.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnimplementedError( + ($serialized?[r'message'] as String?), + _i3.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i3.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i3.Serializers.instance.put( + _i3.Serializer.define<_i5.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i3.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i3.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i5.UnknownError( + ($serialized?[r'message'] as String?), + _i3.Serializers.instance.deserialize<_i11.JsonValue?>( + $serialized?[r'details'], + const _i3.TypeToken<_i11.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i3.Serializers.instance.put( + _i3.Serializer.define<_i10.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i3.Serializers.instance.serialize<_i11.JsonValue?>( + $value.details, + const _i3.TypeToken<_i11.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i10.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i3.Serializers.instance.put( + _i3.Serializer.define<_i11.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i11.JsonValue($serialized); + }, + ), + const _i3.TypeToken<_i11.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': StockTickerTarget()}, + setup: (_i6.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/streaming/lib/fix_data/v1_migration.yaml b/apps/cli/fixtures/legacy/streaming/lib/fix_data/v1_migration.yaml new file mode 100644 index 000000000..50aeba89c --- /dev/null +++ b/apps/cli/fixtures/legacy/streaming/lib/fix_data/v1_migration.yaml @@ -0,0 +1,13 @@ +# Generated by Celest. Do not modify. +version: 1 +transforms: + - title: "Updates the import of the Celest client" + date: 2024-10-06 + element: + uris: ["client.dart"] + variable: celest + changes: + - kind: replacedBy + newElement: + uris: ["package:streaming_client/streaming_client.dart"] + variable: celest diff --git a/apps/cli/fixtures/legacy/streaming/lib/src/functions/server_side.dart b/apps/cli/fixtures/legacy/streaming/lib/src/functions/server_side.dart new file mode 100644 index 000000000..13976abdc --- /dev/null +++ b/apps/cli/fixtures/legacy/streaming/lib/src/functions/server_side.dart @@ -0,0 +1,29 @@ +/// Tests the ability to use server-side streaming. +library; + +import 'package:_common/src/models/available_stock.dart'; +import 'package:celest/celest.dart'; +import 'package:celest/http.dart'; + +@cloud +Stream hello(List names) async* { + for (final name in names) { + yield 'Hello, $name!'; + } +} + +@cloud +Stream stockTicker(@httpQuery() String symbol) async* { + for (var i = 0; i < 3; i++) { + yield AvailableStock(symbol, name: symbol, currentPrice: 100.0 + i); + } +} + +@cloud +Stream jsonValues() async* { + yield JsonBool(true); + yield JsonNum(42); + yield JsonString('hello'); + yield JsonList([JsonBool(false), JsonInt(42), JsonDouble(42.0)]); + yield JsonMap({'key': JsonBool(true)}); +} diff --git a/apps/cli/fixtures/legacy/streaming/lib/src/generated/cloud.celest.dart b/apps/cli/fixtures/legacy/streaming/lib/src/generated/cloud.celest.dart new file mode 100644 index 000000000..f1a89c399 --- /dev/null +++ b/apps/cli/fixtures/legacy/streaming/lib/src/generated/cloud.celest.dart @@ -0,0 +1,45 @@ +// Generated by Celest. This file should not be modified manually, but +// it can be checked into version control. +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +library; + +import 'package:celest/src/core/context.dart'; +import 'package:celest_backend/src/generated/config.celest.dart'; + +/// The interface to your Celest backend. +/// +/// Similar to the `celest` global in the frontend, this +/// provides access to the backend environment and services +/// configured for your project. +const CelestCloud celest = CelestCloud._(); + +/// A per-request context object which propogates request information and common +/// accessors to the Celest server environment. +CelestContext get context => CelestContext._(context); + +/// The interface to your Celest backend. +/// +/// Similar to the `Celest` class in the frontend, this class +/// provides access to the backend environment and services +/// configured for your project. +class CelestCloud { + const CelestCloud._(); + + /// The current environment of the Celest service. + /// + /// This is determined by the `CELEST_ENVIRONMENT` variable + /// which is set for you by the deployment environment. + CelestEnvironment get currentEnvironment => + (variables.currentEnvironment as CelestEnvironment); + + /// The variables of the Celest service. + /// + /// This class provides access to the values configured for the + /// [currentEnvironment]. + CelestVariables get variables => const CelestVariables(); +} + +/// A per-request context object which propogates request information and common +/// accessors to the Celest server environment. +extension type CelestContext._(Context _context) implements Context {} diff --git a/apps/cli/fixtures/legacy/streaming/lib/src/generated/config.celest.dart b/apps/cli/fixtures/legacy/streaming/lib/src/generated/config.celest.dart new file mode 100644 index 000000000..687b9f186 --- /dev/null +++ b/apps/cli/fixtures/legacy/streaming/lib/src/generated/config.celest.dart @@ -0,0 +1,45 @@ +// Generated by Celest. This file should not be modified manually, but +// it can be checked into version control. +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +library; + +import 'package:celest/celest.dart'; +import 'package:celest/src/core/context.dart'; + +/// An environment of a deployed Celest service. +/// +/// Celest services can have multiple isolated branches, for example +/// a `development` and `production` environment. +extension type const CelestEnvironment._(String _env) + implements Environment, String { + /// The local Celest environment, used to delineate when a + /// Celest service is running on a developer machine as opposed + /// to the cloud. + static const CelestEnvironment local = CelestEnvironment._('local'); + + /// The production Celest environment which is common to all + /// Celest projects and labels the environment which is considered + /// live and served to end-users. + static const CelestEnvironment production = CelestEnvironment._('production'); + + /// Whether `this` represents the [local] environment. + bool get isLocal => this == local; + + /// Whether `this` represents the [production] environment. + bool get isProduction => this == production; +} + +/// The environment variables for the Celest service. +/// +/// This class provides access to the environment variable values +/// that are configured for the current [CelestEnvironment]. +class CelestVariables { + const CelestVariables(); + + /// The environment variable that determines the current environment. + /// + /// This is set by the deployment environment and is used to + /// determine the current environment of the Celest service. + String get currentEnvironment => context.expect(env.environment); +} diff --git a/apps/cli/fixtures/legacy/streaming/lib/src/project.dart b/apps/cli/fixtures/legacy/streaming/lib/src/project.dart new file mode 100644 index 000000000..7bbf4ba7d --- /dev/null +++ b/apps/cli/fixtures/legacy/streaming/lib/src/project.dart @@ -0,0 +1,3 @@ +import 'package:celest/celest.dart'; + +const project = Project(name: 'streaming'); diff --git a/apps/cli/fixtures/legacy/streaming/pubspec.yaml b/apps/cli/fixtures/legacy/streaming/pubspec.yaml new file mode 100644 index 000000000..bec67c0b5 --- /dev/null +++ b/apps/cli/fixtures/legacy/streaming/pubspec.yaml @@ -0,0 +1,32 @@ +name: celest_backend +publish_to: none + +environment: + sdk: ^3.4.0 + +dependencies: + _common: + path: ../_common + celest: ^1.0.0 + celest_core: ^1.0.0 + meta: ^1.12.0 + +dependency_overrides: + cedar: + path: ../../../../../cedar/packages/cedar + celest: + path: ../../../../../celest/packages/celest + celest_ast: + path: ../../../../../celest/packages/celest_ast + celest_auth: + path: ../../../../../celest/packages/celest_auth + celest_cloud: + path: ../../../../../celest/packages/celest_cloud + celest_cloud_auth: + path: ../../../../../celest/services/celest_cloud_auth + celest_core: + path: ../../../../../celest/packages/celest_core + +dev_dependencies: + lints: ^4.0.0 + test: ^1.25.0 diff --git a/apps/cli/fixtures/legacy/supabase/.gitignore b/apps/cli/fixtures/legacy/supabase/.gitignore new file mode 100644 index 000000000..29a3a5017 --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/.gitignore @@ -0,0 +1,43 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ +migrate_working_dir/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +**/doc/api/ +**/ios/Flutter/.last_build_id +.dart_tool/ +.flutter-plugins +.flutter-plugins-dependencies +.pub-cache/ +.pub/ +/build/ + +# Symbolication related +app.*.symbols + +# Obfuscation related +app.*.map.json + +# Android Studio will place build artifacts here +/android/app/debug +/android/app/profile +/android/app/release diff --git a/apps/cli/fixtures/legacy/supabase/.metadata b/apps/cli/fixtures/legacy/supabase/.metadata new file mode 100644 index 000000000..2d1be89a7 --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/.metadata @@ -0,0 +1,45 @@ +# This file tracks properties of this Flutter project. +# Used by Flutter tool to assess capabilities and perform upgrades etc. +# +# This file should be version controlled and should not be manually edited. + +version: + revision: "2663184aa79047d0a33a14a3b607954f8fdd8730" + channel: "stable" + +project_type: app + +# Tracks metadata for the flutter migrate command +migration: + platforms: + - platform: root + create_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730 + base_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730 + - platform: android + create_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730 + base_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730 + - platform: ios + create_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730 + base_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730 + - platform: linux + create_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730 + base_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730 + - platform: macos + create_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730 + base_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730 + - platform: web + create_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730 + base_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730 + - platform: windows + create_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730 + base_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730 + + # User provided section + + # List of Local paths (relative to this file) that should be + # ignored by the migrate tool. + # + # Files that are not part of the templates will be ignored by default. + unmanaged_files: + - 'lib/main.dart' + - 'ios/Runner.xcodeproj/project.pbxproj' diff --git a/apps/cli/fixtures/legacy/supabase/README.md b/apps/cli/fixtures/legacy/supabase/README.md new file mode 100644 index 000000000..3e0d96880 --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/README.md @@ -0,0 +1,3 @@ +# supabase_test + +A new Flutter project. diff --git a/apps/cli/fixtures/legacy/supabase/analysis_options.yaml b/apps/cli/fixtures/legacy/supabase/analysis_options.yaml new file mode 100644 index 000000000..08041e3a6 --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/analysis_options.yaml @@ -0,0 +1,5 @@ +include: package:flutter_lints/flutter.yaml + +analyzer: + plugins: + - celest diff --git a/apps/cli/fixtures/legacy/supabase/android/.gitignore b/apps/cli/fixtures/legacy/supabase/android/.gitignore new file mode 100644 index 000000000..55afd919c --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/android/.gitignore @@ -0,0 +1,13 @@ +gradle-wrapper.jar +/.gradle +/captures/ +/gradlew +/gradlew.bat +/local.properties +GeneratedPluginRegistrant.java + +# Remember to never publicly share your keystore. +# See https://flutter.dev/to/reference-keystore +key.properties +**/*.keystore +**/*.jks diff --git a/apps/cli/fixtures/legacy/supabase/android/app/build.gradle b/apps/cli/fixtures/legacy/supabase/android/app/build.gradle new file mode 100644 index 000000000..c303df726 --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/android/app/build.gradle @@ -0,0 +1,44 @@ +plugins { + id "com.android.application" + id "kotlin-android" + // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins. + id "dev.flutter.flutter-gradle-plugin" +} + +android { + namespace = "dev.celest.supabase_test" + compileSdk = flutter.compileSdkVersion + ndkVersion = flutter.ndkVersion + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } + + kotlinOptions { + jvmTarget = JavaVersion.VERSION_1_8 + } + + defaultConfig { + // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). + applicationId = "dev.celest.supabase_test" + // You can update the following values to match your application needs. + // For more information, see: https://flutter.dev/to/review-gradle-config. + minSdk = flutter.minSdkVersion + targetSdk = flutter.targetSdkVersion + versionCode = flutter.versionCode + versionName = flutter.versionName + } + + buildTypes { + release { + // TODO: Add your own signing config for the release build. + // Signing with the debug keys for now, so `flutter run --release` works. + signingConfig = signingConfigs.debug + } + } +} + +flutter { + source = "../.." +} diff --git a/apps/cli/fixtures/legacy/supabase/android/app/src/main/AndroidManifest.xml b/apps/cli/fixtures/legacy/supabase/android/app/src/main/AndroidManifest.xml new file mode 100644 index 000000000..57c91fe4c --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/android/app/src/main/AndroidManifest.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/apps/cli/fixtures/legacy/supabase/android/app/src/main/kotlin/dev/celest/supabase_test/MainActivity.kt b/apps/cli/fixtures/legacy/supabase/android/app/src/main/kotlin/dev/celest/supabase_test/MainActivity.kt new file mode 100644 index 000000000..e4dba2571 --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/android/app/src/main/kotlin/dev/celest/supabase_test/MainActivity.kt @@ -0,0 +1,5 @@ +package dev.celest.supabase_test + +import io.flutter.embedding.android.FlutterActivity + +class MainActivity: FlutterActivity() diff --git a/apps/cli/fixtures/legacy/supabase/android/app/src/main/res/drawable-v21/launch_background.xml b/apps/cli/fixtures/legacy/supabase/android/app/src/main/res/drawable-v21/launch_background.xml new file mode 100644 index 000000000..f74085f3f --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/android/app/src/main/res/drawable-v21/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/apps/cli/fixtures/legacy/supabase/android/app/src/main/res/drawable/launch_background.xml b/apps/cli/fixtures/legacy/supabase/android/app/src/main/res/drawable/launch_background.xml new file mode 100644 index 000000000..304732f88 --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/android/app/src/main/res/drawable/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/apps/cli/fixtures/legacy/supabase/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/apps/cli/fixtures/legacy/supabase/android/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 000000000..db77bb4b7 Binary files /dev/null and b/apps/cli/fixtures/legacy/supabase/android/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/apps/cli/fixtures/legacy/supabase/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/apps/cli/fixtures/legacy/supabase/android/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 000000000..17987b79b Binary files /dev/null and b/apps/cli/fixtures/legacy/supabase/android/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/apps/cli/fixtures/legacy/supabase/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/apps/cli/fixtures/legacy/supabase/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 000000000..09d439148 Binary files /dev/null and b/apps/cli/fixtures/legacy/supabase/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/apps/cli/fixtures/legacy/supabase/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/apps/cli/fixtures/legacy/supabase/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 000000000..d5f1c8d34 Binary files /dev/null and b/apps/cli/fixtures/legacy/supabase/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/apps/cli/fixtures/legacy/supabase/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/apps/cli/fixtures/legacy/supabase/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 000000000..4d6372eeb Binary files /dev/null and b/apps/cli/fixtures/legacy/supabase/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/apps/cli/fixtures/legacy/supabase/android/app/src/main/res/values-night/styles.xml b/apps/cli/fixtures/legacy/supabase/android/app/src/main/res/values-night/styles.xml new file mode 100644 index 000000000..06952be74 --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/android/app/src/main/res/values-night/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/apps/cli/fixtures/legacy/supabase/android/app/src/main/res/values/styles.xml b/apps/cli/fixtures/legacy/supabase/android/app/src/main/res/values/styles.xml new file mode 100644 index 000000000..cb1ef8805 --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/android/app/src/main/res/values/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/apps/cli/fixtures/legacy/supabase/android/app/src/profile/AndroidManifest.xml b/apps/cli/fixtures/legacy/supabase/android/app/src/profile/AndroidManifest.xml new file mode 100644 index 000000000..399f6981d --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/android/app/src/profile/AndroidManifest.xml @@ -0,0 +1,7 @@ + + + + diff --git a/apps/cli/fixtures/legacy/supabase/android/build.gradle b/apps/cli/fixtures/legacy/supabase/android/build.gradle new file mode 100644 index 000000000..d2ffbffa4 --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/android/build.gradle @@ -0,0 +1,18 @@ +allprojects { + repositories { + google() + mavenCentral() + } +} + +rootProject.buildDir = "../build" +subprojects { + project.buildDir = "${rootProject.buildDir}/${project.name}" +} +subprojects { + project.evaluationDependsOn(":app") +} + +tasks.register("clean", Delete) { + delete rootProject.buildDir +} diff --git a/apps/cli/fixtures/legacy/supabase/android/gradle.properties b/apps/cli/fixtures/legacy/supabase/android/gradle.properties new file mode 100644 index 000000000..259717082 --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/android/gradle.properties @@ -0,0 +1,3 @@ +org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=2G -XX:+HeapDumpOnOutOfMemoryError +android.useAndroidX=true +android.enableJetifier=true diff --git a/apps/cli/fixtures/legacy/supabase/android/gradle/wrapper/gradle-wrapper.properties b/apps/cli/fixtures/legacy/supabase/android/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 000000000..7bb2df6ba --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/android/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-all.zip diff --git a/apps/cli/fixtures/legacy/supabase/android/settings.gradle b/apps/cli/fixtures/legacy/supabase/android/settings.gradle new file mode 100644 index 000000000..b9e43bd37 --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/android/settings.gradle @@ -0,0 +1,25 @@ +pluginManagement { + def flutterSdkPath = { + def properties = new Properties() + file("local.properties").withInputStream { properties.load(it) } + def flutterSdkPath = properties.getProperty("flutter.sdk") + assert flutterSdkPath != null, "flutter.sdk not set in local.properties" + return flutterSdkPath + }() + + includeBuild("$flutterSdkPath/packages/flutter_tools/gradle") + + repositories { + google() + mavenCentral() + gradlePluginPortal() + } +} + +plugins { + id "dev.flutter.flutter-plugin-loader" version "1.0.0" + id "com.android.application" version "8.1.0" apply false + id "org.jetbrains.kotlin.android" version "1.8.22" apply false +} + +include ":app" diff --git a/apps/cli/fixtures/legacy/supabase/celest/.env b/apps/cli/fixtures/legacy/supabase/celest/.env new file mode 100644 index 000000000..7a4e7acc0 --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/celest/.env @@ -0,0 +1,2 @@ +SUPABASE_PROJECT_ID=vduqtbtlcxxozghvhdqu +SUPABASE_JWT_SECRET=super-secret-jwt-token-with-at-least-32-characters-long \ No newline at end of file diff --git a/apps/cli/fixtures/legacy/supabase/celest/client/lib/src/auth.dart b/apps/cli/fixtures/legacy/supabase/celest/client/lib/src/auth.dart new file mode 100644 index 000000000..aa00d8f8c --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/celest/client/lib/src/auth.dart @@ -0,0 +1,64 @@ +// Generated by Celest. This file should not be modified manually, but +// it can be checked into version control. +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +library; // ignore_for_file: no_leading_underscores_for_library_prefixes + +import 'package:celest_auth/celest_auth.dart' as _$celest; +import 'package:celest_auth/src/auth_impl.dart' as _$celest; +import 'package:celest_core/_internal.dart' as _$celest; +import 'package:gotrue/gotrue.dart' as _$gotrue_gotrue; +import 'package:native_storage/native_storage.dart' + as _$native_storage_native_storage; +import 'package:stream_transform/stream_transform.dart' show Concatenate; + +extension type CelestAuth._(_$celest.AuthImpl _hub) implements _$celest.Auth { + CelestAuth( + _$celest.CelestBase celest, { + required _$native_storage_native_storage.NativeStorage storage, + }) : _hub = _$celest.AuthImpl(celest, storage: storage); +} + +/// External authentication providers which can be used to sign in to Celest. +/// +/// This class is passed to `celest.init` to configure the token sources for +/// the external auth providers. +class ExternalAuth extends _$celest.TokenSource { + /// {@macro celest_auth.token_source.of} + const ExternalAuth.of({required super.provider, required super.stream}) + : super.of(); + + /// ### Supabase + /// + /// See the [Supabase docs](https://supabase.com/docs/reference/dart/introduction) + /// for more information on how to initialize Supabase. + /// + /// ```dart + /// Future main() async { + /// WidgetsFlutterBinding.ensureInitialized(); + /// await Supabase.initialize( + /// url: 'https://.supabase.co', + /// ... + /// ); + /// celest.init( + /// externalAuth: ExternalAuth.supabase(supabase.auth), + /// ); + /// } + /// ``` + factory ExternalAuth.supabase(_$gotrue_gotrue.GoTrueClient supabase) { + return ExternalAuth.of( + provider: _$celest.AuthProviderType.supabase, + stream: supabase.onAuthStateChange + .where( + (state) => const [ + _$gotrue_gotrue.AuthChangeEvent.initialSession, + _$gotrue_gotrue.AuthChangeEvent.tokenRefreshed, + _$gotrue_gotrue.AuthChangeEvent.signedIn, + _$gotrue_gotrue.AuthChangeEvent.signedOut, + ].contains(state.event), + ) + .map((state) => state.session?.accessToken) + .startWith(supabase.currentSession?.accessToken), + ); + } +} diff --git a/apps/cli/fixtures/legacy/supabase/celest/client/lib/src/functions.dart b/apps/cli/fixtures/legacy/supabase/celest/client/lib/src/functions.dart new file mode 100644 index 000000000..29b4a0dd8 --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/celest/client/lib/src/functions.dart @@ -0,0 +1,300 @@ +// Generated by Celest. This file should not be modified manually, but +// it can be checked into version control. +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +library; // ignore_for_file: no_leading_underscores_for_library_prefixes + +import 'dart:async'; +import 'dart:convert'; + +import 'package:celest/celest.dart' as _$celest; +import 'package:celest_core/celest_core.dart' as _$celest; +import 'package:celest_core/src/auth/user.dart' as _$celest; +import 'package:celest_core/src/exception/cloud_exception.dart' as _$celest; +import 'package:celest_core/src/exception/serialization_exception.dart' + as _$celest; +import 'package:supabase_client/supabase_client.dart'; + +class CelestFunctions { + final auth = CelestFunctionsAuth(); +} + +class CelestFunctionsAuth { + Never _throwError({int? code, required Map body}) { + final status = body['@status'] as Map?; + final message = status?['message'] as String?; + final details = status?['details'] as _$celest.JsonList?; + final (errorType, errorValue, stackTrace) = switch (details) { + null || [] => const (null, null, StackTrace.empty), + [ + final errorDetails as Map, + { + '@type': 'dart.core.StackTrace', + 'value': final stackTraceValue as String, + }, + ..., + ] => + ( + errorDetails['@type'], + errorDetails['value'], + StackTrace.fromString(stackTraceValue), + ), + [final errorDetails as Map, ...] => ( + errorDetails['@type'], + errorDetails['value'], + StackTrace.empty, + ), + }; + + switch (errorType) { + case 'celest.core.v1.CloudException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.CloudException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.CancelledException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.CancelledException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnknownError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.UnknownError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.BadRequestException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.BadRequestException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnauthorizedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.UnauthorizedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.NotFoundException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.NotFoundException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.AlreadyExistsException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.AlreadyExistsException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.PermissionDeniedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.PermissionDeniedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.ResourceExhaustedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.ResourceExhaustedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.FailedPreconditionException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.FailedPreconditionException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.AbortedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.AbortedException>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.OutOfRangeException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.OutOfRangeException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnimplementedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.UnimplementedError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.InternalServerError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.InternalServerError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnavailableError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.UnavailableError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.DataLossError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize<_$celest.DataLossError>( + errorValue, + ), + stackTrace, + ); + case 'celest.core.v1.DeadlineExceededError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.DeadlineExceededError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.SerializationException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.SerializationException>(errorValue), + stackTrace, + ); + case 'dart.core.Error': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.AssertionError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.TypeError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.ArgumentError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.RangeError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.IndexError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.UnsupportedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.UnimplementedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.StateError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.ConcurrentModificationError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.core.OutOfMemoryError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.StackOverflowError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.Exception': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.FormatException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.core.IntegerDivisionByZeroException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.async.AsyncError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.async.TimeoutException': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + case 'dart.convert.JsonUnsupportedObjectError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize( + errorValue, + ), + stackTrace, + ); + default: + Error.throwWithStackTrace( + _$celest.CloudException.http( + code: code, + message: message, + details: ((details ?? body) as _$celest.JsonValue), + ), + StackTrace.empty, + ); + } + } + + @_$celest.CloudFunction(api: 'auth', function: 'currentUser') + Future<_$celest.User> currentUser() async { + final $response = await celest.httpClient.get( + celest.baseUri.resolve('/auth/current-user'), + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + ); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); + if ($response.statusCode != 200) { + _throwError( + code: $response.statusCode, + body: ($body as Map), + ); + } + return _$celest.Serializers.instance.deserialize<_$celest.User>($body); + } +} diff --git a/apps/cli/fixtures/legacy/supabase/celest/client/lib/src/serializers.dart b/apps/cli/fixtures/legacy/supabase/celest/client/lib/src/serializers.dart new file mode 100644 index 000000000..b371ce718 --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/celest/client/lib/src/serializers.dart @@ -0,0 +1,760 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async'; +import 'dart:convert'; + +import 'package:celest_core/celest_core.dart' as _$celest; +import 'package:celest_core/src/auth/user.dart' as _$celest; +import 'package:celest_core/src/exception/cloud_exception.dart' as _$celest; +import 'package:celest_core/src/exception/serialization_exception.dart' + as _$celest; +import 'package:celest_core/src/serialization/json_value.dart' as _$celest; + +void initSerializers({_$celest.Serializers? serializers}) { + return runZoned(() { + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _$celest.Serializers.instance + .serialize($value.stackTrace), + }, + deserialize: ($serialized) { + return AsyncError( + $serialized[r'error']!, + _$celest.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_$celest.Serializers.instance.serialize( + $value.duration, + ) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return TimeoutException( + ($serialized[r'message'] as String?), + _$celest.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest + .Serializer.define>( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + ConcurrentModificationError, + Map? + >( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: + ($value) => { + if (_$celest.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define<_$celest.User, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _$celest.User.fromJson($serialized); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest + .Serializer.define<_$celest.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.AbortedException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.AlreadyExistsException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.BadRequestException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.BadRequestException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.CancelledException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.CancelledException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define<_$celest.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.CloudException.fromJson($serialized); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define<_$celest.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.DataLossError( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.DeadlineExceededError, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.InternalServerError, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.InternalServerError( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest + .Serializer.define<_$celest.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.NotFoundException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.OutOfRangeException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.OutOfRangeException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.UnauthorizedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.UnauthorizedException( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest + .Serializer.define<_$celest.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.UnavailableError( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.UnimplementedError, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.UnimplementedError( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define<_$celest.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.UnknownError( + ($serialized?[r'message'] as String?), + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized?[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define< + _$celest.SerializationException, + Map + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _$celest.Serializers.instance.put( + _$celest.Serializer.define<_$celest.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _$celest.JsonValue($serialized); + }, + ), + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ); + }, zoneValues: {_$celest.Serializers: serializers}); +} diff --git a/apps/cli/fixtures/legacy/supabase/celest/client/lib/supabase_client.dart b/apps/cli/fixtures/legacy/supabase/celest/client/lib/supabase_client.dart new file mode 100644 index 000000000..2879e2b03 --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/celest/client/lib/supabase_client.dart @@ -0,0 +1,92 @@ +// Generated by Celest. This file should not be modified manually, but +// it can be checked into version control. +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +library; // ignore_for_file: no_leading_underscores_for_library_prefixes + +import 'dart:async'; +import 'dart:io'; + +import 'package:celest_core/_internal.dart' as _$celest; +import 'package:celest_core/celest_core.dart' as _$celest; +import 'package:celest_core/src/util/globals.dart' as _$celest; +import 'package:http/http.dart' as _$http_http; +import 'package:native_storage/native_storage.dart' + as _$native_storage_native_storage; +import 'package:supabase_client/src/auth.dart'; +import 'package:supabase_client/src/functions.dart'; +import 'package:supabase_client/src/serializers.dart'; + +export 'package:celest_auth/celest_auth.dart'; +export 'src/auth.dart'; + +final Celest celest = Celest(); + +enum CelestEnvironment { + local, + production; + + Uri get baseUri => switch (this) { + local => + _$celest.kIsWeb || !Platform.isAndroid + ? Uri.parse('http://localhost:7777') + : Uri.parse('http://10.0.2.2:7777'), + production => Uri.parse('https://example.celest.run'), + }; +} + +class Celest with _$celest.CelestBase { + var _initialized = false; + + late CelestEnvironment _currentEnvironment; + + late final _$native_storage_native_storage.NativeStorage nativeStorage = + _$native_storage_native_storage.NativeStorage(scope: 'celest'); + + @override + late _$http_http.Client httpClient = _$celest.CelestHttpClient( + secureStorage: nativeStorage.secure, + ); + + late Uri _baseUri; + + final _functions = CelestFunctions(); + + late final CelestAuth _auth = CelestAuth(this, storage: nativeStorage); + + T _checkInitialized(T Function() value) { + if (!_initialized) { + throw StateError( + 'Celest has not been initialized. Make sure to call `celest.init()` at the start of your `main` method.', + ); + } + return value(); + } + + CelestEnvironment get currentEnvironment => + _checkInitialized(() => _currentEnvironment); + + @override + Uri get baseUri => _checkInitialized(() => _baseUri); + + CelestFunctions get functions => _checkInitialized(() => _functions); + + CelestAuth get auth => _checkInitialized(() => _auth); + + void init({ + CelestEnvironment environment = CelestEnvironment.local, + _$celest.Serializers? serializers, + ExternalAuth? externalAuth, + }) { + if (_initialized && environment != _currentEnvironment) { + _auth.signOut(); + } + _currentEnvironment = environment; + _baseUri = environment.baseUri; + scheduleMicrotask(() => _auth.init(externalAuth: externalAuth)); + if (!_initialized) { + initSerializers(serializers: serializers); + } + _initialized = true; + } +} diff --git a/apps/cli/fixtures/legacy/supabase/celest/client/pubspec.yaml b/apps/cli/fixtures/legacy/supabase/celest/client/pubspec.yaml new file mode 100644 index 000000000..4f3da29c6 --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/celest/client/pubspec.yaml @@ -0,0 +1,31 @@ +name: supabase_client +description: The Celest client for supabase. +publish_to: none + +environment: + sdk: ^3.4.0 + +dependencies: + celest: ^1.0.0 + celest_backend: + path: .. + celest_core: ^1.0.0 + gotrue: ^2.8.0 + http: ^1.0.0 + native_storage: ^0.2.2 + stream_transform: ^2.1.0 + +dependency_overrides: + celest: + path: ../../../../../../../celest/packages/celest + celest_ast: + path: ../../../../../../../celest/packages/celest_ast + celest_auth: + path: ../../../../../../../celest/packages/celest_auth + celest_cloud: + path: ../../../../../../../celest/packages/celest_cloud + celest_cloud_auth: + path: ../../../../../../../celest/services/celest_cloud_auth + celest_core: + path: ../../../../../../../celest/packages/celest_core +dev_dependencies: {} diff --git a/apps/cli/fixtures/legacy/supabase/celest/goldens/api.local.dart b/apps/cli/fixtures/legacy/supabase/celest/goldens/api.local.dart new file mode 100644 index 000000000..8e3e60ef4 --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/celest/goldens/api.local.dart @@ -0,0 +1,18 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'package:celest/src/core/context.dart' as _i3; +import 'package:celest/src/runtime/serve.dart' as _i1; + +import 'functions/auth/currentUser.dart' as _i2; + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/auth/current-user': _i2.CurrentUserTarget()}, + setup: (_i3.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/supabase/celest/goldens/ast.json b/apps/cli/fixtures/legacy/supabase/celest/goldens/ast.json new file mode 100644 index 000000000..b5752331d --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/celest/goldens/ast.json @@ -0,0 +1,595 @@ +{ + "name": "supabase", + "environment": "local", + "reference": { + "$": "Reference", + "symbol": "project", + "url": "package:celest_backend/src/project.dart" + }, + "apis": { + "auth": { + "name": "auth", + "metadata": [], + "functions": { + "currentUser": { + "name": "currentUser", + "apiName": "auth", + "typeParameters": [], + "parameters": [ + { + "name": "user", + "type": { + "$": "TypeReference", + "symbol": "User", + "url": "package:celest_core/src/auth/user.dart", + "isNullable": false + }, + "required": true, + "named": true, + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_PrincipalContextKey", + "url": "package:celest/src/core/context.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_PrincipalContextKey", + "url": "package:celest/src/core/context.dart", + "isNullable": false + } + } + ], + "location": { + "start": { + "offset": 179, + "uri": "package:celest_backend/src/functions/auth.dart", + "line": 7, + "column": 27 + }, + "end": { + "offset": 183, + "uri": "package:celest_backend/src/functions/auth.dart", + "line": 7, + "column": 31 + }, + "text": "user" + }, + "references": { + "name": "$user", + "type": "userContext" + } + } + ], + "returnType": { + "$": "TypeReference", + "symbol": "Future", + "url": "dart:async", + "types": [ + { + "$": "TypeReference", + "symbol": "User", + "url": "package:celest_core/src/auth/user.dart", + "isNullable": false + } + ], + "isNullable": false + }, + "flattenedReturnType": { + "$": "TypeReference", + "symbol": "User", + "url": "package:celest_core/src/auth/user.dart", + "isNullable": false + }, + "metadata": [ + { + "$": "ApiAuthenticated", + "location": { + "start": { + "offset": 80, + "uri": "package:celest_backend/src/functions/auth.dart", + "line": 4, + "column": 0 + }, + "end": { + "offset": 94, + "uri": "package:celest_backend/src/functions/auth.dart", + "line": 4, + "column": 14 + }, + "text": "@authenticated" + } + }, + { + "$": "ApiHttpConfig", + "method": "GET", + "statusCode": 200, + "location": { + "start": { + "offset": 95, + "uri": "package:celest_backend/src/functions/auth.dart", + "line": 5, + "column": 0 + }, + "end": { + "offset": 124, + "uri": "package:celest_backend/src/functions/auth.dart", + "line": 5, + "column": 29 + }, + "text": "@http(method: HttpMethod.get)" + } + } + ], + "annotations": [ + { + "$": "DartInstance", + "classRef": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Cloud", + "url": "package:celest/src/core/annotations.dart", + "isNullable": false + } + }, + { + "$": "DartInstance", + "classRef": { + "symbol": "_Authenticated", + "url": "package:celest/src/grants/grants.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": {}, + "staticType": { + "symbol": "_Authenticated", + "url": "package:celest/src/grants/grants.dart", + "isNullable": false + } + }, + { + "$": "DartInstance", + "classRef": { + "symbol": "http", + "url": "package:celest/src/functions/http/http.dart", + "isNullable": false + }, + "constructor": "", + "positionalArguments": {}, + "namedArguments": { + "method": { + "$": "DartString", + "value": "GET", + "staticType": { + "symbol": "String", + "url": "dart:core" + } + } + }, + "staticType": { + "symbol": "http", + "url": "package:celest/src/functions/http/http.dart", + "isNullable": false + } + } + ], + "docs": [], + "location": { + "start": { + "offset": 138, + "uri": "package:celest_backend/src/functions/auth.dart", + "line": 6, + "column": 13 + }, + "end": { + "offset": 149, + "uri": "package:celest_backend/src/functions/auth.dart", + "line": 6, + "column": 24 + }, + "text": "currentUser" + } + } + }, + "docs": [], + "exceptionTypes": [ + { + "$": "TypeReference", + "symbol": "CloudException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "CancelledException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnknownError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "BadRequestException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnauthorizedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "NotFoundException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AlreadyExistsException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "PermissionDeniedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ResourceExhaustedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "FailedPreconditionException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AbortedException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "OutOfRangeException", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnimplementedError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "InternalServerError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnavailableError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "DataLossError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "DeadlineExceededError", + "url": "package:celest_core/src/exception/cloud_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "SerializationException", + "url": "package:celest_core/src/exception/serialization_exception.dart", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "Error", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AssertionError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "TypeError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ArgumentError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "RangeError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "IndexError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnsupportedError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "UnimplementedError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "StateError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "ConcurrentModificationError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "OutOfMemoryError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "StackOverflowError", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "Exception", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "FormatException", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "IntegerDivisionByZeroException", + "url": "dart:core", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "AsyncError", + "url": "dart:async", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "TimeoutException", + "url": "dart:async", + "isNullable": false + }, + { + "$": "TypeReference", + "symbol": "JsonUnsupportedObjectError", + "url": "dart:convert", + "isNullable": false + } + ], + "location": { + "start": { + "offset": 0, + "uri": "package:celest_backend/src/functions/auth.dart", + "line": 0, + "column": 0 + }, + "end": { + "offset": 0, + "uri": "package:celest_backend/src/functions/auth.dart", + "line": 0, + "column": 0 + }, + "text": "" + } + } + }, + "variables": [ + { + "location": { + "start": { + "offset": 146, + "uri": "package:celest_backend/src/project.dart", + "line": 6, + "column": 6 + }, + "end": { + "offset": 150, + "uri": "package:celest_backend/src/project.dart", + "line": 6, + "column": 10 + }, + "text": "auth" + }, + "name": "SUPABASE_URL", + "docs": [] + } + ], + "secrets": [ + { + "location": { + "start": { + "offset": 88, + "uri": "package:celest_backend/src/project.dart", + "line": 4, + "column": 6 + }, + "end": { + "offset": 105, + "uri": "package:celest_backend/src/project.dart", + "line": 4, + "column": 23 + }, + "text": "supabaseJwtSecret" + }, + "name": "SUPABASE_JWT_SECRET", + "docs": [], + "dartName": "supabaseJwtSecret" + } + ], + "databases": {}, + "sdkConfig": { + "celest": "1.0.6+2", + "dart": { + "type": "dart", + "version": "3.29.0", + "enabledExperiments": [] + }, + "targetSdk": "dart", + "featureFlags": [ + "streaming" + ], + "flutter": { + "type": "flutter", + "version": "3.29.0", + "enabledExperiments": [] + } + }, + "location": { + "start": { + "offset": 44, + "uri": "project.dart", + "line": 2, + "column": 6 + }, + "end": { + "offset": 79, + "uri": "project.dart", + "line": 2, + "column": 41 + }, + "text": "project = Project(name: 'supabase')" + }, + "auth": { + "providers": [], + "externalProviders": [ + { + "$": "SupabaseExternalAuthProvider", + "projectUrl": { + "location": { + "start": { + "offset": 146, + "uri": "package:celest_backend/src/project.dart", + "line": 6, + "column": 6 + }, + "end": { + "offset": 150, + "uri": "package:celest_backend/src/project.dart", + "line": 6, + "column": 10 + }, + "text": "auth" + }, + "name": "SUPABASE_URL", + "docs": [] + }, + "name": "supabase", + "type": "SUPABASE", + "location": { + "start": { + "offset": 146, + "uri": "package:celest_backend/src/project.dart", + "line": 6, + "column": 6 + }, + "end": { + "offset": 150, + "uri": "package:celest_backend/src/project.dart", + "line": 6, + "column": 10 + }, + "text": "auth" + }, + "jwtSecret": { + "location": { + "start": { + "offset": 146, + "uri": "package:celest_backend/src/project.dart", + "line": 6, + "column": 6 + }, + "end": { + "offset": 150, + "uri": "package:celest_backend/src/project.dart", + "line": 6, + "column": 10 + }, + "text": "auth" + }, + "name": "SUPABASE_JWT_SECRET", + "docs": [] + } + } + ], + "location": { + "start": { + "offset": 146, + "uri": "package:celest_backend/src/project.dart", + "line": 6, + "column": 6 + }, + "end": { + "offset": 150, + "uri": "package:celest_backend/src/project.dart", + "line": 6, + "column": 10 + }, + "text": "auth" + } + } +} \ No newline at end of file diff --git a/apps/cli/fixtures/legacy/supabase/celest/goldens/ast.resolved.json b/apps/cli/fixtures/legacy/supabase/celest/goldens/ast.resolved.json new file mode 100644 index 000000000..79a925c55 --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/celest/goldens/ast.resolved.json @@ -0,0 +1,137 @@ +{ + "projectId": "supabase", + "environmentId": "local", + "apis": { + "auth": { + "apiId": "auth", + "functions": { + "currentUser": { + "functionId": "currentUser", + "apiId": "auth", + "httpConfig": { + "route": { + "method": "GET", + "path": "/auth/current-user" + }, + "additionalRoutes": [], + "status": 200, + "statusMappings": {} + }, + "variables": [], + "secrets": [], + "streamConfig": {}, + "policySet": { + "policies": { + "auth/currentUser.authenticated_restrict": { + "effect": "forbid", + "principal": { + "op": "All" + }, + "action": { + "op": "==", + "entity": { + "type": "Celest::Action", + "id": "invoke" + } + }, + "resource": { + "op": "==", + "entity": { + "type": "Celest::Function", + "id": "auth/currentUser" + } + }, + "conditions": [ + { + "kind": "unless", + "body": { + "in": { + "left": { + "Var": "principal" + }, + "right": { + "Value": { + "__entity": { + "type": "Celest::Role", + "id": "authenticated" + } + } + } + } + } + } + ] + } + }, + "templates": {}, + "templateLinks": [ + { + "templateId": "cloud.functions.authenticated", + "newId": "auth/currentUser.authenticated", + "values": { + "?resource": "Celest::Function::\"auth/currentUser\"" + } + } + ] + } + } + } + } + }, + "variables": [ + { + "name": "SUPABASE_URL", + "value": "http://127.0.0.1:54321" + }, + { + "name": "SUPABASE_PROJECT_ID", + "value": "vduqtbtlcxxozghvhdqu" + }, + { + "name": "CELEST_ENVIRONMENT", + "value": "local" + } + ], + "secrets": [ + { + "name": "SUPABASE_JWT_SECRET", + "value": "super-secret-jwt-token-with-at-least-32-characters-long" + } + ], + "databases": {}, + "sdkConfig": { + "celest": "1.0.6+2", + "dart": { + "type": "dart", + "version": "3.29.0", + "enabledExperiments": [] + }, + "targetSdk": "dart", + "featureFlags": [ + "streaming" + ], + "flutter": { + "type": "flutter", + "version": "3.29.0", + "enabledExperiments": [] + } + }, + "auth": { + "providers": [], + "externalProviders": [ + { + "$": "ResolvedSupabaseExternalAuthProvider", + "projectUrl": { + "name": "SUPABASE_URL", + "value": "http://127.0.0.1:54321" + }, + "authProviderId": "supabase", + "type": "SUPABASE", + "jwtSecret": { + "name": "SUPABASE_JWT_SECRET", + "value": "super-secret-jwt-token-with-at-least-32-characters-long" + } + } + ] + } +} \ No newline at end of file diff --git a/apps/cli/fixtures/legacy/supabase/celest/goldens/celest.json b/apps/cli/fixtures/legacy/supabase/celest/goldens/celest.json new file mode 100644 index 000000000..36c2082fd --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/celest/goldens/celest.json @@ -0,0 +1,162 @@ +{ + "projectId": "supabase", + "environmentId": "local", + "apis": { + "auth": { + "apiId": "auth", + "functions": { + "currentUser": { + "functionId": "currentUser", + "parentId": "auth", + "httpConfig": { + "status": 200, + "route": { + "method": "GET", + "path": "/auth/current-user" + }, + "statusMappings": {} + }, + "streamConfig": { + "type": "STREAM_CONFIG_TYPE_UNSPECIFIED" + }, + "policySet": { + "policies": { + "auth/currentUser.authenticated_restrict": { + "effect": "EFFECT_FORBID", + "principal": { + "all": {} + }, + "action": { + "equals": { + "entity": { + "type": "Celest::Action", + "id": "invoke" + } + } + }, + "resource": { + "equals": { + "entity": { + "type": "Celest::Function", + "id": "auth/currentUser" + } + } + }, + "conditions": [ + { + "kind": "CONDITION_KIND_UNLESS", + "body": { + "in": { + "left": { + "variable": { + "variable": "VARIABLE_PRINCIPAL" + } + }, + "right": { + "value": { + "value": { + "entity": { + "uid": { + "type": "Celest::Role", + "id": "authenticated" + } + } + } + } + } + } + } + } + ] + } + }, + "templateLinks": [ + { + "templateId": "cloud.functions.authenticated", + "newId": "auth/currentUser.authenticated", + "values": { + "?resource": { + "type": "Celest::Function", + "id": "auth/currentUser" + } + } + } + ] + } + } + } + } + }, + "variables": [ + { + "name": "SUPABASE_URL", + "value": "http://127.0.0.1:54321" + }, + { + "name": "SUPABASE_PROJECT_ID", + "value": "vduqtbtlcxxozghvhdqu" + }, + { + "name": "CELEST_ENVIRONMENT", + "value": "local" + } + ], + "secrets": [ + { + "name": "SUPABASE_JWT_SECRET", + "value": "super-secret-jwt-token-with-at-least-32-characters-long" + } + ], + "auth": { + "externalProviders": [ + { + "authProviderId": "supabase", + "type": "SUPABASE", + "supabase": { + "projectUrl": { + "name": "SUPABASE_URL", + "value": "http://127.0.0.1:54321" + }, + "jwtSecret": { + "name": "SUPABASE_JWT_SECRET", + "value": "super-secret-jwt-token-with-at-least-32-characters-long" + } + } + } + ] + }, + "databases": {}, + "sdkConfig": { + "celest": { + "major": 1, + "minor": 0, + "patch": 6, + "build": [ + 2.0 + ], + "canonicalizedVersion": "1.0.6+2" + }, + "dart": { + "type": "DART", + "version": { + "major": 3, + "minor": 29, + "patch": 0, + "canonicalizedVersion": "3.29.0" + } + }, + "flutter": { + "type": "FLUTTER", + "version": { + "major": 3, + "minor": 29, + "patch": 0, + "canonicalizedVersion": "3.29.0" + } + }, + "targetSdk": "DART", + "featureFlags": [ + "STREAMING" + ] + } +} \ No newline at end of file diff --git a/apps/cli/fixtures/legacy/supabase/celest/goldens/functions/auth/currentUser.dart b/apps/cli/fixtures/legacy/supabase/celest/goldens/functions/auth/currentUser.dart new file mode 100644 index 000000000..14894434b --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/celest/goldens/functions/auth/currentUser.dart @@ -0,0 +1,1708 @@ +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i10; +import 'dart:convert' as _i4; + +import 'package:celest/celest.dart' as _i3; +import 'package:celest/src/core/context.dart' as _i2; +import 'package:celest/src/runtime/serve.dart' as _i1; +import 'package:celest_backend/src/functions/auth.dart' as _i6; +import 'package:celest_core/celest_core.dart' as _i7; +import 'package:celest_core/src/auth/user.dart' as _i8; +import 'package:celest_core/src/exception/cloud_exception.dart' as _i9; +import 'package:celest_core/src/exception/serialization_exception.dart' as _i11; +import 'package:celest_core/src/serialization/json_value.dart' as _i12; +import 'package:shelf/shelf.dart' as _i5; + +final class CurrentUserTarget extends _i1.CloudFunctionHttpTarget { + @override + String get name => 'currentUser'; + + @override + List<_i1.Middleware> get middlewares => [ + _i1.SupabaseAuthMiddleware( + url: _i2.context.expect(const _i3.env('SUPABASE_URL')), + jwtSecret: _i4.utf8.encode( + _i2.context.expect(const _i3.secret('SUPABASE_JWT_SECRET')), + ), + required: false, + ), + ]; + + @override + String get method => 'GET'; + + @override + Future<_i5.Response> handle( + Map request, { + required Map> headers, + required Map> queryParameters, + }) async { + try { + final response = await _i6.currentUser( + user: _i2.context.expect(_i2.ContextKey.principal), + ); + return _i5.Response( + 200, + headers: const {'Content-Type': 'application/json'}, + body: _i7.JsonUtf8.encode( + _i7.Serializers.instance.serialize<_i8.User>(response), + ), + ); + } on _i9.AbortedException catch (e, st) { + const statusCode = 409; + _i2.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AbortedException', + 'value': _i7.Serializers.instance.serialize<_i9.AbortedException>( + e, + ), + }, + if (_i2.context.environment != _i3.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i7.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i5.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i7.JsonUtf8.encode(status), + ); + } on _i9.AlreadyExistsException catch (e, st) { + const statusCode = 409; + _i2.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.AlreadyExistsException', + 'value': _i7.Serializers.instance + .serialize<_i9.AlreadyExistsException>(e), + }, + if (_i2.context.environment != _i3.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i7.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i5.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i7.JsonUtf8.encode(status), + ); + } on AssertionError catch (e, st) { + const statusCode = 500; + _i2.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.AssertionError', + 'value': _i7.Serializers.instance.serialize(e), + }, + if (_i2.context.environment != _i3.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i7.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i5.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i7.JsonUtf8.encode(status), + ); + } on _i10.AsyncError catch (e, st) { + const statusCode = 500; + _i2.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.async.AsyncError', + 'value': _i7.Serializers.instance.serialize<_i10.AsyncError>(e), + }, + if (_i2.context.environment != _i3.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i7.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i5.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i7.JsonUtf8.encode(status), + ); + } on _i9.CancelledException catch (e, st) { + const statusCode = 499; + _i2.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CancelledException', + 'value': _i7.Serializers.instance + .serialize<_i9.CancelledException>(e), + }, + if (_i2.context.environment != _i3.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i7.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i5.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i7.JsonUtf8.encode(status), + ); + } on ConcurrentModificationError catch (e, st) { + const statusCode = 500; + _i2.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ConcurrentModificationError', + 'value': _i7.Serializers.instance + .serialize(e), + }, + if (_i2.context.environment != _i3.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i7.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i5.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i7.JsonUtf8.encode(status), + ); + } on _i9.DataLossError catch (e, st) { + const statusCode = 500; + _i2.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DataLossError', + 'value': _i7.Serializers.instance.serialize<_i9.DataLossError>(e), + }, + if (_i2.context.environment != _i3.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i7.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i5.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i7.JsonUtf8.encode(status), + ); + } on _i9.DeadlineExceededError catch (e, st) { + const statusCode = 504; + _i2.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.DeadlineExceededError', + 'value': _i7.Serializers.instance + .serialize<_i9.DeadlineExceededError>(e), + }, + if (_i2.context.environment != _i3.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i7.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i5.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i7.JsonUtf8.encode(status), + ); + } on _i9.FailedPreconditionException catch (e, st) { + const statusCode = 412; + _i2.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.FailedPreconditionException', + 'value': _i7.Serializers.instance + .serialize<_i9.FailedPreconditionException>(e), + }, + if (_i2.context.environment != _i3.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i7.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i5.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i7.JsonUtf8.encode(status), + ); + } on IndexError catch (e, st) { + const statusCode = 500; + _i2.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.IndexError', + 'value': _i7.Serializers.instance.serialize(e), + }, + if (_i2.context.environment != _i3.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i7.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i5.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i7.JsonUtf8.encode(status), + ); + } on IntegerDivisionByZeroException catch (e, st) { + const statusCode = 500; + _i2.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.IntegerDivisionByZeroException', + 'value': _i7.Serializers.instance + .serialize(e), + }, + if (_i2.context.environment != _i3.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i7.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i5.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i7.JsonUtf8.encode(status), + ); + } on _i9.InternalServerError catch (e, st) { + const statusCode = 500; + _i2.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.InternalServerError', + 'value': _i7.Serializers.instance + .serialize<_i9.InternalServerError>(e), + }, + if (_i2.context.environment != _i3.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i7.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i5.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i7.JsonUtf8.encode(status), + ); + } on _i4.JsonUnsupportedObjectError catch (e, st) { + const statusCode = 500; + _i2.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.convert.JsonUnsupportedObjectError', + 'value': _i7.Serializers.instance + .serialize<_i4.JsonUnsupportedObjectError>(e), + }, + if (_i2.context.environment != _i3.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i7.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i5.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i7.JsonUtf8.encode(status), + ); + } on _i9.NotFoundException catch (e, st) { + const statusCode = 404; + _i2.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.NotFoundException', + 'value': _i7.Serializers.instance + .serialize<_i9.NotFoundException>(e), + }, + if (_i2.context.environment != _i3.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i7.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i5.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i7.JsonUtf8.encode(status), + ); + } on OutOfMemoryError catch (e, st) { + const statusCode = 500; + _i2.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.OutOfMemoryError', + 'value': _i7.Serializers.instance.serialize(e), + }, + if (_i2.context.environment != _i3.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i7.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i5.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i7.JsonUtf8.encode(status), + ); + } on _i9.OutOfRangeException catch (e, st) { + const statusCode = 416; + _i2.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.OutOfRangeException', + 'value': _i7.Serializers.instance + .serialize<_i9.OutOfRangeException>(e), + }, + if (_i2.context.environment != _i3.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i7.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i5.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i7.JsonUtf8.encode(status), + ); + } on _i9.PermissionDeniedException catch (e, st) { + const statusCode = 403; + _i2.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.PermissionDeniedException', + 'value': _i7.Serializers.instance + .serialize<_i9.PermissionDeniedException>(e), + }, + if (_i2.context.environment != _i3.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i7.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i5.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i7.JsonUtf8.encode(status), + ); + } on RangeError catch (e, st) { + const statusCode = 500; + _i2.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.RangeError', + 'value': _i7.Serializers.instance.serialize(e), + }, + if (_i2.context.environment != _i3.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i7.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i5.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i7.JsonUtf8.encode(status), + ); + } on ArgumentError catch (e, st) { + const statusCode = 500; + _i2.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.ArgumentError', + 'value': _i7.Serializers.instance.serialize(e), + }, + if (_i2.context.environment != _i3.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i7.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i5.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i7.JsonUtf8.encode(status), + ); + } on _i9.ResourceExhaustedException catch (e, st) { + const statusCode = 429; + _i2.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.ResourceExhaustedException', + 'value': _i7.Serializers.instance + .serialize<_i9.ResourceExhaustedException>(e), + }, + if (_i2.context.environment != _i3.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i7.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i5.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i7.JsonUtf8.encode(status), + ); + } on _i11.SerializationException catch (e, st) { + const statusCode = 400; + _i2.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.SerializationException', + 'value': _i7.Serializers.instance + .serialize<_i11.SerializationException>(e), + }, + if (_i2.context.environment != _i3.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i7.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i5.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i7.JsonUtf8.encode(status), + ); + } on _i9.BadRequestException catch (e, st) { + const statusCode = 400; + _i2.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.BadRequestException', + 'value': _i7.Serializers.instance + .serialize<_i9.BadRequestException>(e), + }, + if (_i2.context.environment != _i3.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i7.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i5.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i7.JsonUtf8.encode(status), + ); + } on FormatException catch (e, st) { + const statusCode = 400; + _i2.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.FormatException', + 'value': _i7.Serializers.instance.serialize(e), + }, + if (_i2.context.environment != _i3.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i7.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i5.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i7.JsonUtf8.encode(status), + ); + } on StackOverflowError catch (e, st) { + const statusCode = 500; + _i2.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.StackOverflowError', + 'value': _i7.Serializers.instance.serialize( + e, + ), + }, + if (_i2.context.environment != _i3.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i7.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i5.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i7.JsonUtf8.encode(status), + ); + } on StateError catch (e, st) { + const statusCode = 500; + _i2.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.StateError', + 'value': _i7.Serializers.instance.serialize(e), + }, + if (_i2.context.environment != _i3.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i7.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i5.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i7.JsonUtf8.encode(status), + ); + } on _i10.TimeoutException catch (e, st) { + const statusCode = 400; + _i2.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.async.TimeoutException', + 'value': _i7.Serializers.instance + .serialize<_i10.TimeoutException>(e), + }, + if (_i2.context.environment != _i3.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i7.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i5.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i7.JsonUtf8.encode(status), + ); + } on TypeError catch (e, st) { + const statusCode = 500; + _i2.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.TypeError', + 'value': _i7.Serializers.instance.serialize(e), + }, + if (_i2.context.environment != _i3.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i7.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i5.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i7.JsonUtf8.encode(status), + ); + } on _i9.UnauthorizedException catch (e, st) { + const statusCode = 401; + _i2.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnauthorizedException', + 'value': _i7.Serializers.instance + .serialize<_i9.UnauthorizedException>(e), + }, + if (_i2.context.environment != _i3.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i7.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i5.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i7.JsonUtf8.encode(status), + ); + } on _i9.UnavailableError catch (e, st) { + const statusCode = 503; + _i2.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnavailableError', + 'value': _i7.Serializers.instance.serialize<_i9.UnavailableError>( + e, + ), + }, + if (_i2.context.environment != _i3.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i7.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i5.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i7.JsonUtf8.encode(status), + ); + } on _i9.UnimplementedError catch (e, st) { + const statusCode = 501; + _i2.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnimplementedError', + 'value': _i7.Serializers.instance + .serialize<_i9.UnimplementedError>(e), + }, + if (_i2.context.environment != _i3.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i7.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i5.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i7.JsonUtf8.encode(status), + ); + } on UnimplementedError catch (e, st) { + const statusCode = 500; + _i2.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnimplementedError', + 'value': _i7.Serializers.instance.serialize( + e, + ), + }, + if (_i2.context.environment != _i3.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i7.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i5.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i7.JsonUtf8.encode(status), + ); + } on _i9.UnknownError catch (e, st) { + const statusCode = 500; + _i2.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.UnknownError', + 'value': _i7.Serializers.instance.serialize<_i9.UnknownError>(e), + }, + if (_i2.context.environment != _i3.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i7.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i5.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i7.JsonUtf8.encode(status), + ); + } on _i9.CloudException catch (e, st) { + const statusCode = 400; + _i2.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'celest.core.v1.CloudException', + 'value': _i7.Serializers.instance.serialize<_i9.CloudException>( + e, + ), + }, + if (_i2.context.environment != _i3.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i7.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i5.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i7.JsonUtf8.encode(status), + ); + } on Exception catch (e, st) { + const statusCode = 400; + _i2.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Exception', + 'value': _i7.Serializers.instance.serialize(e), + }, + if (_i2.context.environment != _i3.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i7.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i5.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i7.JsonUtf8.encode(status), + ); + } on UnsupportedError catch (e, st) { + const statusCode = 500; + _i2.context.logger.severe(e.message, e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': e.message, + 'details': [ + { + '@type': 'dart.core.UnsupportedError', + 'value': _i7.Serializers.instance.serialize(e), + }, + if (_i2.context.environment != _i3.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i7.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i5.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i7.JsonUtf8.encode(status), + ); + } on Error catch (e, st) { + const statusCode = 500; + _i2.context.logger.severe(e.toString(), e, st); + final status = { + '@status': { + 'code': statusCode, + 'message': null, + 'details': [ + { + '@type': 'dart.core.Error', + 'value': _i7.Serializers.instance.serialize(e), + }, + if (_i2.context.environment != _i3.Environment.production) + { + '@type': 'dart.core.StackTrace', + 'value': _i7.Serializers.instance.serialize(st), + }, + ], + }, + }; + return _i5.Response( + statusCode, + headers: const {'Content-Type': 'application/json'}, + body: _i7.JsonUtf8.encode(status), + ); + } + } + + @override + void init() { + _i7.Serializers.instance.put( + _i7.Serializer.define<_i10.AsyncError, Map>( + serialize: + ($value) => { + r'error': $value.error, + r'stackTrace': _i7.Serializers.instance.serialize( + $value.stackTrace, + ), + }, + deserialize: ($serialized) { + return _i10.AsyncError( + $serialized[r'error']!, + _i7.Serializers.instance.deserialize( + $serialized[r'stackTrace'], + ), + ); + }, + ), + ); + _i7.Serializers.instance.put( + _i7.Serializer.define<_i10.TimeoutException, Map>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + if (_i7.Serializers.instance.serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _i10.TimeoutException( + ($serialized[r'message'] as String?), + _i7.Serializers.instance.deserialize( + $serialized[r'duration'], + ), + ); + }, + ), + ); + _i7.Serializers.instance.put( + _i7.Serializer.define< + _i4.JsonUnsupportedObjectError, + Map + >( + serialize: + ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _i4.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + ), + ); + _i7.Serializers.instance.put( + _i7.Serializer.define?>( + serialize: + ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + ), + ); + _i7.Serializers.instance.put( + _i7.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + ), + ); + _i7.Serializers.instance.put( + _i7.Serializer.define?>( + serialize: + ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject, + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + ), + ); + _i7.Serializers.instance.put( + _i7.Serializer.define?>( + serialize: + ($value) => { + if (_i7.Serializers.instance.serialize( + $value.stackTrace, + ) + case final stackTrace?) + r'stackTrace': stackTrace, + }, + deserialize: ($serialized) { + return Error(); + }, + ), + ); + _i7.Serializers.instance.put( + _i7.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return Exception($serialized?[r'message']); + }, + ), + ); + _i7.Serializers.instance.put( + _i7.Serializer.define?>( + serialize: + ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + ), + ); + _i7.Serializers.instance.put( + _i7.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) + r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + ), + ); + _i7.Serializers.instance.put( + _i7.Serializer.define< + IntegerDivisionByZeroException, + Map? + >( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + ), + ); + _i7.Serializers.instance.put( + _i7.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + ), + ); + _i7.Serializers.instance.put( + _i7.Serializer.define>( + serialize: + ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + ), + ); + _i7.Serializers.instance.put( + _i7.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + ), + ); + _i7.Serializers.instance.put( + _i7.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + ), + ); + _i7.Serializers.instance.put( + _i7.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + ), + ); + _i7.Serializers.instance.put( + _i7.Serializer.define?>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + ), + ); + _i7.Serializers.instance.put( + _i7.Serializer.define>( + serialize: + ($value) => { + if ($value.message case final message?) r'message': message, + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + ), + ); + _i7.Serializers.instance.put( + _i7.Serializer.define<_i8.User, Map>( + serialize: ($value) => $value.toJson(), + deserialize: ($serialized) { + return _i8.User.fromJson($serialized); + }, + ), + ); + _i7.Serializers.instance.put( + _i7.Serializer.define<_i9.AbortedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i7.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i7.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i9.AbortedException( + ($serialized?[r'message'] as String?), + _i7.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i7.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i7.Serializers.instance.put( + _i7.Serializer.define<_i9.AlreadyExistsException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i7.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i7.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i9.AlreadyExistsException( + ($serialized?[r'message'] as String?), + _i7.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i7.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i7.Serializers.instance.put( + _i7.Serializer.define<_i9.BadRequestException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i7.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i7.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i9.BadRequestException( + ($serialized?[r'message'] as String?), + _i7.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i7.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i7.Serializers.instance.put( + _i7.Serializer.define<_i9.CancelledException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i7.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i7.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i9.CancelledException( + ($serialized?[r'message'] as String?), + _i7.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i7.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i7.Serializers.instance.put( + _i7.Serializer.define<_i9.CloudException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i7.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i7.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i9.CloudException.fromJson($serialized); + }, + ), + ); + _i7.Serializers.instance.put( + _i7.Serializer.define<_i9.DataLossError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i7.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i7.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i9.DataLossError( + ($serialized?[r'message'] as String?), + _i7.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i7.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i7.Serializers.instance.put( + _i7.Serializer.define<_i9.DeadlineExceededError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i7.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i7.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i9.DeadlineExceededError( + ($serialized?[r'message'] as String?), + _i7.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i7.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i7.Serializers.instance.put( + _i7.Serializer.define< + _i9.FailedPreconditionException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i7.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i7.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i9.FailedPreconditionException( + ($serialized?[r'message'] as String?), + _i7.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i7.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i7.Serializers.instance.put( + _i7.Serializer.define<_i9.InternalServerError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i7.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i7.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i9.InternalServerError( + ($serialized?[r'message'] as String?), + _i7.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i7.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i7.Serializers.instance.put( + _i7.Serializer.define<_i9.NotFoundException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i7.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i7.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i9.NotFoundException( + ($serialized?[r'message'] as String?), + _i7.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i7.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i7.Serializers.instance.put( + _i7.Serializer.define<_i9.OutOfRangeException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i7.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i7.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i9.OutOfRangeException( + ($serialized?[r'message'] as String?), + _i7.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i7.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i7.Serializers.instance.put( + _i7.Serializer.define< + _i9.PermissionDeniedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i7.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i7.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i9.PermissionDeniedException( + ($serialized?[r'message'] as String?), + _i7.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i7.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i7.Serializers.instance.put( + _i7.Serializer.define< + _i9.ResourceExhaustedException, + Map? + >( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i7.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i7.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i9.ResourceExhaustedException( + ($serialized?[r'message'] as String?), + _i7.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i7.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i7.Serializers.instance.put( + _i7.Serializer.define<_i9.UnauthorizedException, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i7.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i7.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i9.UnauthorizedException( + ($serialized?[r'message'] as String?), + _i7.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i7.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i7.Serializers.instance.put( + _i7.Serializer.define<_i9.UnavailableError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i7.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i7.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i9.UnavailableError( + ($serialized?[r'message'] as String?), + _i7.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i7.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i7.Serializers.instance.put( + _i7.Serializer.define<_i9.UnimplementedError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i7.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i7.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i9.UnimplementedError( + ($serialized?[r'message'] as String?), + _i7.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i7.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i7.Serializers.instance.put( + _i7.Serializer.define<_i9.UnknownError, Map?>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i7.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i7.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i9.UnknownError( + ($serialized?[r'message'] as String?), + _i7.Serializers.instance.deserialize<_i12.JsonValue?>( + $serialized?[r'details'], + const _i7.TypeToken<_i12.JsonValue?>('JsonValue'), + ), + ($serialized?[r'code'] as num?)?.toInt(), + ); + }, + ), + ); + _i7.Serializers.instance.put( + _i7.Serializer.define<_i11.SerializationException, Map>( + serialize: + ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_i7.Serializers.instance.serialize<_i12.JsonValue?>( + $value.details, + const _i7.TypeToken<_i12.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _i11.SerializationException( + ($serialized[r'message'] as String?), + ); + }, + ), + ); + _i7.Serializers.instance.put( + _i7.Serializer.define<_i12.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _i12.JsonValue($serialized); + }, + ), + const _i7.TypeToken<_i12.JsonValue?>('JsonValue'), + ); + } +} + +Future main() async { + return start(); +} + +Future start() async { + await _i1.serve( + targets: {'/': CurrentUserTarget()}, + setup: (_i2.Context context) async {}, + ); +} diff --git a/apps/cli/fixtures/legacy/supabase/celest/lib/fix_data/v1_migration.yaml b/apps/cli/fixtures/legacy/supabase/celest/lib/fix_data/v1_migration.yaml new file mode 100644 index 000000000..52890a6ec --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/celest/lib/fix_data/v1_migration.yaml @@ -0,0 +1,13 @@ +# Generated by Celest. Do not modify. +version: 1 +transforms: + - title: "Updates the import of the Celest client" + date: 2024-10-06 + element: + uris: ["client.dart"] + variable: celest + changes: + - kind: replacedBy + newElement: + uris: ["package:supabase_client/supabase_client.dart"] + variable: celest diff --git a/apps/cli/fixtures/legacy/supabase/celest/lib/src/functions/auth.dart b/apps/cli/fixtures/legacy/supabase/celest/lib/src/functions/auth.dart new file mode 100644 index 000000000..617f4a2ac --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/celest/lib/src/functions/auth.dart @@ -0,0 +1,11 @@ +import 'package:celest/celest.dart'; +import 'package:celest/http.dart'; + +@cloud +@authenticated +@http(method: HttpMethod.get) +Future currentUser({ + @principal required User user, +}) async { + return user; +} diff --git a/apps/cli/fixtures/legacy/supabase/celest/lib/src/generated/cloud.celest.dart b/apps/cli/fixtures/legacy/supabase/celest/lib/src/generated/cloud.celest.dart new file mode 100644 index 000000000..1a3e01e9c --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/celest/lib/src/generated/cloud.celest.dart @@ -0,0 +1,51 @@ +// Generated by Celest. This file should not be modified manually, but +// it can be checked into version control. +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +library; + +import 'package:celest/src/core/context.dart'; +import 'package:celest_backend/src/generated/config.celest.dart'; + +/// The interface to your Celest backend. +/// +/// Similar to the `celest` global in the frontend, this +/// provides access to the backend environment and services +/// configured for your project. +const CelestCloud celest = CelestCloud._(); + +/// A per-request context object which propogates request information and common +/// accessors to the Celest server environment. +CelestContext get context => CelestContext._(context); + +/// The interface to your Celest backend. +/// +/// Similar to the `Celest` class in the frontend, this class +/// provides access to the backend environment and services +/// configured for your project. +class CelestCloud { + const CelestCloud._(); + + /// The current environment of the Celest service. + /// + /// This is determined by the `CELEST_ENVIRONMENT` variable + /// which is set for you by the deployment environment. + CelestEnvironment get currentEnvironment => + (variables.currentEnvironment as CelestEnvironment); + + /// The variables of the Celest service. + /// + /// This class provides access to the values configured for the + /// [currentEnvironment]. + CelestVariables get variables => const CelestVariables(); + + /// The secrets for the Celest service. + /// + /// This class provides access to the secret values that are configured + /// for the [currentEnvironment]. + CelestSecrets get secrets => const CelestSecrets(); +} + +/// A per-request context object which propogates request information and common +/// accessors to the Celest server environment. +extension type CelestContext._(Context _context) implements Context {} diff --git a/apps/cli/fixtures/legacy/supabase/celest/lib/src/generated/config.celest.dart b/apps/cli/fixtures/legacy/supabase/celest/lib/src/generated/config.celest.dart new file mode 100644 index 000000000..cd64f439e --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/celest/lib/src/generated/config.celest.dart @@ -0,0 +1,60 @@ +// Generated by Celest. This file should not be modified manually, but +// it can be checked into version control. +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use, invalid_use_of_internal_member + +library; + +import 'package:celest/celest.dart'; +import 'package:celest/src/core/context.dart'; + +/// An environment of a deployed Celest service. +/// +/// Celest services can have multiple isolated branches, for example +/// a `development` and `production` environment. +extension type const CelestEnvironment._(String _env) + implements Environment, String { + /// The local Celest environment, used to delineate when a + /// Celest service is running on a developer machine as opposed + /// to the cloud. + static const CelestEnvironment local = CelestEnvironment._('local'); + + /// The production Celest environment which is common to all + /// Celest projects and labels the environment which is considered + /// live and served to end-users. + static const CelestEnvironment production = CelestEnvironment._('production'); + + /// Whether `this` represents the [local] environment. + bool get isLocal => this == local; + + /// Whether `this` represents the [production] environment. + bool get isProduction => this == production; +} + +/// The environment variables for the Celest service. +/// +/// This class provides access to the environment variable values +/// that are configured for the current [CelestEnvironment]. +class CelestVariables { + const CelestVariables(); + + /// The environment variable that determines the current environment. + /// + /// This is set by the deployment environment and is used to + /// determine the current environment of the Celest service. + String get currentEnvironment => context.expect(env.environment); + + /// The value of the `SUPABASE_URL` environment variable. + String get supabaseUrl => context.expect(const env('SUPABASE_URL')); +} + +/// The secrets for the Celest service. +/// +/// This class provides access to the secret values that are configured +/// for the current [CelestEnvironment]. +class CelestSecrets { + const CelestSecrets(); + + /// The value of the `SUPABASE_JWT_SECRET` secret. + String get supabaseJwtSecret => + context.expect(const env('SUPABASE_JWT_SECRET')); +} diff --git a/apps/cli/fixtures/legacy/supabase/celest/lib/src/project.dart b/apps/cli/fixtures/legacy/supabase/celest/lib/src/project.dart new file mode 100644 index 000000000..f21e74627 --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/celest/lib/src/project.dart @@ -0,0 +1,13 @@ +import 'package:celest/celest.dart'; + +const project = Project(name: 'supabase'); + +const supabaseJwtSecret = secret('SUPABASE_JWT_SECRET'); + +const auth = Auth( + providers: [ + ExternalAuthProvider.supabase( + jwtSecret: supabaseJwtSecret, + ), + ], +); diff --git a/apps/cli/fixtures/legacy/supabase/celest/pubspec.yaml b/apps/cli/fixtures/legacy/supabase/celest/pubspec.yaml new file mode 100644 index 000000000..7deabfdf7 --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/celest/pubspec.yaml @@ -0,0 +1,31 @@ +name: celest_backend +publish_to: none + +environment: + sdk: ^3.4.0 + +dependencies: + celest: ^1.0.0 + celest_core: ^1.0.0 + gotrue: ^2.9.0 + meta: ^1.12.0 + supabase: ^2.2.2 + +dependency_overrides: + cedar: + path: ../../../../../../cedar/packages/cedar + celest: + path: ../../../../../../celest/packages/celest + celest_ast: + path: ../../../../../../celest/packages/celest_ast + celest_auth: + path: ../../../../../../celest/packages/celest_auth + celest_cloud: + path: ../../../../../../celest/packages/celest_cloud + celest_cloud_auth: + path: ../../../../../../celest/services/celest_cloud_auth + celest_core: + path: ../../../../../../celest/packages/celest_core +dev_dependencies: + lints: ^4.0.0 + test: ^1.25.0 diff --git a/apps/cli/fixtures/legacy/supabase/ios/.gitignore b/apps/cli/fixtures/legacy/supabase/ios/.gitignore new file mode 100644 index 000000000..7a7f9873a --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/ios/.gitignore @@ -0,0 +1,34 @@ +**/dgph +*.mode1v3 +*.mode2v3 +*.moved-aside +*.pbxuser +*.perspectivev3 +**/*sync/ +.sconsign.dblite +.tags* +**/.vagrant/ +**/DerivedData/ +Icon? +**/Pods/ +**/.symlinks/ +profile +xcuserdata +**/.generated/ +Flutter/App.framework +Flutter/Flutter.framework +Flutter/Flutter.podspec +Flutter/Generated.xcconfig +Flutter/ephemeral/ +Flutter/app.flx +Flutter/app.zip +Flutter/flutter_assets/ +Flutter/flutter_export_environment.sh +ServiceDefinitions.json +Runner/GeneratedPluginRegistrant.* + +# Exceptions to above rules. +!default.mode1v3 +!default.mode2v3 +!default.pbxuser +!default.perspectivev3 diff --git a/apps/cli/fixtures/legacy/supabase/ios/Flutter/AppFrameworkInfo.plist b/apps/cli/fixtures/legacy/supabase/ios/Flutter/AppFrameworkInfo.plist new file mode 100644 index 000000000..7c5696400 --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/ios/Flutter/AppFrameworkInfo.plist @@ -0,0 +1,26 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + App + CFBundleIdentifier + io.flutter.flutter.app + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + App + CFBundlePackageType + FMWK + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1.0 + MinimumOSVersion + 12.0 + + diff --git a/apps/cli/fixtures/legacy/supabase/ios/Flutter/Debug.xcconfig b/apps/cli/fixtures/legacy/supabase/ios/Flutter/Debug.xcconfig new file mode 100644 index 000000000..592ceee85 --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/ios/Flutter/Debug.xcconfig @@ -0,0 +1 @@ +#include "Generated.xcconfig" diff --git a/apps/cli/fixtures/legacy/supabase/ios/Flutter/Release.xcconfig b/apps/cli/fixtures/legacy/supabase/ios/Flutter/Release.xcconfig new file mode 100644 index 000000000..592ceee85 --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/ios/Flutter/Release.xcconfig @@ -0,0 +1 @@ +#include "Generated.xcconfig" diff --git a/apps/cli/fixtures/legacy/supabase/ios/Runner.xcodeproj/project.pbxproj b/apps/cli/fixtures/legacy/supabase/ios/Runner.xcodeproj/project.pbxproj new file mode 100644 index 000000000..5259da484 --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/ios/Runner.xcodeproj/project.pbxproj @@ -0,0 +1,619 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 54; + objects = { + +/* Begin PBXBuildFile section */ + 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; + 331C808B294A63AB00263BE5 /* RunnerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 331C807B294A618700263BE5 /* RunnerTests.swift */; }; + 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; + 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; }; + 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; + 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; + 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 331C8085294A63A400263BE5 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 97C146E61CF9000F007C117D /* Project object */; + proxyType = 1; + remoteGlobalIDString = 97C146ED1CF9000F007C117D; + remoteInfo = Runner; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 9705A1C41CF9048500538489 /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; + 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; + 331C807B294A618700263BE5 /* RunnerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunnerTests.swift; sourceTree = ""; }; + 331C8081294A63A400263BE5 /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; + 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; }; + 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; + 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; + 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; + 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 97C146EB1CF9000F007C117D /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 331C8082294A63A400263BE5 /* RunnerTests */ = { + isa = PBXGroup; + children = ( + 331C807B294A618700263BE5 /* RunnerTests.swift */, + ); + path = RunnerTests; + sourceTree = ""; + }; + 9740EEB11CF90186004384FC /* Flutter */ = { + isa = PBXGroup; + children = ( + 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */, + 9740EEB21CF90195004384FC /* Debug.xcconfig */, + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, + 9740EEB31CF90195004384FC /* Generated.xcconfig */, + ); + name = Flutter; + sourceTree = ""; + }; + 97C146E51CF9000F007C117D = { + isa = PBXGroup; + children = ( + 9740EEB11CF90186004384FC /* Flutter */, + 97C146F01CF9000F007C117D /* Runner */, + 97C146EF1CF9000F007C117D /* Products */, + 331C8082294A63A400263BE5 /* RunnerTests */, + ); + sourceTree = ""; + }; + 97C146EF1CF9000F007C117D /* Products */ = { + isa = PBXGroup; + children = ( + 97C146EE1CF9000F007C117D /* Runner.app */, + 331C8081294A63A400263BE5 /* RunnerTests.xctest */, + ); + name = Products; + sourceTree = ""; + }; + 97C146F01CF9000F007C117D /* Runner */ = { + isa = PBXGroup; + children = ( + 97C146FA1CF9000F007C117D /* Main.storyboard */, + 97C146FD1CF9000F007C117D /* Assets.xcassets */, + 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */, + 97C147021CF9000F007C117D /* Info.plist */, + 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */, + 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */, + 74858FAE1ED2DC5600515810 /* AppDelegate.swift */, + 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */, + ); + path = Runner; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 331C8080294A63A400263BE5 /* RunnerTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 331C8087294A63A400263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */; + buildPhases = ( + 331C807D294A63A400263BE5 /* Sources */, + 331C807F294A63A400263BE5 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + 331C8086294A63A400263BE5 /* PBXTargetDependency */, + ); + name = RunnerTests; + productName = RunnerTests; + productReference = 331C8081294A63A400263BE5 /* RunnerTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; + 97C146ED1CF9000F007C117D /* Runner */ = { + isa = PBXNativeTarget; + buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; + buildPhases = ( + 9740EEB61CF901F6004384FC /* Run Script */, + 97C146EA1CF9000F007C117D /* Sources */, + 97C146EB1CF9000F007C117D /* Frameworks */, + 97C146EC1CF9000F007C117D /* Resources */, + 9705A1C41CF9048500538489 /* Embed Frameworks */, + 3B06AD1E1E4923F5004D2608 /* Thin Binary */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = Runner; + productName = Runner; + productReference = 97C146EE1CF9000F007C117D /* Runner.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 97C146E61CF9000F007C117D /* Project object */ = { + isa = PBXProject; + attributes = { + BuildIndependentTargetsInParallel = YES; + LastUpgradeCheck = 1510; + ORGANIZATIONNAME = ""; + TargetAttributes = { + 331C8080294A63A400263BE5 = { + CreatedOnToolsVersion = 14.0; + TestTargetID = 97C146ED1CF9000F007C117D; + }; + 97C146ED1CF9000F007C117D = { + CreatedOnToolsVersion = 7.3.1; + LastSwiftMigration = 1100; + }; + }; + }; + buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 97C146E51CF9000F007C117D; + productRefGroup = 97C146EF1CF9000F007C117D /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 97C146ED1CF9000F007C117D /* Runner */, + 331C8080294A63A400263BE5 /* RunnerTests */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 331C807F294A63A400263BE5 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 97C146EC1CF9000F007C117D /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */, + 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */, + 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */, + 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { + isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}", + ); + name = "Thin Binary"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin"; + }; + 9740EEB61CF901F6004384FC /* Run Script */ = { + isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Run Script"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 331C807D294A63A400263BE5 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 331C808B294A63AB00263BE5 /* RunnerTests.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 97C146EA1CF9000F007C117D /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */, + 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 331C8086294A63A400263BE5 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 97C146ED1CF9000F007C117D /* Runner */; + targetProxy = 331C8085294A63A400263BE5 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin PBXVariantGroup section */ + 97C146FA1CF9000F007C117D /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 97C146FB1CF9000F007C117D /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 97C147001CF9000F007C117D /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 249021D3217E4FDB00AE95B9 /* Profile */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_USER_SCRIPT_SANDBOXING = NO; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + SUPPORTED_PLATFORMS = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Profile; + }; + 249021D4217E4FDB00AE95B9 /* Profile */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + DEVELOPMENT_TEAM = 3N44X5LWWW; + ENABLE_BITCODE = NO; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = dev.celest.supabaseTest; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; + SWIFT_VERSION = 5.0; + VERSIONING_SYSTEM = "apple-generic"; + }; + name = Profile; + }; + 331C8088294A63A400263BE5 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = dev.celest.supabaseTest.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner"; + }; + name = Debug; + }; + 331C8089294A63A400263BE5 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = dev.celest.supabaseTest.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner"; + }; + name = Release; + }; + 331C808A294A63A400263BE5 /* Profile */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = dev.celest.supabaseTest.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner"; + }; + name = Profile; + }; + 97C147031CF9000F007C117D /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + ENABLE_USER_SCRIPT_SANDBOXING = NO; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 97C147041CF9000F007C117D /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_USER_SCRIPT_SANDBOXING = NO; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + SUPPORTED_PLATFORMS = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 97C147061CF9000F007C117D /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + DEVELOPMENT_TEAM = 3N44X5LWWW; + ENABLE_BITCODE = NO; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = dev.celest.supabaseTest; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; + VERSIONING_SYSTEM = "apple-generic"; + }; + name = Debug; + }; + 97C147071CF9000F007C117D /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + DEVELOPMENT_TEAM = 3N44X5LWWW; + ENABLE_BITCODE = NO; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = dev.celest.supabaseTest; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; + SWIFT_VERSION = 5.0; + VERSIONING_SYSTEM = "apple-generic"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 331C8087294A63A400263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 331C8088294A63A400263BE5 /* Debug */, + 331C8089294A63A400263BE5 /* Release */, + 331C808A294A63A400263BE5 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 97C147031CF9000F007C117D /* Debug */, + 97C147041CF9000F007C117D /* Release */, + 249021D3217E4FDB00AE95B9 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 97C147061CF9000F007C117D /* Debug */, + 97C147071CF9000F007C117D /* Release */, + 249021D4217E4FDB00AE95B9 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 97C146E61CF9000F007C117D /* Project object */; +} diff --git a/apps/cli/fixtures/legacy/supabase/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/apps/cli/fixtures/legacy/supabase/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 000000000..919434a62 --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/apps/cli/fixtures/legacy/supabase/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/apps/cli/fixtures/legacy/supabase/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 000000000..18d981003 --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/apps/cli/fixtures/legacy/supabase/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/apps/cli/fixtures/legacy/supabase/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings new file mode 100644 index 000000000..f9b0d7c5e --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings @@ -0,0 +1,8 @@ + + + + + PreviewsEnabled + + + diff --git a/apps/cli/fixtures/legacy/supabase/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/apps/cli/fixtures/legacy/supabase/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme new file mode 100644 index 000000000..8e3ca5dfe --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -0,0 +1,98 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/apps/cli/fixtures/legacy/supabase/ios/Runner.xcworkspace/contents.xcworkspacedata b/apps/cli/fixtures/legacy/supabase/ios/Runner.xcworkspace/contents.xcworkspacedata new file mode 100644 index 000000000..1d526a16e --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/ios/Runner.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/apps/cli/fixtures/legacy/supabase/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/apps/cli/fixtures/legacy/supabase/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 000000000..18d981003 --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/apps/cli/fixtures/legacy/supabase/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/apps/cli/fixtures/legacy/supabase/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings new file mode 100644 index 000000000..f9b0d7c5e --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings @@ -0,0 +1,8 @@ + + + + + PreviewsEnabled + + + diff --git a/apps/cli/fixtures/legacy/supabase/ios/Runner/AppDelegate.swift b/apps/cli/fixtures/legacy/supabase/ios/Runner/AppDelegate.swift new file mode 100644 index 000000000..626664468 --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/ios/Runner/AppDelegate.swift @@ -0,0 +1,13 @@ +import Flutter +import UIKit + +@main +@objc class AppDelegate: FlutterAppDelegate { + override func application( + _ application: UIApplication, + didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? + ) -> Bool { + GeneratedPluginRegistrant.register(with: self) + return super.application(application, didFinishLaunchingWithOptions: launchOptions) + } +} diff --git a/apps/cli/fixtures/legacy/supabase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json b/apps/cli/fixtures/legacy/supabase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 000000000..d36b1fab2 --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,122 @@ +{ + "images" : [ + { + "size" : "20x20", + "idiom" : "iphone", + "filename" : "Icon-App-20x20@2x.png", + "scale" : "2x" + }, + { + "size" : "20x20", + "idiom" : "iphone", + "filename" : "Icon-App-20x20@3x.png", + "scale" : "3x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-App-29x29@1x.png", + "scale" : "1x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-App-29x29@2x.png", + "scale" : "2x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-App-29x29@3x.png", + "scale" : "3x" + }, + { + "size" : "40x40", + "idiom" : "iphone", + "filename" : "Icon-App-40x40@2x.png", + "scale" : "2x" + }, + { + "size" : "40x40", + "idiom" : "iphone", + "filename" : "Icon-App-40x40@3x.png", + "scale" : "3x" + }, + { + "size" : "60x60", + "idiom" : "iphone", + "filename" : "Icon-App-60x60@2x.png", + "scale" : "2x" + }, + { + "size" : "60x60", + "idiom" : "iphone", + "filename" : "Icon-App-60x60@3x.png", + "scale" : "3x" + }, + { + "size" : "20x20", + "idiom" : "ipad", + "filename" : "Icon-App-20x20@1x.png", + "scale" : "1x" + }, + { + "size" : "20x20", + "idiom" : "ipad", + "filename" : "Icon-App-20x20@2x.png", + "scale" : "2x" + }, + { + "size" : "29x29", + "idiom" : "ipad", + "filename" : "Icon-App-29x29@1x.png", + "scale" : "1x" + }, + { + "size" : "29x29", + "idiom" : "ipad", + "filename" : "Icon-App-29x29@2x.png", + "scale" : "2x" + }, + { + "size" : "40x40", + "idiom" : "ipad", + "filename" : "Icon-App-40x40@1x.png", + "scale" : "1x" + }, + { + "size" : "40x40", + "idiom" : "ipad", + "filename" : "Icon-App-40x40@2x.png", + "scale" : "2x" + }, + { + "size" : "76x76", + "idiom" : "ipad", + "filename" : "Icon-App-76x76@1x.png", + "scale" : "1x" + }, + { + "size" : "76x76", + "idiom" : "ipad", + "filename" : "Icon-App-76x76@2x.png", + "scale" : "2x" + }, + { + "size" : "83.5x83.5", + "idiom" : "ipad", + "filename" : "Icon-App-83.5x83.5@2x.png", + "scale" : "2x" + }, + { + "size" : "1024x1024", + "idiom" : "ios-marketing", + "filename" : "Icon-App-1024x1024@1x.png", + "scale" : "1x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} diff --git a/apps/cli/fixtures/legacy/supabase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png b/apps/cli/fixtures/legacy/supabase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png new file mode 100644 index 000000000..dc9ada472 Binary files /dev/null and b/apps/cli/fixtures/legacy/supabase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png differ diff --git a/apps/cli/fixtures/legacy/supabase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png b/apps/cli/fixtures/legacy/supabase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png new file mode 100644 index 000000000..7353c41ec Binary files /dev/null and b/apps/cli/fixtures/legacy/supabase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png differ diff --git a/apps/cli/fixtures/legacy/supabase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png b/apps/cli/fixtures/legacy/supabase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png new file mode 100644 index 000000000..797d452e4 Binary files /dev/null and b/apps/cli/fixtures/legacy/supabase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png differ diff --git a/apps/cli/fixtures/legacy/supabase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png b/apps/cli/fixtures/legacy/supabase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png new file mode 100644 index 000000000..6ed2d933e Binary files /dev/null and b/apps/cli/fixtures/legacy/supabase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png differ diff --git a/apps/cli/fixtures/legacy/supabase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png b/apps/cli/fixtures/legacy/supabase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png new file mode 100644 index 000000000..4cd7b0099 Binary files /dev/null and b/apps/cli/fixtures/legacy/supabase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png differ diff --git a/apps/cli/fixtures/legacy/supabase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png b/apps/cli/fixtures/legacy/supabase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png new file mode 100644 index 000000000..fe730945a Binary files /dev/null and b/apps/cli/fixtures/legacy/supabase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png differ diff --git a/apps/cli/fixtures/legacy/supabase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png b/apps/cli/fixtures/legacy/supabase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png new file mode 100644 index 000000000..321773cd8 Binary files /dev/null and b/apps/cli/fixtures/legacy/supabase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png differ diff --git a/apps/cli/fixtures/legacy/supabase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png b/apps/cli/fixtures/legacy/supabase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png new file mode 100644 index 000000000..797d452e4 Binary files /dev/null and b/apps/cli/fixtures/legacy/supabase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png differ diff --git a/apps/cli/fixtures/legacy/supabase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png b/apps/cli/fixtures/legacy/supabase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png new file mode 100644 index 000000000..502f463a9 Binary files /dev/null and b/apps/cli/fixtures/legacy/supabase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png differ diff --git a/apps/cli/fixtures/legacy/supabase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png b/apps/cli/fixtures/legacy/supabase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png new file mode 100644 index 000000000..0ec303439 Binary files /dev/null and b/apps/cli/fixtures/legacy/supabase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png differ diff --git a/apps/cli/fixtures/legacy/supabase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png b/apps/cli/fixtures/legacy/supabase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png new file mode 100644 index 000000000..0ec303439 Binary files /dev/null and b/apps/cli/fixtures/legacy/supabase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png differ diff --git a/apps/cli/fixtures/legacy/supabase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png b/apps/cli/fixtures/legacy/supabase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png new file mode 100644 index 000000000..e9f5fea27 Binary files /dev/null and b/apps/cli/fixtures/legacy/supabase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png differ diff --git a/apps/cli/fixtures/legacy/supabase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png b/apps/cli/fixtures/legacy/supabase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png new file mode 100644 index 000000000..84ac32ae7 Binary files /dev/null and b/apps/cli/fixtures/legacy/supabase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png differ diff --git a/apps/cli/fixtures/legacy/supabase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png b/apps/cli/fixtures/legacy/supabase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png new file mode 100644 index 000000000..8953cba09 Binary files /dev/null and b/apps/cli/fixtures/legacy/supabase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png differ diff --git a/apps/cli/fixtures/legacy/supabase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png b/apps/cli/fixtures/legacy/supabase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png new file mode 100644 index 000000000..0467bf12a Binary files /dev/null and b/apps/cli/fixtures/legacy/supabase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png differ diff --git a/apps/cli/fixtures/legacy/supabase/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json b/apps/cli/fixtures/legacy/supabase/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json new file mode 100644 index 000000000..0bedcf2fd --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "LaunchImage.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "LaunchImage@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "LaunchImage@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} diff --git a/apps/cli/fixtures/legacy/supabase/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png b/apps/cli/fixtures/legacy/supabase/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png new file mode 100644 index 000000000..9da19eaca Binary files /dev/null and b/apps/cli/fixtures/legacy/supabase/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png differ diff --git a/apps/cli/fixtures/legacy/supabase/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png b/apps/cli/fixtures/legacy/supabase/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png new file mode 100644 index 000000000..9da19eaca Binary files /dev/null and b/apps/cli/fixtures/legacy/supabase/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png differ diff --git a/apps/cli/fixtures/legacy/supabase/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png b/apps/cli/fixtures/legacy/supabase/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png new file mode 100644 index 000000000..9da19eaca Binary files /dev/null and b/apps/cli/fixtures/legacy/supabase/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png differ diff --git a/apps/cli/fixtures/legacy/supabase/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md b/apps/cli/fixtures/legacy/supabase/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md new file mode 100644 index 000000000..89c2725b7 --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md @@ -0,0 +1,5 @@ +# Launch Screen Assets + +You can customize the launch screen with your own desired assets by replacing the image files in this directory. + +You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images. \ No newline at end of file diff --git a/apps/cli/fixtures/legacy/supabase/ios/Runner/Base.lproj/LaunchScreen.storyboard b/apps/cli/fixtures/legacy/supabase/ios/Runner/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 000000000..f2e259c7c --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/ios/Runner/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/apps/cli/fixtures/legacy/supabase/ios/Runner/Base.lproj/Main.storyboard b/apps/cli/fixtures/legacy/supabase/ios/Runner/Base.lproj/Main.storyboard new file mode 100644 index 000000000..f3c28516f --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/ios/Runner/Base.lproj/Main.storyboard @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/apps/cli/fixtures/legacy/supabase/ios/Runner/Info.plist b/apps/cli/fixtures/legacy/supabase/ios/Runner/Info.plist new file mode 100644 index 000000000..846bea192 --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/ios/Runner/Info.plist @@ -0,0 +1,49 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleDisplayName + Supabase Test + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + supabase_test + CFBundlePackageType + APPL + CFBundleShortVersionString + $(FLUTTER_BUILD_NAME) + CFBundleSignature + ???? + CFBundleVersion + $(FLUTTER_BUILD_NUMBER) + LSRequiresIPhoneOS + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + CADisableMinimumFrameDurationOnPhone + + UIApplicationSupportsIndirectInputEvents + + + diff --git a/apps/cli/fixtures/legacy/supabase/ios/Runner/Runner-Bridging-Header.h b/apps/cli/fixtures/legacy/supabase/ios/Runner/Runner-Bridging-Header.h new file mode 100644 index 000000000..308a2a560 --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/ios/Runner/Runner-Bridging-Header.h @@ -0,0 +1 @@ +#import "GeneratedPluginRegistrant.h" diff --git a/apps/cli/fixtures/legacy/supabase/ios/RunnerTests/RunnerTests.swift b/apps/cli/fixtures/legacy/supabase/ios/RunnerTests/RunnerTests.swift new file mode 100644 index 000000000..86a7c3b1b --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/ios/RunnerTests/RunnerTests.swift @@ -0,0 +1,12 @@ +import Flutter +import UIKit +import XCTest + +class RunnerTests: XCTestCase { + + func testExample() { + // If you add code to the Runner application, consider adding tests here. + // See https://developer.apple.com/documentation/xctest for more information about using XCTest. + } + +} diff --git a/apps/cli/fixtures/legacy/supabase/lib/main.dart b/apps/cli/fixtures/legacy/supabase/lib/main.dart new file mode 100644 index 000000000..a7256585a --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/lib/main.dart @@ -0,0 +1,20 @@ +import 'package:flutter/material.dart'; + +void main() { + runApp(const MainApp()); +} + +class MainApp extends StatelessWidget { + const MainApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: Scaffold( + body: Center( + child: Text('Hello World!'), + ), + ), + ); + } +} diff --git a/apps/cli/fixtures/legacy/supabase/linux/.gitignore b/apps/cli/fixtures/legacy/supabase/linux/.gitignore new file mode 100644 index 000000000..d3896c984 --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/linux/.gitignore @@ -0,0 +1 @@ +flutter/ephemeral diff --git a/apps/cli/fixtures/legacy/supabase/linux/CMakeLists.txt b/apps/cli/fixtures/legacy/supabase/linux/CMakeLists.txt new file mode 100644 index 000000000..ff1acfe88 --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/linux/CMakeLists.txt @@ -0,0 +1,145 @@ +# Project-level configuration. +cmake_minimum_required(VERSION 3.10) +project(runner LANGUAGES CXX) + +# The name of the executable created for the application. Change this to change +# the on-disk name of your application. +set(BINARY_NAME "supabase_test") +# The unique GTK application identifier for this application. See: +# https://wiki.gnome.org/HowDoI/ChooseApplicationID +set(APPLICATION_ID "dev.celest.supabase_test") + +# Explicitly opt in to modern CMake behaviors to avoid warnings with recent +# versions of CMake. +cmake_policy(SET CMP0063 NEW) + +# Load bundled libraries from the lib/ directory relative to the binary. +set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") + +# Root filesystem for cross-building. +if(FLUTTER_TARGET_PLATFORM_SYSROOT) + set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT}) + set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT}) + set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) + set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) + set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) + set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +endif() + +# Define build configuration options. +if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + set(CMAKE_BUILD_TYPE "Debug" CACHE + STRING "Flutter build mode" FORCE) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS + "Debug" "Profile" "Release") +endif() + +# Compilation settings that should be applied to most targets. +# +# Be cautious about adding new options here, as plugins use this function by +# default. In most cases, you should add new options to specific targets instead +# of modifying this function. +function(APPLY_STANDARD_SETTINGS TARGET) + target_compile_features(${TARGET} PUBLIC cxx_std_14) + target_compile_options(${TARGET} PRIVATE -Wall -Werror) + target_compile_options(${TARGET} PRIVATE "$<$>:-O3>") + target_compile_definitions(${TARGET} PRIVATE "$<$>:NDEBUG>") +endfunction() + +# Flutter library and tool build rules. +set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") +add_subdirectory(${FLUTTER_MANAGED_DIR}) + +# System-level dependencies. +find_package(PkgConfig REQUIRED) +pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) + +add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}") + +# Define the application target. To change its name, change BINARY_NAME above, +# not the value here, or `flutter run` will no longer work. +# +# Any new source files that you add to the application should be added here. +add_executable(${BINARY_NAME} + "main.cc" + "my_application.cc" + "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" +) + +# Apply the standard set of build settings. This can be removed for applications +# that need different build settings. +apply_standard_settings(${BINARY_NAME}) + +# Add dependency libraries. Add any application-specific dependencies here. +target_link_libraries(${BINARY_NAME} PRIVATE flutter) +target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK) + +# Run the Flutter tool portions of the build. This must not be removed. +add_dependencies(${BINARY_NAME} flutter_assemble) + +# Only the install-generated bundle's copy of the executable will launch +# correctly, since the resources must in the right relative locations. To avoid +# people trying to run the unbundled copy, put it in a subdirectory instead of +# the default top-level location. +set_target_properties(${BINARY_NAME} + PROPERTIES + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run" +) + + +# Generated plugin build rules, which manage building the plugins and adding +# them to the application. +include(flutter/generated_plugins.cmake) + + +# === Installation === +# By default, "installing" just makes a relocatable bundle in the build +# directory. +set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") +if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) +endif() + +# Start with a clean build bundle directory every time. +install(CODE " + file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") + " COMPONENT Runtime) + +set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") +set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") + +install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" + COMPONENT Runtime) + +install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" + COMPONENT Runtime) + +install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) + +foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES}) + install(FILES "${bundled_library}" + DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) +endforeach(bundled_library) + +# Copy the native assets provided by the build.dart from all packages. +set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/linux/") +install(DIRECTORY "${NATIVE_ASSETS_DIR}" + DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) + +# Fully re-copy the assets directory on each build to avoid having stale files +# from a previous install. +set(FLUTTER_ASSET_DIR_NAME "flutter_assets") +install(CODE " + file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") + " COMPONENT Runtime) +install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" + DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) + +# Install the AOT library on non-Debug builds only. +if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") + install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) +endif() diff --git a/apps/cli/fixtures/legacy/supabase/linux/flutter/CMakeLists.txt b/apps/cli/fixtures/legacy/supabase/linux/flutter/CMakeLists.txt new file mode 100644 index 000000000..d5bd01648 --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/linux/flutter/CMakeLists.txt @@ -0,0 +1,88 @@ +# This file controls Flutter-level build steps. It should not be edited. +cmake_minimum_required(VERSION 3.10) + +set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") + +# Configuration provided via flutter tool. +include(${EPHEMERAL_DIR}/generated_config.cmake) + +# TODO: Move the rest of this into files in ephemeral. See +# https://github.com/flutter/flutter/issues/57146. + +# Serves the same purpose as list(TRANSFORM ... PREPEND ...), +# which isn't available in 3.10. +function(list_prepend LIST_NAME PREFIX) + set(NEW_LIST "") + foreach(element ${${LIST_NAME}}) + list(APPEND NEW_LIST "${PREFIX}${element}") + endforeach(element) + set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE) +endfunction() + +# === Flutter Library === +# System-level dependencies. +find_package(PkgConfig REQUIRED) +pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) +pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0) +pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0) + +set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so") + +# Published to parent scope for install step. +set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) +set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) +set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) +set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE) + +list(APPEND FLUTTER_LIBRARY_HEADERS + "fl_basic_message_channel.h" + "fl_binary_codec.h" + "fl_binary_messenger.h" + "fl_dart_project.h" + "fl_engine.h" + "fl_json_message_codec.h" + "fl_json_method_codec.h" + "fl_message_codec.h" + "fl_method_call.h" + "fl_method_channel.h" + "fl_method_codec.h" + "fl_method_response.h" + "fl_plugin_registrar.h" + "fl_plugin_registry.h" + "fl_standard_message_codec.h" + "fl_standard_method_codec.h" + "fl_string_codec.h" + "fl_value.h" + "fl_view.h" + "flutter_linux.h" +) +list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/") +add_library(flutter INTERFACE) +target_include_directories(flutter INTERFACE + "${EPHEMERAL_DIR}" +) +target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}") +target_link_libraries(flutter INTERFACE + PkgConfig::GTK + PkgConfig::GLIB + PkgConfig::GIO +) +add_dependencies(flutter flutter_assemble) + +# === Flutter tool backend === +# _phony_ is a non-existent file to force this command to run every time, +# since currently there's no way to get a full input/output list from the +# flutter tool. +add_custom_command( + OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} + ${CMAKE_CURRENT_BINARY_DIR}/_phony_ + COMMAND ${CMAKE_COMMAND} -E env + ${FLUTTER_TOOL_ENVIRONMENT} + "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh" + ${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE} + VERBATIM +) +add_custom_target(flutter_assemble DEPENDS + "${FLUTTER_LIBRARY}" + ${FLUTTER_LIBRARY_HEADERS} +) diff --git a/apps/cli/fixtures/legacy/supabase/linux/flutter/generated_plugin_registrant.cc b/apps/cli/fixtures/legacy/supabase/linux/flutter/generated_plugin_registrant.cc new file mode 100644 index 000000000..e71a16d23 --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/linux/flutter/generated_plugin_registrant.cc @@ -0,0 +1,11 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#include "generated_plugin_registrant.h" + + +void fl_register_plugins(FlPluginRegistry* registry) { +} diff --git a/apps/cli/fixtures/legacy/supabase/linux/flutter/generated_plugin_registrant.h b/apps/cli/fixtures/legacy/supabase/linux/flutter/generated_plugin_registrant.h new file mode 100644 index 000000000..e0f0a47bc --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/linux/flutter/generated_plugin_registrant.h @@ -0,0 +1,15 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#ifndef GENERATED_PLUGIN_REGISTRANT_ +#define GENERATED_PLUGIN_REGISTRANT_ + +#include + +// Registers Flutter plugins. +void fl_register_plugins(FlPluginRegistry* registry); + +#endif // GENERATED_PLUGIN_REGISTRANT_ diff --git a/apps/cli/fixtures/legacy/supabase/linux/flutter/generated_plugins.cmake b/apps/cli/fixtures/legacy/supabase/linux/flutter/generated_plugins.cmake new file mode 100644 index 000000000..2e1de87a7 --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/linux/flutter/generated_plugins.cmake @@ -0,0 +1,23 @@ +# +# Generated file, do not edit. +# + +list(APPEND FLUTTER_PLUGIN_LIST +) + +list(APPEND FLUTTER_FFI_PLUGIN_LIST +) + +set(PLUGIN_BUNDLED_LIBRARIES) + +foreach(plugin ${FLUTTER_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin}) + target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) + list(APPEND PLUGIN_BUNDLED_LIBRARIES $) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) +endforeach(plugin) + +foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin}) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) +endforeach(ffi_plugin) diff --git a/apps/cli/fixtures/legacy/supabase/linux/main.cc b/apps/cli/fixtures/legacy/supabase/linux/main.cc new file mode 100644 index 000000000..e7c5c5437 --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/linux/main.cc @@ -0,0 +1,6 @@ +#include "my_application.h" + +int main(int argc, char** argv) { + g_autoptr(MyApplication) app = my_application_new(); + return g_application_run(G_APPLICATION(app), argc, argv); +} diff --git a/apps/cli/fixtures/legacy/supabase/linux/my_application.cc b/apps/cli/fixtures/legacy/supabase/linux/my_application.cc new file mode 100644 index 000000000..bc66fc585 --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/linux/my_application.cc @@ -0,0 +1,124 @@ +#include "my_application.h" + +#include +#ifdef GDK_WINDOWING_X11 +#include +#endif + +#include "flutter/generated_plugin_registrant.h" + +struct _MyApplication { + GtkApplication parent_instance; + char** dart_entrypoint_arguments; +}; + +G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION) + +// Implements GApplication::activate. +static void my_application_activate(GApplication* application) { + MyApplication* self = MY_APPLICATION(application); + GtkWindow* window = + GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application))); + + // Use a header bar when running in GNOME as this is the common style used + // by applications and is the setup most users will be using (e.g. Ubuntu + // desktop). + // If running on X and not using GNOME then just use a traditional title bar + // in case the window manager does more exotic layout, e.g. tiling. + // If running on Wayland assume the header bar will work (may need changing + // if future cases occur). + gboolean use_header_bar = TRUE; +#ifdef GDK_WINDOWING_X11 + GdkScreen* screen = gtk_window_get_screen(window); + if (GDK_IS_X11_SCREEN(screen)) { + const gchar* wm_name = gdk_x11_screen_get_window_manager_name(screen); + if (g_strcmp0(wm_name, "GNOME Shell") != 0) { + use_header_bar = FALSE; + } + } +#endif + if (use_header_bar) { + GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new()); + gtk_widget_show(GTK_WIDGET(header_bar)); + gtk_header_bar_set_title(header_bar, "supabase_test"); + gtk_header_bar_set_show_close_button(header_bar, TRUE); + gtk_window_set_titlebar(window, GTK_WIDGET(header_bar)); + } else { + gtk_window_set_title(window, "supabase_test"); + } + + gtk_window_set_default_size(window, 1280, 720); + gtk_widget_show(GTK_WIDGET(window)); + + g_autoptr(FlDartProject) project = fl_dart_project_new(); + fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments); + + FlView* view = fl_view_new(project); + gtk_widget_show(GTK_WIDGET(view)); + gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view)); + + fl_register_plugins(FL_PLUGIN_REGISTRY(view)); + + gtk_widget_grab_focus(GTK_WIDGET(view)); +} + +// Implements GApplication::local_command_line. +static gboolean my_application_local_command_line(GApplication* application, gchar*** arguments, int* exit_status) { + MyApplication* self = MY_APPLICATION(application); + // Strip out the first argument as it is the binary name. + self->dart_entrypoint_arguments = g_strdupv(*arguments + 1); + + g_autoptr(GError) error = nullptr; + if (!g_application_register(application, nullptr, &error)) { + g_warning("Failed to register: %s", error->message); + *exit_status = 1; + return TRUE; + } + + g_application_activate(application); + *exit_status = 0; + + return TRUE; +} + +// Implements GApplication::startup. +static void my_application_startup(GApplication* application) { + //MyApplication* self = MY_APPLICATION(object); + + // Perform any actions required at application startup. + + G_APPLICATION_CLASS(my_application_parent_class)->startup(application); +} + +// Implements GApplication::shutdown. +static void my_application_shutdown(GApplication* application) { + //MyApplication* self = MY_APPLICATION(object); + + // Perform any actions required at application shutdown. + + G_APPLICATION_CLASS(my_application_parent_class)->shutdown(application); +} + +// Implements GObject::dispose. +static void my_application_dispose(GObject* object) { + MyApplication* self = MY_APPLICATION(object); + g_clear_pointer(&self->dart_entrypoint_arguments, g_strfreev); + G_OBJECT_CLASS(my_application_parent_class)->dispose(object); +} + +static void my_application_class_init(MyApplicationClass* klass) { + G_APPLICATION_CLASS(klass)->activate = my_application_activate; + G_APPLICATION_CLASS(klass)->local_command_line = my_application_local_command_line; + G_APPLICATION_CLASS(klass)->startup = my_application_startup; + G_APPLICATION_CLASS(klass)->shutdown = my_application_shutdown; + G_OBJECT_CLASS(klass)->dispose = my_application_dispose; +} + +static void my_application_init(MyApplication* self) {} + +MyApplication* my_application_new() { + return MY_APPLICATION(g_object_new(my_application_get_type(), + "application-id", APPLICATION_ID, + "flags", G_APPLICATION_NON_UNIQUE, + nullptr)); +} diff --git a/apps/cli/fixtures/legacy/supabase/linux/my_application.h b/apps/cli/fixtures/legacy/supabase/linux/my_application.h new file mode 100644 index 000000000..72271d5e4 --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/linux/my_application.h @@ -0,0 +1,18 @@ +#ifndef FLUTTER_MY_APPLICATION_H_ +#define FLUTTER_MY_APPLICATION_H_ + +#include + +G_DECLARE_FINAL_TYPE(MyApplication, my_application, MY, APPLICATION, + GtkApplication) + +/** + * my_application_new: + * + * Creates a new Flutter-based application. + * + * Returns: a new #MyApplication. + */ +MyApplication* my_application_new(); + +#endif // FLUTTER_MY_APPLICATION_H_ diff --git a/apps/cli/fixtures/legacy/supabase/macos/.gitignore b/apps/cli/fixtures/legacy/supabase/macos/.gitignore new file mode 100644 index 000000000..746adbb6b --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/macos/.gitignore @@ -0,0 +1,7 @@ +# Flutter-related +**/Flutter/ephemeral/ +**/Pods/ + +# Xcode-related +**/dgph +**/xcuserdata/ diff --git a/apps/cli/fixtures/legacy/supabase/macos/Flutter/Flutter-Debug.xcconfig b/apps/cli/fixtures/legacy/supabase/macos/Flutter/Flutter-Debug.xcconfig new file mode 100644 index 000000000..c2efd0b60 --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/macos/Flutter/Flutter-Debug.xcconfig @@ -0,0 +1 @@ +#include "ephemeral/Flutter-Generated.xcconfig" diff --git a/apps/cli/fixtures/legacy/supabase/macos/Flutter/Flutter-Release.xcconfig b/apps/cli/fixtures/legacy/supabase/macos/Flutter/Flutter-Release.xcconfig new file mode 100644 index 000000000..c2efd0b60 --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/macos/Flutter/Flutter-Release.xcconfig @@ -0,0 +1 @@ +#include "ephemeral/Flutter-Generated.xcconfig" diff --git a/apps/cli/fixtures/legacy/supabase/macos/Flutter/GeneratedPluginRegistrant.swift b/apps/cli/fixtures/legacy/supabase/macos/Flutter/GeneratedPluginRegistrant.swift new file mode 100644 index 000000000..cccf817a5 --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/macos/Flutter/GeneratedPluginRegistrant.swift @@ -0,0 +1,10 @@ +// +// Generated file. Do not edit. +// + +import FlutterMacOS +import Foundation + + +func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { +} diff --git a/apps/cli/fixtures/legacy/supabase/macos/Runner.xcodeproj/project.pbxproj b/apps/cli/fixtures/legacy/supabase/macos/Runner.xcodeproj/project.pbxproj new file mode 100644 index 000000000..72085339a --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/macos/Runner.xcodeproj/project.pbxproj @@ -0,0 +1,705 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 54; + objects = { + +/* Begin PBXAggregateTarget section */ + 33CC111A2044C6BA0003C045 /* Flutter Assemble */ = { + isa = PBXAggregateTarget; + buildConfigurationList = 33CC111B2044C6BA0003C045 /* Build configuration list for PBXAggregateTarget "Flutter Assemble" */; + buildPhases = ( + 33CC111E2044C6BF0003C045 /* ShellScript */, + ); + dependencies = ( + ); + name = "Flutter Assemble"; + productName = FLX; + }; +/* End PBXAggregateTarget section */ + +/* Begin PBXBuildFile section */ + 331C80D8294CF71000263BE5 /* RunnerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 331C80D7294CF71000263BE5 /* RunnerTests.swift */; }; + 335BBD1B22A9A15E00E9071D /* GeneratedPluginRegistrant.swift in Sources */ = {isa = PBXBuildFile; fileRef = 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */; }; + 33CC10F12044A3C60003C045 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC10F02044A3C60003C045 /* AppDelegate.swift */; }; + 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F22044A3C60003C045 /* Assets.xcassets */; }; + 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F42044A3C60003C045 /* MainMenu.xib */; }; + 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 331C80D9294CF71000263BE5 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 33CC10E52044A3C60003C045 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 33CC10EC2044A3C60003C045; + remoteInfo = Runner; + }; + 33CC111F2044C79F0003C045 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 33CC10E52044A3C60003C045 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 33CC111A2044C6BA0003C045; + remoteInfo = FLX; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 33CC110E2044A8840003C045 /* Bundle Framework */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + ); + name = "Bundle Framework"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 331C80D5294CF71000263BE5 /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + 331C80D7294CF71000263BE5 /* RunnerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunnerTests.swift; sourceTree = ""; }; + 333000ED22D3DE5D00554162 /* Warnings.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Warnings.xcconfig; sourceTree = ""; }; + 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GeneratedPluginRegistrant.swift; sourceTree = ""; }; + 33CC10ED2044A3C60003C045 /* supabase_test.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "supabase_test.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + 33CC10F02044A3C60003C045 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 33CC10F22044A3C60003C045 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Assets.xcassets; path = Runner/Assets.xcassets; sourceTree = ""; }; + 33CC10F52044A3C60003C045 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = ""; }; + 33CC10F72044A3C60003C045 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Info.plist; path = Runner/Info.plist; sourceTree = ""; }; + 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainFlutterWindow.swift; sourceTree = ""; }; + 33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Debug.xcconfig"; sourceTree = ""; }; + 33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Release.xcconfig"; sourceTree = ""; }; + 33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = "Flutter-Generated.xcconfig"; path = "ephemeral/Flutter-Generated.xcconfig"; sourceTree = ""; }; + 33E51913231747F40026EE4D /* DebugProfile.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = DebugProfile.entitlements; sourceTree = ""; }; + 33E51914231749380026EE4D /* Release.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = Release.entitlements; sourceTree = ""; }; + 33E5194F232828860026EE4D /* AppInfo.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = AppInfo.xcconfig; sourceTree = ""; }; + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = ""; }; + 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 331C80D2294CF70F00263BE5 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 33CC10EA2044A3C60003C045 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 331C80D6294CF71000263BE5 /* RunnerTests */ = { + isa = PBXGroup; + children = ( + 331C80D7294CF71000263BE5 /* RunnerTests.swift */, + ); + path = RunnerTests; + sourceTree = ""; + }; + 33BA886A226E78AF003329D5 /* Configs */ = { + isa = PBXGroup; + children = ( + 33E5194F232828860026EE4D /* AppInfo.xcconfig */, + 9740EEB21CF90195004384FC /* Debug.xcconfig */, + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, + 333000ED22D3DE5D00554162 /* Warnings.xcconfig */, + ); + path = Configs; + sourceTree = ""; + }; + 33CC10E42044A3C60003C045 = { + isa = PBXGroup; + children = ( + 33FAB671232836740065AC1E /* Runner */, + 33CEB47122A05771004F2AC0 /* Flutter */, + 331C80D6294CF71000263BE5 /* RunnerTests */, + 33CC10EE2044A3C60003C045 /* Products */, + D73912EC22F37F3D000D13A0 /* Frameworks */, + ); + sourceTree = ""; + }; + 33CC10EE2044A3C60003C045 /* Products */ = { + isa = PBXGroup; + children = ( + 33CC10ED2044A3C60003C045 /* supabase_test.app */, + 331C80D5294CF71000263BE5 /* RunnerTests.xctest */, + ); + name = Products; + sourceTree = ""; + }; + 33CC11242044D66E0003C045 /* Resources */ = { + isa = PBXGroup; + children = ( + 33CC10F22044A3C60003C045 /* Assets.xcassets */, + 33CC10F42044A3C60003C045 /* MainMenu.xib */, + 33CC10F72044A3C60003C045 /* Info.plist */, + ); + name = Resources; + path = ..; + sourceTree = ""; + }; + 33CEB47122A05771004F2AC0 /* Flutter */ = { + isa = PBXGroup; + children = ( + 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */, + 33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */, + 33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */, + 33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */, + ); + path = Flutter; + sourceTree = ""; + }; + 33FAB671232836740065AC1E /* Runner */ = { + isa = PBXGroup; + children = ( + 33CC10F02044A3C60003C045 /* AppDelegate.swift */, + 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */, + 33E51913231747F40026EE4D /* DebugProfile.entitlements */, + 33E51914231749380026EE4D /* Release.entitlements */, + 33CC11242044D66E0003C045 /* Resources */, + 33BA886A226E78AF003329D5 /* Configs */, + ); + path = Runner; + sourceTree = ""; + }; + D73912EC22F37F3D000D13A0 /* Frameworks */ = { + isa = PBXGroup; + children = ( + ); + name = Frameworks; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 331C80D4294CF70F00263BE5 /* RunnerTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 331C80DE294CF71000263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */; + buildPhases = ( + 331C80D1294CF70F00263BE5 /* Sources */, + 331C80D2294CF70F00263BE5 /* Frameworks */, + 331C80D3294CF70F00263BE5 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + 331C80DA294CF71000263BE5 /* PBXTargetDependency */, + ); + name = RunnerTests; + productName = RunnerTests; + productReference = 331C80D5294CF71000263BE5 /* RunnerTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; + 33CC10EC2044A3C60003C045 /* Runner */ = { + isa = PBXNativeTarget; + buildConfigurationList = 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */; + buildPhases = ( + 33CC10E92044A3C60003C045 /* Sources */, + 33CC10EA2044A3C60003C045 /* Frameworks */, + 33CC10EB2044A3C60003C045 /* Resources */, + 33CC110E2044A8840003C045 /* Bundle Framework */, + 3399D490228B24CF009A79C7 /* ShellScript */, + ); + buildRules = ( + ); + dependencies = ( + 33CC11202044C79F0003C045 /* PBXTargetDependency */, + ); + name = Runner; + productName = Runner; + productReference = 33CC10ED2044A3C60003C045 /* supabase_test.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 33CC10E52044A3C60003C045 /* Project object */ = { + isa = PBXProject; + attributes = { + BuildIndependentTargetsInParallel = YES; + LastSwiftUpdateCheck = 0920; + LastUpgradeCheck = 1510; + ORGANIZATIONNAME = ""; + TargetAttributes = { + 331C80D4294CF70F00263BE5 = { + CreatedOnToolsVersion = 14.0; + TestTargetID = 33CC10EC2044A3C60003C045; + }; + 33CC10EC2044A3C60003C045 = { + CreatedOnToolsVersion = 9.2; + LastSwiftMigration = 1100; + ProvisioningStyle = Automatic; + SystemCapabilities = { + com.apple.Sandbox = { + enabled = 1; + }; + }; + }; + 33CC111A2044C6BA0003C045 = { + CreatedOnToolsVersion = 9.2; + ProvisioningStyle = Manual; + }; + }; + }; + buildConfigurationList = 33CC10E82044A3C60003C045 /* Build configuration list for PBXProject "Runner" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 33CC10E42044A3C60003C045; + productRefGroup = 33CC10EE2044A3C60003C045 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 33CC10EC2044A3C60003C045 /* Runner */, + 331C80D4294CF70F00263BE5 /* RunnerTests */, + 33CC111A2044C6BA0003C045 /* Flutter Assemble */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 331C80D3294CF70F00263BE5 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 33CC10EB2044A3C60003C045 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */, + 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 3399D490228B24CF009A79C7 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + ); + outputFileListPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "echo \"$PRODUCT_NAME.app\" > \"$PROJECT_DIR\"/Flutter/ephemeral/.app_filename && \"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh embed\n"; + }; + 33CC111E2044C6BF0003C045 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + Flutter/ephemeral/FlutterInputs.xcfilelist, + ); + inputPaths = ( + Flutter/ephemeral/tripwire, + ); + outputFileListPaths = ( + Flutter/ephemeral/FlutterOutputs.xcfilelist, + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh && touch Flutter/ephemeral/tripwire"; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 331C80D1294CF70F00263BE5 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 331C80D8294CF71000263BE5 /* RunnerTests.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 33CC10E92044A3C60003C045 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */, + 33CC10F12044A3C60003C045 /* AppDelegate.swift in Sources */, + 335BBD1B22A9A15E00E9071D /* GeneratedPluginRegistrant.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 331C80DA294CF71000263BE5 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 33CC10EC2044A3C60003C045 /* Runner */; + targetProxy = 331C80D9294CF71000263BE5 /* PBXContainerItemProxy */; + }; + 33CC11202044C79F0003C045 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 33CC111A2044C6BA0003C045 /* Flutter Assemble */; + targetProxy = 33CC111F2044C79F0003C045 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin PBXVariantGroup section */ + 33CC10F42044A3C60003C045 /* MainMenu.xib */ = { + isa = PBXVariantGroup; + children = ( + 33CC10F52044A3C60003C045 /* Base */, + ); + name = MainMenu.xib; + path = Runner; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 331C80DB294CF71000263BE5 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = dev.celest.supabaseTest.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/supabase_test.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/supabase_test"; + }; + name = Debug; + }; + 331C80DC294CF71000263BE5 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = dev.celest.supabaseTest.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/supabase_test.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/supabase_test"; + }; + name = Release; + }; + 331C80DD294CF71000263BE5 /* Profile */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = dev.celest.supabaseTest.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/supabase_test.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/supabase_test"; + }; + name = Profile; + }; + 338D0CE9231458BD00FA5F75 /* Profile */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEAD_CODE_STRIPPING = YES; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_USER_SCRIPT_SANDBOXING = NO; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.14; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = macosx; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + }; + name = Profile; + }; + 338D0CEA231458BD00FA5F75 /* Profile */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_VERSION = 5.0; + }; + name = Profile; + }; + 338D0CEB231458BD00FA5F75 /* Profile */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Manual; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Profile; + }; + 33CC10F92044A3C60003C045 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEAD_CODE_STRIPPING = YES; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + ENABLE_USER_SCRIPT_SANDBOXING = NO; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.14; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 33CC10FA2044A3C60003C045 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEAD_CODE_STRIPPING = YES; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_USER_SCRIPT_SANDBOXING = NO; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.14; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = macosx; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + }; + name = Release; + }; + 33CC10FC2044A3C60003C045 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; + }; + name = Debug; + }; + 33CC10FD2044A3C60003C045 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = Runner/Release.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_VERSION = 5.0; + }; + name = Release; + }; + 33CC111C2044C6BA0003C045 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Manual; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + 33CC111D2044C6BA0003C045 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 331C80DE294CF71000263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 331C80DB294CF71000263BE5 /* Debug */, + 331C80DC294CF71000263BE5 /* Release */, + 331C80DD294CF71000263BE5 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 33CC10E82044A3C60003C045 /* Build configuration list for PBXProject "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 33CC10F92044A3C60003C045 /* Debug */, + 33CC10FA2044A3C60003C045 /* Release */, + 338D0CE9231458BD00FA5F75 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 33CC10FC2044A3C60003C045 /* Debug */, + 33CC10FD2044A3C60003C045 /* Release */, + 338D0CEA231458BD00FA5F75 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 33CC111B2044C6BA0003C045 /* Build configuration list for PBXAggregateTarget "Flutter Assemble" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 33CC111C2044C6BA0003C045 /* Debug */, + 33CC111D2044C6BA0003C045 /* Release */, + 338D0CEB231458BD00FA5F75 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 33CC10E52044A3C60003C045 /* Project object */; +} diff --git a/apps/cli/fixtures/legacy/supabase/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/apps/cli/fixtures/legacy/supabase/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 000000000..18d981003 --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/apps/cli/fixtures/legacy/supabase/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/apps/cli/fixtures/legacy/supabase/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme new file mode 100644 index 000000000..e4bcadacc --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -0,0 +1,98 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/apps/cli/fixtures/legacy/supabase/macos/Runner.xcworkspace/contents.xcworkspacedata b/apps/cli/fixtures/legacy/supabase/macos/Runner.xcworkspace/contents.xcworkspacedata new file mode 100644 index 000000000..1d526a16e --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/macos/Runner.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/apps/cli/fixtures/legacy/supabase/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/apps/cli/fixtures/legacy/supabase/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 000000000..18d981003 --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/apps/cli/fixtures/legacy/supabase/macos/Runner/AppDelegate.swift b/apps/cli/fixtures/legacy/supabase/macos/Runner/AppDelegate.swift new file mode 100644 index 000000000..8e02df288 --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/macos/Runner/AppDelegate.swift @@ -0,0 +1,9 @@ +import Cocoa +import FlutterMacOS + +@main +class AppDelegate: FlutterAppDelegate { + override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { + return true + } +} diff --git a/apps/cli/fixtures/legacy/supabase/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json b/apps/cli/fixtures/legacy/supabase/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 000000000..a2ec33f19 --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,68 @@ +{ + "images" : [ + { + "size" : "16x16", + "idiom" : "mac", + "filename" : "app_icon_16.png", + "scale" : "1x" + }, + { + "size" : "16x16", + "idiom" : "mac", + "filename" : "app_icon_32.png", + "scale" : "2x" + }, + { + "size" : "32x32", + "idiom" : "mac", + "filename" : "app_icon_32.png", + "scale" : "1x" + }, + { + "size" : "32x32", + "idiom" : "mac", + "filename" : "app_icon_64.png", + "scale" : "2x" + }, + { + "size" : "128x128", + "idiom" : "mac", + "filename" : "app_icon_128.png", + "scale" : "1x" + }, + { + "size" : "128x128", + "idiom" : "mac", + "filename" : "app_icon_256.png", + "scale" : "2x" + }, + { + "size" : "256x256", + "idiom" : "mac", + "filename" : "app_icon_256.png", + "scale" : "1x" + }, + { + "size" : "256x256", + "idiom" : "mac", + "filename" : "app_icon_512.png", + "scale" : "2x" + }, + { + "size" : "512x512", + "idiom" : "mac", + "filename" : "app_icon_512.png", + "scale" : "1x" + }, + { + "size" : "512x512", + "idiom" : "mac", + "filename" : "app_icon_1024.png", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} diff --git a/apps/cli/fixtures/legacy/supabase/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png b/apps/cli/fixtures/legacy/supabase/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png new file mode 100644 index 000000000..82b6f9d9a Binary files /dev/null and b/apps/cli/fixtures/legacy/supabase/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png differ diff --git a/apps/cli/fixtures/legacy/supabase/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png b/apps/cli/fixtures/legacy/supabase/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png new file mode 100644 index 000000000..13b35eba5 Binary files /dev/null and b/apps/cli/fixtures/legacy/supabase/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png differ diff --git a/apps/cli/fixtures/legacy/supabase/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png b/apps/cli/fixtures/legacy/supabase/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png new file mode 100644 index 000000000..0a3f5fa40 Binary files /dev/null and b/apps/cli/fixtures/legacy/supabase/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png differ diff --git a/apps/cli/fixtures/legacy/supabase/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png b/apps/cli/fixtures/legacy/supabase/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png new file mode 100644 index 000000000..bdb57226d Binary files /dev/null and b/apps/cli/fixtures/legacy/supabase/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png differ diff --git a/apps/cli/fixtures/legacy/supabase/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png b/apps/cli/fixtures/legacy/supabase/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png new file mode 100644 index 000000000..f083318e0 Binary files /dev/null and b/apps/cli/fixtures/legacy/supabase/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png differ diff --git a/apps/cli/fixtures/legacy/supabase/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png b/apps/cli/fixtures/legacy/supabase/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png new file mode 100644 index 000000000..326c0e72c Binary files /dev/null and b/apps/cli/fixtures/legacy/supabase/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png differ diff --git a/apps/cli/fixtures/legacy/supabase/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png b/apps/cli/fixtures/legacy/supabase/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png new file mode 100644 index 000000000..2f1632cfd Binary files /dev/null and b/apps/cli/fixtures/legacy/supabase/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png differ diff --git a/apps/cli/fixtures/legacy/supabase/macos/Runner/Base.lproj/MainMenu.xib b/apps/cli/fixtures/legacy/supabase/macos/Runner/Base.lproj/MainMenu.xib new file mode 100644 index 000000000..80e867a4e --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/macos/Runner/Base.lproj/MainMenu.xib @@ -0,0 +1,343 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/apps/cli/fixtures/legacy/supabase/macos/Runner/Configs/AppInfo.xcconfig b/apps/cli/fixtures/legacy/supabase/macos/Runner/Configs/AppInfo.xcconfig new file mode 100644 index 000000000..e461f714d --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/macos/Runner/Configs/AppInfo.xcconfig @@ -0,0 +1,14 @@ +// Application-level settings for the Runner target. +// +// This may be replaced with something auto-generated from metadata (e.g., pubspec.yaml) in the +// future. If not, the values below would default to using the project name when this becomes a +// 'flutter create' template. + +// The application's name. By default this is also the title of the Flutter window. +PRODUCT_NAME = supabase_test + +// The application's bundle identifier +PRODUCT_BUNDLE_IDENTIFIER = dev.celest.supabaseTest + +// The copyright displayed in application information +PRODUCT_COPYRIGHT = Copyright © 2024 dev.celest. All rights reserved. diff --git a/apps/cli/fixtures/legacy/supabase/macos/Runner/Configs/Debug.xcconfig b/apps/cli/fixtures/legacy/supabase/macos/Runner/Configs/Debug.xcconfig new file mode 100644 index 000000000..36b0fd946 --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/macos/Runner/Configs/Debug.xcconfig @@ -0,0 +1,2 @@ +#include "../../Flutter/Flutter-Debug.xcconfig" +#include "Warnings.xcconfig" diff --git a/apps/cli/fixtures/legacy/supabase/macos/Runner/Configs/Release.xcconfig b/apps/cli/fixtures/legacy/supabase/macos/Runner/Configs/Release.xcconfig new file mode 100644 index 000000000..dff4f4956 --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/macos/Runner/Configs/Release.xcconfig @@ -0,0 +1,2 @@ +#include "../../Flutter/Flutter-Release.xcconfig" +#include "Warnings.xcconfig" diff --git a/apps/cli/fixtures/legacy/supabase/macos/Runner/Configs/Warnings.xcconfig b/apps/cli/fixtures/legacy/supabase/macos/Runner/Configs/Warnings.xcconfig new file mode 100644 index 000000000..42bcbf478 --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/macos/Runner/Configs/Warnings.xcconfig @@ -0,0 +1,13 @@ +WARNING_CFLAGS = -Wall -Wconditional-uninitialized -Wnullable-to-nonnull-conversion -Wmissing-method-return-type -Woverlength-strings +GCC_WARN_UNDECLARED_SELECTOR = YES +CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES +CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE +CLANG_WARN__DUPLICATE_METHOD_MATCH = YES +CLANG_WARN_PRAGMA_PACK = YES +CLANG_WARN_STRICT_PROTOTYPES = YES +CLANG_WARN_COMMA = YES +GCC_WARN_STRICT_SELECTOR_MATCH = YES +CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES +CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES +GCC_WARN_SHADOW = YES +CLANG_WARN_UNREACHABLE_CODE = YES diff --git a/apps/cli/fixtures/legacy/supabase/macos/Runner/DebugProfile.entitlements b/apps/cli/fixtures/legacy/supabase/macos/Runner/DebugProfile.entitlements new file mode 100644 index 000000000..3ba6c1266 --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/macos/Runner/DebugProfile.entitlements @@ -0,0 +1,14 @@ + + + + + com.apple.security.app-sandbox + + com.apple.security.cs.allow-jit + + com.apple.security.network.client + + com.apple.security.network.server + + + diff --git a/apps/cli/fixtures/legacy/supabase/macos/Runner/Info.plist b/apps/cli/fixtures/legacy/supabase/macos/Runner/Info.plist new file mode 100644 index 000000000..4789daa6a --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/macos/Runner/Info.plist @@ -0,0 +1,32 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIconFile + + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + $(FLUTTER_BUILD_NAME) + CFBundleVersion + $(FLUTTER_BUILD_NUMBER) + LSMinimumSystemVersion + $(MACOSX_DEPLOYMENT_TARGET) + NSHumanReadableCopyright + $(PRODUCT_COPYRIGHT) + NSMainNibFile + MainMenu + NSPrincipalClass + NSApplication + + diff --git a/apps/cli/fixtures/legacy/supabase/macos/Runner/MainFlutterWindow.swift b/apps/cli/fixtures/legacy/supabase/macos/Runner/MainFlutterWindow.swift new file mode 100644 index 000000000..3cc05eb23 --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/macos/Runner/MainFlutterWindow.swift @@ -0,0 +1,15 @@ +import Cocoa +import FlutterMacOS + +class MainFlutterWindow: NSWindow { + override func awakeFromNib() { + let flutterViewController = FlutterViewController() + let windowFrame = self.frame + self.contentViewController = flutterViewController + self.setFrame(windowFrame, display: true) + + RegisterGeneratedPlugins(registry: flutterViewController) + + super.awakeFromNib() + } +} diff --git a/apps/cli/fixtures/legacy/supabase/macos/Runner/Release.entitlements b/apps/cli/fixtures/legacy/supabase/macos/Runner/Release.entitlements new file mode 100644 index 000000000..ee95ab7e5 --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/macos/Runner/Release.entitlements @@ -0,0 +1,10 @@ + + + + + com.apple.security.app-sandbox + + com.apple.security.network.client + + + diff --git a/apps/cli/fixtures/legacy/supabase/macos/RunnerTests/RunnerTests.swift b/apps/cli/fixtures/legacy/supabase/macos/RunnerTests/RunnerTests.swift new file mode 100644 index 000000000..61f3bd1fc --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/macos/RunnerTests/RunnerTests.swift @@ -0,0 +1,12 @@ +import Cocoa +import FlutterMacOS +import XCTest + +class RunnerTests: XCTestCase { + + func testExample() { + // If you add code to the Runner application, consider adding tests here. + // See https://developer.apple.com/documentation/xctest for more information about using XCTest. + } + +} diff --git a/apps/cli/fixtures/legacy/supabase/pubspec.yaml b/apps/cli/fixtures/legacy/supabase/pubspec.yaml new file mode 100644 index 000000000..8b526db93 --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/pubspec.yaml @@ -0,0 +1,21 @@ +name: supabase_test +description: "A new Flutter project." +publish_to: 'none' +version: 0.1.0 + +environment: + sdk: ^3.7.0 + +dependencies: + flutter: + sdk: flutter + supabase_client: + path: celest/client/ + +dev_dependencies: + flutter_test: + sdk: flutter + flutter_lints: ^4.0.0 + +flutter: + uses-material-design: true diff --git a/apps/cli/fixtures/legacy/supabase/supabase/.gitignore b/apps/cli/fixtures/legacy/supabase/supabase/.gitignore new file mode 100644 index 000000000..a3ad88055 --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/supabase/.gitignore @@ -0,0 +1,4 @@ +# Supabase +.branches +.temp +.env diff --git a/apps/cli/fixtures/legacy/supabase/supabase/config.toml b/apps/cli/fixtures/legacy/supabase/supabase/config.toml new file mode 100644 index 000000000..9890b3658 --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/supabase/config.toml @@ -0,0 +1,239 @@ +# A string used to distinguish different Supabase projects on the same host. Defaults to the +# working directory name when running `supabase init`. +project_id = "supabase" + +[api] +enabled = true +# Port to use for the API URL. +port = 54321 +# Schemas to expose in your API. Tables, views and stored procedures in this schema will get API +# endpoints. `public` is always included. +schemas = ["public", "graphql_public"] +# Extra schemas to add to the search_path of every request. `public` is always included. +extra_search_path = ["public", "extensions"] +# The maximum number of rows returns from a view, table, or stored procedure. Limits payload size +# for accidental or malicious requests. +max_rows = 1000 + +[api.tls] +enabled = false + +[db] +# Port to use for the local database URL. +port = 54322 +# Port used by db diff command to initialize the shadow database. +shadow_port = 54320 +# The database major version to use. This has to be the same as your remote database's. Run `SHOW +# server_version;` on the remote database to check. +major_version = 15 + +[db.pooler] +enabled = false +# Port to use for the local connection pooler. +port = 54329 +# Specifies when a server connection can be reused by other clients. +# Configure one of the supported pooler modes: `transaction`, `session`. +pool_mode = "transaction" +# How many server connections to allow per user/database pair. +default_pool_size = 20 +# Maximum number of client connections allowed. +max_client_conn = 100 + +[realtime] +enabled = true +# Bind realtime via either IPv4 or IPv6. (default: IPv4) +# ip_version = "IPv6" +# The maximum length in bytes of HTTP request headers. (default: 4096) +# max_header_length = 4096 + +[studio] +enabled = true +# Port to use for Supabase Studio. +port = 54323 +# External URL of the API server that frontend connects to. +api_url = "http://127.0.0.1" +# OpenAI API Key to use for Supabase AI in the Supabase Studio. +openai_api_key = "env(OPENAI_API_KEY)" + +# Email testing server. Emails sent with the local dev setup are not actually sent - rather, they +# are monitored, and you can view the emails that would have been sent from the web interface. +[inbucket] +enabled = true +# Port to use for the email testing server web interface. +port = 54324 +# Uncomment to expose additional ports for testing user applications that send emails. +# smtp_port = 54325 +# pop3_port = 54326 + +[storage] +enabled = true +# The maximum file size allowed (e.g. "5MB", "500KB"). +file_size_limit = "50MiB" + +[storage.image_transformation] +enabled = true + +# Uncomment to configure local storage buckets +# [storage.buckets.images] +# public = false +# file_size_limit = "50MiB" +# allowed_mime_types = ["image/png", "image/jpeg"] +# objects_path = "./images" + +[auth] +enabled = true +# The base URL of your website. Used as an allow-list for redirects and for constructing URLs used +# in emails. +site_url = "http://127.0.0.1:3000" +# A list of *exact* URLs that auth providers are permitted to redirect to post authentication. +additional_redirect_urls = ["https://127.0.0.1:3000"] +# How long tokens are valid for, in seconds. Defaults to 3600 (1 hour), maximum 604,800 (1 week). +jwt_expiry = 3600 +# If disabled, the refresh token will never expire. +enable_refresh_token_rotation = true +# Allows refresh tokens to be reused after expiry, up to the specified interval in seconds. +# Requires enable_refresh_token_rotation = true. +refresh_token_reuse_interval = 10 +# Allow/disallow new user signups to your project. +enable_signup = true +# Allow/disallow anonymous sign-ins to your project. +enable_anonymous_sign_ins = false +# Allow/disallow testing manual linking of accounts +enable_manual_linking = false + +[auth.email] +# Allow/disallow new user signups via email to your project. +enable_signup = true +# If enabled, a user will be required to confirm any email change on both the old, and new email +# addresses. If disabled, only the new email is required to confirm. +double_confirm_changes = true +# If enabled, users need to confirm their email address before signing in. +enable_confirmations = false +# If enabled, users will need to reauthenticate or have logged in recently to change their password. +secure_password_change = false +# Controls the minimum amount of time that must pass before sending another signup confirmation or password reset email. +max_frequency = "1s" + +# Use a production-ready SMTP server +# [auth.email.smtp] +# host = "smtp.sendgrid.net" +# port = 587 +# user = "apikey" +# pass = "env(SENDGRID_API_KEY)" +# admin_email = "admin@email.com" +# sender_name = "Admin" + +# Uncomment to customize email template +# [auth.email.template.invite] +# subject = "You have been invited" +# content_path = "./supabase/templates/invite.html" + +[auth.sms] +# Allow/disallow new user signups via SMS to your project. +enable_signup = true +# If enabled, users need to confirm their phone number before signing in. +enable_confirmations = false +# Template for sending OTP to users +template = "Your code is {{ .Code }} ." +# Controls the minimum amount of time that must pass before sending another sms otp. +max_frequency = "5s" + +# Use pre-defined map of phone number to OTP for testing. +# [auth.sms.test_otp] +# 4152127777 = "123456" + +# Configure logged in session timeouts. +# [auth.sessions] +# Force log out after the specified duration. +# timebox = "24h" +# Force log out if the user has been inactive longer than the specified duration. +# inactivity_timeout = "8h" + +# This hook runs before a token is issued and allows you to add additional claims based on the authentication method used. +# [auth.hook.custom_access_token] +# enabled = true +# uri = "pg-functions:////" + +# Configure one of the supported SMS providers: `twilio`, `twilio_verify`, `messagebird`, `textlocal`, `vonage`. +[auth.sms.twilio] +enabled = false +account_sid = "" +message_service_sid = "" +# DO NOT commit your Twilio auth token to git. Use environment variable substitution instead: +auth_token = "env(SUPABASE_AUTH_SMS_TWILIO_AUTH_TOKEN)" + +[auth.mfa] +# Control how many MFA factors can be enrolled at once per user. +max_enrolled_factors = 10 + +# Control use of MFA via App Authenticator (TOTP) +[auth.mfa.totp] +enroll_enabled = true +verify_enabled = true + +# Configure Multi-factor-authentication via Phone Messaging +# [auth.mfa.phone] +# enroll_enabled = true +# verify_enabled = true +# otp_length = 6 +# template = "Your code is {{ .Code }} ." +# max_frequency = "10s" + +# Use an external OAuth provider. The full list of providers are: `apple`, `azure`, `bitbucket`, +# `discord`, `facebook`, `github`, `gitlab`, `google`, `keycloak`, `linkedin_oidc`, `notion`, `twitch`, +# `twitter`, `slack`, `spotify`, `workos`, `zoom`. +[auth.external.apple] +enabled = false +client_id = "" +# DO NOT commit your OAuth provider secret to git. Use environment variable substitution instead: +secret = "env(SUPABASE_AUTH_EXTERNAL_APPLE_SECRET)" +# Overrides the default auth redirectUrl. +redirect_uri = "" +# Overrides the default auth provider URL. Used to support self-hosted gitlab, single-tenant Azure, +# or any other third-party OIDC providers. +url = "" +# If enabled, the nonce check will be skipped. Required for local sign in with Google auth. +skip_nonce_check = false + +# Use Firebase Auth as a third-party provider alongside Supabase Auth. +[auth.third_party.firebase] +enabled = false +# project_id = "my-firebase-project" + +# Use Auth0 as a third-party provider alongside Supabase Auth. +[auth.third_party.auth0] +enabled = false +# tenant = "my-auth0-tenant" +# tenant_region = "us" + +# Use AWS Cognito (Amplify) as a third-party provider alongside Supabase Auth. +[auth.third_party.aws_cognito] +enabled = false +# user_pool_id = "my-user-pool-id" +# user_pool_region = "us-east-1" + +[edge_runtime] +enabled = true +# Configure one of the supported request policies: `oneshot`, `per_worker`. +# Use `oneshot` for hot reload, or `per_worker` for load testing. +policy = "oneshot" +inspector_port = 8083 + +[analytics] +enabled = true +port = 54327 +# Configure one of the supported backends: `postgres`, `bigquery`. +backend = "postgres" + +# Experimental features may be deprecated any time +[experimental] +# Configures Postgres storage engine to use OrioleDB (S3) +orioledb_version = "" +# Configures S3 bucket URL, eg. .s3-.amazonaws.com +s3_host = "env(S3_HOST)" +# Configures S3 bucket region, eg. us-east-1 +s3_region = "env(S3_REGION)" +# Configures AWS_ACCESS_KEY_ID for S3 bucket +s3_access_key = "env(S3_ACCESS_KEY)" +# Configures AWS_SECRET_ACCESS_KEY for S3 bucket +s3_secret_key = "env(S3_SECRET_KEY)" diff --git a/apps/cli/fixtures/legacy/supabase/supabase/seed.sql b/apps/cli/fixtures/legacy/supabase/supabase/seed.sql new file mode 100644 index 000000000..e69de29bb diff --git a/apps/cli/fixtures/legacy/supabase/web/favicon.png b/apps/cli/fixtures/legacy/supabase/web/favicon.png new file mode 100644 index 000000000..8aaa46ac1 Binary files /dev/null and b/apps/cli/fixtures/legacy/supabase/web/favicon.png differ diff --git a/apps/cli/fixtures/legacy/supabase/web/icons/Icon-192.png b/apps/cli/fixtures/legacy/supabase/web/icons/Icon-192.png new file mode 100644 index 000000000..b749bfef0 Binary files /dev/null and b/apps/cli/fixtures/legacy/supabase/web/icons/Icon-192.png differ diff --git a/apps/cli/fixtures/legacy/supabase/web/icons/Icon-512.png b/apps/cli/fixtures/legacy/supabase/web/icons/Icon-512.png new file mode 100644 index 000000000..88cfd48df Binary files /dev/null and b/apps/cli/fixtures/legacy/supabase/web/icons/Icon-512.png differ diff --git a/apps/cli/fixtures/legacy/supabase/web/icons/Icon-maskable-192.png b/apps/cli/fixtures/legacy/supabase/web/icons/Icon-maskable-192.png new file mode 100644 index 000000000..eb9b4d76e Binary files /dev/null and b/apps/cli/fixtures/legacy/supabase/web/icons/Icon-maskable-192.png differ diff --git a/apps/cli/fixtures/legacy/supabase/web/icons/Icon-maskable-512.png b/apps/cli/fixtures/legacy/supabase/web/icons/Icon-maskable-512.png new file mode 100644 index 000000000..d69c56691 Binary files /dev/null and b/apps/cli/fixtures/legacy/supabase/web/icons/Icon-maskable-512.png differ diff --git a/apps/cli/fixtures/legacy/supabase/web/index.html b/apps/cli/fixtures/legacy/supabase/web/index.html new file mode 100644 index 000000000..be04ab0f4 --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/web/index.html @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + supabase_test + + + + + + diff --git a/apps/cli/fixtures/legacy/supabase/web/manifest.json b/apps/cli/fixtures/legacy/supabase/web/manifest.json new file mode 100644 index 000000000..07de7f937 --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/web/manifest.json @@ -0,0 +1,35 @@ +{ + "name": "supabase_test", + "short_name": "supabase_test", + "start_url": ".", + "display": "standalone", + "background_color": "#0175C2", + "theme_color": "#0175C2", + "description": "A new Flutter project.", + "orientation": "portrait-primary", + "prefer_related_applications": false, + "icons": [ + { + "src": "icons/Icon-192.png", + "sizes": "192x192", + "type": "image/png" + }, + { + "src": "icons/Icon-512.png", + "sizes": "512x512", + "type": "image/png" + }, + { + "src": "icons/Icon-maskable-192.png", + "sizes": "192x192", + "type": "image/png", + "purpose": "maskable" + }, + { + "src": "icons/Icon-maskable-512.png", + "sizes": "512x512", + "type": "image/png", + "purpose": "maskable" + } + ] +} diff --git a/apps/cli/fixtures/legacy/supabase/windows/.gitignore b/apps/cli/fixtures/legacy/supabase/windows/.gitignore new file mode 100644 index 000000000..d492d0d98 --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/windows/.gitignore @@ -0,0 +1,17 @@ +flutter/ephemeral/ + +# Visual Studio user-specific files. +*.suo +*.user +*.userosscache +*.sln.docstates + +# Visual Studio build-related files. +x64/ +x86/ + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ diff --git a/apps/cli/fixtures/legacy/supabase/windows/CMakeLists.txt b/apps/cli/fixtures/legacy/supabase/windows/CMakeLists.txt new file mode 100644 index 000000000..e1ca65783 --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/windows/CMakeLists.txt @@ -0,0 +1,108 @@ +# Project-level configuration. +cmake_minimum_required(VERSION 3.14) +project(supabase_test LANGUAGES CXX) + +# The name of the executable created for the application. Change this to change +# the on-disk name of your application. +set(BINARY_NAME "supabase_test") + +# Explicitly opt in to modern CMake behaviors to avoid warnings with recent +# versions of CMake. +cmake_policy(VERSION 3.14...3.25) + +# Define build configuration option. +get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if(IS_MULTICONFIG) + set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release" + CACHE STRING "" FORCE) +else() + if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + set(CMAKE_BUILD_TYPE "Debug" CACHE + STRING "Flutter build mode" FORCE) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS + "Debug" "Profile" "Release") + endif() +endif() +# Define settings for the Profile build mode. +set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") +set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") +set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}") +set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}") + +# Use Unicode for all projects. +add_definitions(-DUNICODE -D_UNICODE) + +# Compilation settings that should be applied to most targets. +# +# Be cautious about adding new options here, as plugins use this function by +# default. In most cases, you should add new options to specific targets instead +# of modifying this function. +function(APPLY_STANDARD_SETTINGS TARGET) + target_compile_features(${TARGET} PUBLIC cxx_std_17) + target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100") + target_compile_options(${TARGET} PRIVATE /EHsc) + target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0") + target_compile_definitions(${TARGET} PRIVATE "$<$:_DEBUG>") +endfunction() + +# Flutter library and tool build rules. +set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") +add_subdirectory(${FLUTTER_MANAGED_DIR}) + +# Application build; see runner/CMakeLists.txt. +add_subdirectory("runner") + + +# Generated plugin build rules, which manage building the plugins and adding +# them to the application. +include(flutter/generated_plugins.cmake) + + +# === Installation === +# Support files are copied into place next to the executable, so that it can +# run in place. This is done instead of making a separate bundle (as on Linux) +# so that building and running from within Visual Studio will work. +set(BUILD_BUNDLE_DIR "$") +# Make the "install" step default, as it's required to run. +set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) +if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) +endif() + +set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") +set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") + +install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" + COMPONENT Runtime) + +install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" + COMPONENT Runtime) + +install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) + +if(PLUGIN_BUNDLED_LIBRARIES) + install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" + DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) +endif() + +# Copy the native assets provided by the build.dart from all packages. +set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/windows/") +install(DIRECTORY "${NATIVE_ASSETS_DIR}" + DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) + +# Fully re-copy the assets directory on each build to avoid having stale files +# from a previous install. +set(FLUTTER_ASSET_DIR_NAME "flutter_assets") +install(CODE " + file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") + " COMPONENT Runtime) +install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" + DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) + +# Install the AOT library on non-Debug builds only. +install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" + CONFIGURATIONS Profile;Release + COMPONENT Runtime) diff --git a/apps/cli/fixtures/legacy/supabase/windows/flutter/CMakeLists.txt b/apps/cli/fixtures/legacy/supabase/windows/flutter/CMakeLists.txt new file mode 100644 index 000000000..903f4899d --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/windows/flutter/CMakeLists.txt @@ -0,0 +1,109 @@ +# This file controls Flutter-level build steps. It should not be edited. +cmake_minimum_required(VERSION 3.14) + +set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") + +# Configuration provided via flutter tool. +include(${EPHEMERAL_DIR}/generated_config.cmake) + +# TODO: Move the rest of this into files in ephemeral. See +# https://github.com/flutter/flutter/issues/57146. +set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") + +# Set fallback configurations for older versions of the flutter tool. +if (NOT DEFINED FLUTTER_TARGET_PLATFORM) + set(FLUTTER_TARGET_PLATFORM "windows-x64") +endif() + +# === Flutter Library === +set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") + +# Published to parent scope for install step. +set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) +set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) +set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) +set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) + +list(APPEND FLUTTER_LIBRARY_HEADERS + "flutter_export.h" + "flutter_windows.h" + "flutter_messenger.h" + "flutter_plugin_registrar.h" + "flutter_texture_registrar.h" +) +list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/") +add_library(flutter INTERFACE) +target_include_directories(flutter INTERFACE + "${EPHEMERAL_DIR}" +) +target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") +add_dependencies(flutter flutter_assemble) + +# === Wrapper === +list(APPEND CPP_WRAPPER_SOURCES_CORE + "core_implementations.cc" + "standard_codec.cc" +) +list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") +list(APPEND CPP_WRAPPER_SOURCES_PLUGIN + "plugin_registrar.cc" +) +list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") +list(APPEND CPP_WRAPPER_SOURCES_APP + "flutter_engine.cc" + "flutter_view_controller.cc" +) +list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") + +# Wrapper sources needed for a plugin. +add_library(flutter_wrapper_plugin STATIC + ${CPP_WRAPPER_SOURCES_CORE} + ${CPP_WRAPPER_SOURCES_PLUGIN} +) +apply_standard_settings(flutter_wrapper_plugin) +set_target_properties(flutter_wrapper_plugin PROPERTIES + POSITION_INDEPENDENT_CODE ON) +set_target_properties(flutter_wrapper_plugin PROPERTIES + CXX_VISIBILITY_PRESET hidden) +target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) +target_include_directories(flutter_wrapper_plugin PUBLIC + "${WRAPPER_ROOT}/include" +) +add_dependencies(flutter_wrapper_plugin flutter_assemble) + +# Wrapper sources needed for the runner. +add_library(flutter_wrapper_app STATIC + ${CPP_WRAPPER_SOURCES_CORE} + ${CPP_WRAPPER_SOURCES_APP} +) +apply_standard_settings(flutter_wrapper_app) +target_link_libraries(flutter_wrapper_app PUBLIC flutter) +target_include_directories(flutter_wrapper_app PUBLIC + "${WRAPPER_ROOT}/include" +) +add_dependencies(flutter_wrapper_app flutter_assemble) + +# === Flutter tool backend === +# _phony_ is a non-existent file to force this command to run every time, +# since currently there's no way to get a full input/output list from the +# flutter tool. +set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_") +set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE) +add_custom_command( + OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} + ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} + ${CPP_WRAPPER_SOURCES_APP} + ${PHONY_OUTPUT} + COMMAND ${CMAKE_COMMAND} -E env + ${FLUTTER_TOOL_ENVIRONMENT} + "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" + ${FLUTTER_TARGET_PLATFORM} $ + VERBATIM +) +add_custom_target(flutter_assemble DEPENDS + "${FLUTTER_LIBRARY}" + ${FLUTTER_LIBRARY_HEADERS} + ${CPP_WRAPPER_SOURCES_CORE} + ${CPP_WRAPPER_SOURCES_PLUGIN} + ${CPP_WRAPPER_SOURCES_APP} +) diff --git a/apps/cli/fixtures/legacy/supabase/windows/flutter/generated_plugin_registrant.cc b/apps/cli/fixtures/legacy/supabase/windows/flutter/generated_plugin_registrant.cc new file mode 100644 index 000000000..8b6d4680a --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/windows/flutter/generated_plugin_registrant.cc @@ -0,0 +1,11 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#include "generated_plugin_registrant.h" + + +void RegisterPlugins(flutter::PluginRegistry* registry) { +} diff --git a/apps/cli/fixtures/legacy/supabase/windows/flutter/generated_plugin_registrant.h b/apps/cli/fixtures/legacy/supabase/windows/flutter/generated_plugin_registrant.h new file mode 100644 index 000000000..dc139d85a --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/windows/flutter/generated_plugin_registrant.h @@ -0,0 +1,15 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#ifndef GENERATED_PLUGIN_REGISTRANT_ +#define GENERATED_PLUGIN_REGISTRANT_ + +#include + +// Registers Flutter plugins. +void RegisterPlugins(flutter::PluginRegistry* registry); + +#endif // GENERATED_PLUGIN_REGISTRANT_ diff --git a/apps/cli/fixtures/legacy/supabase/windows/flutter/generated_plugins.cmake b/apps/cli/fixtures/legacy/supabase/windows/flutter/generated_plugins.cmake new file mode 100644 index 000000000..b93c4c30c --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/windows/flutter/generated_plugins.cmake @@ -0,0 +1,23 @@ +# +# Generated file, do not edit. +# + +list(APPEND FLUTTER_PLUGIN_LIST +) + +list(APPEND FLUTTER_FFI_PLUGIN_LIST +) + +set(PLUGIN_BUNDLED_LIBRARIES) + +foreach(plugin ${FLUTTER_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin}) + target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) + list(APPEND PLUGIN_BUNDLED_LIBRARIES $) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) +endforeach(plugin) + +foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) +endforeach(ffi_plugin) diff --git a/apps/cli/fixtures/legacy/supabase/windows/runner/CMakeLists.txt b/apps/cli/fixtures/legacy/supabase/windows/runner/CMakeLists.txt new file mode 100644 index 000000000..394917c05 --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/windows/runner/CMakeLists.txt @@ -0,0 +1,40 @@ +cmake_minimum_required(VERSION 3.14) +project(runner LANGUAGES CXX) + +# Define the application target. To change its name, change BINARY_NAME in the +# top-level CMakeLists.txt, not the value here, or `flutter run` will no longer +# work. +# +# Any new source files that you add to the application should be added here. +add_executable(${BINARY_NAME} WIN32 + "flutter_window.cpp" + "main.cpp" + "utils.cpp" + "win32_window.cpp" + "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" + "Runner.rc" + "runner.exe.manifest" +) + +# Apply the standard set of build settings. This can be removed for applications +# that need different build settings. +apply_standard_settings(${BINARY_NAME}) + +# Add preprocessor definitions for the build version. +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION=\"${FLUTTER_VERSION}\"") +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}") +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}") +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}") +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}") + +# Disable Windows macros that collide with C++ standard library functions. +target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") + +# Add dependency libraries and include directories. Add any application-specific +# dependencies here. +target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) +target_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib") +target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") + +# Run the Flutter tool portions of the build. This must not be removed. +add_dependencies(${BINARY_NAME} flutter_assemble) diff --git a/apps/cli/fixtures/legacy/supabase/windows/runner/Runner.rc b/apps/cli/fixtures/legacy/supabase/windows/runner/Runner.rc new file mode 100644 index 000000000..5e047ca0f --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/windows/runner/Runner.rc @@ -0,0 +1,121 @@ +// Microsoft Visual C++ generated resource script. +// +#pragma code_page(65001) +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "winres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (United States) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""winres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDI_APP_ICON ICON "resources\\app_icon.ico" + + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +#if defined(FLUTTER_VERSION_MAJOR) && defined(FLUTTER_VERSION_MINOR) && defined(FLUTTER_VERSION_PATCH) && defined(FLUTTER_VERSION_BUILD) +#define VERSION_AS_NUMBER FLUTTER_VERSION_MAJOR,FLUTTER_VERSION_MINOR,FLUTTER_VERSION_PATCH,FLUTTER_VERSION_BUILD +#else +#define VERSION_AS_NUMBER 1,0,0,0 +#endif + +#if defined(FLUTTER_VERSION) +#define VERSION_AS_STRING FLUTTER_VERSION +#else +#define VERSION_AS_STRING "1.0.0" +#endif + +VS_VERSION_INFO VERSIONINFO + FILEVERSION VERSION_AS_NUMBER + PRODUCTVERSION VERSION_AS_NUMBER + FILEFLAGSMASK VS_FFI_FILEFLAGSMASK +#ifdef _DEBUG + FILEFLAGS VS_FF_DEBUG +#else + FILEFLAGS 0x0L +#endif + FILEOS VOS__WINDOWS32 + FILETYPE VFT_APP + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904e4" + BEGIN + VALUE "CompanyName", "dev.celest" "\0" + VALUE "FileDescription", "supabase_test" "\0" + VALUE "FileVersion", VERSION_AS_STRING "\0" + VALUE "InternalName", "supabase_test" "\0" + VALUE "LegalCopyright", "Copyright (C) 2024 dev.celest. All rights reserved." "\0" + VALUE "OriginalFilename", "supabase_test.exe" "\0" + VALUE "ProductName", "supabase_test" "\0" + VALUE "ProductVersion", VERSION_AS_STRING "\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1252 + END +END + +#endif // English (United States) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED diff --git a/apps/cli/fixtures/legacy/supabase/windows/runner/flutter_window.cpp b/apps/cli/fixtures/legacy/supabase/windows/runner/flutter_window.cpp new file mode 100644 index 000000000..955ee3038 --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/windows/runner/flutter_window.cpp @@ -0,0 +1,71 @@ +#include "flutter_window.h" + +#include + +#include "flutter/generated_plugin_registrant.h" + +FlutterWindow::FlutterWindow(const flutter::DartProject& project) + : project_(project) {} + +FlutterWindow::~FlutterWindow() {} + +bool FlutterWindow::OnCreate() { + if (!Win32Window::OnCreate()) { + return false; + } + + RECT frame = GetClientArea(); + + // The size here must match the window dimensions to avoid unnecessary surface + // creation / destruction in the startup path. + flutter_controller_ = std::make_unique( + frame.right - frame.left, frame.bottom - frame.top, project_); + // Ensure that basic setup of the controller was successful. + if (!flutter_controller_->engine() || !flutter_controller_->view()) { + return false; + } + RegisterPlugins(flutter_controller_->engine()); + SetChildContent(flutter_controller_->view()->GetNativeWindow()); + + flutter_controller_->engine()->SetNextFrameCallback([&]() { + this->Show(); + }); + + // Flutter can complete the first frame before the "show window" callback is + // registered. The following call ensures a frame is pending to ensure the + // window is shown. It is a no-op if the first frame hasn't completed yet. + flutter_controller_->ForceRedraw(); + + return true; +} + +void FlutterWindow::OnDestroy() { + if (flutter_controller_) { + flutter_controller_ = nullptr; + } + + Win32Window::OnDestroy(); +} + +LRESULT +FlutterWindow::MessageHandler(HWND hwnd, UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept { + // Give Flutter, including plugins, an opportunity to handle window messages. + if (flutter_controller_) { + std::optional result = + flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam, + lparam); + if (result) { + return *result; + } + } + + switch (message) { + case WM_FONTCHANGE: + flutter_controller_->engine()->ReloadSystemFonts(); + break; + } + + return Win32Window::MessageHandler(hwnd, message, wparam, lparam); +} diff --git a/apps/cli/fixtures/legacy/supabase/windows/runner/flutter_window.h b/apps/cli/fixtures/legacy/supabase/windows/runner/flutter_window.h new file mode 100644 index 000000000..6da0652f0 --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/windows/runner/flutter_window.h @@ -0,0 +1,33 @@ +#ifndef RUNNER_FLUTTER_WINDOW_H_ +#define RUNNER_FLUTTER_WINDOW_H_ + +#include +#include + +#include + +#include "win32_window.h" + +// A window that does nothing but host a Flutter view. +class FlutterWindow : public Win32Window { + public: + // Creates a new FlutterWindow hosting a Flutter view running |project|. + explicit FlutterWindow(const flutter::DartProject& project); + virtual ~FlutterWindow(); + + protected: + // Win32Window: + bool OnCreate() override; + void OnDestroy() override; + LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam, + LPARAM const lparam) noexcept override; + + private: + // The project to run. + flutter::DartProject project_; + + // The Flutter instance hosted by this window. + std::unique_ptr flutter_controller_; +}; + +#endif // RUNNER_FLUTTER_WINDOW_H_ diff --git a/apps/cli/fixtures/legacy/supabase/windows/runner/main.cpp b/apps/cli/fixtures/legacy/supabase/windows/runner/main.cpp new file mode 100644 index 000000000..1dd6f4252 --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/windows/runner/main.cpp @@ -0,0 +1,43 @@ +#include +#include +#include + +#include "flutter_window.h" +#include "utils.h" + +int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, + _In_ wchar_t *command_line, _In_ int show_command) { + // Attach to console when present (e.g., 'flutter run') or create a + // new console when running with a debugger. + if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) { + CreateAndAttachConsole(); + } + + // Initialize COM, so that it is available for use in the library and/or + // plugins. + ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); + + flutter::DartProject project(L"data"); + + std::vector command_line_arguments = + GetCommandLineArguments(); + + project.set_dart_entrypoint_arguments(std::move(command_line_arguments)); + + FlutterWindow window(project); + Win32Window::Point origin(10, 10); + Win32Window::Size size(1280, 720); + if (!window.Create(L"supabase_test", origin, size)) { + return EXIT_FAILURE; + } + window.SetQuitOnClose(true); + + ::MSG msg; + while (::GetMessage(&msg, nullptr, 0, 0)) { + ::TranslateMessage(&msg); + ::DispatchMessage(&msg); + } + + ::CoUninitialize(); + return EXIT_SUCCESS; +} diff --git a/apps/cli/fixtures/legacy/supabase/windows/runner/resource.h b/apps/cli/fixtures/legacy/supabase/windows/runner/resource.h new file mode 100644 index 000000000..66a65d1e4 --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/windows/runner/resource.h @@ -0,0 +1,16 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by Runner.rc +// +#define IDI_APP_ICON 101 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 102 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1001 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/apps/cli/fixtures/legacy/supabase/windows/runner/resources/app_icon.ico b/apps/cli/fixtures/legacy/supabase/windows/runner/resources/app_icon.ico new file mode 100644 index 000000000..c04e20caf Binary files /dev/null and b/apps/cli/fixtures/legacy/supabase/windows/runner/resources/app_icon.ico differ diff --git a/apps/cli/fixtures/legacy/supabase/windows/runner/runner.exe.manifest b/apps/cli/fixtures/legacy/supabase/windows/runner/runner.exe.manifest new file mode 100644 index 000000000..153653e8d --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/windows/runner/runner.exe.manifest @@ -0,0 +1,14 @@ + + + + + PerMonitorV2 + + + + + + + + + diff --git a/apps/cli/fixtures/legacy/supabase/windows/runner/utils.cpp b/apps/cli/fixtures/legacy/supabase/windows/runner/utils.cpp new file mode 100644 index 000000000..3a0b46511 --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/windows/runner/utils.cpp @@ -0,0 +1,65 @@ +#include "utils.h" + +#include +#include +#include +#include + +#include + +void CreateAndAttachConsole() { + if (::AllocConsole()) { + FILE *unused; + if (freopen_s(&unused, "CONOUT$", "w", stdout)) { + _dup2(_fileno(stdout), 1); + } + if (freopen_s(&unused, "CONOUT$", "w", stderr)) { + _dup2(_fileno(stdout), 2); + } + std::ios::sync_with_stdio(); + FlutterDesktopResyncOutputStreams(); + } +} + +std::vector GetCommandLineArguments() { + // Convert the UTF-16 command line arguments to UTF-8 for the Engine to use. + int argc; + wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc); + if (argv == nullptr) { + return std::vector(); + } + + std::vector command_line_arguments; + + // Skip the first argument as it's the binary name. + for (int i = 1; i < argc; i++) { + command_line_arguments.push_back(Utf8FromUtf16(argv[i])); + } + + ::LocalFree(argv); + + return command_line_arguments; +} + +std::string Utf8FromUtf16(const wchar_t* utf16_string) { + if (utf16_string == nullptr) { + return std::string(); + } + unsigned int target_length = ::WideCharToMultiByte( + CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, + -1, nullptr, 0, nullptr, nullptr) + -1; // remove the trailing null character + int input_length = (int)wcslen(utf16_string); + std::string utf8_string; + if (target_length == 0 || target_length > utf8_string.max_size()) { + return utf8_string; + } + utf8_string.resize(target_length); + int converted_length = ::WideCharToMultiByte( + CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, + input_length, utf8_string.data(), target_length, nullptr, nullptr); + if (converted_length == 0) { + return std::string(); + } + return utf8_string; +} diff --git a/apps/cli/fixtures/legacy/supabase/windows/runner/utils.h b/apps/cli/fixtures/legacy/supabase/windows/runner/utils.h new file mode 100644 index 000000000..3879d5475 --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/windows/runner/utils.h @@ -0,0 +1,19 @@ +#ifndef RUNNER_UTILS_H_ +#define RUNNER_UTILS_H_ + +#include +#include + +// Creates a console for the process, and redirects stdout and stderr to +// it for both the runner and the Flutter library. +void CreateAndAttachConsole(); + +// Takes a null-terminated wchar_t* encoded in UTF-16 and returns a std::string +// encoded in UTF-8. Returns an empty std::string on failure. +std::string Utf8FromUtf16(const wchar_t* utf16_string); + +// Gets the command line arguments passed in as a std::vector, +// encoded in UTF-8. Returns an empty std::vector on failure. +std::vector GetCommandLineArguments(); + +#endif // RUNNER_UTILS_H_ diff --git a/apps/cli/fixtures/legacy/supabase/windows/runner/win32_window.cpp b/apps/cli/fixtures/legacy/supabase/windows/runner/win32_window.cpp new file mode 100644 index 000000000..60608d0fe --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/windows/runner/win32_window.cpp @@ -0,0 +1,288 @@ +#include "win32_window.h" + +#include +#include + +#include "resource.h" + +namespace { + +/// Window attribute that enables dark mode window decorations. +/// +/// Redefined in case the developer's machine has a Windows SDK older than +/// version 10.0.22000.0. +/// See: https://docs.microsoft.com/windows/win32/api/dwmapi/ne-dwmapi-dwmwindowattribute +#ifndef DWMWA_USE_IMMERSIVE_DARK_MODE +#define DWMWA_USE_IMMERSIVE_DARK_MODE 20 +#endif + +constexpr const wchar_t kWindowClassName[] = L"FLUTTER_RUNNER_WIN32_WINDOW"; + +/// Registry key for app theme preference. +/// +/// A value of 0 indicates apps should use dark mode. A non-zero or missing +/// value indicates apps should use light mode. +constexpr const wchar_t kGetPreferredBrightnessRegKey[] = + L"Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize"; +constexpr const wchar_t kGetPreferredBrightnessRegValue[] = L"AppsUseLightTheme"; + +// The number of Win32Window objects that currently exist. +static int g_active_window_count = 0; + +using EnableNonClientDpiScaling = BOOL __stdcall(HWND hwnd); + +// Scale helper to convert logical scaler values to physical using passed in +// scale factor +int Scale(int source, double scale_factor) { + return static_cast(source * scale_factor); +} + +// Dynamically loads the |EnableNonClientDpiScaling| from the User32 module. +// This API is only needed for PerMonitor V1 awareness mode. +void EnableFullDpiSupportIfAvailable(HWND hwnd) { + HMODULE user32_module = LoadLibraryA("User32.dll"); + if (!user32_module) { + return; + } + auto enable_non_client_dpi_scaling = + reinterpret_cast( + GetProcAddress(user32_module, "EnableNonClientDpiScaling")); + if (enable_non_client_dpi_scaling != nullptr) { + enable_non_client_dpi_scaling(hwnd); + } + FreeLibrary(user32_module); +} + +} // namespace + +// Manages the Win32Window's window class registration. +class WindowClassRegistrar { + public: + ~WindowClassRegistrar() = default; + + // Returns the singleton registrar instance. + static WindowClassRegistrar* GetInstance() { + if (!instance_) { + instance_ = new WindowClassRegistrar(); + } + return instance_; + } + + // Returns the name of the window class, registering the class if it hasn't + // previously been registered. + const wchar_t* GetWindowClass(); + + // Unregisters the window class. Should only be called if there are no + // instances of the window. + void UnregisterWindowClass(); + + private: + WindowClassRegistrar() = default; + + static WindowClassRegistrar* instance_; + + bool class_registered_ = false; +}; + +WindowClassRegistrar* WindowClassRegistrar::instance_ = nullptr; + +const wchar_t* WindowClassRegistrar::GetWindowClass() { + if (!class_registered_) { + WNDCLASS window_class{}; + window_class.hCursor = LoadCursor(nullptr, IDC_ARROW); + window_class.lpszClassName = kWindowClassName; + window_class.style = CS_HREDRAW | CS_VREDRAW; + window_class.cbClsExtra = 0; + window_class.cbWndExtra = 0; + window_class.hInstance = GetModuleHandle(nullptr); + window_class.hIcon = + LoadIcon(window_class.hInstance, MAKEINTRESOURCE(IDI_APP_ICON)); + window_class.hbrBackground = 0; + window_class.lpszMenuName = nullptr; + window_class.lpfnWndProc = Win32Window::WndProc; + RegisterClass(&window_class); + class_registered_ = true; + } + return kWindowClassName; +} + +void WindowClassRegistrar::UnregisterWindowClass() { + UnregisterClass(kWindowClassName, nullptr); + class_registered_ = false; +} + +Win32Window::Win32Window() { + ++g_active_window_count; +} + +Win32Window::~Win32Window() { + --g_active_window_count; + Destroy(); +} + +bool Win32Window::Create(const std::wstring& title, + const Point& origin, + const Size& size) { + Destroy(); + + const wchar_t* window_class = + WindowClassRegistrar::GetInstance()->GetWindowClass(); + + const POINT target_point = {static_cast(origin.x), + static_cast(origin.y)}; + HMONITOR monitor = MonitorFromPoint(target_point, MONITOR_DEFAULTTONEAREST); + UINT dpi = FlutterDesktopGetDpiForMonitor(monitor); + double scale_factor = dpi / 96.0; + + HWND window = CreateWindow( + window_class, title.c_str(), WS_OVERLAPPEDWINDOW, + Scale(origin.x, scale_factor), Scale(origin.y, scale_factor), + Scale(size.width, scale_factor), Scale(size.height, scale_factor), + nullptr, nullptr, GetModuleHandle(nullptr), this); + + if (!window) { + return false; + } + + UpdateTheme(window); + + return OnCreate(); +} + +bool Win32Window::Show() { + return ShowWindow(window_handle_, SW_SHOWNORMAL); +} + +// static +LRESULT CALLBACK Win32Window::WndProc(HWND const window, + UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept { + if (message == WM_NCCREATE) { + auto window_struct = reinterpret_cast(lparam); + SetWindowLongPtr(window, GWLP_USERDATA, + reinterpret_cast(window_struct->lpCreateParams)); + + auto that = static_cast(window_struct->lpCreateParams); + EnableFullDpiSupportIfAvailable(window); + that->window_handle_ = window; + } else if (Win32Window* that = GetThisFromHandle(window)) { + return that->MessageHandler(window, message, wparam, lparam); + } + + return DefWindowProc(window, message, wparam, lparam); +} + +LRESULT +Win32Window::MessageHandler(HWND hwnd, + UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept { + switch (message) { + case WM_DESTROY: + window_handle_ = nullptr; + Destroy(); + if (quit_on_close_) { + PostQuitMessage(0); + } + return 0; + + case WM_DPICHANGED: { + auto newRectSize = reinterpret_cast(lparam); + LONG newWidth = newRectSize->right - newRectSize->left; + LONG newHeight = newRectSize->bottom - newRectSize->top; + + SetWindowPos(hwnd, nullptr, newRectSize->left, newRectSize->top, newWidth, + newHeight, SWP_NOZORDER | SWP_NOACTIVATE); + + return 0; + } + case WM_SIZE: { + RECT rect = GetClientArea(); + if (child_content_ != nullptr) { + // Size and position the child window. + MoveWindow(child_content_, rect.left, rect.top, rect.right - rect.left, + rect.bottom - rect.top, TRUE); + } + return 0; + } + + case WM_ACTIVATE: + if (child_content_ != nullptr) { + SetFocus(child_content_); + } + return 0; + + case WM_DWMCOLORIZATIONCOLORCHANGED: + UpdateTheme(hwnd); + return 0; + } + + return DefWindowProc(window_handle_, message, wparam, lparam); +} + +void Win32Window::Destroy() { + OnDestroy(); + + if (window_handle_) { + DestroyWindow(window_handle_); + window_handle_ = nullptr; + } + if (g_active_window_count == 0) { + WindowClassRegistrar::GetInstance()->UnregisterWindowClass(); + } +} + +Win32Window* Win32Window::GetThisFromHandle(HWND const window) noexcept { + return reinterpret_cast( + GetWindowLongPtr(window, GWLP_USERDATA)); +} + +void Win32Window::SetChildContent(HWND content) { + child_content_ = content; + SetParent(content, window_handle_); + RECT frame = GetClientArea(); + + MoveWindow(content, frame.left, frame.top, frame.right - frame.left, + frame.bottom - frame.top, true); + + SetFocus(child_content_); +} + +RECT Win32Window::GetClientArea() { + RECT frame; + GetClientRect(window_handle_, &frame); + return frame; +} + +HWND Win32Window::GetHandle() { + return window_handle_; +} + +void Win32Window::SetQuitOnClose(bool quit_on_close) { + quit_on_close_ = quit_on_close; +} + +bool Win32Window::OnCreate() { + // No-op; provided for subclasses. + return true; +} + +void Win32Window::OnDestroy() { + // No-op; provided for subclasses. +} + +void Win32Window::UpdateTheme(HWND const window) { + DWORD light_mode; + DWORD light_mode_size = sizeof(light_mode); + LSTATUS result = RegGetValue(HKEY_CURRENT_USER, kGetPreferredBrightnessRegKey, + kGetPreferredBrightnessRegValue, + RRF_RT_REG_DWORD, nullptr, &light_mode, + &light_mode_size); + + if (result == ERROR_SUCCESS) { + BOOL enable_dark_mode = light_mode == 0; + DwmSetWindowAttribute(window, DWMWA_USE_IMMERSIVE_DARK_MODE, + &enable_dark_mode, sizeof(enable_dark_mode)); + } +} diff --git a/apps/cli/fixtures/legacy/supabase/windows/runner/win32_window.h b/apps/cli/fixtures/legacy/supabase/windows/runner/win32_window.h new file mode 100644 index 000000000..e901dde68 --- /dev/null +++ b/apps/cli/fixtures/legacy/supabase/windows/runner/win32_window.h @@ -0,0 +1,102 @@ +#ifndef RUNNER_WIN32_WINDOW_H_ +#define RUNNER_WIN32_WINDOW_H_ + +#include + +#include +#include +#include + +// A class abstraction for a high DPI-aware Win32 Window. Intended to be +// inherited from by classes that wish to specialize with custom +// rendering and input handling +class Win32Window { + public: + struct Point { + unsigned int x; + unsigned int y; + Point(unsigned int x, unsigned int y) : x(x), y(y) {} + }; + + struct Size { + unsigned int width; + unsigned int height; + Size(unsigned int width, unsigned int height) + : width(width), height(height) {} + }; + + Win32Window(); + virtual ~Win32Window(); + + // Creates a win32 window with |title| that is positioned and sized using + // |origin| and |size|. New windows are created on the default monitor. Window + // sizes are specified to the OS in physical pixels, hence to ensure a + // consistent size this function will scale the inputted width and height as + // as appropriate for the default monitor. The window is invisible until + // |Show| is called. Returns true if the window was created successfully. + bool Create(const std::wstring& title, const Point& origin, const Size& size); + + // Show the current window. Returns true if the window was successfully shown. + bool Show(); + + // Release OS resources associated with window. + void Destroy(); + + // Inserts |content| into the window tree. + void SetChildContent(HWND content); + + // Returns the backing Window handle to enable clients to set icon and other + // window properties. Returns nullptr if the window has been destroyed. + HWND GetHandle(); + + // If true, closing this window will quit the application. + void SetQuitOnClose(bool quit_on_close); + + // Return a RECT representing the bounds of the current client area. + RECT GetClientArea(); + + protected: + // Processes and route salient window messages for mouse handling, + // size change and DPI. Delegates handling of these to member overloads that + // inheriting classes can handle. + virtual LRESULT MessageHandler(HWND window, + UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept; + + // Called when CreateAndShow is called, allowing subclass window-related + // setup. Subclasses should return false if setup fails. + virtual bool OnCreate(); + + // Called when Destroy is called. + virtual void OnDestroy(); + + private: + friend class WindowClassRegistrar; + + // OS callback called by message pump. Handles the WM_NCCREATE message which + // is passed when the non-client area is being created and enables automatic + // non-client DPI scaling so that the non-client area automatically + // responds to changes in DPI. All other messages are handled by + // MessageHandler. + static LRESULT CALLBACK WndProc(HWND const window, + UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept; + + // Retrieves a class instance pointer for |window| + static Win32Window* GetThisFromHandle(HWND const window) noexcept; + + // Update the window frame's theme to match the system theme. + static void UpdateTheme(HWND const window); + + bool quit_on_close_ = false; + + // window handle for top level window. + HWND window_handle_ = nullptr; + + // window handle for hosted content. + HWND child_content_ = nullptr; +}; + +#endif // RUNNER_WIN32_WINDOW_H_ diff --git a/apps/cli/fixtures/legacy/types.dart b/apps/cli/fixtures/legacy/types.dart new file mode 100644 index 000000000..f6f56e54d --- /dev/null +++ b/apps/cli/fixtures/legacy/types.dart @@ -0,0 +1,135 @@ +import 'dart:convert'; + +import 'package:http/http.dart'; +import 'package:test/test.dart'; + +/// A description of an e2e test. +class Test { + const Test({ + this.apis, + this.environmentVariables = const {}, + this.secrets = const {}, + }); + + final Map? apis; + final Map environmentVariables; + final Map secrets; +} + +class ApiTest { + const ApiTest({this.functionTests = const {}, this.eventTests = const {}}); + + final Map> functionTests; + final Map> eventTests; +} + +sealed class FunctionTest { + const FunctionTest({ + required this.name, + this.input = const {}, + this.method = 'POST', + this.headers = const {}, + this.queryParameters = const {}, + this.logs, + this.setup, + }); + + final String name; + final String method; + final Map input; + final Map headers; + final Map> queryParameters; + final List? logs; + final Future Function(Request request)? setup; +} + +sealed class HttpTest extends FunctionTest { + const HttpTest({ + required super.name, + super.input, + super.method, + super.headers, + super.queryParameters, + super.logs, + super.setup, + }); +} + +class FunctionTestSuccess extends HttpTest { + FunctionTestSuccess({ + required super.name, + super.method, + super.input, + super.headers, + super.queryParameters, + this.statusCode = 200, + required this.output, + super.logs, + super.setup, + }); + + final int statusCode; + final Object? output; +} + +class FunctionTestError extends HttpTest { + const FunctionTestError({ + required super.name, + super.method, + required super.input, + super.headers, + super.queryParameters, + required this.statusCode, + required this.output, + super.logs, + super.setup, + }); + + final int statusCode; + final Object? output; +} + +sealed class EventTest extends FunctionTest { + const EventTest({ + required super.name, + super.input, + super.method, + super.headers, + super.queryParameters, + super.logs, + super.setup, + }); +} + +class EventTestSuccess extends EventTest { + EventTestSuccess({ + required super.name, + super.method, + super.input, + super.headers, + super.queryParameters, + required List? events, + super.logs, + super.setup, + }) : output = emitsInOrder([ + for (final event in events ?? const []) jsonEncode(event), + emitsDone, + ]); + + final Object? output; +} + +class EventTestError extends EventTest { + const EventTestError({ + required super.name, + super.method, + required super.input, + super.headers, + super.queryParameters, + required this.error, + super.logs, + super.setup, + }); + + final Object? error; +} diff --git a/apps/cli/lib/analyzer/analysis_error.dart b/apps/cli/lib/analyzer/analysis_error.dart new file mode 100644 index 000000000..36019d7a3 --- /dev/null +++ b/apps/cli/lib/analyzer/analysis_error.dart @@ -0,0 +1,49 @@ +import 'package:celest_cli/src/context.dart'; +import 'package:source_span/source_span.dart'; + +typedef AnalysisErrorReporter = + void Function( + String message, { + AnalysisErrorSeverity? severity, + FileSpan? location, + }); + +enum AnalysisErrorSeverity { error, warning, info, debug } + +final class CelestAnalysisError { + const CelestAnalysisError({ + AnalysisErrorSeverity? severity, + required this.message, + required this.location, + }) : severity = severity ?? AnalysisErrorSeverity.error; + + final AnalysisErrorSeverity severity; + final String message; + final SourceSpan? location; + + @override + String toString() { + if (location case SourceSpan(sourceUrl: != null) && final location) { + return location.debugHighlight(message); + } + return message; + } +} + +extension SourceSpanDump on SourceSpan { + String debugHighlight(String message) { + // Better `SourceLocation.message` implementation which makes URIs + // clickable in VSCode terminal. + final uri = p.prettyUri(sourceUrl); + final line = start.line + 1; + final column = start.column + 1; + final buffer = StringBuffer()..write('$uri:$line:$column: $message'); + final highlight = this.highlight(); + if (highlight.isNotEmpty) { + buffer + ..writeln() + ..write(highlight); + } + return buffer.toString(); + } +} diff --git a/apps/cli/lib/analyzer/analysis_options.dart b/apps/cli/lib/analyzer/analysis_options.dart new file mode 100644 index 000000000..e43f14fdf --- /dev/null +++ b/apps/cli/lib/analyzer/analysis_options.dart @@ -0,0 +1,49 @@ +import 'package:celest_cli/src/context.dart'; +import 'package:celest_cli/src/utils/json.dart'; +import 'package:logging/logging.dart'; +import 'package:yaml/yaml.dart'; + +final class AnalysisOptions { + const AnalysisOptions._({this.enabledExperiments = const []}); + + final List enabledExperiments; + + static const AnalysisOptions empty = AnalysisOptions._(); + static final _logger = Logger('AnalysisOptions'); + + static Future load(String path) async { + path = + p.isAbsolute(path) + ? path + : p.canonicalize(p.join(projectPaths.projectRoot, path)); + final analysisOptionsFile = fileSystem.file(path); + if (!await analysisOptionsFile.exists()) { + _logger.finest('No analysis options file detected at $path'); + return empty; + } + final analysisOptionsContent = await analysisOptionsFile.readAsString(); + final analysisOptions = loadYamlDocument(analysisOptionsContent); + final analysisOptionsMap = analysisOptions.contents; + if (analysisOptionsMap is! YamlMap) { + _logger.finer('Invalid analysis options file: $analysisOptionsContent'); + return empty; + } + final analyzerOptions = analysisOptionsMap.value['analyzer']; + if (analyzerOptions is! YamlMap) { + _logger.finer('No analyzer settings found'); + return empty; + } + final enabledExperiments = analyzerOptions.value['enable-experiment']; + if (enabledExperiments is! YamlList) { + _logger.finer('No enabled experiments found'); + return empty; + } + return AnalysisOptions._( + enabledExperiments: enabledExperiments.value.cast(), + ); + } + + @override + String toString() => + prettyPrintJson({'enabledExperiments': enabledExperiments}); +} diff --git a/apps/cli/lib/analyzer/analysis_result.dart b/apps/cli/lib/analyzer/analysis_result.dart new file mode 100644 index 000000000..4f656828b --- /dev/null +++ b/apps/cli/lib/analyzer/analysis_result.dart @@ -0,0 +1,85 @@ +import 'package:celest_ast/celest_ast.dart' as ast; +import 'package:celest_cli/analyzer/analysis_error.dart'; + +sealed class CelestAnalysisResult { + const CelestAnalysisResult(); + + factory CelestAnalysisResult.from({ + ast.Project? project, + List errors = const [], + List warnings = const [], + List infos = const [], + }) { + if (project == null) { + return AnalysisFailureResult(errors, warnings: warnings, infos: infos); + } + return AnalysisSuccessResult( + project: project, + errors: errors, + warnings: warnings, + infos: infos, + ); + } + + factory CelestAnalysisResult.success({ + required ast.Project project, + List errors, + List warnings, + List infos, + }) = AnalysisSuccessResult; + + factory CelestAnalysisResult.failure( + List errors, { + List warnings, + List infos, + }) = AnalysisFailureResult; + + ast.Project? get project; + List get errors; + List get warnings; + List get infos; +} + +final class AnalysisSuccessResult implements CelestAnalysisResult { + AnalysisSuccessResult({ + required this.project, + this.errors = const [], + this.warnings = const [], + this.infos = const [], + }); + + @override + final ast.Project project; + + @override + final List errors; + + @override + final List warnings; + + @override + final List infos; +} + +final class AnalysisFailureResult implements CelestAnalysisResult { + AnalysisFailureResult( + this.errors, { + this.warnings = const [], + this.infos = const [], + }) : assert( + errors.isNotEmpty, + 'Errors must not be empty for a failure result.', + ); + + @override + ast.Project? get project => null; + + @override + final List errors; + + @override + final List warnings; + + @override + final List infos; +} diff --git a/apps/cli/lib/analyzer/celest_analysis_helpers.dart b/apps/cli/lib/analyzer/celest_analysis_helpers.dart new file mode 100644 index 000000000..57115b4ca --- /dev/null +++ b/apps/cli/lib/analyzer/celest_analysis_helpers.dart @@ -0,0 +1,372 @@ +import 'package:analyzer/dart/analysis/analysis_context.dart'; +import 'package:analyzer/dart/analysis/results.dart'; +import 'package:analyzer/dart/constant/value.dart'; +import 'package:analyzer/dart/element/element.dart'; +import 'package:analyzer/dart/element/type.dart'; +import 'package:analyzer/src/dart/resolver/scope.dart'; +import 'package:celest_cli/analyzer/analysis_error.dart'; +import 'package:celest_cli/analyzer/resolver/project_resolver.dart'; +import 'package:celest_cli/src/context.dart'; +import 'package:celest_cli/src/utils/analyzer.dart'; +import 'package:celest_cli/src/utils/json.dart'; +import 'package:logging/logging.dart'; +import 'package:meta/meta.dart'; +import 'package:source_span/source_span.dart'; + +enum CustomType { + model, + exception; + + String get legacyPath => switch (this) { + model => projectPaths.modelsDart, + exception => projectPaths.exceptionsDart, + }; + + String get dir => switch (this) { + model => projectPaths.modelsDir, + exception => projectPaths.exceptionsDir, + }; +} + +final class SourceEdit { + const SourceEdit(this.offset, this.length, this.replacement); + + final int offset; + final int length; + final String replacement; + + @override + bool operator ==(Object other) { + if (identical(this, other)) return true; + return other is SourceEdit && + other.offset == offset && + other.length == length && + other.replacement == replacement; + } + + @override + int get hashCode => Object.hash(offset, length, replacement); + + @override + String toString() { + return 'SourceEdit(offset: $offset, length: $length, replacement: $replacement)'; + } +} + +mixin CelestAnalysisHelpers implements CelestErrorReporter { + AnalysisContext get context; + Set get customExceptionTypes; + Set get customModelTypes; + + final pendingEdits = >{}; + + static final Logger _logger = Logger('CelestAnalyzer'); + + @mustCallSuper + void reset() { + pendingEdits.clear(); + } + + Set namespaceForLibrary( + LibraryElement library, { + bool recursive = false, + }) { + final visited = Set.identity(); + + Iterable forNamespace(Namespace namespace) sync* { + yield* namespace.definedNames.values.whereType(); + yield* namespace.definedNames.values + .whereType() + .map((el) => el.aliasedElement ?? el.aliasedType.element) + .whereType(); + } + + Iterable search(LibraryElement library) sync* { + if (!visited.add(library)) { + return; + } + yield* forNamespace(library.exportNamespace); + if (!recursive) { + return; + } + for (final importedLibrary in library.importedLibraries) { + yield* search(importedLibrary).toList(); + } + } + + return search(library).toSet(); + } + + Future resolveLibrary(String path) async { + final library = await context.currentSession.getResolvedLibrary(path); + switch (library) { + case ResolvedLibraryResult(): + return library; + case NotLibraryButPartResult(): + return _resolvePartFile(path); + case UriOfExternalLibraryResult(): + case CannotResolveUriResult(): + case DisposedAnalysisContextResult(): + case InvalidPathResult(): + case NotElementOfThisSessionResult(): + case NotPathOfUriResult(): + case InvalidResult(): + case _: + throw StateError( + 'Could not resolve library at "$path": ${library.runtimeType}', + ); + } + } + + Future resolveLibraryByUri(String uri) async { + final library = await context.currentSession.getLibraryByUri(uri); + switch (library) { + case LibraryElementResult(:final element): + return element; + default: + throw StateError( + 'Could not resolve library by URI "$uri": ${library.runtimeType}', + ); + } + } + + Future _resolvePartFile(String path) async { + final unit = await context.currentSession.getResolvedUnit(path); + if (unit case ResolvedUnitResult(:final libraryElement)) { + final resolvedLibrary = await context.currentSession + .getResolvedLibraryByElement(libraryElement); + if (resolvedLibrary is! ResolvedLibraryResult) { + throw StateError( + 'Could not resolve library for part file at "$path": ${unit.runtimeType}', + ); + } + return resolvedLibrary; + } + throw StateError( + 'Could not resolve part file at "$path": ${unit.runtimeType}', + ); + } + + /// Collects exception types from project and imported libraries. + Future> collectExceptionTypes(LibraryElement apiLibrary) async { + final exceptionTypes = {}; + + final apiNamespace = namespaceForLibrary(apiLibrary, recursive: true); + for (final interfaceElement in apiNamespace) { + if (_validateExceptionType(interfaceElement) case final validType?) { + exceptionTypes.add(validType); + } + } + return exceptionTypes; + } + + InterfaceType? _validateExceptionType(InterfaceElement interfaceElement) { + final definitionPath = context.currentSession.uriConverter.uriToPath( + interfaceElement.library.source.uri, + ); + final errorSeverity = switch (definitionPath) { + // We only care to report warnings for types defined within the project. + // There will be plenty of types in the Dart/Flutter SDKs and in the + // ecosystem that we don't support, but we don't want to spam the console + // with warnings for them. + final path? when p.isWithin(projectPaths.projectRoot, path) => + AnalysisErrorSeverity.warning, + _ => AnalysisErrorSeverity.debug, + }; + + // TODO(dnys1): If the exception type is not in the transitive dependency + // graph, we need to either: a) choose to add it, or b) skip the type. + + final typeUri = + '${interfaceElement.library.source.uri}#${interfaceElement.name}'; + final overriddenBy = typeHelper.overrides[interfaceElement.thisType]; + final isOverriden = overriddenBy != null; + if (isOverriden) { + interfaceElement = overriddenBy.element; + } + final interfaceType = interfaceElement.thisType; + final interfaceUri = interfaceElement.library.source.uri; + final isExceptionType = + identical( + interfaceElement, + typeHelper.coreTypes.coreExceptionType.element, + ) || + typeHelper.typeSystem.isSubtypeOf( + interfaceType.extensionTypeErasure, + typeHelper.coreTypes.coreExceptionType, + ); + final isErrorType = + identical( + interfaceElement, + typeHelper.coreTypes.coreErrorType.element, + ) || + typeHelper.typeSystem.isSubtypeOf( + interfaceType.extensionTypeErasure, + typeHelper.coreTypes.coreErrorType, + ); + final isExceptionOrErrorType = isExceptionType || isErrorType; + if (!isExceptionOrErrorType) { + return null; + } + // Only types defined within the celest/ project folder need to be in + // lib/ since all others can be imported on the client side. + final ( + mustBeExportedFromExceptionsDart, + exportedFromExceptionsDart, + ) = switch (context.currentSession.uriConverter.uriToPath(interfaceUri)) { + final path? => ( + p.isWithin(projectPaths.projectRoot, path), + p.isWithin(projectPaths.projectLib, path), + ), + _ => (false, false), + }; + if (!exportedFromExceptionsDart && mustBeExportedFromExceptionsDart) { + reportError( + 'Custom exception types referenced in APIs must be defined within the ' + '`celest/lib/exceptions` folder', + location: interfaceElement.sourceLocation, + severity: errorSeverity, + ); + return null; + } + final isInstantiable = switch (interfaceElement) { + final ClassElement classElement => + classElement.isConstructable || + classElement.constructors.any((ctor) => ctor.isFactory), + ExtensionTypeElement() || EnumElement() => true, + _ => false, + }; + if (!isInstantiable) { + _logger.finest('❌ $typeUri', 'Cannot be instantiated'); + return null; + } + final isSerializable = typeHelper.isSerializable(interfaceType); + if (!isSerializable.isSerializable) { + _logger.finest('❌ $typeUri', isSerializable.reasons.join(', ')); + // Serialization issues are only reported if the type is a custom type + // (e.g. exported from `exceptions/`). Otherwise, users are still + // allowed to throw it, but it will not be serialized in the response. + if (exportedFromExceptionsDart) { + for (final reason in isSerializable.reasons) { + // TODO(dnys1): Add a helpful link/description for this error. + reportError( + 'The exception type "${interfaceElement.name}" cannot be serialized ' + 'as JSON. Hide this type from the API or make it serializable: ' + '$reason', + location: interfaceElement.sourceLocation, + severity: errorSeverity, + ); + } + } + // TODO(dnys1): Warn based on whether the type is thrown directly or + // just indirectly imported. + // + // Also codegen a comment in the generated client with the reason why + // it's not included instead of reporting in console. (put behind a + // --debug flag or something). + reportError( + 'Cannot serialize the exception type "${interfaceElement.name}": ' + '${isSerializable.reasons.join('\n')}', + location: interfaceElement.sourceLocation, + severity: errorSeverity, + ); + return null; + } + + return interfaceType; + } + + /// Ensures that a referenced type which will be surfaced in the client + /// is defined in the `lib/` directory. + void ensureClientReferenceable( + InterfaceElement modelType, + SourceSpan location, { + required CustomType type, + }) { + final (isCustomType, isDefinedInLib) = switch (context + .currentSession + .uriConverter + .uriToPath(modelType.library.source.uri)) { + final path? => ( + p.isWithin(projectPaths.projectRoot, path), + p.isWithin(projectPaths.projectLib, path), + ), + _ => (false, false), + }; + if (isCustomType && !isDefinedInLib) { + reportError( + 'Custom ${type.name} types referenced in APIs must be defined somewhere ' + 'within the `celest/lib` folder.', + location: location, + ); + } + } +} + +extension TopLevelConstants on LibraryElement { + static final _logger = Logger('TopLevelConstants'); + + (List, bool hasErrors) topLevelConstants({ + required CelestErrorReporter errorReporter, + }) { + var hasConstantEvalErrors = false; + final topLevelConstants = []; + final topLevelVariables = topLevelElements + .whereType() + .where((variable) => !variable.isPrivate); + for (final topLevelVariable in topLevelVariables) { + if (!topLevelVariable.isConst) { + errorReporter.reportError( + 'All top-level variables must be `const`', + location: topLevelVariable.sourceLocation, + ); + hasConstantEvalErrors = true; + continue; + } + switch (topLevelVariable.computeConstantValue()) { + case final DartObject constantValue: + topLevelConstants.add(( + element: topLevelVariable, + value: constantValue, + )); + default: + errorReporter.reportError( + 'Top-level constant could not be evaluated', + location: topLevelVariable.sourceLocation, + ); + hasConstantEvalErrors = true; + } + } + _logger.finest(() { + final constantInfo = { + 'hasConstantEvalErrors': '$hasConstantEvalErrors', + 'constants': { + for (final constant in topLevelConstants) + constant.element.name: { + 'type': constant.element.type.toString(), + 'value': constant.value.toString(), + }, + }, + }; + return 'Resolved top-level constants in ${source.uri}: ' + '${prettyPrintJson(constantInfo)}'; + }); + return (topLevelConstants, hasConstantEvalErrors); + } +} + +typedef TopLevelConstant = + ({TopLevelVariableElement element, DartObject value}); + +extension GetClassType on LibraryElementResult { + ClassElement getClassElement(String name) => + element.exportNamespace.get(name) as ClassElement; + + DartType getClassType(String name) => getClassElement(name).thisType; + + ExtensionTypeElement getExtensionTypeElement(String name) => + element.exportNamespace.get(name) as ExtensionTypeElement; + + DartType getExtensionType(String name) => + getExtensionTypeElement(name).thisType; +} diff --git a/apps/cli/lib/analyzer/celest_analyzer.dart b/apps/cli/lib/analyzer/celest_analyzer.dart new file mode 100644 index 000000000..4b58aedea --- /dev/null +++ b/apps/cli/lib/analyzer/celest_analyzer.dart @@ -0,0 +1,628 @@ +import 'dart:async'; +import 'dart:io'; + +import 'package:analyzer/dart/analysis/results.dart'; +import 'package:analyzer/dart/element/element.dart'; +import 'package:analyzer/diagnostic/diagnostic.dart'; +import 'package:analyzer/error/error.dart'; +import 'package:analyzer/error/listener.dart'; +import 'package:analyzer/src/dart/analysis/analysis_context_collection.dart'; +import 'package:analyzer/src/dart/analysis/driver_based_analysis_context.dart'; +import 'package:celest_ast/celest_ast.dart' as ast; +import 'package:celest_cli/analyzer/analysis_error.dart'; +import 'package:celest_cli/analyzer/analysis_result.dart'; +import 'package:celest_cli/analyzer/celest_analysis_helpers.dart'; +import 'package:celest_cli/analyzer/resolver/legacy_project_resolver.dart'; +import 'package:celest_cli/analyzer/resolver/project_resolver.dart'; +import 'package:celest_cli/ast/ast.dart'; +import 'package:celest_cli/config/feature_flags.dart'; +import 'package:celest_cli/database/cache/cache_database.dart'; +import 'package:celest_cli/pub/project_dependency.dart'; +import 'package:celest_cli/pub/pub_action.dart'; +import 'package:celest_cli/pub/pub_environment.dart'; +import 'package:celest_cli/pub/pubspec.dart'; +import 'package:celest_cli/src/context.dart'; +import 'package:celest_cli/src/sdk/dart_sdk.dart'; +import 'package:celest_cli/src/types/type_helper.dart'; +import 'package:celest_cli/src/utils/analyzer.dart'; +import 'package:collection/collection.dart'; +import 'package:logging/logging.dart'; +import 'package:pubspec_parse/pubspec_parse.dart'; +import 'package:source_span/source_span.dart'; +import 'package:stream_transform/stream_transform.dart'; + +final class CelestAnalyzer + with CelestAnalysisHelpers + implements AnalysisErrorListener { + CelestAnalyzer._(); + + factory CelestAnalyzer() => _instance ??= CelestAnalyzer._(); + static CelestAnalyzer? _instance; + + static final Logger _logger = Logger('CelestAnalyzer'); + + /// Warms up the analyzer caches by resolving the core libraries and types + /// in a background thread. + /// + /// The results will be persisted to the byte store so that they can be + /// reused in subsequent analyzer instances. + static Future warmUp(String projectRoot) async { + final database = await CacheDatabase.open(projectRoot, verbose: false); + + var projectDir = fileSystem.directory(projectRoot); + final Iterable dependencies; + if (!fileSystem.file(p.join(projectRoot, 'pubspec.lock')).existsSync()) { + // If the project hasn't been created yet, create a dummy project to warm + // up the caches. + projectDir = fileSystem.systemTempDirectory.createTempSync('celest_'); + dependencies = ProjectDependency.backendDependencies.keys; + final pubspec = Pubspec( + 'warmup_celest_cache', + environment: {'sdk': PubEnvironment.dartSdkConstraint}, + dependencies: ProjectDependency.backendDependencies.toPub(), + ); + await [ + projectDir.childFile('pubspec.yaml').writeAsString(pubspec.toYaml()), + projectDir.childFile('project.dart').writeAsString(''' +import 'package:celest/celest.dart'; + +const project = Project(name: 'cache_warmup'); +'''), + ].wait; + await runPub(action: PubAction.get, workingDirectory: projectDir.path); + } else { + // Otherwise, cache the dependencies of the existing project. + final pubspec = Pubspec.parse( + projectDir.childFile('pubspec.yaml').readAsStringSync(), + ); + dependencies = pubspec.dependencies.keys; + } + + final contextCollection = AnalysisContextCollectionImpl( + includedPaths: [projectDir.path], + sdkPath: Sdk.current.sdkPath, + // Needed for collecting subtypes. + enableIndex: true, + byteStore: database.byteStore, + ); + final context = contextCollection.contextFor( + p.join(projectDir.path, 'project.dart'), + ); + final libraries = { + 'dart:core', + 'dart:typed_data', + 'package:celest_core/celest_core.dart', + 'package:celest_core/src/exception/cloud_exception.dart', + 'package:celest_core/src/auth/user.dart', + ...dependencies.map((dep) => 'package:$dep/$dep.dart'), + }; + await Future.wait(libraries.map(context.currentSession.getLibraryByUri)); + } + + @override + DriverBasedAnalysisContext get context => celestProject.analysisContext; + + final List _errors = []; + final List _warnings = []; + final List _infos = []; + final List _debugs = []; + + late _ScopedWidgetCollector _widgetCollector; + late ast.ProjectBuilder _project; + CelestProjectResolver? _resolver; + CelestProjectResolver get resolver => _resolver!; + + @override + void reportError( + String error, { + AnalysisErrorSeverity? severity, + SourceSpan? location, + }) { + switch (severity) { + case AnalysisErrorSeverity.error || null: + _errors.add( + CelestAnalysisError( + message: error, + location: location, + severity: severity, + ), + ); + case AnalysisErrorSeverity.warning: + _warnings.add( + CelestAnalysisError( + message: error, + location: location, + severity: severity, + ), + ); + case AnalysisErrorSeverity.info: + _infos.add( + CelestAnalysisError( + message: error, + location: location, + severity: severity, + ), + ); + case AnalysisErrorSeverity.debug: + _debugs.add( + CelestAnalysisError( + message: error, + location: location, + severity: severity, + ), + ); + } + } + + @override + void onError(AnalysisError error) { + // TODO: + } + + @override + void reset() { + _logger.finest('Clearing analyzer caches...'); + super.reset(); + _initFuture = null; + _resolver = null; + typeHelper.reset(); + } + + Future init({required bool migrateProject}) async { + _errors.clear(); + _warnings.clear(); + _infos.clear(); + _debugs.clear(); + _resolver ??= LegacyCelestProjectResolver( + featureFlags: await FeatureFlags.load(), + migrateProject: migrateProject, + errorReporter: this, + context: context, + ); + await Future.wait([ + _initFuture ??= _init(), + _resolver!.resolveCustomTypes(), + ]); + } + + Future? _initFuture; + Future _init() async { + final ( + dartCore as LibraryElementResult, + dartTypedData as LibraryElementResult, + celestCoreExceptions, + celestCoreUser, + celestConfigValues, + jsonAnnotation, + ) = await ( + context.currentSession.getLibraryByUri('dart:core'), + context.currentSession.getLibraryByUri('dart:typed_data'), + + // Resolve the specific URIs instead of resolving the whole package + // (which takes much much longer). + context.currentSession.getLibraryByUri( + 'package:celest_core/src/exception/cloud_exception.dart', + ), + context.currentSession.getLibraryByUri( + 'package:celest_core/src/auth/user.dart', + ), + context.currentSession.getLibraryByUri( + 'package:celest/src/config/config_values.dart', + ), + + // `package:json_annotation/json_annotation.dart` is used in the + // generated code when serializing/deserializing models. + context.currentSession.getLibraryByUri( + 'package:json_annotation/src/json_key.dart', + ), + ).wait; + if (celestCoreExceptions is! LibraryElementResult || + celestCoreUser is! LibraryElementResult) { + await dumpPackageConfig(); + throw StateError('Failed to resolve celest_core'); + } + if (celestConfigValues is! LibraryElementResult) { + await dumpPackageConfig(); + throw StateError('Failed to resolve celest'); + } + final jsonAnnotationLib = switch (jsonAnnotation) { + LibraryElementResult() => jsonAnnotation, + _ => null, + }; + if (jsonAnnotationLib == null) { + await dumpPackageConfig(); + _logger.fine( + 'Failed to resolve package:json_annotation', + jsonAnnotation, + StackTrace.current, + ); + } + + final envElement = celestConfigValues.getClassElement('env'); + final secretElement = celestConfigValues.getClassElement('secret'); + typeHelper + ..coreTypes = CoreTypes( + typeProvider: dartCore.element.typeProvider, + coreExceptionType: dartCore.getClassType('Exception'), + coreErrorType: dartCore.getClassType('Error'), + coreBigIntType: dartCore.getClassType('BigInt'), + dateTimeType: dartCore.getClassType('DateTime'), + durationType: dartCore.getClassType('Duration'), + coreRegExpType: dartCore.getClassType('RegExp'), + coreStackTraceType: dartCore.getClassType('StackTrace'), + coreUriType: dartCore.getClassType('Uri'), + coreUriDataType: dartCore.getClassType('UriData'), + typedDataUint8ListType: dartTypedData.getClassType('Uint8List'), + badRequestExceptionType: celestCoreExceptions.getClassType( + 'BadRequestException', + ), + internalServerErrorType: celestCoreExceptions.getClassType( + 'InternalServerError', + ), + userType: celestCoreUser.getClassType('User'), + cloudExceptionType: celestCoreExceptions.getClassType('CloudException'), + celestEnvType: envElement.thisType, + celestEnvElement: envElement, + celestSecretType: secretElement.thisType, + celestSecretElement: secretElement, + jsonKeyElement: jsonAnnotationLib?.getClassElement('JsonKey'), + ) + ..typeSystem = dartCore.element.typeSystem + ..typeProvider = dartCore.element.typeProvider; + } + + @override + Set get customModelTypes => + _resolver?.customModelTypes ?? const {}; + + @override + Set get customExceptionTypes => + _resolver?.customExceptionTypes ?? const {}; + + Future analyzeProject({ + bool migrateProject = false, + bool updateResources = true, + }) async { + await performance.trace( + 'CelestAnalyzer', + 'init', + () => init(migrateProject: migrateProject), + ); + if (_errors.isNotEmpty) { + return CelestAnalysisResult.failure( + _errors, + warnings: _warnings, + infos: _infos, + ); + } + + final project = await performance.trace( + 'CelestAnalyzer', + 'findProject', + _findProject, + ); + if (project == null || _errors.isNotEmpty) { + return CelestAnalysisResult.failure( + _errors, + warnings: _warnings, + infos: _infos, + ); + } + + _project = project.toBuilder(); + _widgetCollector = _ScopedWidgetCollector(errorReporter: reportError); + final variables = await performance.trace( + 'CelestAnalyzer', + 'resolveEnvVariables', + resolver.resolveVariables, + ); + + final secrets = await performance.trace( + 'CelestAnalyzer', + 'resolveSecrets', + resolver.resolveSecrets, + ); + + final auth = await performance.trace( + 'CelestAnalyzer', + 'collectAuth', + () => _collectAuth(migrateProject: migrateProject), + ); + if (auth != null) { + _project.auth.replace(auth); + variables.addAll(auth.variables.values); + secrets.addAll(auth.secrets.values); + } + + await performance.trace( + 'CelestAnalyzer', + 'collectApis', + () => _collectApis( + hasAuth: auth != null, + variables: variables, + secrets: secrets, + ), + ); + + final databases = await performance.trace( + 'CelestAnalyzer', + 'resolveDatabases', + _resolveDatabases, + ); + if (databases.isNotEmpty) { + _project.databases.addAll({ + for (final database in databases) database.name: database, + }); + } + + if (migrateProject) { + await performance.trace( + 'CelestAnalyzer', + 'applyMigrations', + _applyMigrations, + ); + } + + // Add config values only at the end since other components may contribute + // to them. + _project.variables.replace(variables); + _project.secrets.replace(secrets); + + return CelestAnalysisResult.success( + project: _project.build(), + errors: _errors, + warnings: _warnings, + infos: _infos, + ); + } + + Future _findProject() async { + _logger.fine('Analyzing project...'); + final projectFilePath = projectPaths.projectDart; + if (!fileSystem.file(projectFilePath).existsSync()) { + reportError('No project file found at $projectFilePath'); + return null; + } + _logger.finer('Found project file at $projectFilePath'); + final projectLibrary = context.currentSession.getParsedLibrary( + projectFilePath, + ); + if (projectLibrary is! ParsedLibraryResult) { + reportError('Failed to parse project.dart file'); + return null; + } + final projectErrors = + projectLibrary.units + .expand((unit) => unit.errors) + .where((error) => error.severity == Severity.error) + .toList(); + if (projectErrors.isNotEmpty) { + for (final projectError in projectErrors) { + _logger.finest( + 'ERROR (project.dart): type=${projectError.errorCode.type} ' + 'name=${projectError.errorCode.name}', + ); + reportError( + projectError.message, + location: projectError.source.toSpan( + projectError.problemMessage.offset, + projectError.problemMessage.offset + + projectError.problemMessage.length, + ), + ); + } + return null; + } + _logger.finer('Resolved project file'); + // TODO(dnys1): Some errors are okay, for example if `resources.dart` hasn't + // been updated yet and references a resource that doesn't exist yet. + // if (projectFile.errors.isNotEmpty) { + // reportError( + // 'Project file has errors:\n${projectFile.errors.join('\n')}', + // SourceLocation( + // path: projectFileRelativePath, + // line: 0, + // column: 0, + // ), + // ); + // } + return resolver.resolveProject(projectLibrary: projectLibrary); + } + + Future _collectApis({ + required bool hasAuth, + required Set variables, + required Set secrets, + }) async { + final apiDir = fileSystem.directory(projectPaths.apisDir); + if (!await apiDir.exists()) { + return; + } + + final apiFiles = + await apiDir + .list(followLinks: true) + .whereType() + .map((file) => file.path) + .where((path) => path.endsWith('.dart')) + .toList(); + final apiDeclarations = _widgetCollector.collect( + apiFiles, + scope: 'API', + placeholder: '', + ); + for (final MapEntry(key: apiName, value: apiPath) + in apiDeclarations.entries) { + if (apiName.startsWith('_')) { + // This would lead to private fields being generated in the client. It + // also allows us to reserve all `_` paths for internal usage. + reportError( + 'API names may not start with an underscore (`_`)', + location: SourceFile.fromString( + await fileSystem.file(apiPath).readAsString(), + url: p.toUri(apiPath), + ).span(0, 0), + ); + continue; + } + + final apiLibraryResult = await resolveLibrary(apiPath); + final apiErrors = + apiLibraryResult.units + .expand((unit) => unit.errors) + .where((error) => error.severity == Severity.error) + .toList(); + if (apiErrors.isNotEmpty) { + for (final apiError in apiErrors) { + reportError( + apiError.message, + location: apiError.source.toSpan( + apiError.problemMessage.offset, + apiError.problemMessage.offset + apiError.problemMessage.length, + ), + ); + } + continue; + } + final baseApi = await resolver.resolveApi( + apiFilepath: apiPath, + apiName: apiName, + apiLibrary: apiLibraryResult, + variables: variables, + secrets: secrets, + hasAuth: hasAuth, + ); + if (baseApi == null) { + return; + } + _project.apis.update((apis) => apis[apiName] = baseApi); + } + } + + Future _collectAuth({required bool migrateProject}) async { + final potentialAuthFiles = [ + projectPaths.authDart, + projectPaths.projectDart, + ]; + final authLibraries = await Future.wait( + potentialAuthFiles + .where((it) => fileSystem.file(it).existsSync()) + .map(resolveLibrary), + ); + final authErrors = + authLibraries + .expand((library) => library.units) + .expand((unit) => unit.errors) + .where((error) => error.severity == Severity.error) + .toList(); + if (authErrors.isNotEmpty) { + for (final authError in authErrors) { + reportError( + authError.message, + location: authError.source.toSpan( + authError.problemMessage.offset, + authError.problemMessage.offset + authError.problemMessage.length, + ), + ); + } + return null; + } + + for (final library in authLibraries) { + final auth = await resolver.resolveAuth( + authFilepath: + context.currentSession.uriConverter.uriToPath( + library.element.source.uri, + )!, + authLibrary: library, + ); + if (auth != null) { + return auth; + } + } + return null; + } + + Future> _resolveDatabases() async { + final databaseFile = fileSystem.file(projectPaths.projectDart); + if (!databaseFile.existsSync()) { + return const []; + } + final databaseLibrary = await resolveLibrary(databaseFile.path); + final database = await resolver.resolveDatabase( + databaseFilepath: databaseFile.path, + databaseLibrary: databaseLibrary, + ); + return database == null ? const [] : [database]; + } + + Future _applyMigrations() async { + if (resolver.pendingEdits.isEmpty) { + return; + } + + _logger.fine('Applying ${resolver.pendingEdits.length} migrations'); + + final fileChanges = >[]; + for (final entry in resolver.pendingEdits.entries) { + final path = entry.key; + + // Sort edits in reserve order to avoid offset changes. + final edits = entry.value.sorted((a, b) { + return -a.offset.compareTo(b.offset); + }); + + _logger.finest('Applying migrations to $path: $edits'); + + final file = context.currentSession.getFile(path) as FileResult; + var source = file.content; + + for (final edit in edits) { + source = source.replaceRange( + edit.offset, + edit.offset + edit.length, + edit.replacement, + ); + } + + fileChanges.add(fileSystem.file(path).writeAsString(source)); + } + + await Future.wait(fileChanges); + + _logger.finest('Applied migrations to disk'); + + for (final path in pendingEdits.keys) { + context.changeFile(path); + } + final changes = await context.applyPendingFileChanges(); + + _logger.finest('Applied changes in analyzer: $changes'); + } +} + +final class _ScopedWidgetCollector { + _ScopedWidgetCollector({required this.errorReporter}); + + final AnalysisErrorReporter errorReporter; + + Map collect( + List files, { + required String scope, + required String placeholder, + }) { + final declarations = {}; + for (final file in files) { + switch (p.basename(file).split('.')) { + case [final baseName, 'dart']: + declarations[baseName] = file; + default: + errorReporter( + '$scope files must be named as follows: $placeholder.dart', + ); + continue; + } + } + return declarations; + } +} diff --git a/apps/cli/lib/analyzer/const_to_code_builder.dart b/apps/cli/lib/analyzer/const_to_code_builder.dart new file mode 100644 index 000000000..982a33f50 --- /dev/null +++ b/apps/cli/lib/analyzer/const_to_code_builder.dart @@ -0,0 +1,342 @@ +import 'package:analyzer/dart/constant/value.dart'; +import 'package:analyzer/dart/element/element.dart'; +import 'package:analyzer/dart/element/type.dart'; +import 'package:analyzer/src/dart/constant/value.dart'; +import 'package:celest_ast/celest_ast.dart' as ast; +import 'package:celest_cli/src/context.dart'; +import 'package:celest_cli/src/utils/analyzer.dart'; +import 'package:celest_cli/src/utils/error.dart'; +import 'package:celest_cli/src/utils/reference.dart'; +import 'package:code_builder/code_builder.dart'; +import 'package:collection/collection.dart'; + +extension ConstToCodeBuilder on DartObject { + R accept(DartObjectVisitor visitor) { + return visitor.visit(this as DartObjectImpl); + } + + Expression? get toCodeBuilder => accept(const _ConstToCodeBuilder()); + ast.DartValue? get toDartValue => accept(const _ConstToDartValue()); +} + +abstract base class DartObjectVisitor { + const DartObjectVisitor(); + + R visit(DartObjectImpl node) { + if (node.toBoolValue() case final boolValue?) { + return visitBoolValue(boolValue); + } else if (node.toDoubleValue() case final doubleValue?) { + return visitDoubleValue(doubleValue); + } else if (node.type case final InterfaceType interface + when interface.isEnum) { + return visitEnumValue( + interface, + node.getField('_name')!.toStringValue()!, + ); + } else if (node.getInvocation() case final invocation?) { + return visitInstanceCreation(invocation); + } else if (node.toIntValue() case final intValue?) { + return visitIntValue(intValue); + } else if (node.toListValue() case final listValue?) { + return visitListValue(listValue, node.type); + } else if (node.toMapValue() case final mapValue?) { + return visitMapValue(mapValue, node.type); + } else if (node.isNull) { + return visitNullValue(); + } else if (node.state case final RecordState record) { + return visitRecordValue( + record.positionalFields, + record.namedFields, + node.type, + ); + } else if (node.toStringValue() case final stringValue?) { + return visitStringValue(stringValue); + } else if (node.toSymbolValue() case final symbolValue?) { + return visitSymbolValue(symbolValue); + } else if (node.toTypeValue() case final typeValue?) { + return visitTypeValue(typeValue); + } else { + return null as R; + } + } + + R visitBoolValue(bool value); + + R visitDoubleValue(double value); + + R visitEnumValue(DartType type, String name); + + R visitInstanceCreation(ConstructorInvocation invocation); + + R visitIntValue(int value); + + R visitListValue(List value, DartType staticType); + + R visitMapValue( + Map value, + DartType staticType, + ); + + R visitNullValue(); + + R visitRecordValue( + List positionalFields, + Map namedFields, + DartType staticType, + ); + + R visitStringValue(String value); + + R visitSymbolValue(String value); + + R visitTypeValue(DartType value); + + R visitVariableReference(VariableElement variable); +} + +final class _ConstToCodeBuilder extends DartObjectVisitor { + const _ConstToCodeBuilder(); + + @override + Expression? visit(DartObjectImpl node) { + if (node.variable + case VariableElement(:final library?, isPrivate: false) && + final variable? + // Private variable references cannot be copied to the generated code, so + // we use the raw value instead. + // + // Variables defined outside `lib/` cannot be copied to the generated + // code, so we use the raw value instead. + when !library.isWithinProject || library.isWithinProjectLib) { + return visitVariableReference(variable); + } + return super.visit(node); + } + + @override + Expression visitBoolValue(bool value) => literalBool(value); + + @override + Expression visitDoubleValue(double value) => literalNum(value); + + @override + Expression visitEnumValue(DartType type, String name) { + return typeHelper.toReference(type).property(name); + } + + @override + Expression visitInstanceCreation(ConstructorInvocation invocation) { + final constructorEl = invocation.constructor; + final expressionType = constructorEl.returnType; + final namedParameters = invocation.namedArguments.map((name, value) { + return MapEntry(name, value.toCodeBuilder ?? literalNull); + }); + final positionalParameters = invocation.positionalArguments.map( + (el) => el.toCodeBuilder ?? literalNull, + ); + if (constructorEl.name.isNotEmpty) { + return typeHelper + .toReference(expressionType) + .constInstanceNamed( + constructorEl.name, + positionalParameters, + namedParameters, + ); + } + return typeHelper + .toReference(expressionType) + .constInstance(positionalParameters, namedParameters); + } + + @override + Expression visitIntValue(int value) => literalNum(value); + + @override + Expression visitListValue(List value, DartType staticType) => + literalConstList( + value.map((el) => el.toCodeBuilder ?? literalNull).toList(), + ); + + @override + Expression visitMapValue( + Map mapValue, + DartType staticType, + ) => literalConstMap({ + for (final MapEntry(:key, :value) in mapValue.entries) + key.toCodeBuilder: value.toCodeBuilder ?? literalNull, + }); + + @override + Expression? visitNullValue() => null; + + @override + Expression visitRecordValue( + List positionalFields, + Map namedFields, + DartType staticType, + ) { + return literalConstRecord( + positionalFields.map((el) => el.toCodeBuilder ?? literalNull).toList(), + namedFields.map( + (name, value) => MapEntry(name, value.toCodeBuilder ?? literalNull), + ), + ); + } + + @override + Expression visitStringValue(String value) => literalString(value); + + @override + Expression visitSymbolValue(String value) => CodeExpression(Code('#$value')); + + @override + Expression visitTypeValue(DartType value) => typeHelper.toReference(value); + + @override + Expression visitVariableReference(VariableElement variable) { + return switch (variable) { + TopLevelVariableElement() => refer( + variable.name, + variable.library.source.uri.toString(), + ), + FieldElement(enclosingElement3: final enclosingElement) => refer( + enclosingElement.displayName, + enclosingElement.library!.source.uri.toString(), + ).property(variable.name), + _ => unreachable('Invalid variable element: $variable'), + }; + } +} + +final class _ConstToDartValue extends DartObjectVisitor { + const _ConstToDartValue(); + + @override + ast.DartValue visitBoolValue(bool value) { + return ast.DartBool(value); + } + + @override + ast.DartValue visitDoubleValue(double value) { + return ast.DartDouble(value); + } + + @override + ast.DartValue visitEnumValue(DartType type, String name) { + return ast.DartEnum(typeHelper.toReference(type).toTypeReference, name); + } + + @override + ast.DartValue visitInstanceCreation(ConstructorInvocation invocation) { + final constructorEl = invocation.constructor; + final namedParameters = invocation.namedArguments.map((name, value) { + return MapEntry(name, value.accept(this)); + }); + final positionalParameterNames = + constructorEl.parameters + .where((it) => it.isPositional) + .map((it) => it.name) + .toList(); + final positionalParameterValues = + invocation.positionalArguments.map((el) => el.accept(this)).toList(); + final className = constructorEl.enclosingElement3.displayName; + final classRef = + typeHelper + .toReference(constructorEl.enclosingElement3.thisType) + .toTypeReference; + assert(() { + if (positionalParameterNames.length < positionalParameterValues.length) { + final constructorName = switch (constructorEl.name) { + final name when name.isEmpty => 'new', + final name => name, + }; + throw StateError( + 'Mismatched positional parameters for type $classRef ' + '("$className.$constructorName"): ' + 'names $positionalParameterNames, ' + 'values $positionalParameterValues.', + ); + } + return true; + }()); + return ast.DartInstance( + classRef: classRef, + constructor: constructorEl.name, + positionalArguments: Map.fromEntries( + positionalParameterValues.mapIndexed((index, value) { + return MapEntry(positionalParameterNames[index], value); + }), + ), + namedArguments: namedParameters, + staticType: + typeHelper.toReference(constructorEl.returnType).toTypeReference, + ); + } + + @override + ast.DartValue visitIntValue(int value) { + return ast.DartInt(value); + } + + @override + ast.DartValue visitListValue( + List value, + DartType staticType, + ) { + return ast.DartList( + value.map((el) => el.accept(this)).toList(), + staticType: typeHelper.toReference(staticType).toTypeReference, + ); + } + + @override + ast.DartValue visitMapValue( + Map value, + DartType staticType, + ) { + return ast.DartMap( + value.map((key, value) => MapEntry(key.accept(this), value.accept(this))), + staticType: typeHelper.toReference(staticType).toTypeReference, + ); + } + + @override + ast.DartValue visitNullValue() { + return ast.DartNull(); + } + + @override + ast.DartValue visitRecordValue( + List positionalFields, + Map namedFields, + DartType staticType, + ) { + return ast.DartRecord( + positionalFields: positionalFields.map((el) => el.accept(this)).toList(), + namedFields: namedFields.map( + (name, value) => MapEntry(name, value.accept(this)), + ), + staticType: typeHelper.toReference(staticType).toTypeReference, + ); + } + + @override + ast.DartValue visitStringValue(String value) { + return ast.DartString(value); + } + + @override + ast.DartValue visitSymbolValue(String value) { + return ast.DartSymbolLiteral(value); + } + + @override + ast.DartValue visitTypeValue(DartType value) { + return ast.DartTypeLiteral(typeHelper.toReference(value).toTypeReference); + } + + @override + ast.DartValue visitVariableReference(VariableElement variable) { + unreachable('Should use the raw value instead.'); + } +} diff --git a/apps/cli/lib/analyzer/plugin/celest_analyzer_plugin.dart b/apps/cli/lib/analyzer/plugin/celest_analyzer_plugin.dart new file mode 100644 index 000000000..a4ede939d --- /dev/null +++ b/apps/cli/lib/analyzer/plugin/celest_analyzer_plugin.dart @@ -0,0 +1,81 @@ +import 'package:analyzer/dart/analysis/analysis_context.dart'; +import 'package:analyzer/file_system/file_system.dart'; +import 'package:analyzer/file_system/physical_file_system.dart'; +import 'package:analyzer_plugin/plugin/plugin.dart'; +import 'package:analyzer_plugin/protocol/protocol_common.dart'; +import 'package:analyzer_plugin/protocol/protocol_generated.dart'; +import 'package:celest_cli/analyzer/analysis_error.dart'; +import 'package:celest_cli/src/context.dart'; +import 'package:logging/logging.dart'; +import 'package:meta/meta.dart'; +import 'package:source_span/source_span.dart'; + +final class CelestAnalyzerPlugin extends ServerPlugin { + CelestAnalyzerPlugin({ + void Function(Object error, StackTrace stackTrace)? onError, + void Function()? onDone, + this.withDebugging = false, + @visibleForTesting ResourceProvider? resourceProvider, + }) : _onError = onError, + _onDone = onDone, + super( + resourceProvider: + resourceProvider ?? PhysicalResourceProvider.INSTANCE, + ); + + static final Logger logger = Logger('Celest.AnalyzerPlugin'); + + final void Function(Object error, StackTrace stackTrace)? _onError; + final void Function()? _onDone; + final bool withDebugging; + + @override + void onError(Object exception, StackTrace stackTrace) { + logger.severe('Error in plugin', exception, stackTrace); + _onError?.call(exception, stackTrace); + } + + @override + void onDone() { + logger.info('Plugin done'); + _onDone?.call(); + } + + @override + Future handleAnalysisGetNavigation( + AnalysisGetNavigationParams parameters, + ) async { + logger.info('Handling analysis get navigation'); + if (withDebugging) { + final fileText = await fileSystem.file(parameters.file).readAsString(); + final file = SourceFile.fromString(fileText, url: parameters.file); + final span = file.span( + parameters.offset, + parameters.offset + parameters.length, + ); + logger.info(span.debugHighlight('Navigation request')); + } + return AnalysisGetNavigationResult( + [], + [], + [], + ); + } + + @override + Future analyzeFile({ + required AnalysisContext analysisContext, + required String path, + }) async { + logger.info('Analyzing $path'); + } + + @override + List get fileGlobsToAnalyze => ['**/*.dart']; + + @override + String get name => 'celest'; + + @override + String get version => '1.0.0'; +} diff --git a/apps/cli/lib/analyzer/resolver/config_value_resolver.dart b/apps/cli/lib/analyzer/resolver/config_value_resolver.dart new file mode 100644 index 000000000..37712fd08 --- /dev/null +++ b/apps/cli/lib/analyzer/resolver/config_value_resolver.dart @@ -0,0 +1,356 @@ +import 'dart:collection'; + +import 'package:analyzer/dart/analysis/analysis_context.dart'; +import 'package:analyzer/dart/analysis/results.dart'; +import 'package:analyzer/dart/ast/ast.dart'; +import 'package:analyzer/dart/constant/value.dart'; +import 'package:analyzer/dart/element/element.dart'; +import 'package:celest_ast/celest_ast.dart' as ast; +import 'package:celest_cli/analyzer/resolver/project_resolver.dart'; +import 'package:celest_cli/database/project/project_database.dart'; +import 'package:celest_cli/src/context.dart'; +import 'package:celest_cli/src/utils/analyzer.dart'; +import 'package:celest_cli/src/utils/run.dart'; +import 'package:collection/collection.dart'; +import 'package:logging/logging.dart'; +import 'package:source_span/source_span.dart'; + +typedef ConfigValue = (String name, FileSpan location); +typedef ConfigValueFactory = + T Function( + String, { + String? value, + String? dartName, + Iterable docs, + required FileSpan location, + }); + +final class ConfigVarSet + extends DelegatingSet { + ConfigVarSet() + : super( + LinkedHashSet( + equals: (a, b) => a.name == b.name, + hashCode: (a) => a.name.hashCode, + ), + ); + + factory ConfigVarSet.of(Iterable values) { + return ConfigVarSet()..addAll(values); + } +} + +final class ConfigVarMap + extends DelegatingMap { + factory ConfigVarMap.from(Iterable values) { + return ConfigVarMap() + ..addEntries(values.map((it) => MapEntry(it, it.name))); + } + ConfigVarMap() + : super( + LinkedHashMap( + equals: (a, b) => a.name == b.name, + hashCode: (a) => a.name.hashCode, + ), + ); + + @override + ConfigVarSet get keys => ConfigVarSet.of(super.keys); +} + +final class ConfigValueResolver { + ConfigValueResolver({ + required this.context, + required this.configValueElement, + required this.errorReporter, + required this.factory, + }); + + final AnalysisContext context; + final InterfaceElement configValueElement; + final CelestErrorReporter errorReporter; + final ConfigValueFactory factory; + + static final Logger _logger = Logger('ConfigValueResolver'); + + Future> resolve() async { + final variables = ConfigVarSet(); + final references = await configValueElement.references().toList(); + for (final reference in references) { + _logger.finest( + 'Reference: kind=${reference.kind}, ' + 'elementKind=${reference.enclosingElement.kind}, ' + 'location=${reference.enclosingElement.sourceLocation}', + ); + } + + final topLevelDefinitions = + references + .map((ref) => ref.enclosingElement) + .whereType(); + final topLevelResolutions = + < + ( + String dartName, + Iterable docs, + Future<(String, String?, FileSpan?)?> resolution, + ) + >[]; + for (final variable in topLevelDefinitions) { + topLevelResolutions.add(( + variable.name, + variable.docLines, + resolveVariable( + variable: variable, + value: variable.computeConstantValue(), + location: variable.sourceLocation, + ), + )); + } + final topLevelVariables = await Future.wait( + topLevelResolutions.map((it) => it.$3), + eagerError: true, + ); + variables.addAll( + topLevelVariables.nonNulls.mapIndexed((index, it) { + final (name, value, location) = it; + return factory( + name, + dartName: topLevelResolutions[index].$1, + docs: topLevelResolutions[index].$2, + value: value, + location: location ?? SourceFile.fromString('').span(0), + ); + }), + ); + + final parameters = + references + .map((ref) => ref.enclosingElement) + .whereType(); + final parameterResolutions = >[]; + for (final parameter in parameters) { + for (final metadata in parameter.metadata) { + _logger.finer( + 'Resolving parameter: name=${parameter.name}, ' + 'type=${metadata.element?.runtimeType}', + ); + final element = metadata.element; + final location = parameter.sourceLocation; + switch (element) { + case ConstructorElement(enclosingElement3: final enclosingElement) + when enclosingElement == configValueElement: + parameterResolutions.add( + resolveVariable( + variable: element, + value: metadata.computeConstantValue(), + location: location, + ), + ); + case PropertyAccessorElement(:final returnType) + when returnType == configValueElement.thisType: + parameterResolutions.add( + resolveVariable( + variable: element, + value: metadata.computeConstantValue(), + location: location, + ), + ); + } + } + } + final parameterVariables = await Future.wait( + parameterResolutions, + eagerError: true, + ); + variables.addAll( + parameterVariables.nonNulls.map((it) { + final (name, value, location) = it; + return factory( + name, + dartName: null, + value: value, + location: location ?? SourceFile.fromString('').span(0), + ); + }), + ); + + return variables; + } + + String? resolveConfigValueNode(VariableDeclaration node) { + final initializer = node.initializer; + final argumentList = switch (initializer) { + MethodInvocation(:final argumentList) => argumentList, + InstanceCreationExpression(:final argumentList) => argumentList, + _ => null, + }; + final argument = argumentList?.arguments.singleOrNull; + if (argument == null) { + _logger.fine('No argument found for $node'); + return null; + } + return switch (argument) { + SimpleStringLiteral(:final value) => value, + final unsupported => run(() { + _logger.fine('Unsupported argument type: $unsupported'); + return null; + }), + }; + } + + Future<(String name, String? staticValue, FileSpan? location)?> + resolveVariable({ + required Element variable, + required DartObject? value, + required FileSpan? location, + }) async { + String? name; + String? staticValue; + if (value != null) { + _logger.finest('Resolved value: $value'); + name = + (value.getField('name') ?? + value.getField('(super)')?.getField('name')) + ?.toStringValue(); + staticValue = + (value.getField('value') ?? + value.getField('(super)')?.getField('value')) + ?.toStringValue(); + _logger.finest('Resolved name: $name ($staticValue)'); + } else if (variable.library case final libraryElement?) { + // Only resolve variables in the project backend + if (libraryElement.source.uri case Uri( + scheme: 'package', + pathSegments: [!= 'celest_backend', ...], + )) { + _logger.finest('Skipping: $variable'); + return null; + } + final library = await context.currentSession.getResolvedLibraryByElement( + libraryElement, + ); + ElementDeclarationResult? declaration; + if (library is ResolvedLibraryResult) { + declaration = library.getElementDeclaration(variable); + } else { + performance.captureError( + StateError('Failed to resolve library'), + extra: { + 'uri': libraryElement.source.uri, + 'variable': variable.toString(), + }, + ); + } + _logger.finest('Resolved declaration: ${declaration?.node.runtimeType}'); + if (declaration?.node case final VariableDeclaration declaration) { + name = resolveConfigValueNode(declaration); + _logger.finest('Resolved name: $name'); + } + } + if (name == null) { + errorReporter.reportError( + 'Failed to resolve the environment variable\'s `name`', + location: location, + ); + return null; + } + return (name, staticValue, location); + } +} + +extension WithEnvironment on ProjectDatabase { + Future withEnvironment( + Future Function(Environment environment) withEnv, { + required String environmentId, + }) { + return transaction(() async { + if (await lookupEnvironment(id: environmentId).get() case [ + final environment, + ]) { + return withEnv(environment); + } + final [environment] = await createEnvironment(id: environmentId); + return withEnv(environment); + }); + } +} + +extension ResolveConfigurationVariable on ast.ConfigurationVariable { + Future retrieveValue({required String environmentId}) async { + final db = celestProject.projectDb; + return db.withEnvironment(environmentId: environmentId, ( + environment, + ) async { + switch (this) { + case ast.Variable(:final name): + final value = + await db + .getEnvironmentVariable( + environmentId: environment.id, + name: name, + ) + .get(); + return value.singleOrNull; + case ast.Secret(:final name): + final value = + await db + .getSecret(environmentId: environment.id, name: name) + .get(); + final ref = value.singleOrNull; + if (ref == null) { + return null; + } + final [...scope, key] = ref.split('/'); + return secureStorage.scoped(scope.join('/')).read(key); + } + }); + } +} + +extension ResolveConfigurationVariables + on Iterable { + Future> retrieveValues({ + required String environmentId, + }) async { + if (isEmpty) { + return const {}; + } + final db = celestProject.projectDb; + return db.withEnvironment(environmentId: environmentId, ( + environment, + ) async { + final variableNames = map((it) => it.name).toList(); + final values = {}; + switch (first) { + case ast.Variable(): + final dbValues = + await db + .getEnvironmentVariables( + environmentId: environment.id, + names: variableNames, + ) + .get(); + for (final value in dbValues) { + values[value.name] = value.value; + } + case ast.Secret(): + final dbValues = + await db + .getSecrets( + environmentId: environment.id, + names: variableNames, + ) + .get(); + for (final secret in dbValues) { + final [...scope, key] = secret.valueRef.split('/'); + final value = secureStorage.scoped(scope.join('/')).read(key); + if (value != null) { + values[secret.name] = value; + } + } + } + return values; + }); + } +} diff --git a/apps/cli/lib/analyzer/resolver/legacy_project_resolver.dart b/apps/cli/lib/analyzer/resolver/legacy_project_resolver.dart new file mode 100644 index 000000000..dafa87394 --- /dev/null +++ b/apps/cli/lib/analyzer/resolver/legacy_project_resolver.dart @@ -0,0 +1,1291 @@ +import 'dart:collection'; + +import 'package:analyzer/dart/analysis/results.dart'; +import 'package:analyzer/dart/ast/ast.dart'; +import 'package:analyzer/dart/ast/token.dart'; +import 'package:analyzer/dart/element/element.dart'; +import 'package:analyzer/dart/element/nullability_suffix.dart'; +import 'package:analyzer/dart/element/type.dart'; +import 'package:analyzer/source/file_source.dart'; +import 'package:analyzer/src/dart/analysis/driver_based_analysis_context.dart'; +import 'package:celest_ast/celest_ast.dart' as ast; +import 'package:celest_cli/analyzer/analysis_error.dart'; +import 'package:celest_cli/analyzer/celest_analysis_helpers.dart'; +import 'package:celest_cli/analyzer/resolver/config_value_resolver.dart'; +import 'package:celest_cli/analyzer/resolver/project_resolver.dart'; +import 'package:celest_cli/config/feature_flags.dart'; +import 'package:celest_cli/serialization/common.dart'; +import 'package:celest_cli/serialization/serialization_verdict.dart'; +import 'package:celest_cli/src/context.dart'; +import 'package:celest_cli/src/sdk/dart_sdk.dart'; +import 'package:celest_cli/src/types/type_checker.dart'; +import 'package:celest_cli/src/utils/analyzer.dart'; +import 'package:celest_cli/src/utils/error.dart'; +import 'package:celest_cli/src/utils/list.dart'; +import 'package:celest_cli/src/utils/reference.dart'; +import 'package:celest_cli/src/utils/run.dart'; +import 'package:celest_cli/src/version.dart'; +import 'package:code_builder/code_builder.dart'; +import 'package:collection/collection.dart'; +import 'package:file/file.dart'; +import 'package:http_parser/http_parser.dart'; +import 'package:logging/logging.dart'; +import 'package:pub_semver/pub_semver.dart'; +import 'package:source_span/source_span.dart'; +import 'package:stream_transform/stream_transform.dart'; + +final class LegacyCelestProjectResolver extends CelestProjectResolver { + LegacyCelestProjectResolver({ + required super.migrateProject, + required this.featureFlags, + required CelestErrorReporter errorReporter, + required this.context, + }) : _errorReporter = errorReporter; + + static final _logger = Logger('LegacyCelestProjectResolver'); + + final CelestErrorReporter _errorReporter; + final FeatureFlags featureFlags; + + @override + final DriverBasedAnalysisContext context; + + @override + Set customModelTypes = {}; + + @override + Set customExceptionTypes = {}; + + late final _envVariableResolver = ConfigValueResolver( + context: context, + configValueElement: typeHelper.coreTypes.celestEnvElement, + errorReporter: this, + factory: ast.Variable.new, + ); + + late final _secretResolver = ConfigValueResolver( + context: context, + configValueElement: typeHelper.coreTypes.celestSecretElement, + errorReporter: this, + factory: (name, {dartName, docs = const [], value, required location}) { + return ast.Secret( + name, + docs: docs, + dartName: dartName, + location: location, + ); + }, + ); + + @override + void reportError( + String error, { + AnalysisErrorSeverity? severity, + SourceSpan? location, + }) { + _errorReporter.reportError(error, severity: severity, location: location); + } + + Future> _collectCustomTypes(CustomType type) async { + final files = []; + final dir = fileSystem.directory(type.dir); + if (dir.existsSync()) { + files.addAll(await dir.list(recursive: true).whereType().toList()); + } + final legacyBarrelFile = fileSystem.file(type.legacyPath); + if (legacyBarrelFile.existsSync()) { + files.add(legacyBarrelFile); + } + final customTypes = {}; + await Future.wait([ + for (final file in files) + resolveLibrary(file.path).then((library) { + final types = namespaceForLibrary(library.element); + customTypes.addAll(types); + }), + ]); + return customTypes; + } + + @override + Future resolveCustomTypes() async { + final [customModelTypes, customExceptionTypes] = await Future.wait([ + _collectCustomTypes(CustomType.model), + _collectCustomTypes(CustomType.exception), + ]); + this.customModelTypes = customModelTypes; + this.customExceptionTypes = customExceptionTypes; + typeHelper.overrides.clear(); + for (final element in customExceptionTypes.followedBy(customModelTypes)) { + final overrideAnnotation = element.metadata.firstWhereOrNull( + (annotation) => annotation.isOverride, + ); + final isOverride = overrideAnnotation != null; + final customOverrideAnnotation = element.metadata.firstWhereOrNull( + (annotation) => annotation.isCustomOverride, + ); + final isCustomOverride = customOverrideAnnotation != null; + if (!isOverride && !isCustomOverride) { + continue; + } + if (element is! ExtensionTypeElement) { + reportError( + 'Only extension types may be marked as overrides', + location: element.sourceLocation, + ); + continue; + } + final elementUri = + context.currentSession.uriConverter.uriToPath( + element.librarySource.uri, + ) ?? + p.fromUri(element.librarySource.uri); + if (isOverride && migrateProject) { + // `@override` -> `@customImplementation` + final location = overrideAnnotation.sourceLocation(element.source); + final overlay = pendingEdits[elementUri] ??= {}; + const editText = '@customOverride'; + _logger.finest( + 'Proposing edit: ${location.text} -> $editText (${location.sourceUrl})', + ); + overlay.add( + SourceEdit(location.start.offset, location.length, editText), + ); + } + final typeErasure = element.typeErasure; + if (typeErasure is! InterfaceType) { + reportError( + 'Only interface types may be overridden', + location: element.sourceLocation, + ); + continue; + } + if (typeErasure.element is ExtensionTypeElement) { + reportError( + 'Extension types may not be overridden', + location: element.sourceLocation, + ); + continue; + } + final erasureSource = typeErasure.element.library.source.uri; + if (erasureSource case Uri(scheme: 'dart', path: 'core')) { + reportError( + 'Overriding types from `dart:core` is not allowed', + location: element.sourceLocation, + ); + continue; + } + final overridesCustomType = switch (context.currentSession.uriConverter + .uriToPath(erasureSource)) { + final path? => p.isWithin(projectPaths.projectRoot, path), + _ => false, + }; + if (overridesCustomType) { + reportError( + 'Overriding custom types is not allowed', + location: element.sourceLocation, + ); + continue; + } + if (typeHelper.overrides[typeErasure] case final existing?) { + reportError( + 'The type ${typeErasure.element.name} is already overridden by ' + '${existing.element.name} (${existing.element.library.source.uri}).', + location: element.sourceLocation, + ); + continue; + } + // TODO(dnys1): This shouldn't be required but having an `on` clause with + // an exttype which doesn't implement the interface causes an error. + if (!element.thisType.implementsRepresentationType) { + reportError( + 'Custom overrides must implement their representation type', + location: element.sourceLocation, + ); + continue; + } + typeHelper.overrides[typeErasure] = element.thisType; + } + } + + @override + Future resolveProject({ + required ParsedLibraryResult projectLibrary, + }) async { + final declarations = projectLibrary.units + .expand((unit) => unit.unit.declarations) + .whereType() + .expand((declaration) => declaration.variables.variables); + + final projectFilePath = projectPaths.projectDart; + final projectFile = + context.currentSession.getFile(projectFilePath) as FileResult; + final projectFileSource = FileSource( + projectFile.file, + p.toUri(projectFilePath), + ); + + String? projectName; + String? projectDisplayName; + ast.Region? projectRegion; + String? variableName; + FileSpan? projectDefineLocation; + + for (final declaration in declarations) { + if (declaration case VariableDeclaration( + name: Token(lexeme: final name), + initializer: MethodInvocation( + methodName: SimpleIdentifier(name: 'Project'), + :final argumentList, + ), + )) { + for (final argument in argumentList.arguments) { + switch (argument) { + case NamedExpression( + name: Label(label: SimpleIdentifier(name: 'name')), + expression: SimpleStringLiteral(:final value), + ): + projectName = value; + variableName = name; + projectDefineLocation = declaration.sourceLocation( + projectFileSource, + ); + case NamedExpression( + name: Label(label: SimpleIdentifier(name: 'displayName')), + expression: SimpleStringLiteral(:final value), + ): + projectDisplayName = value; + case NamedExpression( + name: Label(label: SimpleIdentifier(name: 'region')), + expression: PrefixedIdentifier( + prefix: SimpleIdentifier(name: 'Region'), + identifier: SimpleIdentifier(name: final region), + ), + ): + projectRegion = ast.Region.valueOf(region); + default: + performance.captureError( + FormatException( + 'Unknown argument to `Project`: $argument', + projectFileSource, + ), + ); + } + } + } + } + + if (projectName == null) { + reportError('$projectFilePath: No `Project` type found'); + return null; + } + + // Validate `project` variable + _logger.finer( + 'Resolved project definition location: $projectDefineLocation', + ); + if (projectName.isEmpty) { + reportError( + 'The project name cannot be empty.', + location: projectDefineLocation, + ); + } + _logger.finer('Resolved project name: $projectName'); + + final featureFlags = await FeatureFlags.load(); + + return ast.Project( + name: projectName, + environment: 'local', // TODO(dnys1): Pass in from CLI + displayName: projectDisplayName, + primaryRegion: projectRegion, + reference: refer( + variableName!, + projectPaths.normalizeUri(p.toUri(projectFilePath)).toString(), + ), + sdkConfig: ast.SdkConfiguration( + celest: Version.parse(packageVersion), + dart: ast.Sdk( + type: ast.SdkType.dart, + version: Sdk.current.version, + enabledExperiments: celestProject.analysisOptions.enabledExperiments, + ), + flutter: switch (Sdk.current.flutterVersion) { + final flutterVersion? => ast.Sdk( + type: ast.SdkType.flutter, + version: flutterVersion, + enabledExperiments: + celestProject.analysisOptions.enabledExperiments, + ), + _ => null, + }, + targetSdk: await celestProject.determineProjectType(), + featureFlags: featureFlags.toAst(), + ), + location: projectDefineLocation!, + ); + } + + @override + Future> resolveVariables() async { + // TODO(dnys1): Check reserved names + // TODO(dnys1): Check for conflict with secrets + return _envVariableResolver.resolve(); + } + + @override + Future> resolveSecrets() async { + return _secretResolver.resolve(); + } + + (List, bool isCloud) _collectApiMetadata( + Element element, { + required bool hasAuth, + }) { + var hasAuthMetadata = false; + var isCloud = false; + final metadata = + element.metadata.expand((annotation) sync* { + final location = annotation.sourceLocation(element.source!); + final value = annotation.computeConstantValue(); + final type = value?.type; + if (value == null || type == null) { + // TODO(dnys1): Add separate `hints` parameter to `reportError` + /// for suggestions on how to resolve the error/links to docs. + reportError( + 'Could not resolve annotation: $annotation.\n' + 'value=$value, type=$type', + location: location, + ); + return; + } + + void assertSingleAuth() { + if (hasAuthMetadata) { + reportError( + 'Only one `@authenticated` or `@public` annotation ' + 'may be specified on the same function or API library.', + location: location, + ); + } + hasAuthMetadata = true; + } + + switch (type) { + case _ when type.isCloud: + isCloud = true; + return; + case _ when type.isApiAuthenticated: + if (!hasAuth) { + reportError( + 'The `@authenticated` annotation may only be used in ' + 'projects with authentication enabled.', + location: location, + ); + } + assertSingleAuth(); + yield ast.ApiAuthenticated(location: location); + case _ when type.isApiPublic: + assertSingleAuth(); + yield ast.ApiPublic(location: location); + case _ when type.isHttpConfig: + final method = value.getField('method')?.toStringValue(); + final statusCode = value.getField('statusCode')?.toIntValue(); + if (method == null || statusCode == null) { + unreachable('http=$value'); + } + switch (statusCode) { + case >= 200 && < 300 || >= 400 && < 600: + break; + default: + reportError( + 'Invalid HTTP status code. Status codes must be in the range 200-299 or ' + '400-599. Redirection and other codes are not supported at ' + 'this time.', + location: location, + ); + return; + } + yield ast.ApiHttpConfig( + method: method, + statusCode: statusCode, + location: location, + ); + case _ when type.isHttpError: + final errorTypes = + [ + value.getField('type')?.toTypeValue(), + value.getField('type1')?.toTypeValue(), + value.getField('type2')?.toTypeValue(), + value.getField('type3')?.toTypeValue(), + value.getField('type4')?.toTypeValue(), + value.getField('type5')?.toTypeValue(), + value.getField('type6')?.toTypeValue(), + value.getField('type7')?.toTypeValue(), + ].nonNulls.toList(); + final statusCode = value.getField('statusCode')?.toIntValue(); + if (errorTypes.isEmpty || statusCode == null) { + unreachable('httpError=$value'); + } + for (final errorType in errorTypes) { + yield ast.ApiHttpError( + type: typeHelper.toReference(errorType).toTypeReference, + statusCode: statusCode, + location: location, + ); + } + case _ when type.isMiddleware: + // return ast.ApiMiddleware( + // type: typeHelper.toReference(type), + // location: location, + // ); + unreachable(); + default: + return; + } + }).toList(); + + return (metadata, isCloud); + } + + String _applicableHttpMethod({ + required Iterable apiMetadata, + required Iterable functionMetadata, + }) { + return apiMetadata.whereType().firstOrNull?.method ?? + functionMetadata.whereType().firstOrNull?.method ?? + 'POST'; + } + + ast.ApiAuth? _applicableAuth({ + required Iterable apiMetadata, + required Iterable functionMetadata, + }) { + final functionAuth = functionMetadata.whereType().firstOrNull; + final apiAuth = apiMetadata.whereType().firstOrNull; + if (apiAuth is ast.ApiAuthenticated && functionAuth is ast.ApiPublic) { + reportError( + '`@public` has no effect when `@authenticated` is applied at the ' + 'API level. It is recommended to move the `@public` method to ' + 'another API.', + location: functionAuth.location, + severity: AnalysisErrorSeverity.warning, + ); + return apiAuth; + } + if (functionAuth != null) { + return functionAuth; + } + if (apiAuth != null) { + return apiAuth; + } + return null; + } + + // TODO: Implement structured headers for more complex types. + // Actually, needed? + // Do structured headers fit this criteria? + // https://smithy.io/2.0/spec/http-bindings.html#httpheader-serialization-rules + static TypeChecker get _validHeaderQueryTypes => TypeChecker.any( + [ + typeHelper.coreTypes.boolType, + typeHelper.coreTypes.numType, + typeHelper.coreTypes.intType, + typeHelper.coreTypes.doubleType, + typeHelper.coreTypes.stringType, + typeHelper.coreTypes.dateTimeType, + ].map(TypeChecker.fromStatic), + ); + + ast.NodeReference? _parameterReference( + ParameterElement parameter, { + required Iterable variables, + required Iterable secrets, + required ast.ApiAuth? applicableAuth, + required ast.StreamType? streamType, + }) { + final annotations = parameter.metadata; + if (annotations.isEmpty) { + return null; + } + if (annotations.length > 1) { + reportError( + 'Only one annotation may be specified on a parameter', + location: parameter.sourceLocation?.safeExpand( + annotations.fold( + annotations[0].sourceLocation(parameter.source!), + (span, el) { + return span.safeExpand(el.sourceLocation(parameter.source!)); + }, + ), + ), + ); + return null; + } + final annotation = annotations.first; + final location = annotation.sourceLocation(parameter.source!); + final value = annotation.computeConstantValue(); + final annotationType = value?.type; + if (value == null || annotationType == null) { + reportError('Could not resolve annotation', location: location); + return null; + } + const reservedEnvVars = ['PORT']; + switch (annotationType) { + case DartType(isVariable: true): + // Check for migration + // TODO(dnys1): Update for V1 + if (migrateProject) { + switch ((annotation.element, annotation.library)) { + case ( + PropertyAccessorElement( + enclosingElement3: ClassElement(name: 'Env'), + :final name, + ), + final library?, + ): + final libraryPath = p.fromUri(library.source.uri); + assert(p.isWithin(projectPaths.projectRoot, libraryPath)); + final overlay = pendingEdits[libraryPath] ??= {}; + final editText = '@env.$name'; + _logger.finest( + 'Proposing edit: ${location.text} -> $editText ' + '(${location.sourceUrl})', + ); + overlay.add( + // @Env. -> @env. + SourceEdit(location.start.offset, location.length, editText), + ); + } + } + if (!validEnvTypes.isExactlyType(parameter.type)) { + reportError( + 'The type of an environment variable parameter must be one of: ' + '`String`, `Uint8List`, `Uri`, `int`, `double`, `num`, or `bool`', + location: parameter.sourceLocation, + ); + return null; + } + final name = + (value.getField('name') ?? + value.getField('(super)')?.getField('name')) + ?.toStringValue(); + if (name == null) { + reportError( + 'The `name` field is required for environment variables', + location: location, + ); + return null; + } + final reservedCelestVariableOutsideCelest = + name.toUpperCase().startsWith('CELEST_') && + !(annotation.element?.library?.isCelestSdk ?? false); + if (reservedEnvVars.contains(name) || + reservedCelestVariableOutsideCelest) { + reportError( + 'The environment variable name `$name` is reserved by Celest', + location: parameter.sourceLocation, + ); + return null; + } + if (variables.none((envVar) => envVar.name == name)) { + reportError( + 'The environment variable `$name` does not exist', + location: location, + ); + return null; + } + return ast.NodeReference(type: ast.NodeType.variable, name: name); + case DartType(isSecret: true): + if (!validEnvTypes.isExactlyType(parameter.type)) { + reportError( + 'The type of an secret parameter must be one of: ' + '`String`, `Uint8List`, `Uri`, `int`, `double`, `num`, or `bool`', + location: parameter.sourceLocation, + ); + return null; + } + final name = + (value.getField('name') ?? + value.getField('(super)')?.getField('name')) + ?.toStringValue(); + if (name == null) { + reportError( + 'The `name` field is required for secrets', + location: location, + ); + return null; + } + final reservedCelestVariableOutsideCelest = + name.toUpperCase().startsWith('CELEST_') && + !(annotation.element?.library?.isCelestSdk ?? false); + if (reservedEnvVars.contains(name) || + reservedCelestVariableOutsideCelest) { + reportError( + 'The secret name `$name` is reserved by Celest', + location: parameter.sourceLocation, + ); + return null; + } + if (secrets.none((secret) => secret.name == name)) { + reportError('The secret `$name` does not exist', location: location); + return null; + } + return ast.NodeReference(type: ast.NodeType.secret, name: name); + case DartType(isUserContext: true): + if (!TypeChecker.fromStatic( + typeHelper.coreTypes.userType, + ).isExactlyType(parameter.type)) { + reportError( + 'The type of a user context parameter must be `User`', + location: parameter.sourceLocation, + ); + return null; + } + // Check for migration + if (migrateProject) { + switch ((annotation.element, annotation.library)) { + case (PropertyAccessorElement(name: 'user'), final library?): + final overlay = + pendingEdits[p.fromUri(library.source.uri)] ??= {}; + const editText = '@principal'; + _logger.finest( + 'Proposing edit: ${location.text} -> $editText ' + '(${location.sourceUrl})', + ); + overlay.add( + SourceEdit(location.start.offset, location.length, editText), + ); + } + } + if (applicableAuth case null || ast.ApiPublic()) { + if (typeHelper.typeSystem.isNonNullable(parameter.type)) { + reportError( + 'A user context parameter may only be required in an ' + '`@authenticated` function', + location: parameter.sourceLocation, + ); + } + } + return ast.NodeReference( + name: r'$user', + type: ast.NodeType.userContext, + ); + case DartType(isHttpHeader: true): + if (streamType != null) { + reportError( + 'HTTP headers may not be used in functions that return a stream', + location: location, + ); + return null; + } + + var name = value.getField('name')?.toStringValue(); + name ??= parameter.name; + + final validHeaderType = switch (parameter.type) { + final InterfaceType type => _validHeaderQueryTypes.isExactlyType( + type, + ), + _ => false, + }; + if (!validHeaderType) { + reportError( + 'Invalid HTTP header type. The type of an HTTP header parameter must be `String`, `bool`, ' + '`DateTime`, or a number type.', + location: parameter.sourceLocation, + ); + return null; + } + + // https://smithy.io/2.0/spec/http-bindings.html#restricted-http-headers + final disallowedHeaders = CaseInsensitiveMap.from({ + // TODO: This header should be populated by authentication traits. + // 'Authorization': 'This is controlled by Celest authentication traits.', + 'Connection': + 'This is controlled at a lower level by the HTTP client or server.', + 'Content-Length': + 'HTTP clients and servers are responsible for providing a Content-Length header.', + 'Expect': 'This is controlled at a lower level by the HTTP client.', + 'Max-Forwards': + 'This is controlled at a lower level by the HTTP client.', + // TODO: This header should be populated by authentication traits. + // 'Proxy-Authenticate': 'This is controlled by Celest authentication traits.', + 'Server': 'The Server header is controlled by the HTTP server.', + 'TE': + 'This is controlled at a lower level by the HTTP client and server.', + 'Trailer': + 'This is controlled at a lower level by the HTTP client and server.', + 'Transfer-Encoding': + 'This is controlled at a lower level by the HTTP client and server.', + 'Upgrade': 'This is controlled at a lower level by the HTTP server.', + 'User-Agent': + 'Setting a User-Agent is the responsibility of an HTTP client.', + // TODO: This header should be populated by authentication traits. + // 'WWW-Authenticate': 'This is controlled by Celest authentication traits.', + 'Via': 'The Via header is controlled by the HTTP server.', + 'X-Forwarded-For': + 'X-Forwarded-For is an implementation detail of HTTP that does not need to be modeled.', + }); + if (disallowedHeaders[name] case final reason?) { + reportError( + 'The HTTP header `$name` is reserved. $reason', + location: location, + ); + return null; + } + + return ast.NodeReference(type: ast.NodeType.httpHeader, name: name); + case DartType(isHttpQuery: true): + var name = value.getField('name')?.toStringValue(); + name ??= parameter.name; + + final validQueryType = switch (parameter.type) { + InterfaceType(isDartCoreList: true, typeArguments: [final type]) => + _validHeaderQueryTypes.isExactlyType(type), + final InterfaceType type => _validHeaderQueryTypes.isExactlyType( + type, + ), + _ => false, + }; + if (!validQueryType) { + reportError( + 'Invalid HTTP query type. The type of an HTTP query parameter must be `String`, `bool`, ' + '`DateTime`, a number type, or a `List` of these.', + location: parameter.sourceLocation, + ); + return null; + } + + return ast.NodeReference(type: ast.NodeType.httpQuery, name: name); + // TODO + // case DartType(isHttpLabel: true): + } + return null; + } + + var _warnedForNoCloud = false; + void _warnForNoCloud() { + if (_warnedForNoCloud) return; + _warnedForNoCloud = true; + _logger.warning( + 'Beginning in Celest 0.4.0, only functions marked with `@cloud` will be ' + 'included in your backend. All other functions are allowed but will be ' + 'ignored.', + ); + } + + @override + Future resolveApi({ + required String apiFilepath, + required String apiName, + required ResolvedLibraryResult apiLibrary, + required Iterable variables, + required Iterable secrets, + required bool hasAuth, + }) async { + final library = apiLibrary.element; + final (libraryMetdata, _) = _collectApiMetadata(library, hasAuth: hasAuth); + final apiExceptionTypes = await collectExceptionTypes(library); + final functions = Map.fromEntries( + (await library.topLevelElements.whereType().asyncMap(( + func, + ) async { + if (func.isPrivate) { + return null; + } + + final (functionMetadata, isCloud) = _collectApiMetadata( + func, + hasAuth: hasAuth, + ); + + if (!isCloud) { + if (!migrateProject) { + return null; + } + _warnForNoCloud(); + final overlay = pendingEdits[p.fromUri(library.source.uri)] ??= {}; + + final declaration = + apiLibrary.getElementDeclaration(func)!.node + as FunctionDeclaration; + // Put the `@cloud` before the first annotation, or directly + // before the return type if there is no metadata. + final offset = + declaration.metadata.firstOrNull?.offset ?? + declaration.returnType!.offset; + const editText = '@cloud\n'; + _logger.finest( + 'Proposing edit: $editText for ${func.name} ' + '($apiFilepath)', + ); + overlay.add(SourceEdit(offset, 0, editText)); + } + + final returnType = func.returnType; + final (flattenedReturnType, streaming) = switch (returnType) { + final InterfaceType type when type.isDartAsyncStream => ( + type.typeArguments.first.flattened, + true, + ), + _ => (returnType.flattened, false), + }; + final streamType = + streaming ? ast.StreamType.unidirectionalServer : null; + + if (streaming) { + if (!featureFlags.streaming.enabled) { + reportError( + 'Streaming functions are not supported for this project. ' + 'Upgrade to "celest: ^${featureFlags.streaming.enabledVersion}" ' + 'in your pubspec.yaml and try again.', + ); + return null; + } + + final httpConfig = functionMetadata.whereType(); + for (final httpConfig in httpConfig) { + reportError( + 'Functions that return a stream may not customize their HTTP ' + 'configuration', + location: httpConfig.location, + ); + } + } + + final applicableAuth = _applicableAuth( + apiMetadata: libraryMetdata, + functionMetadata: functionMetadata, + ); + final applicableHttpMethod = _applicableHttpMethod( + apiMetadata: streaming ? const [] : libraryMetdata, + functionMetadata: functionMetadata, + ); + final hasBody = switch (applicableHttpMethod) { + 'GET' || 'HEAD' => false, + _ => true, + }; + + final function = ast.CloudFunction( + name: func.name, + apiName: apiName, + typeParameters: await func.typeParameters.asyncMap((type) async { + final typeRef = typeHelper.toReference( + type.instantiate(nullabilitySuffix: NullabilitySuffix.none), + ); + final bound = type.bound; + if (bound == null) { + // Will be caught in serializer. + // TODO(dnys1): Verify that generics are used in parameters/returns + return typeRef; + } + final hasAllowedSubtypes = await bound.hasAllowedSubtypes(); + if (!hasAllowedSubtypes.allowed) { + final disallowedTypes = hasAllowedSubtypes.disallowedTypes + .map((type) => type.element.name) + .join(', '); + reportError( + 'Classes with subtypes (which are not sealed classes) are not ' + 'currently supported as bounds. Disallowed subtypes: ' + '$disallowedTypes', + location: type.sourceLocation, + ); + } + return typeRef; + }), + parameters: await func.parameters.asyncMap((param) async { + final paramType = param.type; + final paramTypeRef = typeHelper.toReference(paramType); + final paramLoc = param.sourceLocation!; + if (paramType.element case final InterfaceElement interface) { + ensureClientReferenceable( + interface, + paramLoc, + type: CustomType.model, + ); + } + final parameter = ast.CloudFunctionParameter( + name: param.name, + type: paramTypeRef, + required: param.isRequired, + named: param.isNamed, + location: paramLoc, + references: _parameterReference( + param, + applicableAuth: applicableAuth, + variables: variables, + secrets: secrets, + streamType: streamType, + ), + annotations: + param.metadata + .map((annotation) => annotation.toDartValue) + .nonNulls + .toList(), + annotationExpressions: + param.metadata + .map((annotation) => annotation.toCodeBuilder) + .nonNulls + .toList(), + defaultTo: param.defaultToValue, + defaultToExpression: param.defaultToExpression, + ); + if (parameter.name.startsWith(r'$')) { + // Ensures that we can have all local variables in the generated + // client start with `$` without conflicting with parameter names + // and no one should absolutely need to do this anyway. + reportError( + r'Parameter names may not start with a dollar sign (`$`)', + location: parameter.location, + ); + } + if (!hasBody && parameter.references == null) { + reportError( + 'Parameters must be mapped with an annotation such as `@httpQuery` ' + 'or `@httpHeader` when the function is a GET or HEAD request.', + location: parameter.location, + ); + } + + // Check must happen before `isSerializable` + final hasAllowedSubtypes = await param.type.hasAllowedSubtypes(); + if (!hasAllowedSubtypes.allowed) { + final disallowedTypes = hasAllowedSubtypes.disallowedTypes + .map((type) => type.element.name) + .join(', '); + reportError( + 'Classes with subtypes (which are not sealed classes) are not ' + 'currently supported as parameters. Disallowed subtypes: ' + '$disallowedTypes', + location: parameter.location, + ); + } + final parameterTypeVerdict = typeHelper.isSerializable(paramType); + if (!parameterTypeVerdict.isSerializable) { + for (final reason in parameterTypeVerdict.reasons) { + reportError( + 'The type of a parameter must be serializable as JSON. $reason', + location: switch (reason.location) { + final reasonLoc? => parameter.location.safeExpand( + reasonLoc, + ), + _ => parameter.location, + }, + ); + } + } + return parameter; + }), + returnType: typeHelper.toReference(returnType), + flattenedReturnType: typeHelper.toReference(flattenedReturnType), + streamType: streamType, + location: func.sourceLocation!, + metadata: functionMetadata, + annotations: + func.metadata + .map((annotation) => annotation.toDartValue) + .nonNulls + .toList(), + annotationExpressions: + func.metadata + .map((annotation) => annotation.toCodeBuilder) + .nonNulls + .toList(), + docs: func.docLines, + ); + + if (flattenedReturnType.element case final InterfaceElement interface) { + ensureClientReferenceable( + interface, + func.sourceLocation!, + type: CustomType.model, + ); + } + + // Check must happen before `isSerializable` + final hasAllowedSubtypes = + await flattenedReturnType.hasAllowedSubtypes(); + if (!hasAllowedSubtypes.allowed) { + final disallowedTypes = hasAllowedSubtypes.disallowedTypes + .map((type) => type.element.name) + .join(', '); + reportError( + 'Classes with subtypes (which are not sealed classes) are not ' + 'currently supported as return types. Disallowed subtypes: ' + '$disallowedTypes', + location: function.location, + ); + } + final returnTypeVerdict = switch (flattenedReturnType) { + VoidType() => const Verdict.yes(), + final flattened => typeHelper.isSerializable(flattened), + }; + if (!returnTypeVerdict.isSerializable) { + for (final reason in returnTypeVerdict.reasons) { + reportError( + 'The return type of a function must be serializable as JSON. $reason', + location: switch (reason.location) { + final reasonLoc? => function.location.safeExpand(reasonLoc), + _ => function.location, + }, + ); + } + } + return MapEntry(function.name, function); + })).nonNulls, + ); + return ast.Api( + name: apiName, + location: SourceFile.fromString( + library.source.contents.data, + url: library.source.uri, + ).span(0, 0), + metadata: libraryMetdata, + functions: functions, + docs: library.docLines, + exceptionTypes: apiExceptionTypes.map(typeHelper.toReference), + ); + } + + @override + Future resolveAuth({ + required String authFilepath, + required ResolvedLibraryResult authLibrary, + }) async { + final (topLevelConstants, hasErrors) = authLibrary.element + .topLevelConstants(errorReporter: _errorReporter); + if (hasErrors) { + return null; + } + final authDefinition = topLevelConstants.firstWhereOrNull( + (el) => el.element.type.isAuth, + ); + if (authDefinition == null) { + _logger.finest('No `Auth` definition found in $authFilepath'); + return null; + } + + final (element: authDefinitionElement, value: authDefinitionValue) = + authDefinition; + + // Validate `auth` variable. + final authDefinitionLocation = authDefinitionElement.sourceLocation; + final authProviders = + authDefinitionValue.getField('providers')?.toListValue(); + if (authProviders == null) { + reportError( + 'The `providers` field is required on `Auth` definitions', + location: authDefinitionLocation, + ); + return null; + } + if (authProviders.isEmpty) { + reportError( + 'At least one Auth provider must be specified in `providers`', + location: authDefinitionLocation, + ); + return null; + } + + final uniqueAuthProviders = LinkedHashSet( + equals: (a, b) => a.type == b.type, + hashCode: (a) => a.type.hashCode, + ); + final uniqueExternalAuthProviders = LinkedHashSet( + equals: (a, b) => a.type == b.type, + hashCode: (a) => a.type.hashCode, + ); + for (final authProvider in authProviders) { + ast.AuthProviderBuilder? provider; + ast.ExternalAuthProviderBuilder? externalProvider; + switch (authProvider.type) { + case InterfaceType(isAuthProviderEmail: true): + provider = ast.EmailAuthProviderBuilder(); + case InterfaceType(isAuthProviderSms: true): + provider = ast.SmsAuthProviderBuilder(); + case InterfaceType(isAuthProviderApple: true): + provider = ast.AppleAuthProviderBuilder(); + case InterfaceType(isAuthProviderGitHub: true): + provider = ast.GitHubAuthProviderBuilder(); + case InterfaceType(isAuthProviderGoogle: true): + provider = ast.GoogleAuthProviderBuilder(); + case InterfaceType(isExternalAuthProviderFirebase: true): + final projectIdValue = authProvider.getField('projectId'); + if (projectIdValue == null) { + // This should be impossible since it's non-nullable. + unreachable( + 'The `projectId` field is required for Firebase auth providers', + ); + } + final projectIdEnvName = projectIdValue.configValueName; + externalProvider = + ast.FirebaseExternalAuthProviderBuilder() + ..projectId.name = projectIdEnvName + ..projectId.location = authDefinitionLocation; + + case InterfaceType(isExternalAuthProviderSupabase: true): + final urlValue = authProvider.getField('url'); + if (urlValue == null) { + // This should be impossible since it's non-nullable. + unreachable( + 'The `url` field is required for Supabase auth providers', + ); + } + final urlVarName = urlValue.configValueName; + final jwtSecretVariable = authProvider.getField('jwtSecret'); + externalProvider = ast.SupabaseExternalAuthProviderBuilder().let((b) { + b + ..projectUrl.name = urlVarName + ..projectUrl.location = authDefinitionLocation; + if (jwtSecretVariable != null && !jwtSecretVariable.isNull) { + final jwtSecretVarName = jwtSecretVariable.configValueName; + b + ..jwtSecret.name = jwtSecretVarName + ..jwtSecret.location = authDefinitionLocation; + } + return b; + }); + + default: + reportError( + 'Unknown auth provider type: ${authProvider.type}', + location: authDefinitionLocation, + ); + continue; + } + if (provider != null) { + provider + ..name = authProvider.variable?.name + ..location = authDefinitionLocation; + final astAuthProvider = provider.build(); + if (!uniqueAuthProviders.add(astAuthProvider)) { + reportError( + 'Duplicate ${astAuthProvider.type.name} auth provider', + location: authDefinitionLocation, + ); + } + } else { + externalProvider! + ..name = authProvider.variable?.name + ..location = authDefinitionLocation; + final astExternalAuthProvider = externalProvider.build(); + if (!uniqueExternalAuthProviders.add(astExternalAuthProvider)) { + reportError( + 'Duplicate ${astExternalAuthProvider.type.name} auth provider', + location: authDefinitionLocation, + ); + } + } + } + return ast.Auth( + location: authDefinitionLocation!, + providers: uniqueAuthProviders.toList(), + externalProviders: uniqueExternalAuthProviders.toList(), + ); + } + + @override + Future resolveDatabase({ + required String databaseFilepath, + required ResolvedLibraryResult databaseLibrary, + }) async { + final (topLevelConstants, hasErrors) = databaseLibrary.element + .topLevelConstants(errorReporter: _errorReporter); + if (hasErrors) { + return null; + } + final databaseDefinition = topLevelConstants.firstWhereOrNull( + (el) => el.element.type.isDatabase, + ); + if (databaseDefinition == null) { + _logger.finest('No `Database` definition found in $databaseFilepath'); + return null; + } + + final (element: databaseDefinitionElement, value: databaseDefinitionValue) = + databaseDefinition; + + // Validate `database` variable. + final databaseDefinitionLocation = + databaseDefinitionElement.sourceLocation!; + final databaseSchema = databaseDefinitionValue.getField('schema'); + if (databaseSchema == null) { + reportError( + 'The `schema` field is required on `Database` definitions', + location: databaseDefinitionLocation, + ); + return null; + } + + final schemaType = databaseSchema.type; + if (schemaType is! DartType || !schemaType.isDriftSchema) { + reportError( + 'Invalid schema type: $schemaType.\n' + 'Only `Schema.drift` is supported for database definitions currently.', + location: databaseDefinitionLocation, + ); + return null; + } + + final driftDatabaseType = + databaseSchema.getField('databaseType')?.toTypeValue(); + if (driftDatabaseType is! InterfaceType) { + reportError( + 'Failed to resolve the Dart type passed to `Schema.drift`', + location: databaseDefinitionLocation, + ); + return null; + } + + final isSubtypeOfDriftDatabase = driftDatabaseType.allSupertypes.any( + (type) => type.isDriftGeneratedDatabase, + ); + if (!isSubtypeOfDriftDatabase) { + reportError( + 'The type passed to `Schema.drift` must be a subtype of `GeneratedDatabase` ' + 'from the `drift` package', + location: databaseDefinitionLocation, + ); + return null; + } + + // Find a constructor we can use + final constructor = driftDatabaseType.element.constructors.firstWhereOrNull( + (ctor) => + ctor.name.isEmpty && + (ctor.parameters.elementAtOrNull(0)?.type.isDriftQueryExecutor ?? + false), + ); + if (constructor == null) { + reportError( + '$driftDatabaseType must have an unnamed constructor that takes a single `QueryExecutor` ' + 'parameter like `$driftDatabaseType(super.e)` or `$driftDatabaseType(QueryExecutor e)`', + location: databaseDefinitionLocation, + ); + return null; + } + + final schemaTypeReference = typeHelper.toReference(driftDatabaseType); + return ast.Database( + name: schemaTypeReference.symbol!, + dartName: databaseDefinitionElement.name, + docs: databaseDefinitionElement.docLines, + schema: ast.DriftDatabaseSchema( + declaration: schemaTypeReference.toTypeReference, + location: databaseDefinitionLocation, + ), + config: ast.CelestDatabaseConfig( + hostname: ast.Variable( + 'CELEST_DATABASE_HOST', + location: databaseDefinitionLocation, + ), + token: ast.Secret( + 'CELEST_DATABASE_TOKEN', + location: databaseDefinitionLocation, + ), + ), + location: databaseDefinitionLocation, + ); + } +} diff --git a/apps/cli/lib/analyzer/resolver/project_resolver.dart b/apps/cli/lib/analyzer/resolver/project_resolver.dart new file mode 100644 index 000000000..f49a0855c --- /dev/null +++ b/apps/cli/lib/analyzer/resolver/project_resolver.dart @@ -0,0 +1,56 @@ +import 'package:analyzer/dart/analysis/results.dart'; +import 'package:celest_ast/celest_ast.dart' as ast; +import 'package:celest_cli/analyzer/analysis_error.dart'; +import 'package:celest_cli/analyzer/celest_analysis_helpers.dart'; +import 'package:source_span/source_span.dart'; + +abstract interface class CelestErrorReporter { + void reportError( + String message, { + AnalysisErrorSeverity? severity, + SourceSpan? location, + }); +} + +abstract base class CelestProjectResolver with CelestAnalysisHelpers { + CelestProjectResolver({required this.migrateProject}); + + final bool migrateProject; + + Future resolveCustomTypes(); + + /// Finds the project in the current workspace. + Future resolveProject({ + required ParsedLibraryResult projectLibrary, + }); + + /// Collects the environment variables of the project. + Future> resolveVariables(); + + /// Collects the secrets of the project. + Future> resolveSecrets(); + + /// Collects the Celest Auth component of the project. + /// + /// Returns `true` if the project uses Celest Auth. + Future resolveAuth({ + required String authFilepath, + required ResolvedLibraryResult authLibrary, + }); + + /// Collects the Celest Functions component of the project. + Future resolveApi({ + required String apiFilepath, + required String apiName, + required ResolvedLibraryResult apiLibrary, + required bool hasAuth, + required Iterable variables, + required Iterable secrets, + }); + + /// Collects the Celest Data components of the project. + Future resolveDatabase({ + required String databaseFilepath, + required ResolvedLibraryResult databaseLibrary, + }); +} diff --git a/apps/cli/lib/ast/ast.dart b/apps/cli/lib/ast/ast.dart new file mode 100644 index 000000000..17216a590 --- /dev/null +++ b/apps/cli/lib/ast/ast.dart @@ -0,0 +1,98 @@ +import 'package:built_collection/built_collection.dart'; +import 'package:celest_ast/celest_ast.dart'; +import 'package:celest_cli/src/utils/reference.dart'; + +extension CloudFunctionExt on CloudFunction { + bool get hasHttpBody { + for (final parameter in parameters) { + if (!parameter.includeInClient) continue; + switch (parameter.references?.type) { + case NodeType.httpHeader || NodeType.httpQuery || NodeType.httpLabel: + continue; + default: + break; + } + return true; + } + return false; + } +} + +extension CloudFunctionParameterExt on CloudFunctionParameter { + /// Whether to include this parameter in the generated client. + bool get includeInClient { + if (type.isFunctionContext) return false; + switch (references?.type) { + case NodeType.variable || NodeType.secret || NodeType.userContext: + return false; + default: + break; + } + return true; + } +} + +extension AuthConfigurationValues on Auth { + BuiltListMultimap get variables { + return BuiltListMultimap.build((b) { + for (final authProvider in providers) { + switch (authProvider) { + case EmailAuthProvider(): + break; + case SmsAuthProvider(): + break; + case GitHubAuthProvider(): + break; + case GoogleAuthProvider(): + break; + case AppleAuthProvider(): + break; + } + } + for (final externalAuthProvider in externalProviders) { + switch (externalAuthProvider) { + case FirebaseExternalAuthProvider(:final projectId): + b.add(FirebaseExternalAuthProvider.$type, projectId); + case SupabaseExternalAuthProvider(:final projectUrl): + b.add(SupabaseExternalAuthProvider.$type, projectUrl); + } + } + }); + } + + BuiltListMultimap get secrets { + return BuiltListMultimap.build((b) { + for (final authProvider in providers) { + switch (authProvider) { + case EmailAuthProvider(): + case SmsAuthProvider(): + break; + case GitHubAuthProvider(:final clientId, :final clientSecret): + b.addValues(GitHubAuthProvider.$type, [clientId, clientSecret]); + case GoogleAuthProvider(:final clientId, :final clientSecret): + b.addValues(GoogleAuthProvider.$type, [clientId, clientSecret]); + case AppleAuthProvider( + :final clientId, + :final teamId, + :final keyId, + :final privateKey, + ): + b.addValues(AppleAuthProvider.$type, [ + clientId, + teamId, + keyId, + privateKey, + ]); + } + } + for (final externalAuthProvider in externalProviders) { + switch (externalAuthProvider) { + case FirebaseExternalAuthProvider(): + break; + case SupabaseExternalAuthProvider(): + break; + } + } + }); + } +} diff --git a/apps/cli/lib/ast/project_diff.dart b/apps/cli/lib/ast/project_diff.dart new file mode 100644 index 000000000..ce31e164e --- /dev/null +++ b/apps/cli/lib/ast/project_diff.dart @@ -0,0 +1,156 @@ +import 'package:celest_ast/celest_ast.dart'; +import 'package:collection/collection.dart'; + +typedef ProjectDiffContext = ({AstNode parent, AstNode? old}); + +final class ProjectDiff extends AstVisitorWithArg { + ProjectDiff(this.oldProject); + + final Project oldProject; + + bool requiresRestart = false; + + @override + void visitProject(Project project, ProjectDiffContext context) { + for (final api in project.apis.values) { + visitApi(api, (parent: project, old: oldProject.apis[api.name])); + } + for (final env in project.variables) { + visitVariable(env, ( + parent: project, + old: oldProject.variables.firstWhereOrNull( + (oldEnv) => oldEnv.name == env.name, + ), + )); + } + } + + @override + void visitApi(Api api, ProjectDiffContext context) { + final (parent: _, :old as Api?) = context; + if (old == null) { + requiresRestart = true; + } + for (final metadata in api.metadata) { + visitNode(metadata, ( + parent: api, + old: old?.metadata.firstWhereOrNull( + (oldMetadata) => oldMetadata == metadata, + ), + )); + } + for (final function in api.functions.values) { + visitFunction(function, ( + parent: api, + old: old?.functions[function.name], + )); + } + } + + @override + void visitApiAuthenticated( + ApiAuthenticated annotation, + ProjectDiffContext context, + ) {} + + @override + void visitApiMiddleware( + ApiMiddleware annotation, + ProjectDiffContext context, + ) {} + + @override + void visitApiPublic(ApiPublic annotation, ProjectDiffContext context) {} + + @override + void visitApiHttpMetadata( + ApiHttpMetadata metadata, + ProjectDiffContext context, + ) {} + + @override + void visitVariable(Variable variable, ProjectDiffContext context) { + final (parent: _, :old as Variable?) = context; + if (old == null) { + requiresRestart = true; + } + } + + @override + void visitSecret(Secret secret, covariant ProjectDiffContext context) { + final (parent: _, :old as Secret?) = context; + if (old == null) { + requiresRestart = true; + } + } + + @override + void visitFunction(CloudFunction function, ProjectDiffContext context) { + final (parent: _, old: oldFunction as CloudFunction?) = context; + if (oldFunction == null) { + requiresRestart = true; + return; + } + if (function.returnType != oldFunction.returnType) { + requiresRestart = true; + return; + } + for (final parameter in function.parameters) { + visitNode(parameter, ( + parent: function, + old: oldFunction.parameters.firstWhereOrNull( + (oldParameter) => oldParameter.name == parameter.name, + ), + )); + } + for (final metadata in function.metadata) { + visitNode(metadata, ( + parent: function, + old: oldFunction.metadata.firstWhereOrNull( + (oldMetadata) => oldMetadata == metadata, + ), + )); + } + } + + @override + void visitParameter( + CloudFunctionParameter parameter, + ProjectDiffContext context, + ) { + final (parent: _, old: oldParameter as CloudFunctionParameter?) = context; + if (oldParameter == null) { + requiresRestart = true; + return; + } + if (parameter.type != oldParameter.type) { + requiresRestart = true; + return; + } + } + + @override + void visitAuth(Auth auth, ProjectDiffContext context) {} + + @override + void visitAuthProvider(AuthProvider provider, ProjectDiffContext context) {} + + @override + void visitExternalAuthProvider( + ExternalAuthProvider provider, + covariant ProjectDiffContext context, + ) {} + + @override + void visitDatabase(Database database, covariant ProjectDiffContext context) { + // TODO: implement visitDatabase + } + + @override + void visitDatabaseSchema( + DatabaseSchema schema, + covariant ProjectDiffContext context, + ) { + // TODO: implement visitSchema + } +} diff --git a/apps/cli/lib/codegen/allocator.dart b/apps/cli/lib/codegen/allocator.dart new file mode 100644 index 000000000..c0009fd5e --- /dev/null +++ b/apps/cli/lib/codegen/allocator.dart @@ -0,0 +1,182 @@ +import 'package:celest_cli/src/context.dart'; +import 'package:celest_cli/src/utils/error.dart'; +import 'package:celest_cli/src/utils/path.dart'; +import 'package:code_builder/code_builder.dart'; +import 'package:logging/logging.dart'; +import 'package:meta/meta.dart'; +import 'package:path/path.dart' as path; + +enum PrefixingStrategy { + indexed, + pretty, + none, + + /// Useful for generating part of libraries. + /// + /// In this mode, all imports must be manually managed. + noImports, +} + +enum PathStrategy { + /// Pretty, relative paths, the way a user would type it. + /// + /// Used for client-facing codegen where relative paths are guaranteed to exist. + pretty, + + /// Robust path handling, with little manipulation. + /// + /// Used for non-client-facing codegen where the aesthetics do not matter and pretty, + /// relative paths may fail. + robust, +} + +final class CelestAllocator implements Allocator { + CelestAllocator({ + required this.forFile, + this.prefixingStrategy = PrefixingStrategy.indexed, + required this.pathStrategy, + @visibleForTesting String? packageName, + @visibleForTesting String? clientPackageName, + }) : packageName = packageName ?? celestProject.pubspec.name, + clientPackageName = + clientPackageName ?? celestProject.clientPubspec.name; + + static const _doNotPrefix = ['dart:core', 'package:meta/meta.dart']; + static final Logger _logger = Logger('CelestAllocator'); + + final String forFile; + final PrefixingStrategy prefixingStrategy; + final PathStrategy pathStrategy; + + final String packageName; + final String clientPackageName; + + late final _fileContext = path.Context( + current: p.dirname(forFile), + style: p.style, + ); + final importMap = {}; + var _keys = 1; + + @override + String allocate(Reference reference) { + final symbol = reference.symbol!; + var url = reference.url; + if (url == null || _doNotPrefix.contains(url) || p.equals(url, forFile)) { + return symbol; + } + // Fix `file://` and root-relative paths to match expected `pathStrategy`. + var uri = Uri.parse(url); + const supportedSchemes = ['', 'file', 'project', 'package', 'dart']; + if (!supportedSchemes.contains(uri.scheme)) { + final fileUri = p.toUri(url); + if (!supportedSchemes.contains(fileUri.scheme)) { + unreachable('Unexpected reference URL: $url (Tried: [$uri, $fileUri])'); + } + uri = fileUri; + } + switch (uri) { + case Uri(scheme: '' || 'file'): + final path = uri.toFilePath(); + final absolutePath = + _fileContext.isRelative(path) ? _fileContext.absolute(path) : path; + if (p.equals(absolutePath, forFile)) { + return symbol; + } + + final normalizedUri = projectPaths.fileToPackageUri(absolutePath); + if (normalizedUri.scheme != 'package') { + _logger.finest('Failed to normalize $normalizedUri'); + // Ensure that the path being imported is in the outputs directory, + // the only place we should ever use non-package: imports. + assert(p.isWithin(projectPaths.outputsDir, forFile)); + + // To prevent compilation issues, we must also assert that the file + // doing the import is also in the outputs directory. + assert(p.isWithin(projectPaths.outputsDir, path)); + + // We need to use relative paths because the path will be made + // absolute by the frontend server, but needs paths that translate + // to the virtual filesystem root. + final urlStylePath = absolutePath.to(p.url); + final urlStyleRoot = p.dirname(forFile).to(p.url); + url = p.url.relative(urlStylePath, from: urlStyleRoot); + uri = Uri.file(url); + break; + } + + _logger.finest('Normalized $uri to $normalizedUri'); + uri = normalizedUri; + url = uri.toString(); + + case Uri( + scheme: 'package', + pathSegments: [final package, ...final segments], + ) + when package == packageName || package == clientPackageName: + final importFilepath = p.joinAll([ + if (package == packageName) + projectPaths.packageRoot + else + projectPaths.clientPackageRoot, + ...segments, + ]); + if (p.equals(importFilepath, forFile)) { + return symbol; + } + case Uri(scheme: 'package' || 'dart'): + break; + default: + unreachable('Unexpected reference URL: $url ($uri)'); + } + return _importFor(url, uri, symbol); + } + + String _importFor(String url, Uri uri, String symbol) { + switch (prefixingStrategy) { + case PrefixingStrategy.indexed: + return '${importMap.putIfAbsent(url, _nextKey)}.$symbol'; + case PrefixingStrategy.pretty: + final import = importMap.putIfAbsent(url, () => prefixForUrl(uri)); + return switch (import) { + final import? => '$import.$symbol', + null => symbol, + }; + case PrefixingStrategy.none: + importMap.putIfAbsent(url, () => null); + return symbol; + case PrefixingStrategy.noImports: + return symbol; + } + } + + String? prefixForUrl(Uri uri) { + switch (uri) { + case Uri(scheme: 'package', pathSegments: [final package, ...]) + when package == packageName || package == clientPackageName: + return null; + case Uri(scheme: 'package', pathSegments: [final package, ...]) + when package.startsWith('celest'): + return r'_$celest'; + case Uri(scheme: '' || 'file'): + return null; + case Uri(pathSegments: [final packageName, ..., final filename]): + // TODO(dnys1): This may start causing issues if, for example, Celest + // starts importing internal libraries where the types conflict with + // public members. + // + // But this should be fairly robust and I don't expect we'll see any + // issues. + return '_\$${packageName}_${p.url.basenameWithoutExtension(filename)}'; + default: + _logger.fine('Could not allocate prefix.', 'Unexpected URI: $uri'); + } + return null; + } + + String _nextKey() => '_i${_keys++}'; + + @override + Iterable get imports => + importMap.keys.map((u) => Directive.import(u, as: importMap[u])); +} diff --git a/apps/cli/lib/codegen/api/dockerfile_generator.dart b/apps/cli/lib/codegen/api/dockerfile_generator.dart new file mode 100644 index 000000000..576e86d43 --- /dev/null +++ b/apps/cli/lib/codegen/api/dockerfile_generator.dart @@ -0,0 +1,60 @@ +import 'package:celest_ast/celest_ast.dart' as ast; +import 'package:celest_ast/celest_ast.dart'; +import 'package:celest_cli/src/utils/error.dart'; + +/// Generates a `Dockerfile` for the user's project so they can self-host it. +final class DockerfileGenerator { + DockerfileGenerator({required this.project}); + + final ast.Project project; + + static const String _dartTemplate = r''' +FROM celestdev/dart-builder:{{version}} AS build + +WORKDIR /app +COPY celest.aot.dill main.aot.dill + +RUN [ "/usr/lib/dart/bin/utils/gen_snapshot", "--snapshot_kind=app-aot-elf", "--elf=/app/main.aot", "/app/main.aot.dill" ] + +FROM celestdev/dart-runtime:{{version}} + +WORKDIR /app +COPY celest.json . +COPY --from=build /app/main.aot . + +ENV PORT=8080 +EXPOSE 8080 +'''; + + static const String _flutterTemplate = r''' +FROM celestdev/flutter-builder:{{version}} AS build + +WORKDIR /app +COPY celest.aot.dill main.aot.dill + +RUN [ "/usr/lib/dart/bin/utils/gen_snapshot", "--snapshot_kind=app-aot-elf", "--elf=/app/main.aot", "/app/main.aot.dill" ] + +FROM celestdev/flutter-runtime:{{version}} + +WORKDIR /app +COPY celest.json . +COPY --from=build /app/main.aot . + +ENV PORT=8080 +EXPOSE 8080 +'''; + + String generate() { + return switch (project.sdkConfig.targetSdk) { + SdkType.flutter => _flutterTemplate.replaceAll( + '{{version}}', + project.sdkConfig.flutter!.version.canonicalizedVersion, + ), + SdkType.dart => _dartTemplate.replaceAll( + '{{version}}', + project.sdkConfig.dart.version.canonicalizedVersion, + ), + final unknown => unreachable('Unknown SDK: $unknown'), + }; + } +} diff --git a/apps/cli/lib/codegen/api/entrypoint_generator.dart b/apps/cli/lib/codegen/api/entrypoint_generator.dart new file mode 100644 index 000000000..c108e9bcd --- /dev/null +++ b/apps/cli/lib/codegen/api/entrypoint_generator.dart @@ -0,0 +1,898 @@ +import 'dart:collection'; + +import 'package:analyzer/dart/element/element.dart' as ast; +import 'package:analyzer/dart/element/type.dart' as ast; +import 'package:celest_ast/celest_ast.dart'; +import 'package:celest_cli/ast/ast.dart'; +import 'package:celest_cli/codegen/api/local_api_generator.dart'; +import 'package:celest_cli/serialization/common.dart'; +import 'package:celest_cli/serialization/from_string_generator.dart'; +import 'package:celest_cli/serialization/serializer_generator.dart'; +import 'package:celest_cli/src/context.dart'; +import 'package:celest_cli/src/types/dart_types.dart'; +import 'package:celest_cli/src/types/type_graph.dart'; +import 'package:celest_cli/src/utils/analyzer.dart'; +import 'package:celest_cli/src/utils/error.dart'; +import 'package:celest_cli/src/utils/recase.dart'; +import 'package:celest_cli/src/utils/reference.dart'; +import 'package:celest_cli/src/utils/run.dart'; +import 'package:code_builder/code_builder.dart'; +import 'package:collection/collection.dart'; + +final class EntrypointGenerator { + EntrypointGenerator({ + required this.project, + required this.api, + required this.function, + required this.httpConfig, + required this.outputDir, + }); + + final Project project; + final Api api; + final CloudFunction function; + final ResolvedHttpConfig httpConfig; + final String outputDir; + + late final String projectRoot = projectPaths.projectRoot; + late final String targetName = '${function.name.pascalCase}Target'; + + // Map of serializer classes to their type tokens, if any. + final _customSerializers = LinkedHashSet( + equals: (a, b) => a.type == b.type, + hashCode: (a) => a.type.hashCode, + ); + final _anonymousRecordTypes = {}; + + Expression _decodeReference( + CloudFunctionParameter param, + NodeReference reference, + ) { + Expression paramExp; + switch (reference.type) { + case NodeType.variable || NodeType.secret: + final dartType = + reference.type == NodeType.variable + ? DartTypes.celest.environmentVariable + : DartTypes.celest.secret; + paramExp = DartTypes.celest.globalContext.property('expect').call([ + dartType.constInstance([literalString(reference.name, raw: true)]), + ]); + if (param.type.symbol == 'Uint8List') { + paramExp = DartTypes.convert.base64Decode.call([paramExp]); + } else { + final toType = switch (param.type.symbol) { + 'int' => DartTypes.core.int, + 'double' => DartTypes.core.double, + 'bool' => DartTypes.core.bool, + 'num' => DartTypes.core.num, + 'Uri' => DartTypes.core.uri, + 'String' => null, + _ => unreachable(), + }; + if (toType != null) { + paramExp = toType.property('parse').call([paramExp]); + } + } + case NodeType.userContext: + paramExp = DartTypes.celest.globalContext + .property(param.type.isNullableOrFalse ? 'get' : 'expect') + .call([DartTypes.celest.contextKey.property('principal')]); + + case NodeType.httpHeader || NodeType.httpQuery: + final map = + reference.type == NodeType.httpHeader + ? 'headers' + : 'queryParameters'; + var fromMap = refer(map).index(literalString(reference.name)); + final isNullable = param.type.isNullableOrFalse; + final (toType, isList) = switch (param.type.toTypeReference) { + TypeReference(:final types) when types.isNotEmpty => ( + types.first, + true, + ), + final type => (type, false), + }; + + var serialized = fromMap; + if (isList) { + serialized = refer('el'); + } else { + serialized = serialized.nullChecked.property('first'); + } + final deserialized = fromString( + toType, + serialized, + defaultValue: param.defaultToExpression, + ); + if (!isList) { + if (isNullable) { + return fromMap + .equalTo(literalNull) + .conditional(literalNull, deserialized); + } + return deserialized; + } + if (!isNullable) { + fromMap = fromMap.nullChecked; + } + paramExp = fromMap + .nullableProperty('map', isNullable) + .call([ + Method( + (m) => + m + ..requiredParameters.add( + Parameter( + (p) => + p + ..name = 'el' + ..type = DartTypes.core.string, + ), + ) + ..lambda = true + ..body = deserialized.code, + ).closure, + ]) + .property('toList') + .call([]); + default: + unreachable('Invalid reference type: ${reference.type}'); + } + return paramExp; + } + + Library generate() { + final library = LibraryBuilder(); + // final middleware = [ + // ...api.metadata, + // ...function.metadata, + // ].whereType().toList(); + final innerHandle = Method( + (m) => + m + ..returns = switch (function.streamType) { + null => DartTypes.core.future(DartTypes.shelf.response), + _ => DartTypes.core.stream(DartTypes.core.object.nullable), + } + ..name = 'innerHandle' + ..types.addAll(function.typeParameters) + ..requiredParameters.addAll([ + Parameter( + (p) => + p + ..type = typeHelper.toReference(jsonMapType) + ..name = 'request', + ), + ]) + ..optionalParameters.addAll([ + Parameter( + (p) => + p + ..type = DartTypes.core.map( + DartTypes.core.string, + DartTypes.core.list(DartTypes.core.string), + ) + ..name = 'headers' + ..named = true + ..required = true, + ), + Parameter( + (p) => + p + ..type = DartTypes.core.map( + DartTypes.core.string, + DartTypes.core.list(DartTypes.core.string), + ) + ..name = 'queryParameters' + ..named = true + ..required = true, + ), + ]) + ..modifier = switch (function.streamType) { + null => MethodModifier.async, + _ => MethodModifier.asyncStar, + } + ..body = Block((b) { + final functionReference = refer( + function.name, + function.location.sourceUrl.toString(), + ); + final positionalParams = []; + final namedParams = {}; + for (final param in function.parameters) { + Expression paramExp; + if (param.references case final reference?) { + paramExp = _decodeReference(param, reference); + } else { + final fromMap = refer( + 'request', + ).index(literalString(param.name, raw: true)); + final deserialized = jsonGenerator.fromJson( + param.type, + fromMap, + defaultValue: param.defaultToExpression, + inNullableContext: true, + ); + paramExp = deserialized; + } + if (param.named) { + namedParams[param.name] = paramExp; + } else { + positionalParams.add(paramExp); + } + } + if (api.exceptionTypes.isNotEmpty) { + b.statements.add(const Code('try {')); + } + var response = functionReference.call( + positionalParams, + namedParams, + function.typeParameters.map((t) => t.noBound).toList(), + ); + final returnType = function.returnType; + final flattenedReturnType = function.flattenedReturnType; + final dartReturnType = typeHelper.fromReference(returnType); + if (dartReturnType.isDartAsyncFuture || + dartReturnType.isDartAsyncFutureOr) { + response = response.awaited; + } else if (dartReturnType.isDartAsyncStream) { + response = CodeExpression( + Block.of([ + const Code('await for (final response in '), + response.code, + const Code(') {'), + ]), + ); + } + switch (flattenedReturnType.symbol) { + case 'void': + const resultBody = literalNull; + switch (function.streamType) { + case null: + b.addExpression(response); + b.addExpression( + DartTypes.shelf.response + .newInstance( + [literalNum(httpConfig.status)], + { + 'headers': literalConstMap({ + 'Content-Type': 'application/json', + }), + 'body': DartTypes.celest.jsonUtf8 + .property('encode') + .call([resultBody]), + }, + ) + .returned, + ); + default: + b.statements.addAll([ + response.code, + const Code('yield '), + resultBody.statement, + const Code('}'), + ]); + } + default: + final result = jsonGenerator.toJson( + flattenedReturnType, + refer('response'), + ); + switch (function.streamType) { + case null: + b.addExpression( + declareFinal('response').assign(response), + ); + b.addExpression( + DartTypes.shelf + .response( + [literalNum(httpConfig.status)], + { + 'headers': literalConstMap({ + 'Content-Type': 'application/json', + }), + 'body': DartTypes.celest.jsonUtf8 + .property('encode') + .call([result]), + }, + ) + .returned, + ); + default: + b.statements.addAll([ + response.code, + const Code('yield '), + result.statement, + const Code('}'), + ]); + } + } + + final typeHiearchy = topologicallySortTypes( + api.exceptionTypes.map(typeHelper.fromReference), + ); + final exceptionTypes = typeHiearchy + .where( + (type) => !identical(type, typeHelper.coreTypes.objectType), + ) + .map(typeHelper.toReference); + final dartExceptionTypes = { + for (final exceptionType in exceptionTypes) + exceptionType: typeHelper.fromReference(exceptionType), + }; + + final rawStatusCodes = httpConfig.statusMappings.toMap().map( + (type, status) => + MapEntry(typeHelper.fromReference(type), status), + ); + + final exceptionCodes = {}; + for (final exceptionType in exceptionTypes) { + final dartExceptionType = dartExceptionTypes[exceptionType]!; + + var statusCode = httpConfig.statusMappings[exceptionType]?.let( + literalNum, + ); + if (statusCode == null && + httpConfig.statusMappings.isNotEmpty) { + final relevantExceptionCodes = + SplayTreeMap((a, b) { + if (identical(a, b) || a == b) { + return 0; + } + // We want the most specific type to be first. + return typeHelper.typeSystem.isSubtypeOf(a, b) ? -1 : 1; + }); + rawStatusCodes.forEach((type, statusCode) { + if (typeHelper.typeSystem.isSubtypeOf( + dartExceptionType, + type, + )) { + relevantExceptionCodes[type] = statusCode; + } + }); + statusCode = relevantExceptionCodes.values.firstOrNull?.let( + literalNum, + ); + } + + // Check if the type or one of its supertypes is annotated with an + // `@httpError` config. + final exceptionElement = dartExceptionType.element; + if (statusCode == null && + exceptionElement is ast.InterfaceElement) { + final errorConfig = + [ + ...exceptionElement.metadata, + ...exceptionElement.allSupertypes.expand( + (it) => it.element.metadata, + ), + ].where((m) => m.isHttpError).firstOrNull; + if (errorConfig?.computeConstantValue() case final value?) { + statusCode = value + .getField('statusCode') + ?.toIntValue() + ?.let(literalNum); + } + } + + // Fallback based on the type hierarchy. + statusCode ??= + dartExceptionType.isErrorType + ? literalNum(500) + : literalNum(400); + + exceptionCodes[exceptionType] = statusCode; + } + + for (final exceptionType in exceptionTypes) { + final dartExceptionType = dartExceptionTypes[exceptionType]!; + + b.statements.add( + Code.scope( + (alloc) => '} on ${alloc(exceptionType)} catch (e, st) {', + ), + ); + final statusCode = exceptionCodes[exceptionType]!; + b.addExpression(declareConst('statusCode').assign(statusCode)); + + final messageExpression = switch (dartExceptionType) { + ast.DartType(isCloudExceptionType: true) => refer( + 'e', + ).property('message'), + ast.DartType(element: ast.InterfaceElement(:final fields)) + when fields.any( + (f) => f.name == 'message' && f.type.isDartCoreString, + ) => + refer('e').property('message'), + _ => null, + }; + + b.addExpression( + DartTypes.celest.globalContext + .property('logger') + .property('severe') + .call([ + messageExpression ?? + refer('e').property('toString').call([]), + refer('e'), + refer('st'), + ]), + ); + + b.addExpression( + declareFinal('status').assign( + literalMap({ + '@status': literalMap({ + 'code': refer('statusCode'), + 'message': messageExpression, + 'details': literalList([ + literalMap({ + '@type': dartExceptionType.externalUri( + project.name, + ), + 'value': jsonGenerator.toJson( + exceptionType, + refer('e'), + ), + }), + collectionIf( + DartTypes.celest.globalContext + .property('environment') + .notEqualTo( + DartTypes.celest.environment.property( + 'production', + ), + ), + literalMap({ + '@type': typeHelper.coreTypes.stackTraceType + .externalUri(project.name), + 'value': jsonGenerator.toJson( + DartTypes.core.stackTrace, + refer('st'), + ), + }), + ), + ]), + }), + }), + ), + ); + switch (function.streamType) { + case null: + b.addExpression( + DartTypes.shelf.response + .newInstance( + [refer('statusCode')], + { + 'headers': literalConstMap({ + 'Content-Type': 'application/json', + }), + 'body': DartTypes.celest.jsonUtf8 + .property('encode') + .call([refer('status')]), + }, + ) + .returned, + ); + default: + b.statements.add(const Code('yield status;')); + } + } + if (api.exceptionTypes.isNotEmpty) { + b.statements.add(const Code('}')); + } + }), + ); + + final Code handleBody; + if (function.typeParameters.isEmpty) { + handleBody = + refer('innerHandle') + .call( + [refer('request')], + { + 'headers': refer('headers'), + 'queryParameters': refer('queryParameters'), + }, + ) + .returned + .statement; + } else { + handleBody = Block((b) { + // TODO: `@type.T` + final request = refer('request'); + final types = []; + for (final typeParameter in function.typeParameters) { + final typeMapName = '\$${typeParameter.symbol!}'; + b.addExpression( + declareFinal(typeMapName).assign( + request + .index(literalString(typeMapName, raw: true)) + .asA(DartTypes.core.string.nullable), + ), + ); + types.add(refer(typeMapName)); + } + b.addExpression( + declareFinal(r'$types').assign(literalRecord(types, {})), + ); + b.statements.addAll([ + const Code(r'return switch($types) {'), + for (final typeParameters in _combinations( + function.typeParameters.map(_subtypes), + )) ...[ + literalRecord( + typeParameters + .map( + (t) => switch (t) { + _BoundReference(:final reference) => literalString( + reference.symbol!, + raw: true, + ).or(literalNull), + _SubtypeReference(:final reference) => literalString( + reference.symbol!, + raw: true, + ), + }, + ) + .toList(), + {}, + ).code, + const Code(' => '), + refer('innerHandle') + .call( + [request], + { + 'headers': refer('headers'), + 'queryParameters': refer('queryParameters'), + }, + typeParameters.references, + ) + .code, + const Code(','), + ], + const Code('_ => '), + // TODO(dnys1): Test this + DartTypes.celest.serializationException + .newInstance([ + literalString(r'Invalid type parameters: ${$types}'), + ]) + .thrown + .code, + const Code(',};'), + ]); + }); + } + + final handle = Method( + (m) => + m + ..returns = switch (function.streamType) { + null => DartTypes.core.future(DartTypes.shelf.response), + _ => DartTypes.core.stream(DartTypes.core.object.nullable), + } + ..annotations.add(DartTypes.core.override) + ..name = 'handle' + ..requiredParameters.addAll([ + Parameter( + (p) => + p + ..name = 'request' + ..type = typeHelper.toReference(jsonMapType), + ), + ]) + ..optionalParameters.addAll([ + Parameter( + (p) => + p + ..type = DartTypes.core.map( + DartTypes.core.string, + DartTypes.core.list(DartTypes.core.string), + ) + ..name = 'headers' + ..named = true + ..required = true, + ), + Parameter( + (p) => + p + ..type = DartTypes.core.map( + DartTypes.core.string, + DartTypes.core.list(DartTypes.core.string), + ) + ..name = 'queryParameters' + ..named = true + ..required = true, + ), + ]) + ..body = handleBody, + ); + + final allTypes = Set.of( + [ + function.flattenedReturnType, + ...function.parameters.map((p) => p.type), + ...api.exceptionTypes, + ].where((type) => !type.isFunctionContext), + ); + for (final type in allTypes) { + final dartType = typeHelper.fromReference(type); + _customSerializers.addAll(typeHelper.customSerializers(dartType)); + if ((dartType, type) case ( + final ast.RecordType dartType, + final RecordType recordType, + )) { + _anonymousRecordTypes[dartType.symbol] = + // Typedefs should always point to the non-nullable + // version since the type is only used to invoke the + // serializer and the serializer handles null values. + recordType.rebuild((r) => r.isNullable = false); + } + } + + Expression? authMiddleware; + final authMetadata = [ + ...function.metadata.whereType(), + ...api.metadata.whereType(), + ]; + // final authRequired = authMetadata.whereType().isNotEmpty; + if (authMetadata.isNotEmpty) { + if (project.auth?.providers.isNotEmpty ?? false) { + authMiddleware = DartTypes.celest.middleware.property('shelf').call([ + refer( + 'CelestCloudAuth', + 'package:celest_cloud_auth/celest_cloud_auth.dart', + ) + .property('of') + .call([DartTypes.celest.globalContext]) + .property('middleware') + .property('call'), + ]); + } + final externalAuthProviders = [...?project.auth?.externalProviders]; + for (final externalAuthProvider in externalAuthProviders) { + switch (externalAuthProvider) { + case FirebaseExternalAuthProvider(:final projectId): + authMiddleware = DartTypes.celest.firebaseAuthMiddleware + .newInstance([], { + 'projectId': DartTypes.celest.globalContext + .property('expect') + .call([ + DartTypes.celest.environmentVariable.constInstance([ + literalString( + projectId.name, + raw: projectId.name.contains(r'$'), + ), + ]), + ]), + 'required': literalBool(false), + }); + case SupabaseExternalAuthProvider( + :final projectUrl, + :final jwtSecret, + ): + authMiddleware = DartTypes.celest.supabaseAuthMiddleware + .newInstance([], { + 'url': DartTypes.celest.globalContext.property('expect').call( + [ + DartTypes.celest.environmentVariable.constInstance([ + literalString( + projectUrl.name, + raw: projectUrl.name.contains(r'$'), + ), + ]), + ], + ), + if (jwtSecret != null) + 'jwtSecret': DartTypes.convert.utf8.property('encode').call( + [ + DartTypes.celest.globalContext.property('expect').call([ + DartTypes.celest.secret.constInstance([ + literalString( + jwtSecret.name, + raw: jwtSecret.name.contains(r'$'), + ), + ]), + ]), + ], + ), + 'required': literalBool(false), + }); + } + } + } + final middlewares = [if (authMiddleware != null) authMiddleware]; + + final target = Class( + (c) => + c + ..name = targetName + ..modifier = ClassModifier.final$ + ..extend = + project.sdkConfig.featureEnabled(FeatureFlag.streaming) + ? switch (function.streamType) { + null => DartTypes.celest.cloudFunctionHttpTarget, + _ => DartTypes.celest.cloudEventSourceTarget, + } + : DartTypes.celest.cloudFunctionTarget + ..methods.addAll([ + Method( + (m) => + m + ..name = 'name' + ..annotations.add(DartTypes.core.override) + ..returns = DartTypes.core.string + ..type = MethodType.getter + ..lambda = true + ..body = literalString(function.name).code, + ), + if (middlewares.isNotEmpty) + Method( + (m) => + m + ..name = 'middlewares' + ..annotations.add(DartTypes.core.override) + ..returns = DartTypes.core.list( + DartTypes.celest.middleware, + ) + ..type = MethodType.getter + ..lambda = true + ..body = literalList(middlewares).code, + ), + if (function.streamType == null) + Method( + (m) => + m + ..name = 'method' + ..annotations.add(DartTypes.core.override) + ..returns = DartTypes.core.string + ..type = MethodType.getter + ..lambda = true + ..body = literalString(httpConfig.route.method).code, + ) + else + Method( + (m) => + m + ..name = 'hasBody' + ..annotations.add(DartTypes.core.override) + ..returns = DartTypes.core.bool + ..type = MethodType.getter + ..lambda = true + ..body = literalBool(function.hasHttpBody).code, + ), + if (function.typeParameters.isEmpty) + innerHandle.rebuild( + (m) => + m + ..name = 'handle' + ..annotations.add(DartTypes.core.override), + ) + else ...[ + handle, + innerHandle, + ], + if (_customSerializers.isNotEmpty) + Method( + (m) => + m + ..returns = DartTypes.core.void$ + ..annotations.add(DartTypes.core.override) + ..name = 'init' + ..body = Block.of( + _customSerializers + .sorted((a, b) { + final aLoc = a.type.url; + final bLoc = b.type.url; + if (aLoc == null) { + return -1; + } + if (bLoc == null) { + return 1; + } + final loc = aLoc.compareTo(bLoc); + if (loc != 0) { + return loc; + } + final aSym = a.type.symbol!; + final bSym = b.type.symbol!; + return aSym.compareTo(bSym); + }) + .map((s) => s.initAll), + ), + ), + ]), + ); + + final entrypoint = + LocalApiGenerator( + project: project, + targets: {'/': refer(targetName)}, + ).body; + library.body.addAll([ + target, + ...entrypoint, + ..._anonymousRecordTypes.entries + .map( + (recordType) => TypeDef( + (t) => + t + ..name = recordType.key + ..definition = recordType.value, + ), + ) + .toList() + ..sort((a, b) => a.name.compareTo(b.name)), + ..._customSerializers.map((s) => s.serializerClass).nonNulls.toList() + ..sort((a, b) => a.name.compareTo(b.name)), + ]); + return library.build(); + } +} + +List<_Reference> _subtypes(Reference typeParameter) { + final typeParameterType = + typeHelper.fromReference(typeParameter) as ast.TypeParameterType; + final typeParameterBound = + typeParameterType.bound.element as ast.InterfaceElement; + final subtypes = <_Reference>{ + _BoundReference(typeHelper.toReference(typeParameterType.bound)), + }; + for (final subtype in typeHelper.subtypes[typeParameterBound]!) { + subtypes.add(_SubtypeReference(typeHelper.toReference(subtype))); + } + return subtypes.toList(); +} + +Iterable> _combinations( + Iterable> types, +) sync* { + if (types.isEmpty) { + return; + } + if (types.length == 1) { + yield* types.first.map((t) => [t]); + return; + } + final type = types.first; + final rest = types.skip(1); + for (final t in type) { + for (final r in _combinations(rest)) { + yield [t, ...r]; + } + } +} + +sealed class _Reference { + const _Reference(this.reference); + + final Reference reference; +} + +final class _SubtypeReference extends _Reference { + _SubtypeReference(super.reference); + + @override + bool operator ==(Object other) => + other is _SubtypeReference && reference == other.reference; + + @override + int get hashCode => reference.hashCode; +} + +final class _BoundReference extends _Reference { + _BoundReference(super.reference); + + @override + bool operator ==(Object other) => + other is _BoundReference && reference == other.reference; + + @override + int get hashCode => reference.hashCode; +} + +extension on Iterable<_Reference> { + List get references => map((r) => r.reference).toList(); +} diff --git a/apps/cli/lib/codegen/api/local_api_generator.dart b/apps/cli/lib/codegen/api/local_api_generator.dart new file mode 100644 index 000000000..686cf3220 --- /dev/null +++ b/apps/cli/lib/codegen/api/local_api_generator.dart @@ -0,0 +1,127 @@ +import 'dart:collection'; + +import 'package:celest_ast/celest_ast.dart'; +import 'package:celest_cli/codegen/cloud/cloud_client_types.dart'; +import 'package:celest_cli/src/types/dart_types.dart'; +import 'package:celest_cli/src/utils/error.dart'; +import 'package:code_builder/code_builder.dart'; + +class LocalApiGenerator { + LocalApiGenerator({ + required this.project, + required Map targets, + }) : // Provides consistent ordering which helps with codegen diffing. + // TODO(dnys1): Order by API then definition order. + targets = SplayTreeMap.of(targets); + + final Project project; + final SplayTreeMap targets; + + Method get _mainMethod => Method( + (m) => + m + ..name = 'main' + ..returns = DartTypes.core.future(DartTypes.core.void$) + ..modifier = MethodModifier.async + ..body = Code.scope( + (alloc) => switch (project.sdkConfig.targetSdk) { + SdkType.dart => ''' +return start(); +''', + + // TODO(dnys1): No longer possible with stateful isolates (WS/SSE). + // ''' + // await Future.wait(eagerError: true, [ + // for (var i = 0; i < ${alloc(DartTypes.io.platform)}.numberOfProcessors; i++) + // ${alloc(DartTypes.isolate.isolate)}.run(start), + // ]); + // ''', + SdkType.flutter => ''' +return start(); +''', + // TODO(dnys1): Not sure if this is possible... + // ''' + // final rootIsolateToken = ${alloc(DartTypes.flutter.servicesBiding)}.rootIsolateToken!; + // await Future.wait(eagerError: true, [ + // for (var i = 0; i < ${alloc(DartTypes.io.platform)}.numberOfProcessors; i++) + // ${alloc(DartTypes.isolate.isolate)}.run(() => start(rootIsolateToken)), + // ]); + // ''' + final unknown => unreachable('Unknown project type: $unknown'), + }, + ), + ); + + Method get _setupCallback { + return Method((m) { + m + ..requiredParameters.add( + Parameter( + (p) => + p + ..name = 'context' + ..type = DartTypes.celest.context, + ), + ) + ..modifier = MethodModifier.async + ..body = Block((b) { + if (project.databases.isNotEmpty) { + b.addExpression( + CloudClientTypes.dataClass.ref.property('init').call([ + refer('context'), + ]).awaited, + ); + } + if (project.auth?.providers.isNotEmpty ?? false) { + b.addExpression( + CloudClientTypes.authClass.ref.property('init').call([ + refer('context'), + ]).awaited, + ); + } + }); + }); + } + + Method get _startMethod => Method( + (m) => + m + ..name = 'start' + ..returns = DartTypes.core.future(DartTypes.core.void$) + ..modifier = MethodModifier.async + // ..requiredParameters.addAll([ + // if (projectType == CelestProjectType.flutter) + // Parameter( + // (p) => p + // ..name = 'rootIsolateToken' + // ..type = DartTypes.flutter.rootIsolateToken, + // ), + // ]) + ..body = Block((b) { + // if (projectType == CelestProjectType.flutter) { + // b.addExpression( + // DartTypes.flutter.backgroundIsolateBinaryMessenger + // .property('ensureInitialized') + // .call([refer('rootIsolateToken')]), + // ); + // } + b.addExpression( + DartTypes.celest.serve.call([], { + 'targets': literalMap( + targets.map((route, reference) { + return MapEntry( + literalString(route), + reference.newInstance([]), + ); + }), + ), + 'setup': _setupCallback.closure, + }).awaited, + ); + }), + ); + + List get body => [_mainMethod, _startMethod]; + + Library generate() => Library((library) => library.body.addAll(body)); +} diff --git a/apps/cli/lib/codegen/client/categories/client_auth_generator.dart b/apps/cli/lib/codegen/client/categories/client_auth_generator.dart new file mode 100644 index 000000000..093336f1c --- /dev/null +++ b/apps/cli/lib/codegen/client/categories/client_auth_generator.dart @@ -0,0 +1,336 @@ +import 'package:celest_ast/celest_ast.dart' as ast; +import 'package:celest_cli/codegen/client/client_generator.dart'; +import 'package:celest_cli/codegen/client/client_types.dart'; +import 'package:celest_cli/codegen/client_code_generator.dart'; +import 'package:celest_cli/src/types/dart_types.dart'; +import 'package:celest_cli/src/utils/error.dart'; +import 'package:celest_cli/src/utils/run.dart'; +import 'package:code_builder/code_builder.dart'; + +final class ClientAuthGenerator { + ClientAuthGenerator({required this.auth}) { + _library = + LibraryBuilder() + ..name = '' + ..comments.addAll(kClientHeader) + ..body.add(lazySpec(_client.build)); + } + + final ast.Auth auth; + + late final LibraryBuilder _library; + final _client = + ExtensionTypeBuilder() + ..name = ClientTypes.authClass.name + ..primaryConstructorName = '_' + ..representationDeclaration = RepresentationDeclaration( + (r) => + r + ..declaredRepresentationType = _hubClass + ..name = '_hub', + ) + ..implements.add(refer('Auth', 'package:celest_auth/celest_auth.dart')) + ..constructors.add( + Constructor( + (c) => + c + ..requiredParameters.add( + Parameter( + (p) => + p + ..name = 'celest' + ..type = refer( + 'CelestBase', + 'package:celest_core/_internal.dart', + ), + ), + ) + ..optionalParameters.add( + Parameter( + (p) => + p + ..name = 'storage' + ..type = DartTypes.nativeStorage.nativeStorage + ..named = true + ..required = true, + ), + ) + ..initializers.add( + refer('_hub') + .assign( + _hubClass.newInstance( + [refer('celest')], + {'storage': refer('storage')}, + ), + ) + .code, + ), + ), + ); + + static final _hubClass = refer( + 'AuthImpl', + 'package:celest_auth/src/auth_impl.dart', + ); + + static const _externalProviderDocs = >{ + ast.AuthProviderType.firebase: [ + '/// Creates an instance of [ExternalAuth] for Firebase Auth.', + '///', + '/// See the [Firebase docs](https://firebase.google.com/docs/flutter/setup)', + '/// for more information on how to initialize Firebase.', + '///', + '/// ```dart', + '/// Future main() async {', + '/// WidgetsFlutterBinding.ensureInitialized();', + '/// await Firebase.initializeApp();', + '/// celest.init(', + '/// externalAuth: ExternalAuth.firebase(FirebaseAuth.instance),', + '/// );', + '/// }', + '/// ```', + ], + ast.AuthProviderType.supabase: [ + '/// ### Supabase', + '///', + '/// See the [Supabase docs](https://supabase.com/docs/reference/dart/introduction)', + '/// for more information on how to initialize Supabase.', + '///', + '/// ```dart', + '/// Future main() async {', + '/// WidgetsFlutterBinding.ensureInitialized();', + '/// await Supabase.initialize(', + "/// url: 'https://.supabase.co',", + '/// ...', + '/// );', + '/// celest.init(', + '/// externalAuth: ExternalAuth.supabase(supabase.auth),', + '/// );', + '/// }', + '/// ```', + ], + }; + + Class? get _externalAuthClass { + if (auth.externalProviders.isEmpty) { + return null; + } + final cls = + ClassBuilder() + ..name = 'ExternalAuth' + ..extend = DartTypes.celestAuth.tokenSource + ..docs.addAll([ + '/// External authentication providers which can be used to sign in to Celest.', + '///', + '/// This class is passed to `celest.init` to configure the token sources for', + '/// the external auth providers.', + ]) + ..constructors.add( + Constructor( + (c) => + c + ..name = 'of' + ..constant = true + ..docs.add('/// {@macro celest_auth.token_source.of}') + ..optionalParameters.addAll([ + Parameter( + (p) => + p + ..name = 'provider' + ..toSuper = true + ..named = true + ..required = true, + ), + Parameter( + (p) => + p + ..name = 'stream' + ..toSuper = true + ..named = true + ..required = true, + ), + ]) + ..initializers.add( + refer('super').property('of').call([]).code, + ), + ), + ); + for (final provider in auth.externalProviders) { + switch (provider.type) { + case ast.AuthProviderType.firebase: + CodegenDependencies.current.add('firebase_auth'); + case ast.AuthProviderType.supabase: + CodegenDependencies.current.add('gotrue'); + CodegenDependencies.current.add('stream_transform'); + _library.directives.add( + // For `.startWith` Stream extension + Directive.import( + 'package:stream_transform/stream_transform.dart', + show: const ['Concatenate'], + ), + ); + default: + break; + } + cls.constructors.add( + Constructor( + (c) => + c + ..name = provider.name + ..factory = true + ..docs.addAll(_externalProviderDocs[provider.type]!) + ..requiredParameters.add( + Parameter( + (p) => + p + ..name = provider.type.name + ..type = switch (provider.type) { + ast.AuthProviderType.firebase => refer( + 'FirebaseAuth', + 'package:firebase_auth/firebase_auth.dart', + ), + ast.AuthProviderType.supabase => refer( + 'GoTrueClient', + 'package:gotrue/gotrue.dart', + ), + _ => unreachable(), + }, + ), + ) + ..body = + refer('ExternalAuth') + .newInstanceNamed('of', [], { + 'provider': DartTypes.celestAuth.authProviderType + .property(provider.type.name), + 'stream': switch (provider.type) { + ast.AuthProviderType.firebase => CodeExpression( + Code( + '${provider.type.name}.idTokenChanges()' + '.asyncMap((user) => user?.getIdToken())', + ), + ), + ast.AuthProviderType.supabase => run(() { + final authChangeEvent = refer( + 'AuthChangeEvent', + 'package:gotrue/gotrue.dart', + ); + return CodeExpression( + Code.scope( + (alloc) => + '${provider.type.name}.onAuthStateChange' + '.where((state) => const [' + ' ${alloc(authChangeEvent)}.initialSession, ' + ' ${alloc(authChangeEvent)}.tokenRefreshed, ' + ' ${alloc(authChangeEvent)}.signedIn, ' + ' ${alloc(authChangeEvent)}.signedOut, ' + '].contains(state.event),)' + '.map((state) => state.session?.accessToken)' + // From `package:stream_transform` + '.startWith(supabase.currentSession?.accessToken)', + ), + ); + }), + _ => unreachable(), + }, + }) + .returned + .statement, + ), + ); + } + return cls.build(); + } + + Library generate() { + for (final provider in auth.providers) { + switch (provider) { + case ast.EmailAuthProvider(): + final emailClass = refer( + 'Email', + 'package:celest_auth/src/auth_impl.dart', + ); + _client.methods.add( + Method( + (m) => + m + ..returns = emailClass + ..type = MethodType.getter + ..name = 'email' + ..lambda = true + ..body = emailClass.newInstance([refer('_hub')]).code, + ), + ); + case ast.SmsAuthProvider(): + final smsClass = refer( + 'Sms', + 'package:celest_auth/src/auth_impl.dart', + ); + _client.methods.add( + Method( + (m) => + m + ..returns = smsClass + ..type = MethodType.getter + ..name = 'sms' + ..lambda = true + ..body = smsClass.newInstance([refer('_hub')]).code, + ), + ); + case ast.AppleAuthProvider(): + final appleClass = refer( + 'Apple', + 'package:celest_auth/src/auth_impl.dart', + ); + _client.methods.add( + Method( + (m) => + m + ..returns = appleClass + ..type = MethodType.getter + ..name = 'apple' + ..lambda = true + ..body = appleClass.newInstance([refer('_hub')]).code, + ), + ); + case ast.GitHubAuthProvider(): + final gitHubClass = refer( + 'GitHub', + 'package:celest_auth/src/auth_impl.dart', + ); + _client.methods.add( + Method( + (m) => + m + ..returns = gitHubClass + ..type = MethodType.getter + ..name = 'gitHub' + ..lambda = true + ..body = gitHubClass.newInstance([refer('_hub')]).code, + ), + ); + case ast.GoogleAuthProvider(): + final googleClass = refer( + 'Google', + 'package:celest_auth/src/auth_impl.dart', + ); + _client.methods.add( + Method( + (m) => + m + ..returns = googleClass + ..type = MethodType.getter + ..name = 'google' + ..lambda = true + ..body = googleClass.newInstance([refer('_hub')]).code, + ), + ); + } + } + + if (_externalAuthClass case final externalAuth?) { + _library.body.add(externalAuth); + } + + return _library.build(); + } +} diff --git a/apps/cli/lib/codegen/client/categories/client_functions_generator.dart b/apps/cli/lib/codegen/client/categories/client_functions_generator.dart new file mode 100644 index 000000000..2c2bb9cdc --- /dev/null +++ b/apps/cli/lib/codegen/client/categories/client_functions_generator.dart @@ -0,0 +1,500 @@ +import 'dart:collection'; + +import 'package:analyzer/dart/element/element.dart' as dart_ast; +import 'package:analyzer/dart/element/type.dart' as dart_ast; +import 'package:analyzer/dart/element/type.dart' hide RecordType; +import 'package:celest_ast/celest_ast.dart' as ast; +import 'package:celest_cli/ast/ast.dart'; +import 'package:celest_cli/codegen/client/client_generator.dart'; +import 'package:celest_cli/codegen/client/client_types.dart'; +import 'package:celest_cli/serialization/common.dart'; +import 'package:celest_cli/serialization/from_string_generator.dart'; +import 'package:celest_cli/serialization/serializer_generator.dart'; +import 'package:celest_cli/src/context.dart'; +import 'package:celest_cli/src/types/dart_types.dart'; +import 'package:celest_cli/src/utils/analyzer.dart'; +import 'package:celest_cli/src/utils/recase.dart'; +import 'package:celest_cli/src/utils/reference.dart'; +import 'package:code_builder/code_builder.dart'; + +final class ClientFunctionsGenerator { + ClientFunctionsGenerator({ + required this.resolvedProject, + required this.project, + required this.apis, + }) { + apis.sort((a, b) => a.name.compareTo(b.name)); + _library = + LibraryBuilder() + ..name = '' + ..comments.addAll(kClientHeader) + ..body.add(lazySpec(_client.build)); + } + + final ast.ResolvedProject resolvedProject; + final ast.Project project; + final List apis; + + final customSerializers = LinkedHashSet( + equals: (a, b) => a.type == b.type, + hashCode: (a) => a.type.hashCode, + ); + final anonymousRecordTypes = {}; + + late final LibraryBuilder _library; + final _client = ClassBuilder()..name = ClientTypes.functionsClass.name; + + final _classBuilders = {}; + ClassBuilder _beginClass(String name) { + final cached = _classBuilders[name]; + if (cached != null) { + return cached; + } + final builder = ClassBuilder()..name = name; + _library.body.add(lazySpec(builder.build)); + return builder; + } + + void _sendHttp({ + required BlockBuilder b, + required ast.CloudFunction function, + required ast.ResolvedCloudFunction resolvedFunction, + required Expression uri, + required Map headers, + required Expression? payload, + }) { + final httpClient = ClientTypes.topLevelClient.ref.property('httpClient'); + final functionCall = + httpClient + .property(resolvedFunction.httpConfig.route.method.toLowerCase()) + .call( + [uri], + { + 'headers': (headers.isEmpty ? literalConstMap : literalMap)({ + 'Content-Type': literalString('application/json'), + 'Accept': literalString('application/json'), + ...headers, + }), + if (payload != null) + 'body': DartTypes.celest.jsonUtf8.property('encode').call([ + payload, + ]), + }, + ) + .awaited; + + b.addExpression(declareFinal(r'$response').assign(functionCall)); + b.addExpression( + declareFinal(r'$body').assign( + DartTypes.celest.jsonUtf8.property('decode').call([ + refer(r'$response').property('bodyBytes'), + ]), + ), + ); + + final returnedBody = + typeHelper.fromReference(function.flattenedReturnType) is VoidType + ? const Code('return;') + : jsonGenerator + .fromJson( + function.flattenedReturnType, + refer(r'$body'), + inNullableContext: true, + ) + .returned + .statement; + + final handleError = refer('_throwError').call([], { + 'code': refer(r'$response').property('statusCode'), + 'body': refer(r'$body').asA(typeHelper.toReference(jsonMapType)), + }); + + b.statements + ..add( + handleError.wrapWithBlockIf( + refer( + r'$response', + ).property('statusCode').notEqualTo(literalNum(200)), + ), + ) + ..add(returnedBody); + } + + void _streamEvents({ + required BlockBuilder b, + required ast.CloudFunction function, + required Expression uri, + required Expression? payload, + }) { + final eventClient = ClientTypes.topLevelClient.ref.property('eventClient'); + b.addExpression( + declareFinal( + r'$channel', + ).assign(eventClient.property('connect').call([uri])), + ); + final channel = refer(r'$channel'); + if (payload != null) { + b.addExpression(channel.property('sink').property('add').call([payload])); + } + + final returnedBody = + typeHelper.fromReference(function.flattenedReturnType) is VoidType + ? const Code('return;') + : jsonGenerator + .fromJson( + function.flattenedReturnType, + refer(r'$event'), + inNullableContext: true, + ) + .returned + .statement; + b.addExpression( + channel.property('stream').property('map').call([ + Method( + (m) => + m + ..requiredParameters.add(Parameter((p) => p.name = r'$event')) + ..body = Block.of([ + const Code(r''' +if ($event is Map && $event.containsKey('@error')) { + _throwError(body: $event); +}'''), + returnedBody, + ]), + ).closure, + ]).returned, + ); + } + + void _generateApi(ast.Api api, ast.ResolvedApi resolvedApi) { + final apiType = ClientTypes.api(api); + final apiClass = + _beginClass(apiType.name) + ..docs.addAll(api.docs) + ..methods.add(_throwError(api)); + + _client.fields.add( + Field( + (f) => + f + ..docs.addAll(api.docs) + ..modifier = FieldModifier.final$ + ..name = api.name.camelCase + ..assignment = apiType.ref.newInstance([]).code, + ), + ); + + final functions = api.functions.values.toList()..sort(); + for (final function in functions) { + final resolvedFunction = resolvedApi.functions[function.name]!; + final clientParameters = function.parameters.where( + (p) => p.includeInClient, + ); + final bodyParameters = Set.of(clientParameters); + final headerParameters = {}; + final queryParameters = {}; + for (final parameter in clientParameters) { + switch (parameter.references) { + case ast.NodeReference(type: ast.NodeType.httpHeader, :final name): + bodyParameters.remove(parameter); + headerParameters[name] = parameter; + case ast.NodeReference(type: ast.NodeType.httpQuery, :final name): + bodyParameters.remove(parameter); + queryParameters[name] = parameter; + default: + break; + } + } + final functionCall = Method( + (m) => + m + ..name = function.name.camelCase + ..returns = switch (function.streamType) { + null => DartTypes.core.future( + function.flattenedReturnType.noBound, + ), + _ => DartTypes.core.stream( + function.flattenedReturnType.noBound, + ), + } + ..types.addAll(function.typeParameters) + ..modifier = switch (function.streamType) { + null => MethodModifier.async, + _ => null, + } + ..docs.addAll(function.docs) + ..annotations.addAll( + function.annotationExpressions.map( + (annotation) => annotation.stripConst, + ), + ) + ..annotations.add( + DartTypes.celest.cloudFunction.newInstance([], { + 'api': literalString(api.name), + 'function': literalString(function.name), + }), + ) + ..requiredParameters.addAll( + clientParameters + .where((p) => p.required && !p.named) + .map( + (param) => Parameter( + (p) => + p + ..name = param.name + ..type = param.type.noBound + ..defaultTo = param.defaultToExpression?.code + ..annotations.addAll( + param.annotationExpressions.map( + (annotation) => annotation.stripConst, + ), + ), + ), + ), + ) + ..optionalParameters.addAll( + clientParameters + .where((p) => !p.required || p.named) + .map( + (param) => Parameter( + (p) => + p + ..name = param.name + ..type = param.type.noBound + ..named = param.named + ..required = param.required + ..defaultTo = param.defaultToExpression?.code + ..annotations.addAll( + param.annotationExpressions.map( + (annotation) => annotation.stripConst, + ), + ), + ), + ), + ) + ..body = Block((b) { + final typeMaps = {}; + for (final typeParameter in function.typeParameters) { + final typeParameterType = + typeHelper.fromReference(typeParameter) + as dart_ast.TypeParameterType; + final typeParameterBound = + typeParameterType.bound.element + as dart_ast.InterfaceElement; + final typeMap = {}; + final bound = typeHelper.toReference(typeParameterType.bound); + typeMap[bound] = literalString(bound.symbol!, raw: true); + for (final subtype + in typeHelper.subtypes[typeParameterBound]!) { + final subtypeReference = typeHelper.toReference(subtype); + typeMap[subtypeReference] = literalString( + subtypeReference.symbol!, + raw: true, + ); + } + final typeMapName = '\$${typeParameter.symbol!}'; + b.addExpression( + declareConst(typeMapName).assign(literalConstMap(typeMap)), + ); + typeMaps[typeParameter] = typeMapName; + } + + final headers = headerParameters.map((name, parameter) { + return MapEntry( + CodeExpression( + Block.of([ + if (parameter.type.isNullableOrFalse) + Code('if ($name != null) '), + literalString(name, raw: true).code, + ]), + ), + generateToString(parameter.type, refer(parameter.name)), + ); + }); + final query = literalMap( + queryParameters.map((name, parameter) { + return MapEntry( + CodeExpression( + Block.of([ + if (parameter.type.isNullableOrFalse) + Code('if ($name != null) '), + literalString(name, raw: true).code, + ]), + ), + generateToString(parameter.type, refer(parameter.name)), + ); + }), + ); + + final baseUri = ClientTypes.topLevelClient.ref.property( + 'baseUri', + ); + var uri = baseUri.property('resolve').call([ + literalString(function.route), + ]); + if (queryParameters.isNotEmpty) { + uri = uri.property('replace').call([], { + 'queryParameters': query, + }); + } + + Expression? payload; + if (bodyParameters.isNotEmpty || + function.typeParameters.isNotEmpty) { + payload = literalMap({ + for (final typeParameter in function.typeParameters) + literalString(typeMaps[typeParameter]!, raw: true): + refer( + typeMaps[typeParameter]!, + ).index(refer(typeParameter.symbol!)).nullChecked, + for (final parameter in bodyParameters) + literalString(parameter.name, raw: true): jsonGenerator + .toJson(parameter.type, refer(parameter.name)), + }); + } + switch (function.streamType) { + case null: + _sendHttp( + b: b, + function: function, + resolvedFunction: resolvedFunction, + uri: uri, + headers: headers, + payload: payload, + ); + default: + assert( + headers.isEmpty, + 'Headers are not supported for streams. Should be caught in ' + 'resolver.', + ); + _streamEvents( + b: b, + function: function, + uri: uri, + payload: payload, + ); + } + }), + ); + apiClass.methods.add(functionCall); + final allTypes = Set.of( + [ + function.flattenedReturnType, + ...clientParameters.map((p) => p.type), + ...api.exceptionTypes, + ].where((type) => !type.isFunctionContext), + ); + for (final type in allTypes) { + final dartType = typeHelper.fromReference(type); + customSerializers.addAll(typeHelper.customSerializers(dartType)); + if ((dartType, type) case ( + final dart_ast.RecordType dartType, + final RecordType recordType, + )) { + anonymousRecordTypes[dartType.symbol] = + // Typedefs should always point to the non-nullable + // version since the type is only used to invoke the + // serializer and the serializer handles null values. + recordType.rebuild((r) => r.isNullable = false); + } + } + } + } + + Method _throwError(ast.Api api) => Method((m) { + m + ..name = '_throwError' + ..returns = DartTypes.core.never + ..optionalParameters.addAll([ + Parameter( + (p) => + p + ..name = 'code' + ..named = true + ..type = DartTypes.core.int.nullable, + ), + Parameter( + (p) => + p + ..name = 'body' + ..named = true + ..required = true + ..type = typeHelper.toReference(jsonMapType), + ), + ]) + ..body = Block((b) { + b.statements.add( + Code.scope( + (alloc) => ''' +final status = body['@status'] as Map?; +final message = status?['message'] as String?; +final details = status?['details'] as ${alloc(DartTypes.celest.jsonList)}?; +final (errorType, errorValue, stackTrace) = switch (details) { + null || [] => const (null, null, StackTrace.empty), + [ + final errorDetails as Map, + { + '@type': 'dart.core.StackTrace', + 'value': final stackTraceValue as String + }, + ... + ] => + ( + errorDetails['@type'], + errorDetails['value'], + StackTrace.fromString(stackTraceValue), + ), + [final errorDetails as Map, ...] => ( + errorDetails['@type'], + errorDetails['value'], + StackTrace.empty, + ), +}; +''', + ), + ); + b.statements.add(const Code('switch (errorType) {')); + for (final exceptionType in api.exceptionTypes) { + final dartExceptionType = typeHelper.fromReference(exceptionType); + final deserializedException = jsonGenerator.fromJson( + exceptionType, + refer('errorValue'), + inNullableContext: true, + ); + final exceptionUri = dartExceptionType.externalUri(project.name)!; + b.statements.addAll([ + const Code('case '), + literalString(exceptionUri, raw: exceptionUri.contains(r'$')).code, + const Code(': '), + DartTypes.core.error.property('throwWithStackTrace').call([ + deserializedException, + refer('stackTrace'), + ]).statement, + ]); + } + b.statements.addAll([ + const Code('default: '), + DartTypes.core.error.property('throwWithStackTrace').call([ + DartTypes.celest.cloudException.newInstanceNamed('http', [], { + 'code': refer('code'), + 'message': refer('message'), + 'details': refer('details') + .ifNullThen(refer('body')) + .parenthesized + .asA(DartTypes.celest.jsonValue), + }), + DartTypes.core.stackTrace.property('empty'), + ]).statement, + const Code('}'), + ]); + }); + }); + + Library generate() { + for (final api in apis) { + _generateApi(api, resolvedProject.apis[api.name]!); + } + return _library.build(); + } +} diff --git a/apps/cli/lib/codegen/client/categories/client_serializers_generator.dart b/apps/cli/lib/codegen/client/categories/client_serializers_generator.dart new file mode 100644 index 000000000..1b11a68cd --- /dev/null +++ b/apps/cli/lib/codegen/client/categories/client_serializers_generator.dart @@ -0,0 +1,94 @@ +import 'package:celest_cli/serialization/serializer_generator.dart'; +import 'package:celest_cli/src/types/dart_types.dart'; +import 'package:celest_cli/src/utils/reference.dart'; +import 'package:code_builder/code_builder.dart'; +import 'package:collection/collection.dart'; + +final class ClientSerializersGenerator { + ClientSerializersGenerator({ + required this.customSerializers, + required this.anonymousRecordTypes, + }); + + final Set customSerializers; + final Map anonymousRecordTypes; + + Method get _initSerializers { + return Method( + (m) => + m + ..returns = DartTypes.core.void$ + ..name = 'initSerializers' + ..optionalParameters.add( + Parameter( + (p) => + p + ..name = 'serializers' + ..type = DartTypes.celest.serializers.nullable + ..named = true, + ), + ) + ..body = + DartTypes.async.runZoned + .call( + [ + Method( + (m) => + m + ..body = Block.of( + customSerializers + .sorted((a, b) { + final aLoc = a.type.url; + final bLoc = b.type.url; + if (aLoc == null) { + return -1; + } + if (bLoc == null) { + return 1; + } + final loc = aLoc.compareTo(bLoc); + if (loc != 0) { + return loc; + } + final aSym = a.type.symbol!; + final bSym = b.type.symbol!; + return aSym.compareTo(bSym); + }) + .map((s) => s.initAll), + ), + ).closure, + ], + { + 'zoneValues': literalMap({ + DartTypes.celest.serializers: refer('serializers'), + }), + }, + ) + .returned + .statement, + ); + } + + Library generate() => Library( + (lib) => + lib.body + ..add(_initSerializers) + ..addAll( + anonymousRecordTypes.entries + .map( + (recordType) => TypeDef( + (t) => + t + ..name = recordType.key + ..definition = recordType.value, + ), + ) + .toList() + ..sort((a, b) => a.name.compareTo(b.name)), + ) + ..addAll( + customSerializers.map((s) => s.serializerClass).nonNulls.toList() + ..sort((a, b) => a.name.compareTo(b.name)), + ), + ); +} diff --git a/apps/cli/lib/codegen/client/client_generator.dart b/apps/cli/lib/codegen/client/client_generator.dart new file mode 100644 index 000000000..d1a6d8aca --- /dev/null +++ b/apps/cli/lib/codegen/client/client_generator.dart @@ -0,0 +1,515 @@ +import 'package:celest_ast/celest_ast.dart' as ast; +import 'package:celest_cli/codegen/client/categories/client_auth_generator.dart'; +import 'package:celest_cli/codegen/client/categories/client_functions_generator.dart'; +import 'package:celest_cli/codegen/client/categories/client_serializers_generator.dart'; +import 'package:celest_cli/codegen/client/client_types.dart'; +import 'package:celest_cli/project/celest_project.dart'; +import 'package:celest_cli/serialization/serializer_generator.dart'; +import 'package:celest_cli/src/context.dart'; +import 'package:celest_cli/src/types/dart_types.dart'; +import 'package:celest_cli/src/utils/path.dart'; +import 'package:celest_cli/src/utils/reference.dart'; +import 'package:code_builder/code_builder.dart'; +import 'package:collection/collection.dart'; + +const kClientHeader = [ + 'Generated by Celest. This file should not be modified manually, but', + 'it can be checked into version control.', +]; + +final class _ReferencedTypesCollector extends ast.AstVisitor { + _ReferencedTypesCollector(); + + final Set _types = {}; + Set get types { + return { + for (final type in _types) + if (type.url case final url?) + if (url.startsWith('package:celest_backend')) type, + }; + } + + @override + void visitApi(ast.Api api) { + _types.addAll(api.exceptionTypes); + api.functions.values.forEach(visitFunction); + } + + @override + void visitFunction(ast.CloudFunction function) { + _types.add(function.flattenedReturnType); + function.parameters.forEach(visitParameter); + } + + @override + void visitParameter(ast.CloudFunctionParameter parameter) { + _types.add(parameter.type); + } + + @override + void visitProject(ast.Project project) { + project.apis.values.forEach(visitApi); + } + + @override + void visitApiAuthenticated(ast.ApiAuthenticated annotation) {} + + @override + void visitApiHttpMetadata(ast.ApiHttpMetadata metadata) {} + + @override + void visitApiMiddleware(ast.ApiMiddleware annotation) {} + + @override + void visitApiPublic(ast.ApiPublic annotation) {} + + @override + void visitAuth(ast.Auth auth) {} + + @override + void visitAuthProvider(ast.AuthProvider provider) {} + + @override + void visitVariable(ast.Variable variable) {} + + @override + void visitSecret(ast.Secret secret) {} + + @override + void visitExternalAuthProvider(ast.ExternalAuthProvider provider) {} + + @override + void visitDatabase(ast.Database database) { + // TODO: implement visitDatabase + } + + @override + void visitDatabaseSchema(ast.DatabaseSchema schema) { + // TODO: implement visitSchema + } +} + +final class ClientGenerator { + ClientGenerator({ + required this.project, + required this.resolvedProject, + required this.projectUris, + }) { + final referencedTypes = _ReferencedTypesCollector(); + project.accept(referencedTypes); + _library = + LibraryBuilder() + ..name = '' + ..comments.addAll(kClientHeader) + ..directives.addAll([ + if (project.auth != null) ...[ + Directive.export( + p + .relative( + ClientPaths.auth, + from: p.dirname(ClientPaths.client), + ) + .to(p.posix), + ), + // TODO(dnys1): This may cause conflicts with other packages/types + Directive.export('package:celest_auth/celest_auth.dart'), + ], + ...referencedTypes.types + .groupSetsBy((ref) => ref.url!) + .entries + .map( + (symbols) => Directive.export( + symbols.key, + show: symbols.value.map((s) => s.symbol!).toSet().toList(), + ), + ), + ]) + ..body.addAll([ + _client, + _celestEnvironment, + lazySpec(_clientClass.build), + ]); + } + + final ast.Project project; + final ast.ResolvedProject resolvedProject; + final CelestProjectUris projectUris; + late final LibraryBuilder _library; + + bool get _hasServer => project.apis.isNotEmpty || project.auth != null; + + final _client = Field( + (f) => + f + ..modifier = FieldModifier.final$ + ..type = ClientTypes.clientClass.ref + ..name = ClientTypes.topLevelClient.name + ..assignment = ClientTypes.clientClass.ref.newInstance([]).code, + ); + late final _celestEnvironment = Enum( + (e) => + e + ..name = 'CelestEnvironment' + ..methods.addAll([ + Method( + (m) => + m + ..type = MethodType.getter + ..returns = DartTypes.core.uri + ..name = 'baseUri' + ..lambda = true + ..body = Block.of([ + const Code('switch (this) {'), + const Code('local => '), + DartTypes.globals.kIsWeb + .or( + DartTypes.io.platform + .property('isAndroid') + .negate(), + ) + .conditional( + DartTypes.core.uri.property('parse').call([ + literalString(projectUris.localUri.toString()), + ]), + DartTypes.core.uri.property('parse').call([ + literalString( + 'http://10.0.2.2:${projectUris.localUri.port}', + ), + ]), + ) + .code, + const Code(','), + if (projectUris.productionUri + case final productionUri?) ...[ + const Code('production => '), + DartTypes.core.uri.property('parse').call([ + literalString(productionUri.toString()), + ]).code, + const Code(','), + ], + const Code('}'), + ]), + ), + ]) + ..values.addAll([ + EnumValue((v) => v..name = 'local'), + if (projectUris.productionUri != null) + EnumValue((v) => v..name = 'production'), + ]), + ); + late final _clientClass = + ClassBuilder() + ..name = ClientTypes.clientClass.name + ..mixins.addAll([ + if (_hasServer) + refer('CelestBase', 'package:celest_core/_internal.dart'), + ]) + ..methods.addAll([ + Method( + (m) => + m + ..returns = refer('T') + ..name = '_checkInitialized' + ..types.add(refer('T')) + ..requiredParameters.add( + Parameter( + (p) => + p + ..name = 'value' + ..type = FunctionType( + (f) => f..returnType = refer('T'), + ), + ), + ) + ..body = Block( + (b) => + b + ..statements.add( + DartTypes.core.stateError + .newInstance([ + literalString( + 'Celest has not been initialized. Make sure to call ' + '`celest.init()` at the start of your `main` method.', + ), + ]) + .thrown + .wrapWithBlockIf( + refer('_initialized').negate(), + ), + ) + ..addExpression(refer('value').call([]).returned), + ), + ), + Method( + (m) => + m + ..returns = refer('CelestEnvironment') + ..type = MethodType.getter + ..name = 'currentEnvironment' + ..lambda = true + ..body = + refer('_checkInitialized').call([ + Method( + (m) => m..body = refer('_currentEnvironment').code, + ).closure, + ]).code, + ), + if (_hasServer) ...[ + Method( + (m) => + m + ..annotations.add(DartTypes.core.override) + ..returns = DartTypes.core.uri + ..type = MethodType.getter + ..name = 'baseUri' + ..lambda = true + ..body = + refer('_checkInitialized').call([ + Method( + (m) => m..body = refer('_baseUri').code, + ).closure, + ]).code, + ), + ], + ]) + ..fields.addAll([ + Field( + (f) => + f + ..modifier = FieldModifier.var$ + ..name = '_initialized' + ..assignment = literalBool(false).code, + ), + Field( + (f) => + f + ..late = true + ..type = refer('CelestEnvironment') + ..name = '_currentEnvironment', + ), + if (_hasServer) ...[ + Field( + (f) => + f + // TODO(dnys1): Add back in 0.5.0 + // ..annotations.add(DartTypes.core.override) + ..late = true + ..modifier = FieldModifier.final$ + ..type = DartTypes.nativeStorage.nativeStorage + ..name = 'nativeStorage' + ..assignment = + DartTypes.nativeStorage.nativeStorage.newInstance([], { + 'scope': literalString('celest'), + }).code, + ), + Field( + (f) => + f + ..annotations.add(DartTypes.core.override) + ..late = true + ..type = DartTypes.http.client + ..name = 'httpClient' + ..assignment = + refer( + 'CelestHttpClient', + 'package:celest_core/_internal.dart', + ).newInstance([], { + 'secureStorage': refer( + 'nativeStorage', + ).property('secure'), + }).code, + ), + Field( + (f) => + f + ..late = true + ..type = DartTypes.core.uri + ..name = '_baseUri', + ), + ], + ]); + + Map generate() { + final libraries = {}; + + final clientInitBody = BlockBuilder(); + + // Common setup work + clientInitBody.addExpression( + refer('_currentEnvironment').assign(refer('environment')), + ); + if (_hasServer) { + clientInitBody.addExpression( + refer('_baseUri').assign(refer('environment').property('baseUri')), + ); + } + + var customSerializers = {}; + var anonymousRecordTypes = {}; + + final hasExternalAuth = project.auth?.externalProviders.isNotEmpty ?? false; + + final apis = project.apis.values; + if (apis.isNotEmpty) { + final functionsGenerator = ClientFunctionsGenerator( + project: project, + resolvedProject: resolvedProject, + apis: apis.toList(), + ); + libraries[ClientPaths.functions] = functionsGenerator.generate(); + _clientClass + ..fields.add( + Field( + (f) => + f + ..modifier = FieldModifier.final$ + ..name = '_functions' + ..assignment = + ClientTypes.functionsClass.ref.newInstance([]).code, + ), + ) + ..methods.add( + Method( + (m) => + m + ..returns = ClientTypes.functionsClass.ref + ..type = MethodType.getter + ..name = 'functions' + ..lambda = true + ..body = + refer('_checkInitialized').call([ + Method( + (m) => m..body = refer('_functions').code, + ).closure, + ]).code, + ), + ); + customSerializers = functionsGenerator.customSerializers; + anonymousRecordTypes = functionsGenerator.anonymousRecordTypes; + } + if (project.auth case final auth?) { + final authLibrary = ClientAuthGenerator(auth: auth).generate(); + libraries[ClientPaths.auth] = authLibrary; + _clientClass + ..fields.add( + Field( + (f) => + f + ..late = true + ..modifier = FieldModifier.final$ + ..type = ClientTypes.authClass.ref + ..name = '_auth' + ..assignment = + ClientTypes.authClass.ref + .newInstance( + [refer('this')], + {'storage': refer('nativeStorage')}, + ) + .code, + ), + ) + ..methods.add( + Method( + (m) => + m + ..returns = ClientTypes.authClass.ref + ..type = MethodType.getter + ..name = 'auth' + ..lambda = true + ..body = + refer('_checkInitialized').call([ + Method((m) => m..body = refer('_auth').code).closure, + ]).code, + ), + ); + clientInitBody + ..statements.insert( + 0, + refer('_auth') + .property('signOut') + .call([]) + .wrapWithBlockIf( + refer('_initialized').and( + refer('environment').notEqualTo(refer('_currentEnvironment')), + ), + ), + ) + ..addExpression( + refer('scheduleMicrotask', 'dart:async').call([ + if (hasExternalAuth) + Method( + (m) => + m + ..body = + refer('_auth').property('init').call([], { + 'externalAuth': refer('externalAuth'), + }).code, + ).closure + else + refer('_auth').property('init'), + ]), + ); + } + + if (customSerializers.isNotEmpty) { + final clientSerializers = ClientSerializersGenerator( + customSerializers: customSerializers, + anonymousRecordTypes: anonymousRecordTypes, + ); + libraries[ClientPaths.serializers] = clientSerializers.generate(); + + final initSerializers = + refer( + 'initSerializers', + ClientPaths.serializers, + ).call([], {'serializers': refer('serializers')}).statement; + clientInitBody.statements.add( + initSerializers.wrapWithBlockIf(refer('_initialized').negate()), + ); + } + + clientInitBody.addExpression( + refer('_initialized').assign(literalBool(true)), + ); + + // Add client methods + final clientInit = Method( + (m) => + m + ..name = 'init' + ..returns = DartTypes.core.void$ + ..optionalParameters.addAll([ + Parameter( + (p) => + p + ..name = 'environment' + ..type = refer('CelestEnvironment') + ..named = true + ..defaultTo = + refer('CelestEnvironment').property('local').code, + ), + Parameter( + (p) => + p + ..name = 'serializers' + ..type = DartTypes.celest.serializers.nullable + ..named = true, + ), + if (hasExternalAuth) + Parameter( + (p) => + p + ..name = 'externalAuth' + ..type = + refer('ExternalAuth', ClientPaths.auth).nullable + ..named = true, + ), + ]) + ..body = clientInitBody.build(), + ); + _clientClass.methods.add(clientInit); + libraries[ClientPaths.client] = _library.build(); + + return libraries; + } +} diff --git a/apps/cli/lib/codegen/client/client_types.dart b/apps/cli/lib/codegen/client/client_types.dart new file mode 100644 index 000000000..f87ee1de6 --- /dev/null +++ b/apps/cli/lib/codegen/client/client_types.dart @@ -0,0 +1,39 @@ +import 'package:celest_ast/celest_ast.dart'; +import 'package:celest_cli/src/context.dart'; +import 'package:celest_cli/src/utils/recase.dart'; +import 'package:code_builder/code_builder.dart'; + +abstract final class ClientPaths { + static String get client => p.join( + projectPaths.clientRoot, + 'lib', + '${celestProject.projectName.snakeCase}_client.dart', + ); + static String get functions => + p.join(projectPaths.clientOutputsDir, 'functions.dart'); + static String get serializers => + p.join(projectPaths.clientOutputsDir, 'serializers.dart'); + static String get auth => p.join(projectPaths.clientOutputsDir, 'auth.dart'); +} + +final class ClientTypes { + ClientTypes._(this.name, this.uri); + + static ClientTypes get topLevelClient => + ClientTypes._('celest', ClientPaths.client); + static ClientTypes get clientClass => + ClientTypes._('Celest', ClientPaths.client); + static ClientTypes get functionsClass => + ClientTypes._('CelestFunctions', ClientPaths.functions); + static ClientTypes api(Api api) => ClientTypes._( + '${ClientTypes.functionsClass.name}${api.name.pascalCase}', + ClientPaths.functions, + ); + static ClientTypes get authClass => + ClientTypes._('CelestAuth', ClientPaths.auth); + + final String name; + final String uri; + + Reference get ref => refer(name, p.toUri(uri).toString()); +} diff --git a/apps/cli/lib/codegen/client_code_generator.dart b/apps/cli/lib/codegen/client_code_generator.dart new file mode 100644 index 000000000..1f0ae187b --- /dev/null +++ b/apps/cli/lib/codegen/client_code_generator.dart @@ -0,0 +1,58 @@ +import 'dart:async'; + +import 'package:celest_ast/celest_ast.dart' as ast; +import 'package:celest_cli/codegen/allocator.dart'; +import 'package:celest_cli/codegen/client/client_generator.dart'; +import 'package:celest_cli/codegen/code_generator.dart'; +import 'package:celest_cli/codegen/code_outputs.dart'; +import 'package:celest_cli/project/celest_project.dart'; +import 'package:celest_cli/src/context.dart'; +import 'package:collection/collection.dart'; + +final class ClientCodeGenerator { + ClientCodeGenerator({ + required this.project, + required this.resolvedProject, + required this.projectUris, + }); + + final ast.Project project; + final ast.ResolvedProject resolvedProject; + final CelestProjectUris projectUris; + + CodeOutputs generate() { + final clientDeps = CodegenDependencies(rootDir: projectPaths.clientRoot); + final outputs = runZoned(() { + final generator = ClientGenerator( + project: project, + resolvedProject: resolvedProject, + projectUris: projectUris, + ); + return generator.generate(); + }, zoneValues: {CodegenDependencies: clientDeps}); + return CodeOutputs( + outputs.map( + (path, library) => MapEntry( + path, + CodeGenerator.emit( + library, + forFile: path, + prefixingStrategy: PrefixingStrategy.pretty, + pathStrategy: PathStrategy.pretty, + ), + ), + ), + codegenDependencies: clientDeps, + ); + } +} + +final class CodegenDependencies extends DelegatingSet { + CodegenDependencies({required this.rootDir}) : super({}); + + final String rootDir; + + static CodegenDependencies get current { + return Zone.current[CodegenDependencies] as CodegenDependencies; + } +} diff --git a/apps/cli/lib/codegen/cloud/cloud_client_generator.dart b/apps/cli/lib/codegen/cloud/cloud_client_generator.dart new file mode 100644 index 000000000..7877993b2 --- /dev/null +++ b/apps/cli/lib/codegen/cloud/cloud_client_generator.dart @@ -0,0 +1,586 @@ +import 'package:celest_ast/celest_ast.dart' as ast; +import 'package:celest_cli/codegen/client_code_generator.dart'; +import 'package:celest_cli/codegen/cloud/cloud_client_types.dart'; +import 'package:celest_cli/src/types/dart_types.dart'; +import 'package:celest_cli/src/utils/recase.dart'; +import 'package:celest_cli/src/utils/reference.dart'; +import 'package:code_builder/code_builder.dart'; + +const kClientHeader = [ + 'Generated by Celest. This file should not be modified manually, but', + 'it can be checked into version control.', +]; + +/// Generates the `celest` global for the backend, similar to the frontend +/// `celest` global. +final class CloudClientGenerator { + CloudClientGenerator({required this.project}) { + _library = + LibraryBuilder() + ..name = '' + ..comments.addAll(kClientHeader) + ..body.addAll([ + _client, + _globalContext, + lazySpec(_clientClass.build), + _contextWrapper, + ]); + _configLibrary = + LibraryBuilder() + ..name = '' + ..comments.addAll(kClientHeader) + ..body.addAll([ + _celestEnvironment, + _variablesClass, + if (project.secrets.isNotEmpty) _secretsClass, + ]); + _dataLibrary = + LibraryBuilder() + ..name = '' + ..comments.addAll(kClientHeader) + ..body.addAll([_dataClass]); + _authLibrary = + LibraryBuilder() + ..name = '' + ..comments.addAll(kClientHeader) + ..body.addAll([_authClass]); + } + + final ast.Project project; + late final LibraryBuilder _library; + late final LibraryBuilder _configLibrary; + late final LibraryBuilder _dataLibrary; + late final LibraryBuilder _authLibrary; + + final _client = Field( + (f) => + f + ..docs.addAll([ + '/// The interface to your Celest backend.', + '///', + '/// Similar to the `celest` global in the frontend, this ', + '/// provides access to the backend environment and services', + '/// configured for your project.', + ]) + ..modifier = FieldModifier.constant + ..type = CloudClientTypes.clientClass.ref + ..name = CloudClientTypes.topLevelClient.name + ..assignment = + CloudClientTypes.clientClass.ref.constInstanceNamed('_', []).code, + ); + + final _globalContext = Method( + (m) => + m + ..docs.addAll([ + '/// A per-request context object which propogates request information and common', + '/// accessors to the Celest server environment.', + ]) + ..type = MethodType.getter + ..returns = CloudClientTypes.contextClass.ref + ..name = CloudClientTypes.topLevelContext.name + ..lambda = true + ..body = + CloudClientTypes.contextClass.ref.newInstanceNamed('_', [ + DartTypes.celest.globalContext, + ]).code, + ); + + late final _celestEnvironment = ExtensionType( + (e) => + e + ..name = 'CelestEnvironment' + ..constant = true + ..primaryConstructorName = '_' + ..representationDeclaration = RepresentationDeclaration( + (d) => + d + ..name = '_env' + ..declaredRepresentationType = DartTypes.core.string, + ) + ..implements.addAll([ + DartTypes.celest.environment, + DartTypes.core.string, + ]) + ..docs.addAll([ + '/// An environment of a deployed Celest service.', + '///', + '/// Celest services can have multiple isolated branches, for example', + '/// a `development` and `production` environment.', + ]) + ..fields.addAll([ + Field( + (f) => + f + ..static = true + ..modifier = FieldModifier.constant + ..type = refer('CelestEnvironment') + ..name = 'local' + ..docs.addAll([ + '/// The local Celest environment, used to delineate when a', + '/// Celest service is running on a developer machine as opposed', + '/// to the cloud.', + ]) + ..assignment = + refer('CelestEnvironment').constInstanceNamed('_', [ + literalString('local'), + ]).code, + ), + Field( + (f) => + f + ..static = true + ..modifier = FieldModifier.constant + ..type = refer('CelestEnvironment') + ..name = 'production' + ..docs.addAll([ + '/// The production Celest environment which is common to all', + '/// Celest projects and labels the environment which is considered', + '/// live and served to end-users.', + ]) + ..assignment = + refer('CelestEnvironment').constInstanceNamed('_', [ + literalString('production'), + ]).code, + ), + ]) + ..methods.addAll([ + Method( + (m) => + m + ..type = MethodType.getter + ..returns = DartTypes.core.bool + ..name = 'isLocal' + ..lambda = true + ..docs.addAll([ + '/// Whether `this` represents the [local] environment.', + ]) + ..body = refer('this').equalTo(refer('local')).code, + ), + Method( + (m) => + m + ..type = MethodType.getter + ..returns = DartTypes.core.bool + ..name = 'isProduction' + ..lambda = true + ..docs.addAll([ + '/// Whether `this` represents the [production] environment.', + ]) + ..body = refer('this').equalTo(refer('production')).code, + ), + ]), + ); + + late final _contextWrapper = ExtensionType((e) { + e + ..name = CloudClientTypes.contextClass.name + ..docs.addAll([ + '/// A per-request context object which propogates request information and common', + '/// accessors to the Celest server environment.', + ]) + ..primaryConstructorName = '_' + ..representationDeclaration = RepresentationDeclaration( + (d) => + d + ..name = '_context' + ..declaredRepresentationType = DartTypes.celest.context, + ) + ..implements.add(DartTypes.celest.context); + }); + + late final _clientClass = + ClassBuilder() + ..name = CloudClientTypes.clientClass.name + ..docs.addAll([ + '/// The interface to your Celest backend.', + '///', + '/// Similar to the `Celest` class in the frontend, this class', + '/// provides access to the backend environment and services', + '/// configured for your project.', + ]) + ..constructors.add( + Constructor( + (c) => + c + ..constant = true + ..name = '_', + ), + ) + ..methods.addAll([ + Method( + (m) => + m + ..returns = CloudClientTypes.environmentClass.ref + ..type = MethodType.getter + ..name = 'currentEnvironment' + ..lambda = true + ..docs.addAll([ + '/// The current environment of the Celest service.', + '///', + '/// This is determined by the `CELEST_ENVIRONMENT` variable', + '/// which is set for you by the deployment environment.', + ]) + ..body = + refer('variables') + .property('currentEnvironment') + .asA(CloudClientTypes.environmentClass.ref) + .code, + ), + Method( + (m) => + m + ..returns = CloudClientTypes.variablesClass.ref + ..type = MethodType.getter + ..name = 'variables' + ..lambda = true + ..docs.addAll([ + '/// The variables of the Celest service.', + '///', + '/// This class provides access to the values configured for the', + '/// [currentEnvironment].', + ]) + ..body = + CloudClientTypes.variablesClass.ref + .constInstance([]) + .code, + ), + if (project.secrets.isNotEmpty) + Method( + (m) => + m + ..returns = CloudClientTypes.secretsClass.ref + ..type = MethodType.getter + ..name = 'secrets' + ..lambda = true + ..docs.addAll([ + '/// The secrets for the Celest service.', + '///', + '/// This class provides access to the secret values that are configured', + '/// for the [currentEnvironment].', + ]) + ..body = + CloudClientTypes.secretsClass.ref + .constInstance([]) + .code, + ), + if (project.databases.isNotEmpty) + Method( + (m) => + m + ..returns = CloudClientTypes.dataClass.ref + ..type = MethodType.getter + ..name = 'data' + ..lambda = true + ..docs.addAll([ + '/// The data services for the Celest backend.', + '///', + '/// This class provides access to the databases that are configured', + '/// for the [currentEnvironment].', + ]) + ..body = + CloudClientTypes.dataClass.ref.constInstance([]).code, + ), + ]); + + late final _variablesClass = Class((b) { + b + ..name = CloudClientTypes.variablesClass.name + ..docs.addAll([ + '/// The environment variables for the Celest service.', + '///', + '/// This class provides access to the environment variable values', + '/// that are configured for the current [CelestEnvironment].', + ]) + ..constructors.add(Constructor((c) => c..constant = true)) + ..methods.addAll([ + Method((m) { + m + ..type = MethodType.getter + ..returns = DartTypes.core.string + ..name = 'currentEnvironment' + ..docs.addAll([ + '/// The environment variable that determines the current environment.', + '///', + '/// This is set by the deployment environment and is used to', + '/// determine the current environment of the Celest service.', + ]) + ..body = + DartTypes.celest.globalContext.property('expect').call([ + DartTypes.celest.environmentVariable.property('environment'), + ]).code; + }), + for (final envVar in project.variables) + Method((m) { + m + ..type = MethodType.getter + ..returns = DartTypes.core.string + ..name = envVar.dartName ?? envVar.name.camelCase + ..docs.addAll( + envVar.docs.isNotEmpty + ? envVar.docs + : [ + '/// The value of the `${envVar.name}` environment variable.', + ], + ) + ..body = + DartTypes.celest.globalContext.property('expect').call([ + DartTypes.celest.environmentVariable.constInstance([ + literalString( + envVar.name, + raw: envVar.name.contains(r'$'), + ), + ]), + ]).code; + }), + ]); + }); + + late final _secretsClass = Class((b) { + b + ..name = CloudClientTypes.secretsClass.name + ..docs.addAll([ + '/// The secrets for the Celest service.', + '///', + '/// This class provides access to the secret values that are configured', + '/// for the current [CelestEnvironment].', + ]) + ..constructors.add(Constructor((c) => c..constant = true)) + ..methods.addAll([ + for (final secret in project.secrets) + Method((m) { + m + ..type = MethodType.getter + ..returns = DartTypes.core.string + ..name = secret.dartName ?? secret.name.camelCase + ..docs.addAll( + secret.docs.isNotEmpty + ? secret.docs + : ['/// The value of the `${secret.name}` secret.'], + ) + ..body = + DartTypes.celest.globalContext.property('expect').call([ + DartTypes.celest.environmentVariable.constInstance([ + literalString( + secret.name, + raw: secret.name.contains(r'$'), + ), + ]), + ]).code; + }), + ]); + }); + + late final _dataClass = Class((b) { + b + ..name = CloudClientTypes.dataClass.name + ..docs.addAll([ + '/// The data services for the Celest backend.', + '///', + '/// This class provides access to the databases that are configured', + '/// for the current [CelestEnvironment].', + ]) + ..constructors.add(Constructor((c) => c..constant = true)) + ..methods.addAll([ + Method((m) { + m + ..static = true + ..name = 'init' + ..returns = DartTypes.core.future(DartTypes.core.void$) + ..requiredParameters.add( + Parameter( + (p) => + p + ..name = 'context' + ..type = DartTypes.celest.context, + ), + ) + ..modifier = MethodModifier.async + ..docs.addAll([ + '/// Initializes the databases attached to this project in the given [context].', + ]) + ..body = Block((b) { + for (final database in project.databases.values) { + final config = database.config as ast.CelestDatabaseConfig; + b.addExpression( + refer('context').property('put').call([ + refer('_${database.dartName}Key'), + refer( + 'connect', + 'package:celest/src/runtime/data/connect.dart', + ) + .call( + [refer('context')], + { + 'name': literalString( + database.name, + raw: database.name.contains(r'$'), + ), + 'factory': database.schema.declaration.property( + 'new', + ), + 'hostnameVariable': DartTypes + .celest + .environmentVariable + .constInstance([ + literalString(config.hostname.name), + ]), + 'tokenSecret': DartTypes.celest.secret + .constInstance([ + literalString(config.token.name), + ]), + }, + ) + .awaited, + ]), + ); + } + }); + }), + for (final database in project.databases.values) ...[ + Method((m) { + final schemaType = switch (database.schema) { + ast.DriftDatabaseSchema(:final declaration) => declaration, + }; + m + ..type = MethodType.getter + ..returns = schemaType + ..name = database.dartName + ..docs.addAll( + database.docs.isNotEmpty + ? database.docs + : [ + '/// The `${schemaType.symbol}` instance for this project.', + ], + ) + ..body = + DartTypes.celest.context + .property('current') + .property('expect') + .call([refer('_${database.dartName}Key')]) + .code; + }), + Method((m) { + final schemaType = switch (database.schema) { + ast.DriftDatabaseSchema(:final declaration) => declaration, + }; + m + ..static = true + ..type = MethodType.getter + ..returns = DartTypes.celest.contextKey.toTypeReference.rebuild( + (t) => t.types.add(schemaType), + ) + ..name = '_${database.dartName}Key' + ..docs.addAll( + database.docs.isNotEmpty + ? database.docs + : [ + '/// The context key for the [${database.dartName}] instance.', + ], + ) + ..body = + DartTypes.celest.contextKey.constInstance([ + literalString( + database.name, + raw: database.name.contains(r'$'), + ), + ]).code; + }), + ], + ]); + }); + + late final _authClass = Class((b) { + b + ..name = CloudClientTypes.authClass.name + ..docs.addAll([ + '/// The auth service for the Celest backend.', + '///', + '/// This class provides access to authentication and authorization', + '/// operations for the current [CelestEnvironment].', + ]) + ..constructors.add(Constructor((c) => c..constant = true)) + ..methods.addAll([ + Method((m) { + m + ..static = true + ..name = 'init' + ..returns = DartTypes.core.future(DartTypes.core.void$) + ..requiredParameters.add( + Parameter( + (p) => + p + ..name = 'context' + ..type = DartTypes.celest.context, + ), + ) + ..modifier = MethodModifier.async + ..docs.addAll([ + '/// Initializes the Celest Auth service in the given [context].', + ]) + ..body = Block((b) { + final database = declareFinal('database').assign( + refer('connect', 'package:celest/src/runtime/data/connect.dart') + .call( + [refer('context')], + { + 'name': literalString('CelestAuthDatabase'), + 'factory': refer( + 'AuthDatabase', + 'package:celest_cloud_auth/celest_cloud_auth.dart', + ).property('new'), + 'hostnameVariable': DartTypes.celest.environmentVariable + .constInstance([ + literalString('CELEST_AUTH_DATABASE_HOST'), + ]), + 'tokenSecret': DartTypes.celest.secret.constInstance([ + literalString('CELEST_AUTH_DATABASE_TOKEN'), + ]), + }, + ) + .awaited, + ); + b.addExpression(database); + b.addExpression( + declareFinal('service').assign( + refer( + 'CelestCloudAuth', + 'package:celest_cloud_auth/celest_cloud_auth.dart', + ).property('create').call([], { + 'database': refer('database'), + }).awaited, + ), + ); + b.addExpression( + refer('context').property('router').property('mount').call([ + literalString('/v1alpha1/auth/'), + refer('service').property('handler'), + ]), + ); + b.addExpression( + refer('context').property('put').call([ + refer('CelestCloudAuth').property('contextKey'), + refer('service'), + ]), + ); + }); + }), + ]); + }); + + Map generate() { + final libraries = {}; + libraries[CloudPaths.config] = _configLibrary.build(); + if (project.databases.isNotEmpty) { + CodegenDependencies.current.add('drift_hrana'); + libraries[CloudPaths.data] = _dataLibrary.build(); + } + if (project.auth?.providers.isNotEmpty ?? false) { + CodegenDependencies.current.add('celest_cloud_auth'); + CodegenDependencies.current.add('drift_hrana'); + libraries[CloudPaths.auth] = _authLibrary.build(); + } + libraries[CloudPaths.client] = _library.build(); + return libraries; + } +} diff --git a/apps/cli/lib/codegen/cloud/cloud_client_types.dart b/apps/cli/lib/codegen/cloud/cloud_client_types.dart new file mode 100644 index 000000000..566dd9c3a --- /dev/null +++ b/apps/cli/lib/codegen/cloud/cloud_client_types.dart @@ -0,0 +1,40 @@ +import 'package:code_builder/code_builder.dart'; + +abstract final class CloudPaths { + static Uri get client => + Uri.parse('package:celest_backend/src/generated/cloud.celest.dart'); + static Uri get config => + Uri.parse('package:celest_backend/src/generated/config.celest.dart'); + static Uri get data => + Uri.parse('package:celest_backend/src/generated/data.celest.dart'); + static Uri get auth => + Uri.parse('package:celest_backend/src/generated/auth.celest.dart'); +} + +final class CloudClientTypes { + CloudClientTypes._(this.name, this.uri); + + static CloudClientTypes get topLevelClient => + CloudClientTypes._('celest', CloudPaths.client); + static CloudClientTypes get topLevelContext => + CloudClientTypes._('context', CloudPaths.client); + static CloudClientTypes get clientClass => + CloudClientTypes._('CelestCloud', CloudPaths.client); + static CloudClientTypes get contextClass => + CloudClientTypes._('CelestContext', CloudPaths.client); + static CloudClientTypes get environmentClass => + CloudClientTypes._('CelestEnvironment', CloudPaths.config); + static CloudClientTypes get variablesClass => + CloudClientTypes._('CelestVariables', CloudPaths.config); + static CloudClientTypes get secretsClass => + CloudClientTypes._('CelestSecrets', CloudPaths.config); + static CloudClientTypes get dataClass => + CloudClientTypes._('CelestData', CloudPaths.data); + static CloudClientTypes get authClass => + CloudClientTypes._('CelestAuth', CloudPaths.auth); + + final String name; + final Uri uri; + + Reference get ref => refer(name, uri.toString()); +} diff --git a/apps/cli/lib/codegen/cloud_code_generator.dart b/apps/cli/lib/codegen/cloud_code_generator.dart new file mode 100644 index 000000000..6baaf2c44 --- /dev/null +++ b/apps/cli/lib/codegen/cloud_code_generator.dart @@ -0,0 +1,140 @@ +import 'dart:async'; + +import 'package:celest_ast/celest_ast.dart'; +import 'package:celest_cli/codegen/allocator.dart'; +import 'package:celest_cli/codegen/api/entrypoint_generator.dart'; +import 'package:celest_cli/codegen/api/local_api_generator.dart'; +import 'package:celest_cli/codegen/client_code_generator.dart'; +import 'package:celest_cli/codegen/cloud/cloud_client_generator.dart'; +import 'package:celest_cli/codegen/code_generator.dart'; +import 'package:celest_cli/codegen/code_outputs.dart'; +import 'package:celest_cli/src/context.dart'; +import 'package:code_builder/code_builder.dart'; + +final class CloudCodeGenerator extends AstVisitor { + CloudCodeGenerator({required this.project, required this.resolvedProject}); + + final Project project; + final ResolvedProject resolvedProject; + final _codegenDependencies = CodegenDependencies( + rootDir: projectPaths.projectRoot, + ); + + /// A map of generated files to their contents. + final Map fileOutputs = {}; + + /// A map of API routes to their target reference. + final Map _targets = {}; + + CodeOutputs generate() { + visitProject(project); + return CodeOutputs(fileOutputs, codegenDependencies: _codegenDependencies); + } + + @override + void visitProject(Project project) { + final cloudClientLibraries = runZoned( + CloudClientGenerator(project: project).generate, + zoneValues: {CodegenDependencies: _codegenDependencies}, + ); + for (final library in cloudClientLibraries.entries) { + final filePath = projectPaths.denormalizeUri(library.key).toFilePath(); + fileOutputs[filePath] = CodeGenerator.emit( + library.value, + forFile: filePath, + pathStrategy: PathStrategy.pretty, + prefixingStrategy: PrefixingStrategy.none, + ); + } + + project.apis.values.forEach(visitApi); + + if (project.apis.isNotEmpty) { + final localApiFile = projectPaths.localApiEntrypoint; + final localApi = + LocalApiGenerator(targets: _targets, project: project).generate(); + fileOutputs[localApiFile] = CodeGenerator.emit( + localApi, + forFile: localApiFile, + pathStrategy: PathStrategy.pretty, + ); + } + } + + @override + void visitApi(Api api) { + final outputDir = projectPaths.apiOutput(api.name); + for (final function in api.functions.values) { + final generator = EntrypointGenerator( + project: project, + api: api, + function: function, + httpConfig: + resolvedProject + .apis[api.name]! + .functions[function.name]! + .httpConfig, + outputDir: outputDir, + ); + final entrypoint = generator.generate(); + final entrypointFile = projectPaths.functionEntrypoint( + api.name, + function.name, + ); + fileOutputs[entrypointFile] = CodeGenerator.emit( + entrypoint, + forFile: entrypointFile, + pathStrategy: PathStrategy.pretty, + ); + _targets[function.route] = refer( + generator.targetName, + p.toUri(entrypointFile).toString(), + ); + } + } + + @override + void visitApiAuthenticated(ApiAuthenticated annotation) {} + + @override + void visitApiPublic(ApiPublic annotation) {} + + @override + void visitApiMiddleware(ApiMiddleware annotation) {} + + @override + void visitApiHttpMetadata(ApiHttpMetadata metadata) {} + + @override + void visitFunction(CloudFunction function) {} + + @override + void visitParameter(CloudFunctionParameter parameter) {} + + @override + void visitVariable(Variable variable) {} + + @override + void visitSecret(Secret secret) {} + + @override + void visitAuth(Auth auth) { + throw UnimplementedError(); + } + + @override + void visitAuthProvider(AuthProvider provider) { + throw UnimplementedError(); + } + + @override + void visitExternalAuthProvider(ExternalAuthProvider provider) { + throw UnimplementedError(); + } + + @override + void visitDatabase(Database database) {} + + @override + void visitDatabaseSchema(DatabaseSchema schema) {} +} diff --git a/apps/cli/lib/codegen/code_generator.dart b/apps/cli/lib/codegen/code_generator.dart new file mode 100644 index 000000000..4140f1716 --- /dev/null +++ b/apps/cli/lib/codegen/code_generator.dart @@ -0,0 +1,70 @@ +import 'package:celest_cli/codegen/allocator.dart'; +import 'package:celest_cli/src/sdk/dart_sdk.dart'; +import 'package:code_builder/code_builder.dart'; +import 'package:dart_style/dart_style.dart'; + +abstract final class CodeGenerator { + static const _ignoredRules = [ + 'type=lint', + 'unused_local_variable', + 'unnecessary_cast', + 'unnecessary_import', + 'deprecated_member_use', + 'invalid_use_of_internal_member', + ]; + static final _header = 'ignore_for_file: ${_ignoredRules.join(', ')}'; + static final _formatter = DartFormatter(languageVersion: Sdk.current.version); + static DartEmitter _emitter({ + required String forFile, + PrefixingStrategy prefixingStrategy = PrefixingStrategy.indexed, + required PathStrategy pathStrategy, + }) => DartEmitter( + allocator: CelestAllocator( + prefixingStrategy: prefixingStrategy, + pathStrategy: pathStrategy, + forFile: forFile, + ), + useNullSafetySyntax: true, + orderDirectives: true, + ); + + static String rawEmit( + Spec spec, { + required String forFile, + PrefixingStrategy prefixingStrategy = PrefixingStrategy.indexed, + required PathStrategy pathStrategy, + }) => + spec + .accept( + _emitter( + forFile: forFile, + prefixingStrategy: prefixingStrategy, + pathStrategy: pathStrategy, + ), + ) + .toString(); + + static String emit( + Spec spec, { + required String forFile, + PrefixingStrategy prefixingStrategy = PrefixingStrategy.indexed, + required PathStrategy pathStrategy, + }) { + if (spec is Library) { + spec = spec.rebuild((lib) => lib.comments.add(_header)); + } + final code = rawEmit( + spec, + forFile: forFile, + prefixingStrategy: prefixingStrategy, + pathStrategy: pathStrategy, + ); + try { + return _formatter.format(code); + } on FormatException { + rethrow; + } on Object catch (e) { + throw FormatException(e.toString(), code); + } + } +} diff --git a/apps/cli/lib/codegen/code_outputs.dart b/apps/cli/lib/codegen/code_outputs.dart new file mode 100644 index 000000000..b63897862 --- /dev/null +++ b/apps/cli/lib/codegen/code_outputs.dart @@ -0,0 +1,81 @@ +import 'package:celest_cli/codegen/client_code_generator.dart'; +import 'package:celest_cli/pub/project_dependency.dart'; +import 'package:celest_cli/pub/pub_action.dart'; +import 'package:celest_cli/pub/pubspec.dart'; +import 'package:celest_cli/src/context.dart'; +import 'package:collection/collection.dart'; +import 'package:logging/logging.dart'; +import 'package:pub_semver/pub_semver.dart'; +import 'package:pubspec_parse/pubspec_parse.dart'; + +final class CodeOutputs extends DelegatingMap { + const CodeOutputs(super.base, {required this.codegenDependencies}); + + /// Dependencies added as part of the code generation process. + /// + /// These must be added to the respective pubspec.yaml after generation + /// to ensure referenced types are available. + final CodegenDependencies codegenDependencies; + + static final Logger _logger = Logger('CodeOutputs'); + + Future write() async { + final outputFutures = >[]; + forEach((path, library) { + assert(p.isAbsolute(path), 'Path must be absolute: $path'); + outputFutures.add( + Future(() async { + final file = fileSystem.file(path); + await file.create(recursive: true); + await file.writeAsString(library); + }), + ); + }); + if (codegenDependencies.isNotEmpty) { + var (pubspec, pubspecYaml) = + p.equals(codegenDependencies.rootDir, projectPaths.projectRoot) + ? (celestProject.pubspec, celestProject.pubspecYaml) + : (celestProject.clientPubspec, celestProject.clientPubspecYaml); + final pubspecFile = fileSystem + .directory(codegenDependencies.rootDir) + .childFile('pubspec.yaml'); + final currentDependencies = Set.of(pubspec.dependencies.keys); + final missingDependencies = codegenDependencies.difference( + currentDependencies, + ); + if (missingDependencies.isNotEmpty) { + _logger.fine( + 'Adding dependencies to ${pubspecFile.path}: ' + '${missingDependencies.toList()}', + ); + pubspec = pubspec.addDeps( + dependencies: { + for (final dependency in codegenDependencies) + dependency: + ProjectDependency.all[dependency]?.pubDependency ?? + HostedDependency(version: VersionConstraint.any), + }, + ); + if (pubspecFile.existsSync()) { + outputFutures.add( + pubspecFile.writeAsString(pubspec.toYaml(source: pubspecYaml)).then( + (_) { + return runPub( + action: PubAction.get, + workingDirectory: pubspecFile.parent.path, + ); + }, + ), + ); + } else { + _logger.fine( + 'Skipping dependency update', + 'Pubspec not found: ${pubspecFile.path}', + StackTrace.current, + ); + } + } + } + await Future.wait(outputFutures); + } +} diff --git a/apps/cli/lib/codegen/doc_comments.dart b/apps/cli/lib/codegen/doc_comments.dart new file mode 100644 index 000000000..832018dc7 --- /dev/null +++ b/apps/cli/lib/codegen/doc_comments.dart @@ -0,0 +1,66 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + +import 'package:html2md/html2md.dart' as html2md; + +String? docsFromParts(String? summary, String? description) { + if (summary == null && description == null) { + return null; + } + final docs = StringBuffer(); + if (summary != null) { + docs.write(formatDocs(summary)); + if (description != null) { + docs + ..writeln() + ..writeln('///'); + } + } + if (description != null) { + docs.write(formatDocs(description)); + } + return docs.toString(); +} + +/// Formats documentation to follow Dart standards. +String formatDocs(String docs) { + final lines = + html2md + .convert( + docs, + rules: [ + // Format as H1 + html2md.Rule( + 'fullname', + filters: ['fullname'], + replacement: (text, node) { + return '## $text\n\n'; + }, + ), + + // Format

with line breaks + html2md.Rule( + 'p', + filters: ['p'], + replacement: (text, node) { + return '$text\n\n'; + }, + ), + ], + ) + .split('\n') + .map((doc) => doc.replaceFirst(RegExp(r'^/*'), '')) + // unescape pre-convert MD + .map((doc) => doc.replaceAll(r'\*', '*').replaceAll(r'\.', '.')) + .toList(); + + // Empty lines are not needed + if (lines.isNotEmpty && lines.first.trim().isEmpty) { + lines.removeAt(0); + } + if (lines.isNotEmpty && lines.last.trim().isEmpty) { + lines.removeLast(); + } + + return lines.map((doc) => '/// $doc'.trim()).join('\n'); +} diff --git a/apps/cli/lib/codegen/project/resources_generator.dart b/apps/cli/lib/codegen/project/resources_generator.dart new file mode 100644 index 000000000..02ee6d4bf --- /dev/null +++ b/apps/cli/lib/codegen/project/resources_generator.dart @@ -0,0 +1,215 @@ +import 'dart:collection'; + +import 'package:celest_ast/celest_ast.dart'; +import 'package:celest_cli/src/types/dart_types.dart'; +import 'package:celest_cli/src/utils/error.dart'; +import 'package:celest_cli/src/utils/recase.dart'; +import 'package:code_builder/code_builder.dart'; + +const _header = [ + 'Generated by Celest. This file should not be modified manually, but', + 'it can be checked into version control.', +]; + +final class ResourcesGenerator { + ResourcesGenerator({required this.project}); + + final Project project; + final _library = + LibraryBuilder() + ..name = '' + ..comments.addAll(_header); + + // SplayTree ensures consistent ordering in output file which helps with + // diffs. + /// All resources, sorted by API name, then definition order. + final _allResources = SplayTreeMap((a, b) { + return switch ((a, b)) { + (final Api a, final Api b) => a.name.compareTo(b.name), + (final CloudFunction a, final CloudFunction b) => a.compareTo(b), + (final Variable a, final Variable b) => a.name.compareTo(b.name), + (Api(), _) => -1, + (CloudFunction(), Api()) => 1, + (CloudFunction(), Variable()) => -1, + (Variable(), _) => 1, + _ => unreachable(), + }; + }); + + final _classBuilders = {}; + ClassBuilder _beginClass(String name, String? oldName) { + final cached = _classBuilders[name]; + if (cached != null) { + return cached; + } + + // TODO(dnys1): Remove in 0.3.0 + // Adds a typedef for the old name to avoid breaking changes. + if (oldName != null) { + final typedef = TypeDef( + (b) => + b + ..annotations.add( + DartTypes.core.deprecated.newInstance([ + literalString('Use `$name` instead.'), + ]), + ) + ..name = oldName + ..definition = refer(name), + ); + _library.body.add(typedef); + } + + final builder = + ClassBuilder() + ..name = name + ..abstract = true + ..modifier = ClassModifier.final$; + _library.body.add(lazySpec(builder.build)); + return builder; + } + + void _generateApi( + Api api, { + required Map apis, + required Map functions, + }) { + final apiFieldName = api.name.camelCase; + apis[apiFieldName] ??= Field( + (f) => + f + ..static = true + ..modifier = FieldModifier.constant + ..name = api.name.camelCase + ..assignment = + DartTypes.celest.cloudApi.constInstance([], { + 'name': literalString(api.name, raw: true), + }).code, + ); + for (final function in api.functions.values) { + // final inputParameters = + // function.parameters.where((p) => !p.type.isFunctionContext).toList(); + // // final inputType = switch (inputParameters) { + // // [] => refer('void'), + // // [final single] => single.type, + // // final multiple => RecordType( + // // (r) => r + // // // `TODO`(dnys1): Treat all parameters the same (named/optional)? + // // // This is only a Dart concept and we can handle the mapping to/from. + // // // i.e. it does not affect the actual HTTP API. + // // ..positionalFieldTypes.addAll([ + // // for (final parameter in multiple.where((p) => !p.named)) + // // parameter.type, + // // ]) + // // ..namedFieldTypes.addAll({ + // // for (final parameter in multiple.where((p) => p.named)) + // // parameter.name: parameter.type, + // // }), + // // ), + // // }; + final functionFieldName = '${api.name}_${function.name}'.camelCase; + functions[functionFieldName] ??= Field( + (f) => + f + ..static = true + ..name = functionFieldName + ..modifier = FieldModifier.constant + ..assignment = + DartTypes.celest.cloudFunction.constInstance([], { + 'api': literalString(api.name, raw: true), + 'functionName': literalString(function.name, raw: true), + }).code, + ); + _allResources[api] = 'Apis.$apiFieldName'; + _allResources[function] = 'Functions.$functionFieldName'; + } + } + + void _generateEnv(Iterable variables) { + final env = _beginClass('env', 'Env'); + for (final envVar in variables) { + final fieldName = envVar.name.camelCase; + env.fields.add( + Field( + (f) => + f + ..static = true + ..modifier = FieldModifier.constant + ..name = fieldName + ..assignment = + DartTypes.celest.environmentVariable.constInstance([], { + 'name': literalString(envVar.name, raw: true), + }).code, + ), + ); + _allResources[envVar] = 'env.$fieldName'; + } + } + + void _generateContext() { + final context = + _beginClass('context', null) + ..constructors.add( + Constructor( + (c) => + c + ..name = '_' + ..constant = true + ..requiredParameters.add( + Parameter( + (p) => + p + ..name = 'key' + ..toThis = true, + ), + ), + ), + ) + ..fields.add( + Field( + (f) => + f + ..modifier = FieldModifier.final$ + ..type = DartTypes.core.string + ..name = 'key', + ), + ); + if (project.auth != null) { + context.constructors.add( + Constructor( + (c) => + c + ..constant = true + ..name = 'user' + ..initializers.add( + refer('this').property('_').call([ + literalString(raw: true, r'$user'), + ]).code, + ), + ), + ); + } + } + + Library generate() { + // final allApis = project.apis.values; + // if (allApis.isNotEmpty) { + // // Ensures consistent ordering in output file which helps with diffs. + // final apis = SplayTreeMap(); + // final functions = SplayTreeMap(); + // for (final api in allApis) { + // _generateApi( + // api, + // apis: apis, + // functions: functions, + // ); + // } + // _beginClass('Apis').fields.addAll(apis.build().values); + // _beginClass('Functions').fields.addAll(functions.build().values); + // } + // if (project.variables.isNotEmpty) { + // _generateEnv(project.variables); + // } + return _library.build(); + } +} diff --git a/apps/cli/lib/codegen/reserved_words.dart b/apps/cli/lib/codegen/reserved_words.dart new file mode 100644 index 000000000..6a3ae8298 --- /dev/null +++ b/apps/cli/lib/codegen/reserved_words.dart @@ -0,0 +1,124 @@ +final RegExp _illegalChars = RegExp('[+]'); + +String sanitizeVariableName(String name) { + name = name.replaceAll(_illegalChars, '_'); + if (hardReservedWords.contains(name)) { + name = '${name}_'; + } + return name; +} + +/// Keywords in Dart which *may* be used as identifiers in the right context. +/// Try to avoid using these keywords if possible, since it can be difficult to +/// keep track of their valid contexts. +/// +/// See [here](https://dart.dev/guides/language/language-tour#keywords) for +/// more info. +const softReservedWords = { + 'abstract', + 'as', + 'async', + 'covariant', + 'deferred', + 'dynamic', + 'export', + 'extension', + 'external', + 'factory', + 'Function', + 'get', + 'hide', + 'implements', + 'import', + 'interface', + 'late', + 'library', + 'mixin', + 'on', + 'operator', + 'part', + 'required', + 'set', + 'show', + 'static', + 'sync', + 'typedef', + 'yield', +}; + +/// The Dart language's reserved words. These are words which can never be used +/// as identifiers and must be suffixed with "$" before they can be used. +/// +/// See [here](https://dart.dev/guides/language/language-tour#keywords) for +/// more info. +const hardReservedWords = { + 'assert', + 'await', + 'break', + 'case', + 'catch', + 'class', + 'const', + 'continue', + 'default', + 'do', + 'else', + 'enum', + 'extends', + 'false', + 'finally', + 'for', + 'if', + 'in', + 'is', + 'new', + 'null', + 'rethrow', + 'return', + 'super', + 'switch', + 'this', + 'throw', + 'true', + 'try', + 'var', + 'void', + 'while', + 'with', + + // Lowercase type names create conflicts + 'double', + 'int', + 'bool', + + // Conflicts with `dart:core` + 'override', + + // aws equatable + 'props', + + // All generated types + 'serializers', +}; + +const enumReservedWords = ['name', 'value', 'index', 'values']; + +const unionReservedWords = ['name', 'value', 'sdkUnknown', 'unknown']; + +// Reserved due to `built_value` +const structReservedWords = [ + 'update', + 'build', + 'rebuild', + 'serializer', + 'replace', + 'toBuilder', + 'object', +]; + +const reservedTypeNames = [ + // Conflicts with usages of core.Type in serializer classes. + 'Type', + 'Function', + 'Object', +]; diff --git a/apps/cli/lib/commands/analysis_server_command.dart b/apps/cli/lib/commands/analysis_server_command.dart new file mode 100644 index 000000000..5f59d6e7a --- /dev/null +++ b/apps/cli/lib/commands/analysis_server_command.dart @@ -0,0 +1,82 @@ +import 'dart:async'; +import 'dart:convert'; +import 'dart:io' as io; + +import 'package:analyzer_plugin/channel/channel.dart'; +import 'package:analyzer_plugin/protocol/protocol.dart'; +import 'package:celest_cli/analyzer/plugin/celest_analyzer_plugin.dart'; +import 'package:celest_cli/commands/celest_command.dart'; + +final class AnalysisServerCommand extends CelestCommand { + AnalysisServerCommand(); + + @override + String get description => 'Starts an analysis server for a Celest project.'; + + @override + String get name => 'analysis-server'; + + @override + bool get hidden => true; + + @override + Future run() async { + await super.run(); + + logger.fine('Starting analysis server...'); + io.stdout.writeln('{"event":"ready"}'); + + final done = Completer(); + final plugin = CelestAnalyzerPlugin( + onError: done.completeError, + onDone: done.complete, + ); + plugin.start(_StdIoPluginChannel()); + + await done.future; + return 0; + } +} + +final class _StdIoPluginChannel implements PluginCommunicationChannel { + _StdIoPluginChannel(); + + StreamSubscription? _requestSubscription; + + @override + void close() { + _requestSubscription?.cancel(); + _requestSubscription = null; + } + + @override + void listen( + void Function(Request request) onRequest, { + Function? onError, + void Function()? onDone, + }) { + final requestStream = io.stdin + .transform(utf8.decoder) + .transform(const LineSplitter()) + .map((requestJson) { + return Request.fromJson( + jsonDecode(requestJson) as Map, + ); + }); + _requestSubscription = requestStream.listen( + onRequest, + onError: onError, + onDone: onDone, + ); + } + + @override + void sendNotification(Notification notification) { + io.stdout.writeln(jsonEncode(notification.toJson())); + } + + @override + void sendResponse(Response response) { + io.stdout.writeln(jsonEncode(response.toJson())); + } +} diff --git a/apps/cli/lib/commands/build_command.dart b/apps/cli/lib/commands/build_command.dart new file mode 100644 index 000000000..3ab344b7d --- /dev/null +++ b/apps/cli/lib/commands/build_command.dart @@ -0,0 +1,33 @@ +import 'package:celest_cli/commands/celest_command.dart'; +import 'package:celest_cli/commands/project_init.dart'; +import 'package:celest_cli/commands/project_migrate.dart'; +import 'package:celest_cli/frontend/celest_frontend.dart'; +import 'package:celest_cli/src/context.dart'; +import 'package:mason_logger/src/mason_logger.dart'; + +final class BuildCommand extends CelestCommand with Configure, Migrate { + @override + String get name => 'build'; + + @override + String get description => 'Builds your Celest project for hosting.'; + + @override + String get category => 'Project'; + + @override + Progress? currentProgress; + + @override + Future run() async { + await super.run(); + + final needsMigration = await configure(); + + return CelestFrontend().build( + migrateProject: needsMigration, + currentProgress: cliLogger.progress('Building project'), + environmentId: 'production', // TODO(dnys1): Allow setting environment + ); + } +} diff --git a/apps/cli/lib/commands/celest_command.dart b/apps/cli/lib/commands/celest_command.dart new file mode 100644 index 000000000..357e7590a --- /dev/null +++ b/apps/cli/lib/commands/celest_command.dart @@ -0,0 +1,122 @@ +import 'dart:async'; +import 'dart:convert'; +import 'dart:io'; + +import 'package:args/command_runner.dart'; +import 'package:celest_cli/src/context.dart'; +import 'package:celest_cli/src/models.dart'; +import 'package:celest_cli/src/releases/latest_release.dart'; +import 'package:celest_cli/src/sdk/dart_sdk.dart'; +import 'package:cli_util/cli_util.dart'; +import 'package:http/http.dart' as http; +import 'package:logging/logging.dart'; +import 'package:meta/meta.dart'; +import 'package:path/path.dart' as p; +import 'package:pub_semver/pub_semver.dart'; + +/// Base class for all commands in this package providing common functionality. +abstract base class CelestCommand extends Command { + late final Logger logger = Logger(name); + + /// The version of the CLI. + late final String version; + + /// Whether verbose logging is enabled. + bool get verbose => globalResults?['verbose'] as bool? ?? false; + + /// The path to the Flutter SDK, if installed. + late final String? flutterRoot = () { + final dartSdkPath = getSdkPath(); + final flutterBin = p.dirname(p.dirname(dartSdkPath)); + if (File(p.join(flutterBin, 'flutter')).existsSync()) { + return p.dirname(flutterBin); + } + return null; + }(); + + /// Resolves the latest version information from `pub.dev`. + Future resolveVersionInfo(String package) async { + // Get the currently published version of the package. + final uri = Uri.parse('https://pub.dev/api/packages/$package'); + final resp = await httpClient.get( + uri, + headers: const {HttpHeaders.acceptHeader: 'application/vnd.pub.v2+json'}, + ); + + // Package is unpublished + if (resp.statusCode == 404) { + return null; + } + if (resp.statusCode != 200) { + throw http.ClientException(resp.body, uri); + } + + final respJson = jsonDecode(resp.body) as Map; + final versions = (respJson['versions'] as List?) ?? []; + final semvers = []; + for (final version in versions) { + final map = (version as Map).cast(); + final semver = map['version'] as String?; + if (semver == null) { + continue; + } + semvers.add(Version.parse(semver)); + } + + return PubVersionInfo(semvers..sort()); + } + + Future checkForLatestVersion() async { + try { + final latestRelease = await performance.trace( + 'CelestCommand', + 'retrieveLatestRelease', + () => + retrieveLatestRelease(version).timeout(const Duration(seconds: 3)), + ); + if (latestRelease.version > Version.parse(version)) { + cliLogger.warn( + 'A new version of Celest is available! Run `celest upgrade` ' + 'to get the latest changes.', + ); + } + } on Object catch (e, st) { + performance.captureError(e, stackTrace: st); + } + } + + @override + @mustCallSuper + Future run() async { + logger.finest( + 'Running `celest $name` from "${fileSystem.currentDirectory.path}"', + ); + analytics.capture( + 'cli', + properties: { + 'command': name, + 'args': argResults!.arguments.join(' '), + 'environment': kCliEnvironment, + 'version': version, + 'sdk_version': Sdk.current.version.toString(), + if (Sdk.current.flutterVersion case final flutterVersion?) + 'flutter_sdk_version': flutterVersion.toString(), + }, + ); + return 0; + } + + final _deferred = Function()>[]; + + /// Defers a function to be called when the command is closed. + void defer(FutureOr Function() fn) { + _deferred.add(fn); + } + + @mustCallSuper + Future close() async { + await Future.wait([ + for (final deferred in _deferred) Future.value(deferred()), + ]); + } +} diff --git a/apps/cli/lib/commands/init_command.dart b/apps/cli/lib/commands/init_command.dart new file mode 100644 index 000000000..20cbce98d --- /dev/null +++ b/apps/cli/lib/commands/init_command.dart @@ -0,0 +1,94 @@ +import 'dart:io'; + +import 'package:celest_cli/commands/celest_command.dart'; +import 'package:celest_cli/commands/project_init.dart'; +import 'package:celest_cli/src/context.dart'; +import 'package:mason_logger/mason_logger.dart'; + +final class InitCommand extends CelestCommand with Configure, ProjectCreator { + InitCommand(); + + @override + String get description => 'Creates a new Celest project.'; + + @override + String get name => 'init'; + + @override + String get category => 'Project'; + + @override + Progress? currentProgress; + + /// Precache assets in the background. + Future _precacheInBackground() async { + final List command; + if (fileSystem.path.fromUri(platform.script).endsWith('.snapshot')) { + command = [ + platform.resolvedExecutable, + 'pub', + 'global', + 'run', + 'celest_cli:celest', + 'precache', + projectPaths.projectRoot, + ]; + } else if (platform.executable.contains('dart')) { + command = [ + platform.resolvedExecutable, + 'run', + platform.script.toFilePath(), + 'precache', + projectPaths.projectRoot, + ]; + } else { + command = [ + platform.resolvedExecutable, + 'precache', + projectPaths.projectRoot, + ]; + } + try { + logger.fine('Precaching assets in background...'); + await processManager.start( + command, + mode: ProcessStartMode.detached, + workingDirectory: projectPaths.projectRoot, + ); + } on Object catch (e, st) { + logger.fine('Failed to precache assets', e, st); + performance.captureError(e, stackTrace: st, extra: {'command': command}); + } + } + + @override + Future run() async { + await super.run(); + + await checkForLatestVersion(); + await configure(); + await _precacheInBackground(); + + final projectRoot = projectPaths.projectRoot; + + var command = 'celest start'; + // `celest start` can be run from either the project root, the attached + // Flutter app's root if there is one, or any subdirectory therof. + // + // If we're in none of those, then add a `cd` command to the start messsage. + final currentDir = fileSystem.currentDirectory.path; + final appRoot = celestProject.parentProject?.path ?? projectRoot; + if (!p.equals(appRoot, currentDir) && !p.isWithin(appRoot, currentDir)) { + final relativePath = p.relative(appRoot, from: currentDir); + command = 'cd $relativePath && $command'; + } + stdout.writeln(); + cliLogger.success('🚀 To start a local development server, run:'); + stdout + ..writeln() + ..writeln(' $command') + ..writeln(); + + return 0; + } +} diff --git a/apps/cli/lib/commands/precache_command.dart b/apps/cli/lib/commands/precache_command.dart new file mode 100644 index 000000000..c1c0d9782 --- /dev/null +++ b/apps/cli/lib/commands/precache_command.dart @@ -0,0 +1,65 @@ +import 'dart:isolate'; + +import 'package:celest_cli/analyzer/celest_analyzer.dart'; +import 'package:celest_cli/commands/celest_command.dart'; +import 'package:celest_cli/pub/pub_cache.dart'; +import 'package:celest_cli/src/context.dart'; + +final class PrecacheCommand extends CelestCommand { + @override + String get name => 'precache'; + + @override + String get description => 'Precaches assets for a Celest Cloud project.'; + + @override + bool get hidden => true; + + @override + String get category => 'Tools'; + + static Future _warmUp() async { + final projectRoot = projectPaths.projectRoot; + await Isolate.run(() => CelestAnalyzer.warmUp(projectRoot)); + } + + @override + Future run() async { + await super.run(); + + final projectRoot = + argResults!.rest.firstOrNull ?? fileSystem.currentDirectory.path; + + await init(projectRoot: projectRoot); + + logger.fine('Precaching assets for project: $projectRoot'); + final operations = >[]; + + operations.add( + performance.trace('CelestAnalyzer', 'warmUp', () async { + logger.fine('Warming up Dart Analyzer'); + await _warmUp(); + logger.fine('Dart Analyzer warmed up'); + }), + ); + + operations.add( + performance.trace('Celest', 'fixPubCache', () async { + logger.finest('Hydrating pub cache...'); + await pubCache.hydrate(); + logger.finest('Fixing pub cache...'); + await pubCache.fix(); + logger.finest('Pub cache fixed.'); + }), + ); + + try { + await Future.wait(operations); + } on Object catch (e, st) { + logger.fine('Failed to precache assets', e, st); + performance.captureError(e, stackTrace: st); + } + + return 0; + } +} diff --git a/apps/cli/lib/commands/project_init.dart b/apps/cli/lib/commands/project_init.dart new file mode 100644 index 000000000..4e8e10a66 --- /dev/null +++ b/apps/cli/lib/commands/project_init.dart @@ -0,0 +1,303 @@ +import 'dart:async'; +import 'dart:io'; + +import 'package:celest_cli/commands/celest_command.dart'; +import 'package:celest_cli/commands/init_command.dart'; +import 'package:celest_cli/commands/project_migrate.dart'; +import 'package:celest_cli/commands/start_command.dart'; +import 'package:celest_cli/init/project_generator.dart'; +import 'package:celest_cli/project/celest_project.dart'; +import 'package:celest_cli/pub/pub_action.dart'; +import 'package:celest_cli/src/context.dart'; +import 'package:celest_cli/src/exceptions.dart'; +import 'package:celest_cli/src/sdk/dart_sdk.dart'; +import 'package:celest_cli/src/utils/error.dart'; +import 'package:celest_cli/src/utils/recase.dart'; +import 'package:celest_cli/src/utils/run.dart'; +import 'package:dcli/dcli.dart' as dcli; +import 'package:mason_logger/mason_logger.dart'; + +base mixin ProjectCreator on Configure { + Future createProject({ + required String projectName, + required ParentProject? parentProject, + }) async { + logger.finest( + 'Generating project for "$projectName" at ' + '"${projectPaths.projectRoot}"...', + ); + await performance.trace('ProjectCreator', 'createProject', () async { + await ProjectGenerator( + parentProject: parentProject, + projectRoot: projectPaths.projectRoot, + projectName: projectName, + ).generate(); + logger.fine('Project generated successfully'); + }); + return projectName; + } +} + +sealed class ConfigureState {} + +final class Initializing implements ConfigureState { + const Initializing(); +} + +final class CreatingProject implements ConfigureState { + const CreatingProject(); +} + +final class CreatedProject implements ConfigureState { + const CreatedProject(); +} + +final class MigratingProject implements ConfigureState { + const MigratingProject(); +} + +final class MigratedProject implements ConfigureState { + const MigratedProject(); +} + +final class Initialized implements ConfigureState { + const Initialized({required this.needsAnalyzerMigration}); + + final bool needsAnalyzerMigration; +} + +base mixin Configure on CelestCommand { + abstract Progress? currentProgress; + + static Never _throwNoProject() => + throw const CliException( + 'No Celest project found in the current directory. ' + 'To create a new project, run `celest init`.', + ); + + String newProjectName({String? defaultName}) { + if (defaultName != null && defaultName.startsWith('celest')) { + defaultName = null; + } + defaultName ??= 'my_project'; + String? projectName; + while (projectName == null) { + final input = + dcli + .ask('Enter a name for your project', defaultValue: defaultName) + .trim(); + if (input.isEmpty) { + cliLogger.err('Project name cannot be empty.'); + continue; + } + final words = input.groupIntoWords(); + for (final (index, word) in List.of(words).indexed) { + if (word == 'celest') { + words.removeAt(index); + } + } + projectName = words.snakeCase; + } + return projectName; + } + + Future configure() async { + await for (final state in _configure()) { + switch (state) { + case Initializing(): + currentProgress?.complete(); + currentProgress = cliLogger.progress('Initializing Celest'); + case CreatingProject(): + currentProgress?.complete(); + currentProgress = cliLogger.progress('Generating project'); + case CreatedProject(): + currentProgress?.complete('Project successfully generated'); + currentProgress = null; + case MigratingProject(): + currentProgress?.complete(); + currentProgress = cliLogger.progress('Migrating project'); + case MigratedProject(): + currentProgress?.complete('Project successfully migrated'); + currentProgress = null; + case Initialized(needsAnalyzerMigration: final needsMigration): + currentProgress?.complete(); + currentProgress = null; + return needsMigration; + } + } + unreachable(); + } + + /// Returns true if the project needs to be migrated. + Stream _configure() async* { + var currentDir = fileSystem.currentDirectory; + final currentDirIsEmpty = await currentDir.list().isEmpty; + + var pubspecFile = currentDir.childFile('pubspec.yaml'); + if (this case (StartCommand() || InitCommand())) { + // Do not search recursively for the pubspec file. Just search the current + // directory. + } else { + // For other commands, search recursively for the Celest pubspec file. + while (!pubspecFile.existsSync()) { + if (currentDir == currentDir.parent) { + _throwNoProject(); + } + currentDir = currentDir.parent; + pubspecFile = currentDir.childFile('pubspec.yaml'); + } + } + final projectFiles = [ + // Legacy + currentDir.childFile('project.dart'), + currentDir + .childDirectory('lib') + .childDirectory('src') + .childFile('project.dart'), + ]; + + final (celestDir, isExistingProject, parentProject) = switch (( + projectFiles.any((f) => f.existsSync()), + pubspecFile.existsSync(), + )) { + // We're inside the `celest` directory. + (true, _) => ( + currentDir, + true, + await ParentProject.load(currentDir.parent.path), + ), + + // We're inside a parent project. + (false, true) => await run(() async { + final celestDir = fileSystem.directory( + p.join(currentDir.path, 'celest'), + ); + return ( + celestDir, + celestDir.existsSync(), + await ParentProject.load(currentDir.path), + ); + }), + + // We're inside a folder which is neither a Dart/Flutter app nor a + // Celest project. + (false, false) => (null, false, null), + }; + + logger.finest( + 'Project state: dir=$celestDir, existing=$isExistingProject, ' + 'parent=${parentProject?.type}', + ); + + String projectRoot; + String? projectName; + if (isExistingProject) { + if (this is InitCommand) { + cliLogger.success( + 'A Celest project already exists in the current directory. ' + 'Run `celest start` to start the project.', + ); + await Future(() => exit(0)); + } + projectRoot = celestDir!.path; + } else { + switch (this) { + case StartCommand(): + cliLogger.warn('No Celest project found in the current directory.'); + final createNew = dcli.confirm( + dcli.green('Would you like to create a new one?', bold: true), + defaultValue: true, + ); + if (!createNew) { + cliLogger.info('Skipping project creation.'); + await Future(() => exit(0)); + } + case InitCommand(): + break; + default: + _throwNoProject(); + } + + var defaultProjectName = parentProject?.name; + if (currentDirIsEmpty) { + defaultProjectName ??= p.basename(currentDir.path); + } + projectName = newProjectName(defaultName: defaultProjectName); + + // Choose where to store the project based on the current directory. + projectRoot = switch (celestDir) { + final celestDir? => celestDir.path, + + // If the current directory is not empty, ee should create a new folder + // for the project which is unattached to any parent project, named + // after the project. + null when !currentDirIsEmpty => await run(() async { + final projectRoot = p.join(currentDir.path, projectName); + final projectDir = fileSystem.directory(projectRoot); + if (projectDir.existsSync() && !await projectDir.list().isEmpty) { + throw CliException( + 'A directory named "$projectName" already exists. ' + 'Please choose a different name, or run this command from a ' + 'different directory.', + ); + } + return projectRoot; + }), + + // Otherwise, we're in an empty directory, and can use it as the root. + null => currentDir.path, + }; + } + + yield const Initializing(); + await init(projectRoot: projectRoot, parentProject: parentProject); + + final postUpgrade = celestProject.cacheDb.needsProjectUpgrade; + var needsAnalyzerMigration = false; + Future? upgradePackages; + if (!isExistingProject) { + if (this case final ProjectCreator projectCreator) { + yield const CreatingProject(); + await projectCreator.createProject( + projectName: projectName!, + parentProject: parentProject, + ); + yield const CreatedProject(); + } else { + _throwNoProject(); + } + } else if (this case final Migrate projectMigrator) { + yield const MigratingProject(); + needsAnalyzerMigration = await projectMigrator.migrateProject( + parentProject: parentProject, + ); + await (upgradePackages = _pubUpgrade()); + if (postUpgrade && parentProject != null) { + await processManager.run([ + Sdk.current.dart, + 'fix', + '--apply', + ], workingDirectory: parentProject.path); + } + yield const MigratedProject(); + } + await (upgradePackages ??= _pubUpgrade()); + + yield Initialized(needsAnalyzerMigration: needsAnalyzerMigration); + } + + // TODO(dnys1): Improve logic here so that we don't run pub upgrade if + // the dependencies in the lockfile are already up to date. + Future _pubUpgrade() async { + final projectRoot = projectPaths.projectRoot; + await runPub(action: PubAction.upgrade, workingDirectory: projectRoot); + // Run serially to avoid `flutter pub` locks. + if (celestProject.parentProject case final parentProject?) { + await runPub( + exe: parentProject.type.name, + action: PubAction.get, + workingDirectory: parentProject.path, + ); + } + } +} diff --git a/apps/cli/lib/commands/project_migrate.dart b/apps/cli/lib/commands/project_migrate.dart new file mode 100644 index 000000000..5f5cb16a4 --- /dev/null +++ b/apps/cli/lib/commands/project_migrate.dart @@ -0,0 +1,20 @@ +import 'package:celest_cli/commands/project_init.dart'; +import 'package:celest_cli/init/project_migrator.dart'; +import 'package:celest_cli/project/celest_project.dart'; +import 'package:celest_cli/src/context.dart'; + +base mixin Migrate on Configure { + Future migrateProject({required ParentProject? parentProject}) async { + logger.finest('Migrating project at "${projectPaths.projectRoot}"...'); + return performance.trace('Migrate', 'migrateProject', () async { + final result = + await ProjectMigrator( + parentProject: parentProject, + projectRoot: projectPaths.projectRoot, + projectName: celestProject.projectName, + ).migrate(); + logger.fine('Project migration result: $result'); + return result.needsAnalyzerMigration; + }); + } +} diff --git a/apps/cli/lib/commands/start_command.dart b/apps/cli/lib/commands/start_command.dart new file mode 100644 index 000000000..86552cf8b --- /dev/null +++ b/apps/cli/lib/commands/start_command.dart @@ -0,0 +1,39 @@ +import 'package:celest_cli/commands/celest_command.dart'; +import 'package:celest_cli/commands/project_init.dart'; +import 'package:celest_cli/commands/project_migrate.dart'; +import 'package:celest_cli/frontend/celest_frontend.dart'; +import 'package:celest_cli/src/context.dart'; +import 'package:mason_logger/mason_logger.dart'; + +final class StartCommand extends CelestCommand + with Configure, Migrate, ProjectCreator { + StartCommand(); + + @override + String get description => 'Starts a local Celest environment.'; + + @override + String get name => 'start'; + + @override + String get category => 'Project'; + + @override + Progress? currentProgress; + + @override + Future run() async { + await super.run(); + + await checkForLatestVersion(); + final needsMigration = await configure(); + + currentProgress ??= cliLogger.progress('Starting local environment'); + + // Start the Celest Frontend Loop + return CelestFrontend().run( + migrateProject: needsMigration, + currentProgress: currentProgress, + ); + } +} diff --git a/apps/cli/lib/commands/uninstall/celest_uninstaller.dart b/apps/cli/lib/commands/uninstall/celest_uninstaller.dart new file mode 100644 index 000000000..f84bf017a --- /dev/null +++ b/apps/cli/lib/commands/uninstall/celest_uninstaller.dart @@ -0,0 +1,153 @@ +import 'dart:convert'; +import 'dart:io'; + +import 'package:celest_cli/src/context.dart'; +import 'package:celest_cli/src/exceptions.dart'; +import 'package:celest_cli/src/utils/error.dart'; +import 'package:logging/logging.dart'; + +class CelestUninstaller { + const CelestUninstaller(); + + static final logger = Logger('CelestUninstaller'); + + static const windowsPackageName = 'Celest.CLI'; + static const macosEntrypoint = '/usr/local/bin/celest'; + + Future uninstall() async { + await removeConfig(); + + if (fileSystem.path.fromUri(platform.script).endsWith('.snapshot')) { + await _uninstallPubGlobal(); + } else if (platform.executable.contains('dart')) { + // Celest is running from source. Nothing to uninstall. + } else { + await _uninstallAot(); + } + } + + Future removeConfig() async { + await celestProject.config.delete(); + storage.clear(); + secureStorage.clear(); + } + + Future _uninstallPubGlobal() async { + logger.fine('Removing Celest from pub global...'); + final result = await processManager.run( + [ + platform.resolvedExecutable, + 'pub', + 'global', + 'deactivate', + 'celest_cli', + ], + stdoutEncoding: utf8, + stderrEncoding: utf8, + ); + if (result.exitCode != 0) { + logger.fine( + 'Failed to uninstall Celest from pub global.', + '${result.stdout}\n${result.stderr}', + ); + throw const CliException('Failed to uninstall Celest from pub global.'); + } + } + + Future _uninstallAot() async { + final exe = platform.resolvedExecutable; + switch (platform.operatingSystem) { + case 'linux': + final dpkgOutput = await processManager.run( + ['dpkg', '-S', exe], + stdoutEncoding: utf8, + stderrEncoding: utf8, + ); + if (dpkgOutput.exitCode != 0) { + return logger.warning( + 'Celest configuration has been removed. To uninstall the CLI, delete ' + 'the downloaded executable and associated files from your computer.', + ); + } + final package = (dpkgOutput.stdout as String).split(':').first.trim(); + if (package != 'celest') { + throw StateError('Unexpected package: $package'); + } + final uninstallOutput = await processManager.start([ + 'sudo', + 'dpkg', + '--purge', + package, + ], mode: ProcessStartMode.inheritStdio); + if (await uninstallOutput.exitCode != 0) { + throw const CliException( + 'Celest was partially uninstalled. Please use dpkg to clean up ' + 'remaining files.', + ); + } + case 'macos': + if (p.basename(p.dirname(exe)) == 'MacOS') { + // celest/celest.app/Contents/MacOS/celest + final installPath = p.dirname(p.dirname(p.dirname(p.dirname(exe)))); + if (p.basename(installPath) != 'celest') { + throw StateError('Unexpected install path: $installPath'); + } + final uninstallScript = + "[[ -d '$installPath' ]] && rm -r '$installPath'; [[ -h '$macosEntrypoint' || -f '$macosEntrypoint' ]] && rm '$macosEntrypoint'"; + final uninstallOutput = await processManager.run( + [ + 'osascript', + '-e', + 'do shell script "$uninstallScript" ' + 'with prompt "Celest needs your permission to uninstall" ' + 'with administrator privileges', + ], + stdoutEncoding: utf8, + stderrEncoding: utf8, + ); + logger.finest( + 'Uninstall output:\n' + '${uninstallOutput.exitCode}\n' + '${uninstallOutput.stdout}\n' + '${uninstallOutput.stderr}', + ); + if (uninstallOutput.exitCode != 0) { + throw ProcessException( + uninstallScript, + [], + 'Failed to uninstall Celest: ' + '${uninstallOutput.stdout}\n${uninstallOutput.stderr}', + uninstallOutput.exitCode, + ); + } + } else if (exe.contains(p.join('apps', 'cli')) || + exe.contains('apps/cli')) { + // Local AOT compile. Remove parent directory. + final localDir = fileSystem.directory(p.dirname(exe)); + logger.fine('Deleting directory: $localDir'); + await localDir.delete(recursive: true); + } else { + throw StateError('Unrecognized install location: $exe'); + } + case 'windows': + final appxPackageInfo = await processManager.run( + [ + 'powershell', + '-Command', + 'Get-AppxPackage -Name "$windowsPackageName" | Remove-AppxPackage -Confirm:\$false', + ], + stdoutEncoding: utf8, + stderrEncoding: utf8, + ); + if (appxPackageInfo.exitCode != 0) { + throw StateError( + 'Could not uninstall package "$windowsPackageName". ' + 'Stdout: ${appxPackageInfo.stdout}\n' + 'Stderr: ${appxPackageInfo.stderr}', + ); + } + case final unsupported: + unreachable('Unsupported OS: $unsupported'); + } + } +} diff --git a/apps/cli/lib/commands/uninstall_command.dart b/apps/cli/lib/commands/uninstall_command.dart new file mode 100644 index 000000000..ed3314885 --- /dev/null +++ b/apps/cli/lib/commands/uninstall_command.dart @@ -0,0 +1,37 @@ +import 'package:celest_cli/commands/celest_command.dart'; +import 'package:celest_cli/commands/uninstall/celest_uninstaller.dart'; +import 'package:celest_cli/src/context.dart'; + +final class UninstallCommand extends CelestCommand { + UninstallCommand(); + + @override + String get description => 'Uninstalls the Celest CLI.'; + + @override + String get name => 'uninstall'; + + @override + String get category => 'Tools'; + + @override + Future run() async { + await super.run(); + + final areYouSure = cliLogger.confirm( + 'Are you sure you want to uninstall Celest and all associated data?', + ); + if (!areYouSure) { + cliLogger.info('Aborted uninstall'); + return 0; + } + + // Bare init so we can access the celest config. + await init(projectRoot: fileSystem.currentDirectory.path); + + await const CelestUninstaller().uninstall(); + + cliLogger.success('Successfully uninstalled Celest'); + return 0; + } +} diff --git a/apps/cli/lib/commands/upgrade/celest_upgrader.dart b/apps/cli/lib/commands/upgrade/celest_upgrader.dart new file mode 100644 index 000000000..55bdbcfda --- /dev/null +++ b/apps/cli/lib/commands/upgrade/celest_upgrader.dart @@ -0,0 +1,307 @@ +import 'dart:convert'; +import 'dart:io'; + +import 'package:archive/archive_io.dart'; +import 'package:celest_cli/src/context.dart'; +import 'package:celest_cli/src/exceptions.dart'; +import 'package:celest_cli/src/releases/celest_release_info.dart'; +import 'package:celest_cli/src/utils/error.dart'; +import 'package:file/file.dart'; +import 'package:http/http.dart' as http; +import 'package:logging/logging.dart'; +import 'package:mason_logger/mason_logger.dart' as mason_logger; + +enum ReleaseType { zip, installer } + +final class CelestUpgrader { + CelestUpgrader({required this.cliLogger}); + + static final _logger = Logger('CelestUpgrader'); + + final mason_logger.Logger cliLogger; + mason_logger.Progress? _progress; + final _tempDir = fileSystem.systemTempDirectory.childDirectory('celest_cli_'); + + late final ReleaseType _releaseType = () { + switch (platform.operatingSystem) { + case 'windows' || 'macos': + return ReleaseType.installer; + case 'linux': + final isDpkg = + processManager + .runSync( + ['dpkg', '-S', platform.resolvedExecutable], + stdoutEncoding: utf8, + stderrEncoding: utf8, + ) + .exitCode == + 0; + return isDpkg ? ReleaseType.installer : ReleaseType.zip; + default: + unreachable(); + } + }(); + + Future downloadRelease(CelestReleaseInfo release) async { + final downloadUri = CelestReleasesInfo.baseUri.resolve( + switch (_releaseType) { + ReleaseType.zip => release.zip!, + ReleaseType.installer => release.installer!, + }, + ); + final downloadResp = await httpClient.send( + http.Request('GET', downloadUri), + ); + if (downloadResp.statusCode != 200) { + throw CliException( + 'Failed to download Celest. Please check your internet ' + 'connection and try again or download directly from: ' + 'https://celest.dev/download', + additionalContext: { + 'statusCode': downloadResp.statusCode.toString(), + 'body': await downloadResp.stream.bytesToString(), + }, + ); + } + + final downloadFile = _tempDir.childFile(p.url.basename(downloadUri.path)); + await downloadFile.create(recursive: true); + await downloadResp.stream.pipe(downloadFile.openWrite()); + return downloadFile; + } + + Future installRelease(File releasePackage) async { + try { + // Skip on macOS since the permissions prompt will count towards the + // progress timer. + // Skip on Linux installer since we shell out to dpkg which conflicts + // with our CLI spinner. + if (platform.isWindows) { + _progress = cliLogger.progress('Updating Celest'); + } else if (platform.isMacOS) { + cliLogger.info( + 'Please enter your password in the dialog that appears.', + ); + } + switch (platform.operatingSystem) { + case 'macos': + await _installMacOS(releasePackage.path); + case 'linux': + await _installLinux(releasePackage); + case 'windows': + await _installWindows(releasePackage); + default: + unreachable(); + } + const successMessage = 'Celest has been updated to the latest version!'; + if (_progress case final progress?) { + progress.complete(successMessage); + } else { + cliLogger.success(successMessage); + } + } on Object catch (e, st) { + _progress?.cancel(); + if (e is CliException) { + rethrow; + } + performance.captureError(e, stackTrace: st); + throw CliException( + 'Failed to upgrade Celest. Please install the latest version from ' + 'https://celest.dev/download.', + additionalContext: {'error': e.toString(), 'stackTrace': st.toString()}, + ); + } finally { + _progress = null; + } + } + + Future _installWindows(File installerAppx) async { + final installOutput = await processManager.run( + [ + 'powershell', + '-Command', + 'Add-AppxPackage -Path "${installerAppx.path}" -DeferRegistrationWhenPackagesAreInUse', + ], + stdoutEncoding: utf8, + stderrEncoding: utf8, + ); + if (installOutput.exitCode != 0) { + throw ProcessException( + 'Add-AppxPackage', + [installerAppx.path], + 'Failed to install Celest:\n' + 'stdout: ${installOutput.stdout}\n' + 'stderr: ${installOutput.stderr}', + installOutput.exitCode, + ); + } + } + + Future _installLinuxZip(File installerZip) async { + _logger.finest('Installing Celest from ${installerZip.path}'); + if (p.extension(installerZip.path) != '.zip') { + throw StateError('Expected zip file but got: $installerZip'); + } + final zipStream = InputFileStream(installerZip.path); + final archive = ZipDecoder().decodeStream(zipStream); + final resolvedExe = platform.resolvedExecutable; + if (p.basename(resolvedExe) != 'celest') { + throw StateError('Expected `celest` exe but got: $resolvedExe'); + } + final currentExeDir = fileSystem.directory(p.dirname(resolvedExe)); + _logger.finest('Unzipping to ${currentExeDir.path}'); + try { + for (final zippedFile in archive.files) { + // Replace current executable + final file = currentExeDir.childFile(p.basename(zippedFile.name)); + final exists = await file.exists(); + _logger.finest('Updating ${file.path}. Exists: $exists'); + if (exists) { + // Need to rm (unlink) before replacing + // https://stackoverflow.com/questions/1712033/replacing-a-running-executable-in-linux + final rmOutput = await processManager.start([ + 'sudo', + 'rm', + file.path, + ], mode: ProcessStartMode.inheritStdio); + if (await rmOutput.exitCode case final exitCode && != 0) { + throw ProcessException( + 'rm', + [file.path], + 'Failed to rm ${file.path}', + exitCode, + ); + } + } + final output = OutputFileStream(file.path); + zippedFile.writeContent(output); + output.flush(); + await output.close(); + } + // Make files executable + for (final file in [ + currentExeDir.childFile('celest'), + currentExeDir.childFile('launcher.sh'), + ]) { + if (!await file.exists()) continue; + _logger.finest('Making ${file.path} executable'); + final chmodOutput = await processManager.start([ + 'sudo', + 'chmod', + '+x', + file.path, + ], mode: ProcessStartMode.inheritStdio); + if (await chmodOutput.exitCode case final exitCode && != 0) { + throw ProcessException( + 'chmod', + ['+x', file.path], + 'Failed to chmod +x ${file.path}', + exitCode, + ); + } + } + } finally { + await zipStream.close(); + } + } + + Future _installLinuxInstaller(File installer) async { + if (p.extension(installer.path) != '.deb') { + throw StateError('Expected zip file but got: $installer'); + } + final sudoOutput = await processManager.start([ + 'sudo', + '-v', + ], mode: ProcessStartMode.inheritStdio); + if (await sudoOutput.exitCode case final exitCode && != 0) { + throw ProcessException('sudo', ['-v'], 'Failed to check sudo', exitCode); + } + final updateOutput = await processManager.run( + ['sudo', 'apt-get', 'update'], + stdoutEncoding: utf8, + stderrEncoding: utf8, + ); + if (updateOutput.exitCode != 0) { + throw ProcessException( + 'apt-get', + ['update'], + 'Failed to update apt-get:\n' + 'stdout: ${updateOutput.stdout}\n' + 'stderr: ${updateOutput.stderr}', + updateOutput.exitCode, + ); + } + final installOutput = await processManager.run( + [ + 'sudo', + 'apt-get', + 'install', + '-y', + '--fix-broken', + installer.path, + ], + stdoutEncoding: utf8, + stderrEncoding: utf8, + ); + if (installOutput.exitCode != 0) { + throw ProcessException( + 'apt-get', + ['install', installer.path], + 'Failed to install Celest:\n' + 'stdout: ${installOutput.stdout}\n' + 'stderr: ${installOutput.stderr}', + installOutput.exitCode, + ); + } + } + + Future _installLinux(File installerZip) async { + return switch (_releaseType) { + ReleaseType.zip => _installLinuxZip(installerZip), + ReleaseType.installer => _installLinuxInstaller(installerZip), + }; + } + + Future _installMacOS(String installerFile) async { + final volumeInfo = await processManager.run( + ['installer', '-pkg', installerFile, '-volinfo'], + stdoutEncoding: utf8, + stderrEncoding: utf8, + ); + _logger.finest( + 'Found volumes for installation:\n' + '${volumeInfo.exitCode}\n' + '${volumeInfo.stdout}\n' + '${volumeInfo.stderr}', + ); + final installerCommand = + 'installer -pkg $installerFile -target / -verbose -dumplog'; + final installOutput = await processManager.run( + [ + 'osascript', + '-e', + 'do shell script "$installerCommand" ' + 'with prompt "Celest needs your permission to upgrade" ' + 'with administrator privileges', + ], + stdoutEncoding: utf8, + stderrEncoding: utf8, + ); + _logger.finest( + 'Installer output:\n' + '${installOutput.exitCode}\n' + '${installOutput.stdout}\n' + '${installOutput.stderr}', + ); + if (installOutput.exitCode != 0) { + throw ProcessException( + 'installer', + [installerFile], + 'Failed to install Celest:\n' + 'stdout: ${installOutput.stdout}\n' + 'stderr: ${installOutput.stderr}', + installOutput.exitCode, + ); + } + } +} diff --git a/apps/cli/lib/commands/upgrade_command.dart b/apps/cli/lib/commands/upgrade_command.dart new file mode 100644 index 000000000..414cb87fe --- /dev/null +++ b/apps/cli/lib/commands/upgrade_command.dart @@ -0,0 +1,70 @@ +import 'package:celest_cli/commands/celest_command.dart'; +import 'package:celest_cli/commands/upgrade/celest_upgrader.dart'; +import 'package:celest_cli/src/context.dart'; +import 'package:celest_cli/src/exceptions.dart'; +import 'package:celest_cli/src/logging/with_progress.dart'; +import 'package:celest_cli/src/releases/latest_release.dart'; +import 'package:celest_cli/src/version.dart'; +import 'package:pub_semver/pub_semver.dart'; + +final class UpgradeCommand extends CelestCommand { + UpgradeCommand() { + argParser.addFlag( + 'dev', + help: 'Include dev versions', + defaultsTo: false, + hide: true, + ); + } + + @override + String get description => 'Upgrades the Celest CLI to the latest version.'; + + @override + String get name => 'upgrade'; + + @override + String get category => 'Tools'; + + @override + List get aliases => ['update']; + + late final bool includeDev = argResults!.flag('dev'); + + @override + Future run() async { + await super.run(); + + final upgrader = CelestUpgrader(cliLogger: cliLogger); + + try { + final latest = await retrieveLatestRelease( + packageVersion, + includeDev: includeDev, + ); + logger.fine('Latest published release: ${latest.version}'); + if (latest.version <= Version.parse(version)) { + cliLogger.success('Celest is already up to date!'); + return 0; + } + + final installerFile = await withProgress( + 'Downloading Celest ${latest.version}', + (progres) => upgrader.downloadRelease(latest), + ); + + await upgrader.installRelease(installerFile); + } on Object catch (e, st) { + Error.throwWithStackTrace( + CliException( + 'Failed to upgrade Celest. Please visit https://celest.dev/download ' + 'to upgrade manually.', + additionalContext: {'error': '$e'}, + ), + st, + ); + } + + return 0; + } +} diff --git a/apps/cli/lib/compiler/api/entrypoint_compiler.dart b/apps/cli/lib/compiler/api/entrypoint_compiler.dart new file mode 100644 index 000000000..66eb03b44 --- /dev/null +++ b/apps/cli/lib/compiler/api/entrypoint_compiler.dart @@ -0,0 +1,149 @@ +import 'dart:convert'; +import 'dart:io'; +import 'dart:isolate'; +import 'dart:typed_data'; + +import 'package:celest_ast/celest_ast.dart' as ast; +import 'package:celest_cli/compiler/package_config_transform.dart'; +import 'package:celest_cli/src/context.dart'; +import 'package:celest_cli/src/sdk/dart_sdk.dart'; +import 'package:celest_cli/src/utils/error.dart'; +import 'package:celest_cli/src/utils/json.dart'; +import 'package:crypto/crypto.dart'; +import 'package:logging/logging.dart'; + +final class EntrypointDefinition { + EntrypointDefinition({required this.functionName, required this.apiName}); + + final String functionName; + final String apiName; + + String get name => '$apiName/$functionName'; + late final String path = projectPaths.functionEntrypoint( + apiName, + functionName, + ); + + @override + String toString() => + prettyPrintJson({'name': name, 'apiName': apiName, 'path': path}); +} + +final class EntrypointResult { + const EntrypointResult({ + required this.outputDillPath, + required this.outputDill, + required this.outputDillDigest, + }); + + final String outputDillPath; + final Uint8List outputDill; + final Digest outputDillDigest; + + @override + String toString() => prettyPrintJson({ + 'outputDillPath': outputDillPath, + 'outputDillSha256': outputDillDigest.toString(), + }); +} + +final class EntrypointCompiler { + EntrypointCompiler({ + required this.logger, + required this.verbose, + required this.enabledExperiments, + }); + + final Logger logger; + final bool verbose; + final List enabledExperiments; + + Future compile({ + required ast.ResolvedProject resolvedProject, + required String entrypointPath, + }) async { + logger.fine('Compiling entrypoint: $entrypointPath'); + if (!fileSystem.isFileSync(entrypointPath)) { + throw StateError( + 'Entrypoint file does not exist or is not a file: ' + '$entrypointPath', + ); + } + final pathWithoutDart = entrypointPath.substring( + 0, + entrypointPath.length - 5, + ); + final packageConfig = await transformPackageConfig( + packageConfigPath: projectPaths.packagesConfig, + fromRoot: projectPaths.projectRoot, + toRoot: projectPaths.outputsDir, + ); + final outputPath = '$pathWithoutDart.dill'; + final (target, platformDill, sdkRoot) = switch (resolvedProject + .sdkConfig + .targetSdk) { + SdkType.flutter => ( + 'flutter', + Sdk.current.flutterPlatformDill!, + Sdk.current.flutterPatchedSdk!, + ), + SdkType.dart => ( + 'vm', + Sdk.current.vmPlatformDill, + p.join(Sdk.current.sdkPath, 'lib', '_internal'), + ), + final unknown => unreachable('Unknown SDK type: $unknown'), + }; + + // NOTE: FE server requires file: URIs for *some* paths on Windows. + final buildArgs = [ + Sdk.current.dartAotRuntime, + Sdk.current.frontendServerAotSnapshot, + '--aot', + '--tfa', + '--no-support-mirrors', + '--sdk-root=$sdkRoot', // Must be path + '--platform=${Uri.file(platformDill)}', // Must be URI + '--link-platform', + '--target=$target', + '-Ddart.vm.product=true', + '--output-dill=$outputPath', // Must be path + '--packages=${Uri.file(packageConfig)}', + if (enabledExperiments.isNotEmpty) + '--enable-experiment=${enabledExperiments.join(',')}', + Uri.file(p.canonicalize(p.normalize(entrypointPath))).toString(), + ]; + logger.finer('Compiling with args: $buildArgs'); + final result = await processManager.run( + buildArgs, + workingDirectory: projectPaths.outputsDir, + includeParentEnvironment: true, + stdoutEncoding: utf8, + stderrEncoding: utf8, + ); + final ProcessResult(:exitCode, :stdout as String, :stderr as String) = + result; + logger.fine('Compilation finished with status $exitCode'); + if (exitCode != 0) { + throw ProcessException( + Sdk.current.dart, + buildArgs, + 'Compilation failed:\n$stdout\n$stderr', + exitCode, + ); + } + logger.finer('Compilation succeeded'); + + final outputDill = await fileSystem.file(outputPath).readAsBytes(); + final outputDillDigest = await _computeMd5(outputDill.asUnmodifiableView()); + return EntrypointResult( + outputDillPath: outputPath, + outputDill: outputDill, + outputDillDigest: outputDillDigest, + ); + } +} + +Future _computeMd5(Uint8List data) async { + return Isolate.run(() => md5.convert(data)); +} diff --git a/apps/cli/lib/compiler/api/local_api_runner.dart b/apps/cli/lib/compiler/api/local_api_runner.dart new file mode 100644 index 000000000..52dd5f452 --- /dev/null +++ b/apps/cli/lib/compiler/api/local_api_runner.dart @@ -0,0 +1,643 @@ +import 'dart:async'; +import 'dart:convert'; +import 'dart:io'; + +import 'package:celest_ast/celest_ast.dart' as ast; +import 'package:celest_cli/compiler/frontend_server_client.dart'; +import 'package:celest_cli/src/context.dart'; +import 'package:celest_cli/src/process/port_finder.dart'; +import 'package:celest_cli/src/sdk/dart_sdk.dart'; +import 'package:celest_cli/src/utils/cli.dart'; +import 'package:celest_cli/src/utils/error.dart'; +import 'package:celest_cli/src/utils/json.dart'; +import 'package:celest_cli/src/utils/run.dart'; +import 'package:collection/collection.dart'; +import 'package:logging/logging.dart'; +import 'package:meta/meta.dart'; +import 'package:vm_service/vm_service.dart'; + +final Logger _logger = Logger('LocalApiRunner'); + +/// Like [EntrypointCompiler], this class runs Celest API functions as a local +/// server, watching for changes and hot-reloading when functions are changed. +final class LocalApiRunner { + LocalApiRunner._({ + required this.path, + required this.verbose, + required this.port, + required FrontendServerClient client, + required Process localApiProcess, + }) : _client = client, + _localApiProcess = localApiProcess; + + final bool verbose; + final String path; + + /// The port that the local API is running on. + final int port; + + final FrontendServerClient _client; + final Process _localApiProcess; + VmService? _vmService; + late final String _vmIsolateId; + + late final StreamSubscription _stdoutSub; + late final StreamSubscription _stderrSub; + + static Future start({ + required ast.ResolvedProject resolvedProject, + required String path, + required String environmentId, + required Map configValues, + required bool verbose, + List additionalSources = const [], + int? port, + @visibleForTesting Duration? vmServiceTimeout, + @visibleForTesting StringSink? stdoutPipe, + @visibleForTesting StringSink? stderrPipe, + // Local API should use random port since it's being proxied by the user + // hub and is never exposed to the user. + @visibleForTesting PortFinder portFinder = const RandomPortFinder(), + }) async { + final (target, platformDill, sdkRoot) = switch (resolvedProject + .sdkConfig + .targetSdk) { + SdkType.flutter => ( + 'flutter', + Sdk.current.flutterPlatformDill!, + Sdk.current.flutterPatchedSdk!, + ), + SdkType.dart => ( + 'vm', + Sdk.current.vmPlatformDill, + p.join(Sdk.current.sdkPath, 'lib', '_internal'), + ), + final unknown => unreachable('Unknown SDK type: $unknown'), + }; + + // Create initial kernel file so that it links the platform + // + // Incremental compilations do not the need the platform since it will be + // loaded into memory already. + var outputDill = p.setExtension(path, '.dill'); + + var outputDillFile = fileSystem.file(outputDill); + var index = 0; + while (outputDillFile.existsSync()) { + try { + await outputDillFile.delete(); + } on Object { + // Windows gets fussy about deleting files sometimes. + // Just use a different name. + outputDill = p.setExtension('$path.${index++}', '.dill'); + outputDillFile = fileSystem.file(outputDill); + } + } + + // Copy SQLite3 to the output directory on Windows. + if (platform.isWindows) { + final sqlite3Out = fileSystem + .directory(p.dirname(path)) + .childFile('sqlite3.dll'); + if (!sqlite3Out.existsSync()) { + final cachedSqlite3 = celestProject.config.configDir.childFile( + 'sqlite3.dll', + ); + await cachedSqlite3.copy(sqlite3Out.path); + } + } + + // NOTE: FE server requires file: URIs for *some* paths on Windows. + final genKernelRes = await processManager.start([ + Sdk.current.dartAotRuntime, + Sdk.current.frontendServerAotSnapshot, + '--sdk-root', + sdkRoot, // Must be path + '--platform', + Uri.file(platformDill).toString(), // Must be URI + '--link-platform', + '--target', + target, + '--packages', + Uri.file(projectPaths.packagesConfig).toString(), + '--filesystem-root=${projectPaths.projectRoot}', + '--filesystem-scheme=celest', + '--output-dill', + outputDill, // Must be path + _projectFsUri(path).toString(), + ], workingDirectory: projectPaths.outputsDir); + final genKernelLogs = StringBuffer(); + genKernelRes.captureStdout( + sink: genKernelLogs.writeln, + prefix: '[stdout] ', + ); + genKernelRes.captureStderr( + sink: genKernelLogs.writeln, + prefix: '[stderr] ', + ); + if (await genKernelRes.exitCode != 0) { + _logger.finer('Error generating initial kernel file:\n$genKernelLogs'); + throw CompilationException('Error generating initial kernel file'); + } + + // This is so confusing but it seems to work. + // + // To enable incremental compilation, we need to pass the output dill file + // as the incremental output dill file. If we set it the other way around + // Windows will complain about the file being in use. + final incrementalOutputDill = p.setExtension( + outputDill, + '.incremental.dill', + ); // Must be path + final client = await FrontendServerClient.start( + entrypoint: _projectFsUri(path).toString(), // must be URI + outputDillPath: incrementalOutputDill, // must be path + platformKernel: Uri.file(platformDill).toString(), // must be URI + incrementalOutputDill: outputDill, + fileSystemRoots: [projectPaths.projectRoot], + fileSystemScheme: 'celest', + workingDirectory: projectPaths.projectRoot, + target: target, + verbose: verbose, + sdkRoot: sdkRoot, + enabledExperiments: celestProject.analysisOptions.enabledExperiments, + frontendServerPath: Sdk.current.frontendServerAotSnapshot, + // additionalSources: additionalSources, + additionalArgs: [ + '--no-support-mirrors', // Since it won't be supported in the cloud. + '--incremental-serialization', // Faster hot reload. + ], + ); + _logger.fine('Compiling local API...'); + + final flutterCacheDir = await fileSystem.systemTempDirectory.createTemp( + 'celest_', + ); + + // Give the VM service a deterministic port, since allowing it to find one + // can lead to a race condition with our random port finder picking the same + // port. + // + // When we check the port below, it's valid because the VM service is not + // started yet, but later the API fails because it picked the same port. + final vmServicePort = await const RandomPortFinder() + // If we've specified a port, though, that must be reserved for us to + // use, so start the search from the next port. + .findOpenPort(port == null ? null : port + 1); + final command = switch (resolvedProject.sdkConfig.targetSdk) { + SdkType.dart => [ + Sdk.current.dart, + 'run', + '--enable-vm-service=$vmServicePort', // Start VM service + '--no-dds', // We want to talk directly to VM service. + '--enable-asserts', + '--packages', + projectPaths.packagesConfig, + outputDill, + ], + SdkType.flutter => [ + Sdk.current.flutterTester, + '--non-interactive', + '--vm-service-port=$vmServicePort', + '--run-forever', + '--icu-data-file-path=' + '${p.join(Sdk.current.flutterOsArtifacts, 'icudtl.dat')}', + '--packages=${projectPaths.packagesConfig}', + '--log-tag=_CELEST', + if (verbose) '--verbose-logging', + '--enable-platform-isolates', + '--force-multithreading', + '--cache-dir-path=${flutterCacheDir.absolute.path}', + // '--enable-impeller', + outputDill, + ], + final unknown => unreachable('Unknown SDK type: $unknown'), + }; + + port = await portFinder.checkOrUpdatePort(port, excluding: [vmServicePort]); + _logger.finer('Starting local API on port $port...'); + final celestConfig = prettyPrintJson( + resolvedProject.toProto().toProto3Json(), + ); + await fileSystem + .directory(projectPaths.outputsDir) + .childFile('celest.json') + .writeAsString(celestConfig); + final localApiProcess = await processManager.start( + command, + workingDirectory: projectPaths.outputsDir, + environment: { + ...configValues, + // The HTTP port to serve Celest on. + 'PORT': platform.environment['PORT'] ?? '$port', + 'CELEST_ENVIRONMENT': environmentId, + }, + ); + + final runner = LocalApiRunner._( + path: path, + verbose: verbose, + port: port, + client: client, + localApiProcess: localApiProcess, + ); + await runner._init( + stdoutPipe: stdoutPipe, + stderrPipe: stderrPipe, + vmServiceTimeout: vmServiceTimeout, + ); + return runner; + } + + /// The virtual FS URI for the project [path]. + static Uri _projectFsUri(String path) { + final relativePath = p.relative(path, from: projectPaths.projectRoot); + final rootPrefix = platform.isWindows ? r'\' : '/'; + return Uri(scheme: 'celest', path: '$rootPrefix$relativePath'); + } + + static final _vmServicePattern = RegExp( + r'The Dart VM service is listening on ([^\s]+)', + ); + + static final _warnOnNoDebuggerPattern = RegExp( + r'Connect to the Dart VM service at ([^\s]+) to debug.', + ); + + /// Waits for the main Isolate to be available, resume it, then return its ID. + static Future _waitForIsolatesAndResume(VmService vmService) async { + var vm = await vmService.getVM(); + var isolates = vm.isolates; + final stopwatch = Stopwatch()..start(); + const timeout = Duration(seconds: 10); + _logger.finest('Waiting for VM service to report isolates...'); + while (isolates == null || isolates.isEmpty) { + if (stopwatch.elapsed > timeout) { + throw TimeoutException('Timed out waiting for VM to start.'); + } + await Future.delayed(const Duration(milliseconds: 50)); + vm = await vmService.getVM(); + isolates = vm.isolates; + } + stopwatch.stop(); + _logger.finest( + 'VM started in ${stopwatch.elapsedMilliseconds}ms. ' + 'Isolates: $isolates', + ); + var isolateRef = isolates.firstWhereOrNull( + (isolate) => isolate.isSystemIsolate ?? false, + ); + isolateRef ??= isolates.firstOrNull; + if (isolateRef == null) { + throw StateError('Could not determine main isolate ID.'); + } + return isolateRef.id!; + } + + // Doesn't seem that we need pause-on-start anymore, but keeping code around + // if needed later. + // ignore: unused_element + static Future _resumeIsolate( + VmService vmService, + String isolateId, + ) async { + _logger.finest('[Isolate $isolateId] Waiting for pause on start event...'); + var isolate = await vmService.getIsolate(isolateId); + final stopwatch = Stopwatch()..start(); + const timeout = Duration(seconds: 5); + while (isolate.pauseEvent?.kind != EventKind.kPauseStart) { + if (stopwatch.elapsed > timeout) { + throw TimeoutException( + 'Timed out waiting for isolate to report PauseStart event.', + ); + } + await Future.delayed(const Duration(milliseconds: 50)); + isolate = await vmService.getIsolate(isolateId); + } + + // Only needed if `--observe` is used. + // Disable pause-on-exit and pause-on-unhandled-exceptions. + // + // This must be done here instead of as a flag since the VM service just + // exits immediately for some reason. + // _logger.finest('[Isolate $isolateId] Disabling pause on exit/exception...'); + // await vmService.setIsolatePauseMode( + // isolateId, + // exceptionPauseMode: 'None', + // shouldPauseOnExit: false, + // ); + + _logger.finest('[Isolate $isolateId] Resuming isolate...'); + await vmService.resume(isolateId); + } + + Future _init({ + StringSink? stdoutPipe, + StringSink? stderrPipe, + Duration? vmServiceTimeout, + }) async { + stdoutPipe ??= stdout; + stderrPipe ??= stderr; + + final vmServiceCompleter = Completer(); + void completeVmService(String rawObservatoryUrl) { + final observatoryUri = + '${rawObservatoryUrl.replaceFirst('http', 'ws')}ws'; + _logger.finer('Connecting to local API at: $observatoryUri'); + vmServiceCompleter.complete(_vmServiceConnectUri(observatoryUri)); + } + + final serverStartedCompleter = Completer(); + _stdoutSub = _localApiProcess.stdout + .transform(utf8.decoder) + .transform(const LineSplitter()) + .listen((line) { + _logger.finest('[stdout] $line'); + if (!vmServiceCompleter.isCompleted) { + final vmServiceInfo = _vmServicePattern.firstMatch(line)?.group(1); + if (vmServiceInfo != null) { + return completeVmService(vmServiceInfo); + } + } + if (line.startsWith('The Dart') || + line.startsWith('vm-service') || + line.contains('_CELEST')) { + // Ignore + } else if (line.startsWith('Serving on')) { + if (!serverStartedCompleter.isCompleted) { + serverStartedCompleter.complete(); + } + } else if (line.startsWith('/')) { + analytics.capture('local_api_call', properties: {'route': line}); + } else { + stdoutPipe!.writeln(line); + } + }); + _stderrSub = _localApiProcess.stderr + .transform(utf8.decoder) + .transform(const LineSplitter()) + .listen((line) { + _logger.finest('[stderr] $line'); + if (!vmServiceCompleter.isCompleted) { + final vmServiceInfo = _warnOnNoDebuggerPattern + .firstMatch(line) + ?.group(1); + if (vmServiceInfo != null) { + return completeVmService(vmServiceInfo); + } + } + if (line.startsWith('vm-service')) { + // Ignore + } else { + stderrPipe!.writeln(line); + } + }); + + try { + vmServiceTimeout ??= const Duration(seconds: 10); + _logger.finer('Waiting for local API to report VM URI...'); + var vmService = vmServiceCompleter.future; + if (vmServiceTimeout > Duration.zero) { + vmService = vmService.timeout( + vmServiceTimeout, + onTimeout: () { + throw TimeoutException( + 'Could not connect to local API VM service.', + vmServiceTimeout, + ); + }, + ); + } + _vmService = await vmService; + + // Pipe logs to output + _vmService!.onLoggingEvent.listen((event) { + assert(event.kind == EventKind.kLogging); + final record = event.logRecord!; + // TODO(dnys1): Should this be the project name or something to help + // distinguish logs? + const defaultLoggerName = ''; + final loggerName = + record.loggerName?.valueAsString ?? defaultLoggerName; + final logger = Logger(loggerName); + final level = + record.level?.let( + (level) => Level.LEVELS.firstWhere((l) => l.value == level), + ) ?? + Level.FINE; + if (!logger.isLoggable(level)) { + return; + } + logger.log( + level, + record.message?.valueAsString ?? '', + switch (record.error?.valueAsString) { + null || 'null' || '' => null, + final error => error, + }, + switch (record.stackTrace?.valueAsString) { + null || 'null' || '' => null, + final stackTrace => StackTrace.fromString(stackTrace), + }, + ); + }); + await _vmService!.streamListen(EventStreams.kLogging); + + _vmIsolateId = await _waitForIsolatesAndResume(_vmService!); + + await Future.any([ + serverStartedCompleter.future, + _localApiProcess.exitCode.then((exitCode) { + throw StateError( + 'Local API process exited before serving (exitCode=$exitCode)', + ); + }), + ]).timeout( + const Duration(seconds: 5), + onTimeout: () { + throw TimeoutException('Local API did not start in time.'); + }, + ); + _logger.fine('Connected to local API.'); + } on Object catch (e, st) { + _logger.finer('Failure starting local API runner', e, st); + rethrow; + } + } + + Future hotReload(List pathsToInvalidate) async { + _logger.fine('Recompiling local API...'); + final result = await _client.compile([ + for (final path in pathsToInvalidate) + if (p.isWithin(projectPaths.projectRoot, path)) + _projectFsUri(path) + else + p.toUri(path), + ]); + final dillOutput = _client.expectOutput(result); + _logger.fine('Hot reloading local API with entrypoint: $dillOutput'); + await _vmService!.reloadSources(_vmIsolateId, rootLibUri: dillOutput); + } + + // Copied from `package:flutter_tools/src/run_hot.dart` + // ignore: unused_element + Future _killIsolates() async { + if (_vmService case final vmService?) { + final isolateOperations = >[]; + final isolateRefs = await vmService.getVM().then((vm) => vm.isolates!); + final isolateIds = isolateRefs.map((r) => r.id!).toList(); + _logger.finest('Killing isolates: ${isolateIds.join(', ')}'); + for (final isolateId in isolateIds) { + isolateOperations.add( + _vmService! + .kill(isolateId) + .then( + (Success success) => + _logger.finest('Killed isolate $isolateId'), + onError: (Object error, StackTrace st) { + if (error is SentinelException || + (error is RPCError && + error.code == + RPCErrorKind.kIsolateMustBeRunnable.code)) { + // Do nothing on a SentinelException since it means the isolate + // has already been killed. + // Error code 105 indicates the isolate is not yet runnable, and might + // be triggered if the tool is attempting to kill the asset parsing + // isolate before it has finished starting up. + return null; + } + _logger.finer('Error killing isolate $isolateId', error, st); + return Future.error(error, st); + }, + ), + ); + } + await Future.wait(isolateOperations); + } + } + + Future close() async { + _logger.finer('Shutting down local API...'); + if (!await Future(() => _client.closed)) { + _client.kill(); + } + _logger.finest('Killing local process'); + // flutter_tester requires a gentle nudge when using `--run-forever`. + _localApiProcess.kill(ProcessSignal.sigkill); + + _logger.finest('Closing VM service...'); + await _vmService?.dispose(); + await Future.wait([ + _stdoutSub.cancel().then((_) => _logger.finest('Stdout closed')), + _stderrSub.cancel().then((_) => _logger.finest('Stderr closed')), + _localApiProcess.exitCode.then( + (exitCode) => _logger.finest('Exit code: $exitCode'), + ), + Future.value( + _vmService?.onDone, + ).then((_) => _logger.finest('VM service done')), + ]); + _logger.finer('Shut down local API.'); + } +} + +final class CompilationException implements Exception { + CompilationException(this.message); + + final String message; + + @override + String toString() => message; +} + +extension on FrontendServerClient { + String expectOutput(CompileResult result) { + _logger.finest( + 'Compile result: dillOutput=${result.dillOutput} ' + 'errors=${result.errorCount}', + ); + switch (result) { + case CompileResult(errorCount: > 0): + _logger.finest('Error compiling local API', result.debugResult); + throw CompilationException( + 'Error compiling local API: ${result.debugResult}', + ); + case CompileResult(:final dillOutput?): + accept(); + return dillOutput; + default: + _logger.finest('Compile result:\n${result.debugResult}'); + // `dillOutput` should never be null (see its docs). + unreachable('An unknown error occurred compiling local API.'); + } + } +} + +extension on CompileResult { + String get debugResult { + final buffer = + StringBuffer() + ..writeln('dillOutput: $dillOutput') + ..writeln('Error count: $errorCount') + ..writeln('Compiler output:'); + for (final line in compilerOutputLines) { + buffer.writeln(' $line'); + } + buffer.writeln('New sources:'); + for (final source in newSources) { + buffer.writeln(' $source'); + } + buffer.writeln('Removed sources:'); + for (final source in removedSources) { + buffer.writeln(' $source'); + } + return buffer.toString(); + } +} + +/// Copied from `package:vm_service/vm_service_io.dart` to provide better +/// logging and debugging support. +Future _vmServiceConnectUri(String wsUri) async { + final socket = await WebSocket.connect(wsUri); + final controller = StreamController(); + final streamClosedCompleter = Completer(); + + socket.listen( + (data) { + controller.add(data); + if (verbose) { + _logger.finest('VM service WS data: $data'); + } + }, + onError: (Object error, StackTrace stackTrace) { + _logger.finest('VM service WS error', error, stackTrace); + }, + cancelOnError: true, + onDone: () { + _logger.finest('VM service WS closed'); + streamClosedCompleter.complete(); + controller.close(); + }, + ); + + return VmService.defaultFactory( + inStream: controller.stream, + writeMessage: socket.add, + log: VmServiceLogs(), + disposeHandler: socket.close, + streamClosed: streamClosedCompleter.future, + wsUri: wsUri, + ); +} + +final class VmServiceLogs implements Log { + @override + void severe(String message) { + _logger.finest('[vm-service] SEVERE: $message'); + } + + @override + void warning(String message) { + _logger.finest('[vm-service] WARNING: $message'); + } +} diff --git a/apps/cli/lib/compiler/frontend_server_client.dart b/apps/cli/lib/compiler/frontend_server_client.dart new file mode 100644 index 000000000..ffe9b2ef1 --- /dev/null +++ b/apps/cli/lib/compiler/frontend_server_client.dart @@ -0,0 +1,421 @@ +// Copied from https://github.com/dart-lang/webdev/blob/master/frontend_server_client/lib/src/frontend_server_client.dart +// We need to copy it so we can support using the frontend_server_client +// from an AOT-compiled app. The published version only supports JIT. + +// Copyright 2020 The Dart Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'dart:async'; +import 'dart:convert'; +import 'dart:io'; + +import 'package:async/async.dart'; +import 'package:celest_cli/src/context.dart'; +import 'package:celest_cli/src/sdk/dart_sdk.dart'; +import 'package:celest_core/_internal.dart'; +import 'package:logging/logging.dart'; +import 'package:path/path.dart' as p; + +/// Wrapper around the incremental frontend server compiler. +class FrontendServerClient { + FrontendServerClient._( + this._entrypoint, + this._feServer, + this._feServerStdoutLines, { + bool? verbose, + }) : _state = _ClientState.waitingForFirstCompile { + _feServer.stderr + .transform(utf8.decoder) + .listen((err) => _logger.finest('Error in FE server: $err')); + _feServer.exitCode.then((_) => closed = true); + } + + static final _logger = Logger('FrontendServerClient'); + + final String _entrypoint; + final Process _feServer; + final StreamQueue _feServerStdoutLines; + + _ClientState _state; + + /// Whether the frontend server has been closed. + var closed = false; + + /// Starts the frontend server. + /// + /// Most arguments directly mirror the command line arguments for the + /// frontend_server (see `pkg/frontend_server/lib/frontend_server.dart` in + /// the sdk). Options are exposed on an as-needed basis. + /// + /// The [entrypoint] and [packagesJson] may be a relative path or any uri + /// supported by the frontend server. + /// + /// The [outputDillPath] determines where the primary output should be, and + /// some targets may output additional files based on that file name (by + /// adding file extensions for instance). + static Future start({ + required String entrypoint, + required String outputDillPath, + required String platformKernel, + required String workingDirectory, + String? incrementalOutputDill, + List? enabledExperiments, + List fileSystemRoots = const [], // For `fileSystemScheme` uris, + String fileSystemScheme = + 'org-dartlang-root', // Custom scheme for virtual `fileSystemRoots`. + required String frontendServerPath, + String packagesJson = '.dart_tool/package_config.json', + required String sdkRoot, + String target = 'vm', // The kernel target type. + bool verbose = false, // Verbose logs, including server/client messages + bool printIncrementalDependencies = true, + List additionalSources = const [], + String? nativeAssets, + List additionalArgs = const [], + }) async { + final feServer = await processManager.start([ + Sdk.current.dartAotRuntime, + frontendServerPath, + '--sdk-root', + sdkRoot, + '--platform=$platformKernel', + '--target=$target', + for (final root in fileSystemRoots) '--filesystem-root=$root', + '--filesystem-scheme', + fileSystemScheme, + '--output-dill', + outputDillPath, + if (incrementalOutputDill != null) ...[ + '--output-incremental-dill', + incrementalOutputDill, + ], + '--packages=$packagesJson', + '--incremental', + if (verbose) '--verbose', + if (!printIncrementalDependencies) '--no-print-incremental-dependencies', + if (enabledExperiments != null) + for (final experiment in enabledExperiments) + '--enable-experiment=$experiment', + for (final source in additionalSources) ...['--source', source], + if (nativeAssets != null) ...['--native-assets', nativeAssets], + ...additionalArgs, + ], workingDirectory: workingDirectory); + final feServerStdoutLines = StreamQueue( + feServer.stdout.transform(utf8.decoder).transform(const LineSplitter()), + ); + + // The frontend_server doesn't appear to recursively create files, so we + // need to make sure the output dir already exists. + final outputDir = Directory(p.dirname(outputDillPath)); + if (!outputDir.existsSync()) await outputDir.create(); + + return FrontendServerClient._( + entrypoint, + feServer, + feServerStdoutLines, + verbose: verbose, + ); + } + + /// Compiles [_entrypoint], using an incremental recompile if possible. + /// + /// [invalidatedUris] must not be null for all but the very first compile. + /// + /// The frontend server _does not_ do any of its own invalidation. + Future compile([List? invalidatedUris]) async { + String action; + switch (_state) { + case _ClientState.waitingForFirstCompile: + action = 'compile'; + case _ClientState.waitingForRecompile: + action = 'recompile'; + case _ClientState.waitingForAcceptOrReject: + throw StateError( + 'Previous `CompileResult` must be accepted or rejected by ' + 'calling `accept` or `reject`.', + ); + case _ClientState.compiling: + throw StateError( + 'App is already being compiled, you must wait for that to ' + 'complete and `accept` or `reject` the result before compiling ' + 'again.', + ); + case _ClientState.rejecting: + throw StateError( + 'Still waiting for previous `reject` call to finish. ' + 'You must await that before compiling again.', + ); + } + _state = _ClientState.compiling; + + try { + final command = StringBuffer('$action $_entrypoint'); + if (action == 'recompile') { + if (invalidatedUris == null || invalidatedUris.isEmpty) { + throw StateError( + 'Subsequent compile invocations must provide a non-empty list ' + 'of invalidated uris.', + ); + } + final boundaryKey = Uuid.v7(); + command.writeln(' $boundaryKey'); + for (final uri in invalidatedUris) { + command.writeln('$uri'); + } + command.write(boundaryKey); + } + + _sendCommand(command.toString()); + var state = _CompileState.started; + late String feBoundaryKey; + final newSources = {}; + final removedSources = {}; + final compilerOutputLines = []; + var errorCount = 0; + String? outputDillPath; + while (!closed && + state != _CompileState.done && + await _feServerStdoutLines.hasNext) { + final line = await _nextInputLine(); + switch (state) { + case _CompileState.started: + assert(line.startsWith('result')); + feBoundaryKey = line.substring(line.indexOf(' ') + 1); + state = _CompileState.waitingForKey; + continue; + case _CompileState.waitingForKey: + if (line == feBoundaryKey) { + state = _CompileState.gettingSourceDiffs; + } else { + compilerOutputLines.add(line); + } + continue; + case _CompileState.gettingSourceDiffs: + if (line.startsWith(feBoundaryKey)) { + state = _CompileState.done; + final parts = line.split(' '); + outputDillPath = parts.getRange(1, parts.length - 1).join(' '); + errorCount = int.parse(parts.last); + continue; + } + final diffUri = Uri.parse(line.substring(1)); + if (line.startsWith('+')) { + newSources.add(diffUri); + } else if (line.startsWith('-')) { + removedSources.add(diffUri); + } else { + throw StateError( + 'unrecognized diff line, should start with a + or - but got: $line', + ); + } + continue; + case _CompileState.done: + throw StateError('Unreachable'); + } + } + + return CompileResult._( + dillOutput: outputDillPath, + errorCount: errorCount, + newSources: newSources, + removedSources: removedSources, + compilerOutputLines: compilerOutputLines, + ); + } finally { + _state = _ClientState.waitingForAcceptOrReject; + } + } + + Future compileExpression({ + required String expression, + required List definitions, + required bool isStatic, + required String klass, + required String libraryUri, + required List typeDefinitions, + }) => throw UnimplementedError(); + + Future compileExpressionToJs({ + required String expression, + required int column, + required Map jsFrameValues, + required Map jsModules, + required String libraryUri, + required int line, + required String moduleName, + }) => throw UnimplementedError(); + + /// Should be invoked when results of compilation are accepted by the client. + /// + /// Either [accept] or [reject] should be called after every [compile] call. + void accept() { + if (_state != _ClientState.waitingForAcceptOrReject) { + throw StateError( + 'Called `accept` but there was no previous compile to accept.', + ); + } + _sendCommand('accept'); + _state = _ClientState.waitingForRecompile; + } + + /// Should be invoked when results of compilation are rejected by the client. + /// + /// Either [accept] or [reject] should be called after every [compile] call. + /// + /// The result of this call must be awaited before a new [compile] can be + /// done. + Future reject() async { + if (_state != _ClientState.waitingForAcceptOrReject) { + throw StateError( + 'Called `reject` but there was no previous compile to reject.', + ); + } + _state = _ClientState.rejecting; + _sendCommand('reject'); + late String boundaryKey; + var rejectState = _RejectState.started; + while (rejectState != _RejectState.done && + await _feServerStdoutLines.hasNext) { + final line = await _nextInputLine(); + switch (rejectState) { + case _RejectState.started: + if (!line.startsWith('result')) { + throw StateError( + 'Expected a line like `result ` after a `reject` ' + 'command, but got:\n$line', + ); + } + boundaryKey = line.split(' ').last; + rejectState = _RejectState.waitingForKey; + continue; + case _RejectState.waitingForKey: + if (line != boundaryKey) { + throw StateError('Expected exactly `$boundaryKey` but got:\n$line'); + } + rejectState = _RejectState.done; + continue; + case _RejectState.done: + throw StateError('Unreachable'); + } + } + _state = _ClientState.waitingForRecompile; + } + + /// Should be invoked when frontend server compiler should forget what was + /// accepted previously so that next call to [compile] produces complete + /// kernel file. + void reset() { + if (_state == _ClientState.compiling) { + throw StateError( + 'Called `reset` during an active compile, you must wait for that to ' + 'complete first.', + ); + } + _sendCommand('reset'); + _state = _ClientState.waitingForRecompile; + } + + /// Stop the service gracefully (using the shutdown command) + Future shutdown() async { + _sendCommand('quit'); + final timer = Timer(const Duration(seconds: 1), _feServer.kill); + final exitCode = await _feServer.exitCode; + timer.cancel(); + await _feServerStdoutLines.cancel(); + return exitCode; + } + + /// Kills the server forcefully by calling `kill` on the process, and + /// returns the result. + bool kill({ProcessSignal processSignal = ProcessSignal.sigterm}) { + _feServerStdoutLines.cancel(); + return _feServer.kill(processSignal); + } + + /// Sends [command] to the [_feServer] via stdin, and logs it if [_verbose]. + void _sendCommand(String command) { + // if (_verbose) { + // final lines = const LineSplitter().convert(command); + // for (final line in lines) { + // _logger.finest('>> $line'); + // } + // } + _feServer.stdin.writeln(command); + } + + /// Reads a line from [_feServerStdoutLines] and logs it if [_verbose]. + Future _nextInputLine() async { + var line = await _feServerStdoutLines.next; + if (line.startsWith('The Resident Frontend Compiler is listening at')) { + // This is a message from the frontend server, not a response to a + // command. + line = await _nextInputLine(); + } + // if (_verbose) _logger.finest('<< $line'); + return line; + } +} + +/// The result of a compile call. +class CompileResult { + const CompileResult._({ + required this.dillOutput, + required this.compilerOutputLines, + required this.errorCount, + required this.newSources, + required this.removedSources, + }); + + /// The produced dill output file, this will either be a full dill file, an + /// incremental dill file, or `null` if no file was produced. + final String? dillOutput; + + /// All output from the compiler, typically this would contain errors or + /// warnings. + final Iterable compilerOutputLines; + + /// The total count of errors, details should appear in + /// [compilerOutputLines]. + final int errorCount; + + /// A single file containing all source maps for all JS outputs. + /// + /// Read [jsManifestOutput] for file offsets for each sourcemap. + String? get jsSourceMapsOutput => + dillOutput == null ? null : '$dillOutput.map'; + + /// A single file containing all JS outputs. + /// + /// Read [jsManifestOutput] for file offsets for each source. + String? get jsSourcesOutput => + dillOutput == null ? null : '$dillOutput.sources'; + + /// A JSON manifest containing offsets for the sources and source maps in + /// the [jsSourcesOutput] and [jsSourceMapsOutput] files. + String? get jsManifestOutput => + dillOutput == null ? null : '$dillOutput.json'; + + /// All the transitive source dependencies that were added as a part of this + /// compile. + final Iterable newSources; + + /// All the transitive source dependencies that were removed as a part of + /// this compile. + final Iterable removedSources; +} + +/// Internal states for the client. +enum _ClientState { + compiling, + rejecting, + waitingForAcceptOrReject, + waitingForFirstCompile, + waitingForRecompile, +} + +/// Frontend server interaction states for a `compile` call. +enum _CompileState { started, waitingForKey, gettingSourceDiffs, done } + +/// Frontend server interaction states for a `reject` call. +enum _RejectState { started, waitingForKey, done } diff --git a/apps/cli/lib/compiler/native_assets/native_asset_helpers.dart b/apps/cli/lib/compiler/native_assets/native_asset_helpers.dart new file mode 100644 index 000000000..9f86961eb --- /dev/null +++ b/apps/cli/lib/compiler/native_assets/native_asset_helpers.dart @@ -0,0 +1,87 @@ +// Coped from: https://github.com/dart-lang/sdk/blob/553df4be869f1175ee2c098584f58e0d860f42fa/pkg/dartdev/lib/src/commands/build.dart#L126 +library; + +import 'package:celest_cli/src/context.dart'; +import 'package:celest_cli/src/sdk/dart_sdk.dart'; +import 'package:file/file.dart'; +import 'package:logging/logging.dart'; +import 'package:native_assets_builder/native_assets_builder.dart'; +import 'package:native_assets_cli/native_assets_cli.dart'; +import 'package:native_assets_cli/native_assets_cli_internal.dart'; + +final Logger _logger = Logger('NativeAssetsBuilder'); + +Future generateNativeAssetsYaml({ + Uri? packageRoot, + Directory? outputDir, +}) async { + final target = Target.current; + final buildResult = await NativeAssetsBuildRunner( + dartExecutable: Uri.file(Sdk.current.dart), + logger: _logger, + ).build( + workingDirectory: packageRoot ?? fileSystem.currentDirectory.uri, + target: target, + linkModePreference: LinkModePreferenceImpl.dynamic, + buildMode: BuildModeImpl.release, + includeParentEnvironment: true, + supportedAssetTypes: [NativeCodeAsset.type], + linkingEnabled: false, + ); + if (!buildResult.success) { + throw StateError('Native assets build failed.'); + } + final assets = buildResult.assets; + final nativeAssets = assets.whereType(); + _logger.finest('Copying native assets.'); + KernelAsset targetLocation(NativeCodeAssetImpl asset) { + final linkMode = asset.linkMode; + final KernelAssetPath kernelAssetPath; + switch (linkMode) { + case DynamicLoadingSystemImpl _: + kernelAssetPath = KernelAssetSystemPath(linkMode.uri); + case LookupInExecutableImpl _: + kernelAssetPath = KernelAssetInExecutable(); + case LookupInProcessImpl _: + kernelAssetPath = KernelAssetInProcess(); + case DynamicLoadingBundledImpl _: + kernelAssetPath = KernelAssetRelativePath( + Uri(path: asset.file!.pathSegments.last), + ); + default: + throw Exception( + 'Unsupported NativeCodeAsset linkMode ${linkMode.runtimeType} in ' + 'asset $asset', + ); + } + return KernelAsset(id: asset.id, target: target, path: kernelAssetPath); + } + + outputDir ??= await fileSystem.systemTempDirectory.createTemp( + 'native_assets_', + ); + + final assetTargetLocations = { + for (final asset in nativeAssets) asset: targetLocation(asset), + }; + final copiedFiles = await Future.wait([ + for (final assetMapping in assetTargetLocations.entries) + if (assetMapping.value.path is KernelAssetRelativePath) + fileSystem + .file(assetMapping.key.file) + .copy( + outputDir.uri + .resolveUri( + (assetMapping.value.path as KernelAssetRelativePath).uri, + ) + .toFilePath(), + ), + ]); + _logger.finest('Copied ${copiedFiles.length} native assets.'); + + final nativeAssetsFile = outputDir.childFile('native_assets.yaml'); + final assetsContent = + KernelAssets(assetTargetLocations.values.toList()).toNativeAssetsFile(); + await nativeAssetsFile.writeAsString(assetsContent); + return nativeAssetsFile; +} diff --git a/apps/cli/lib/compiler/package_config_transform.dart b/apps/cli/lib/compiler/package_config_transform.dart new file mode 100644 index 000000000..2e12108b4 --- /dev/null +++ b/apps/cli/lib/compiler/package_config_transform.dart @@ -0,0 +1,46 @@ +import 'package:celest_cli/src/context.dart'; +import 'package:package_config/package_config.dart'; +import 'package:package_config/src/package_config_io.dart'; + +/// Transforms a package config to use the new root. +Future transformPackageConfig({ + required String packageConfigPath, + required String fromRoot, + required String toRoot, +}) async { + final packageConfig = await loadPackageConfig( + fileSystem.file(packageConfigPath), + ); + final newPackages = + packageConfig.packages.map((package) { + return Package( + package.name, + switch (package.root.scheme) { + '' => Uri( + path: p.relative( + p.join(fromRoot, '.dart_tool', package.root.path), + from: p.join(toRoot, '.dart_tool'), + ), + ), + _ => package.root, + }, + packageUriRoot: package.packageUriRoot, + languageVersion: package.languageVersion, + extraData: package.extraData, + relativeRoot: package.relativeRoot, + ); + }).toList(); + final newPackageConfig = PackageConfig( + newPackages, + extraData: packageConfig.extraData, + ); + final toRootDir = fileSystem.directory(toRoot); + final newPackageConfigBuf = StringBuffer(); + PackageConfig.writeString(newPackageConfig, newPackageConfigBuf); + final newPackageConfigFile = toRootDir + .childDirectory('.dart_tool') + .childFile(packageConfigFileName); + await newPackageConfigFile.create(recursive: true); + await newPackageConfigFile.writeAsString(newPackageConfigBuf.toString()); + return newPackageConfigFile.path; +} diff --git a/apps/cli/lib/config/celest_config.dart b/apps/cli/lib/config/celest_config.dart new file mode 100644 index 000000000..dab6c440b --- /dev/null +++ b/apps/cli/lib/config/celest_config.dart @@ -0,0 +1,70 @@ +import 'dart:convert'; + +import 'package:celest_cli/config/find_application_home.dart'; +import 'package:celest_cli/src/context.dart'; +import 'package:file/file.dart'; +import 'package:logging/logging.dart'; +import 'package:native_storage/native_storage.dart'; + +final class CelestConfig { + CelestConfig._(this.configDir); + + static final Logger logger = Logger('CelestConfig'); + + static Future load({Directory? configHome}) async { + configHome ??= fileSystem.directory(applicationConfigHome('Celest')); + logger.finest('Loading configuration from $configHome'); + if (!await configHome.exists()) { + await configHome.create(recursive: true); + } + + // Migrate the old config JSON to local storage if it exists. + final configJson = configHome.childFile('config.json'); + if (configJson.existsSync()) { + logger.finest('Migrating configuration to local storage'); + final config = + jsonDecode(await configJson.readAsString()) as Map; + await Future.wait( + config.entries.map( + (entry) => _settings.write(entry.key, entry.value.toString()), + ), + ); + await configJson.delete(); + logger.finest('Successfully migrated configuration to local storage'); + } else { + logger.finest('Configuration already migrated to local storage'); + } + return CelestConfig._(configHome); + } + + static CelestConfigValues get _settings => + CelestConfigValues(storage.isolated); + final Directory configDir; + CelestConfigValues get settings => _settings; + + Future delete() async { + await _settings.clear(); + if (await configDir.exists()) { + logger.fine('Removing Celest config dir: $configDir'); + await configDir.delete(recursive: true); + } + } + + @override + String toString() => 'CelestConfig: $configDir'; +} + +extension type CelestConfigValues(IsolatedNativeStorage settings) + implements IsolatedNativeStorage { + Future getOrganizationId() async { + return settings.read('organization_id'); + } + + Future setOrganizationId(String? value) async { + if (value == null) { + await settings.delete('organization_id'); + } else { + await settings.write('organization_id', value); + } + } +} diff --git a/apps/cli/lib/config/feature_flags.dart b/apps/cli/lib/config/feature_flags.dart new file mode 100644 index 000000000..cd7047d5e --- /dev/null +++ b/apps/cli/lib/config/feature_flags.dart @@ -0,0 +1,73 @@ +import 'package:celest_ast/celest_ast.dart' as ast; +import 'package:celest_cli/src/context.dart'; +import 'package:package_config/package_config.dart'; +import 'package:pub_semver/pub_semver.dart'; +import 'package:pubspec_parse/pubspec_parse.dart'; + +final class FeatureFlags { + FeatureFlags._({required Version runtimeVersion}) + : _runtimeVersion = runtimeVersion; + + static Future load() async { + final packageConfigFile = fileSystem.file(projectPaths.packagesConfig); + final packageConfig = await loadPackageConfig(packageConfigFile); + final celestRuntime = packageConfig.packages.firstWhere( + (package) => package.name == 'celest', + ); + final celestRuntimeRoot = celestRuntime.root; + final celestRuntimePubspec = Pubspec.parse( + await fileSystem + .file(celestRuntimeRoot.resolve('pubspec.yaml')) + .readAsString(), + ); + final runtimeVersion = celestRuntimePubspec.version!; + return FeatureFlags._(runtimeVersion: runtimeVersion); + } + + final Version _runtimeVersion; + + late final FeatureFlag streaming = FeatureFlag( + name: 'streaming', + runtimeVersion: _runtimeVersion, + enabledVersion: Version(0, 4, 2), + ); + + Iterable toAst() sync* { + for (final flag in allFlags) { + if (flag.enabled) { + yield ast.FeatureFlag.valueOf(flag.name); + } + } + } + + List get allFlags => [streaming]; +} + +final class FeatureFlag { + factory FeatureFlag({ + required String name, + required Version runtimeVersion, + required Version enabledVersion, + }) { + return FeatureFlag._( + name: name, + enabledVersion: enabledVersion, + enabled: runtimeVersion >= enabledVersion, + ); + } + + const FeatureFlag._({ + required this.name, + required this.enabledVersion, + required this.enabled, + }); + + final String name; + final Version enabledVersion; + final bool enabled; + + @override + String toString() { + return 'FeatureFlag($name): ${enabled ? 'enabled' : 'disabled'}'; + } +} diff --git a/apps/cli/lib/config/find_application_home.dart b/apps/cli/lib/config/find_application_home.dart new file mode 100644 index 000000000..a781aa618 --- /dev/null +++ b/apps/cli/lib/config/find_application_home.dart @@ -0,0 +1,83 @@ +// Copied from cli_util so that we can support mocking platforms. +// https://github.com/dart-lang/cli_util/blob/e5b38ac76887e6eefaf417f5222c317929eed278/lib/cli_util.dart#L41 + +import 'package:celest_cli/src/context.dart'; + +/// Get the user-specific application configuration folder for the current +/// platform. +/// +/// This is a location appropriate for storing application specific +/// configuration for the current user. The [productName] should be unique to +/// avoid clashes with other applications on the same machine. This method won't +/// actually create the folder, merely return the recommended location for +/// storing user-specific application configuration. +/// +/// The folder location depends on the platform: +/// * `%APPDATA%\` on **Windows**, +/// * `$HOME/Library/Application Support/` on **Mac OS**, +/// * `$XDG_CONFIG_HOME/` on **Linux** +/// (if `$XDG_CONFIG_HOME` is defined), and, +/// * `$HOME/.config/` otherwise. +/// +/// This aims follows best practices for each platform, honoring the +/// [XDG Base Directory Specification][1] on Linux and [File System Basics][2] +/// on Mac OS. +/// +/// Throws an [EnvironmentNotFoundException] if `%APPDATA%` or `$HOME` is needed +/// but undefined. +/// +/// [1]: https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html +/// [2]: https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/FileSystemOverview/FileSystemOverview.html#//apple_ref/doc/uid/TP40010672-CH2-SW1 +String applicationConfigHome(String productName) => + p.join(_configHome, productName); + +String get _configHome { + if (platform.isWindows) { + final appdata = _env['APPDATA']; + if (appdata == null) { + throw EnvironmentNotFoundException( + 'Environment variable %APPDATA% is not defined!', + ); + } + return appdata; + } + + if (platform.isMacOS) { + return p.join(_home, 'Library', 'Application Support'); + } + + if (platform.isLinux) { + final xdgConfigHome = _env['XDG_CONFIG_HOME']; + if (xdgConfigHome != null) { + return xdgConfigHome; + } + // XDG Base Directory Specification says to use $HOME/.config/ when + // $XDG_CONFIG_HOME isn't defined. + return p.join(_home, '.config'); + } + + // We have no guidelines, perhaps we should just do: $HOME/.config/ + // same as XDG specification would specify as fallback. + return p.join(_home, '.config'); +} + +String get _home { + final home = _env['HOME']; + if (home == null) { + throw EnvironmentNotFoundException( + r'Environment variable $HOME is not defined!', + ); + } + return home; +} + +class EnvironmentNotFoundException implements Exception { + EnvironmentNotFoundException(this.message); + + final String message; + + @override + String toString() => message; +} + +Map get _env => platform.environment; diff --git a/apps/cli/lib/database/cache/cache.drift b/apps/cli/lib/database/cache/cache.drift new file mode 100644 index 000000000..3d9a26319 --- /dev/null +++ b/apps/cli/lib/database/cache/cache.drift @@ -0,0 +1,27 @@ +-- Stores Dart analyzer caches. +-- +-- With a persistent ByteStore, we can improve the performance of `celest start` +-- by reusing the Dart analyzer cache between runs. +CREATE TABLE IF NOT EXISTS analyzer_byte_store ( + -- The entry's key in the cache. + cache_key TEXT NOT NULL PRIMARY KEY, + + -- The content of the entry. + content BLOB +); + +-- Stores verison information for the cache. +CREATE TABLE IF NOT EXISTS version_info ( + -- The version of the Celest CLI. + celest TEXT NOT NULL, + + -- The version of the Dart SDK. + dart TEXT NOT NULL, + + -- The version of the Flutter SDK. + flutter TEXT +); + +getVersionInfo: SELECT * FROM version_info WHERE rowid = 1 LIMIT 1; +setVersionInfo: INSERT INTO version_info (celest, dart, flutter) VALUES (:celest, :dart, :flutter); +updateVersionInfo: UPDATE version_info SET celest = :celest, dart = :dart, flutter = :flutter WHERE rowid = 1; diff --git a/apps/cli/lib/database/cache/cache.migrations.dart b/apps/cli/lib/database/cache/cache.migrations.dart new file mode 100644 index 000000000..718c999b5 --- /dev/null +++ b/apps/cli/lib/database/cache/cache.migrations.dart @@ -0,0 +1,17 @@ +// dart format width=80 +import 'package:drift/internal/versioned_schema.dart' as i0; +import 'package:drift/drift.dart' as i1; +import 'package:drift/drift.dart'; // ignore_for_file: type=lint,unused_import + +// GENERATED BY drift_dev, DO NOT MODIFY. +i0.MigrationStepWithVersion migrationSteps() { + return (currentVersion, database) async { + switch (currentVersion) { + default: + throw ArgumentError.value('Unknown migration from $currentVersion'); + } + }; +} + +i1.OnUpgrade stepByStep() => + i0.VersionedSchema.stepByStepHelper(step: migrationSteps()); diff --git a/apps/cli/lib/database/cache/cache_database.dart b/apps/cli/lib/database/cache/cache_database.dart new file mode 100644 index 000000000..c58b407ab --- /dev/null +++ b/apps/cli/lib/database/cache/cache_database.dart @@ -0,0 +1,224 @@ +import 'dart:async'; + +import 'package:analyzer/src/dart/analysis/byte_store.dart'; +import 'package:celest_cli/database/cache/cache.migrations.dart'; +import 'package:celest_cli/src/context.dart'; +import 'package:celest_cli/src/sdk/dart_sdk.dart'; +import 'package:celest_cli/src/utils/error.dart'; +import 'package:celest_cli/src/utils/run.dart'; +import 'package:celest_cli/src/utils/typeid.dart'; +import 'package:celest_cli/src/version.dart'; +import 'package:drift/drift.dart'; +import 'package:drift/native.dart'; +import 'package:file/memory.dart'; +import 'package:logging/logging.dart'; +import 'package:pool/pool.dart'; +import 'package:pub_semver/pub_semver.dart' as semver; +import 'package:sqlite3/sqlite3.dart'; + +part 'cache_database.g.dart'; + +@DriftDatabase(include: {'cache.drift'}) +final class CacheDatabase extends _$CacheDatabase { + CacheDatabase(super.e); + + CacheDatabase._( + String projectRoot, { + required Completer rawDatabase, + required bool verbose, + }) : super( + _openConnection( + projectRoot, + verbose: verbose, + rawDatabase: rawDatabase, + ), + ); + + static Future memory() async { + final completer = Completer(); + final db = CacheDatabase(NativeDatabase.memory(setup: _setup(completer))); + await db.customSelect('SELECT 1').get(); + final rawDb = await completer.future; + db.byteStore = CachingByteStore(rawDb); + return db; + } + + static Future open( + String projectRoot, { + required bool verbose, + }) async { + final rawCompleter = Completer(); + final database = CacheDatabase._( + projectRoot, + verbose: verbose, + rawDatabase: rawCompleter, + ); + final versionInfo = await database.getVersionInfo().getSingleOrNull(); + if (versionInfo case VersionInfoData( + :final dart, + :final flutter, + :final celest, + )) { + final dartCacheVersion = semver.Version.parse(dart); + final flutterCacheVersion = flutter?.let(semver.Version.parse); + if (Sdk.current.version != dartCacheVersion || + Sdk.current.flutterVersion != flutterCacheVersion) { + await database.clear(); + await database._setVersionInfo(update: true); + } + if (semver.Version.parse(celest) < semver.Version.parse(packageVersion)) { + database._needsProjectUpgrade = true; + await database._setVersionInfo(update: true); + } + } else if (versionInfo == null) { + database._needsProjectUpgrade = true; + await database._setVersionInfo(update: false); + } + final rawDb = await rawCompleter.future; + database.byteStore = CachingByteStore(rawDb); + return database; + } + + bool _needsProjectUpgrade = false; + bool get needsProjectUpgrade => _needsProjectUpgrade; + + Future _setVersionInfo({required bool update}) async { + if (update) { + await updateVersionInfo( + celest: packageVersion, + dart: Sdk.current.version.toString(), + flutter: Sdk.current.flutterVersion?.toString(), + ); + } else { + await setVersionInfo( + celest: packageVersion, + dart: Sdk.current.version.toString(), + flutter: Sdk.current.flutterVersion?.toString(), + ); + } + } + + Future clear() async { + await delete(analyzerByteStore).go(); + await delete(versionInfo).go(); + } + + @override + int get schemaVersion => 1; + + static final Pool _lock = Pool(1); + + @override + MigrationStrategy get migration { + return MigrationStrategy( + beforeOpen: + (details) => _lock.withResource(() async { + await customStatement('PRAGMA foreign_keys = ON'); + await customStatement('PRAGMA journal_mode = WAL'); + await customStatement('PRAGMA busy_timeout = 5000'); + await customStatement('PRAGMA synchronous = NORMAL'); + await customStatement('PRAGMA mmap_size = 30000000000'); + await customStatement('PRAGMA cache_size = 1000000000'); + await customStatement('PRAGMA page_size = 32768'); + await customStatement('PRAGMA temp_store = memory'); + }), + onCreate: + (m) => _lock.withResource(() async { + await m.createAll(); + }), + onUpgrade: + (m, from, to) => _lock.withResource(() async { + return stepByStep()(m, from, to); + }), + ); + } + + late final CachingByteStore byteStore; +} + +final class CachingByteStore implements ByteStore { + CachingByteStore(this._database); + + final Database _database; + static final _logger = Logger('DatabaseByteStore'); + + late final _selectStmt = _database.prepare( + 'SELECT content FROM analyzer_byte_store WHERE cache_key = ?', + ); + late final _insertStmt = _database.prepare( + 'INSERT INTO analyzer_byte_store(cache_key, content) ' + 'VALUES(:cache_key, :content) ' + 'ON CONFLICT(cache_key) DO UPDATE SET content = :content ' + 'RETURNING content', + ); + + @override + Uint8List? get(String key) { + final result = _selectStmt.select([key]); + return switch (result.rows) { + [] => null, + [[final Uint8List content]] => content, + _ => () { + _logger.finest('Unexpected result: $result'); + return null; + }(), + }; + } + + @override + Uint8List putGet(String key, Uint8List bytes) { + final result = _insertStmt.selectWith( + StatementParameters.named({':cache_key': key, ':content': bytes}), + ); + return switch (result.rows) { + [[final Uint8List content]] => content, + _ => unreachable('Unexpected result: $result'), + }; + } + + @override + void release(Iterable keys) {} +} + +void Function(Database) _setup(Completer rawDatabase) { + return (Database db) { + rawDatabase.complete(db); + db.createFunction( + functionName: 'typeid', + argumentCount: const AllowedArgumentCount(1), + deterministic: false, + directOnly: false, + function: (List args) { + final type = args.first as String; + return typeId(type); + }, + ); + }; +} + +QueryExecutor _openConnection( + String projectRoot, { + required Completer rawDatabase, + required bool verbose, +}) { + return LazyDatabase(() async { + if (fileSystem is MemoryFileSystem) { + return NativeDatabase.memory( + logStatements: verbose, + cachePreparedStatements: true, + setup: _setup(rawDatabase), + ); + } + final file = fileSystem.file( + p.join(projectRoot, '.dart_tool', 'celest', 'cache.db'), + ); + await file.parent.create(recursive: true); + return NativeDatabase( + file, + logStatements: verbose, + cachePreparedStatements: true, + enableMigrations: true, + setup: _setup(rawDatabase), + ); + }); +} diff --git a/apps/cli/lib/database/cache/cache_database.g.dart b/apps/cli/lib/database/cache/cache_database.g.dart new file mode 100644 index 000000000..2caaced4d --- /dev/null +++ b/apps/cli/lib/database/cache/cache_database.g.dart @@ -0,0 +1,817 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'cache_database.dart'; + +// ignore_for_file: type=lint +class AnalyzerByteStore extends Table + with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + AnalyzerByteStore(this.attachedDatabase, [this._alias]); + late final GeneratedColumn cacheKey = GeneratedColumn( + 'cache_key', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL PRIMARY KEY', + ); + late final GeneratedColumn content = GeneratedColumn( + 'content', + aliasedName, + true, + type: DriftSqlType.blob, + requiredDuringInsert: false, + $customConstraints: '', + ); + @override + List get $columns => [cacheKey, content]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'analyzer_byte_store'; + @override + Set get $primaryKey => {cacheKey}; + @override + AnalyzerByteStoreData map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return AnalyzerByteStoreData( + cacheKey: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}cache_key'], + )!, + content: attachedDatabase.typeMapping.read( + DriftSqlType.blob, + data['${effectivePrefix}content'], + ), + ); + } + + @override + AnalyzerByteStore createAlias(String alias) { + return AnalyzerByteStore(attachedDatabase, alias); + } + + @override + bool get dontWriteConstraints => true; +} + +class AnalyzerByteStoreData extends DataClass + implements Insertable { + /// The entry's key in the cache. + final String cacheKey; + + /// The content of the entry. + final Uint8List? content; + const AnalyzerByteStoreData({required this.cacheKey, this.content}); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['cache_key'] = Variable(cacheKey); + if (!nullToAbsent || content != null) { + map['content'] = Variable(content); + } + return map; + } + + factory AnalyzerByteStoreData.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return AnalyzerByteStoreData( + cacheKey: serializer.fromJson(json['cache_key']), + content: serializer.fromJson(json['content']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'cache_key': serializer.toJson(cacheKey), + 'content': serializer.toJson(content), + }; + } + + AnalyzerByteStoreData copyWith({ + String? cacheKey, + Value content = const Value.absent(), + }) => AnalyzerByteStoreData( + cacheKey: cacheKey ?? this.cacheKey, + content: content.present ? content.value : this.content, + ); + AnalyzerByteStoreData copyWithCompanion(AnalyzerByteStoreCompanion data) { + return AnalyzerByteStoreData( + cacheKey: data.cacheKey.present ? data.cacheKey.value : this.cacheKey, + content: data.content.present ? data.content.value : this.content, + ); + } + + @override + String toString() { + return (StringBuffer('AnalyzerByteStoreData(') + ..write('cacheKey: $cacheKey, ') + ..write('content: $content') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash(cacheKey, $driftBlobEquality.hash(content)); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is AnalyzerByteStoreData && + other.cacheKey == this.cacheKey && + $driftBlobEquality.equals(other.content, this.content)); +} + +class AnalyzerByteStoreCompanion + extends UpdateCompanion { + final Value cacheKey; + final Value content; + final Value rowid; + const AnalyzerByteStoreCompanion({ + this.cacheKey = const Value.absent(), + this.content = const Value.absent(), + this.rowid = const Value.absent(), + }); + AnalyzerByteStoreCompanion.insert({ + required String cacheKey, + this.content = const Value.absent(), + this.rowid = const Value.absent(), + }) : cacheKey = Value(cacheKey); + static Insertable custom({ + Expression? cacheKey, + Expression? content, + Expression? rowid, + }) { + return RawValuesInsertable({ + if (cacheKey != null) 'cache_key': cacheKey, + if (content != null) 'content': content, + if (rowid != null) 'rowid': rowid, + }); + } + + AnalyzerByteStoreCompanion copyWith({ + Value? cacheKey, + Value? content, + Value? rowid, + }) { + return AnalyzerByteStoreCompanion( + cacheKey: cacheKey ?? this.cacheKey, + content: content ?? this.content, + rowid: rowid ?? this.rowid, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (cacheKey.present) { + map['cache_key'] = Variable(cacheKey.value); + } + if (content.present) { + map['content'] = Variable(content.value); + } + if (rowid.present) { + map['rowid'] = Variable(rowid.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('AnalyzerByteStoreCompanion(') + ..write('cacheKey: $cacheKey, ') + ..write('content: $content, ') + ..write('rowid: $rowid') + ..write(')')) + .toString(); + } +} + +class VersionInfo extends Table with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + VersionInfo(this.attachedDatabase, [this._alias]); + late final GeneratedColumn celest = GeneratedColumn( + 'celest', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn dart = GeneratedColumn( + 'dart', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn flutter = GeneratedColumn( + 'flutter', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '', + ); + @override + List get $columns => [celest, dart, flutter]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'version_info'; + @override + Set get $primaryKey => const {}; + @override + VersionInfoData map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return VersionInfoData( + celest: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}celest'], + )!, + dart: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}dart'], + )!, + flutter: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}flutter'], + ), + ); + } + + @override + VersionInfo createAlias(String alias) { + return VersionInfo(attachedDatabase, alias); + } + + @override + bool get dontWriteConstraints => true; +} + +class VersionInfoData extends DataClass implements Insertable { + /// The version of the Celest CLI. + final String celest; + + /// The version of the Dart SDK. + final String dart; + + /// The version of the Flutter SDK. + final String? flutter; + const VersionInfoData({ + required this.celest, + required this.dart, + this.flutter, + }); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['celest'] = Variable(celest); + map['dart'] = Variable(dart); + if (!nullToAbsent || flutter != null) { + map['flutter'] = Variable(flutter); + } + return map; + } + + factory VersionInfoData.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return VersionInfoData( + celest: serializer.fromJson(json['celest']), + dart: serializer.fromJson(json['dart']), + flutter: serializer.fromJson(json['flutter']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'celest': serializer.toJson(celest), + 'dart': serializer.toJson(dart), + 'flutter': serializer.toJson(flutter), + }; + } + + VersionInfoData copyWith({ + String? celest, + String? dart, + Value flutter = const Value.absent(), + }) => VersionInfoData( + celest: celest ?? this.celest, + dart: dart ?? this.dart, + flutter: flutter.present ? flutter.value : this.flutter, + ); + VersionInfoData copyWithCompanion(VersionInfoCompanion data) { + return VersionInfoData( + celest: data.celest.present ? data.celest.value : this.celest, + dart: data.dart.present ? data.dart.value : this.dart, + flutter: data.flutter.present ? data.flutter.value : this.flutter, + ); + } + + @override + String toString() { + return (StringBuffer('VersionInfoData(') + ..write('celest: $celest, ') + ..write('dart: $dart, ') + ..write('flutter: $flutter') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash(celest, dart, flutter); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is VersionInfoData && + other.celest == this.celest && + other.dart == this.dart && + other.flutter == this.flutter); +} + +class VersionInfoCompanion extends UpdateCompanion { + final Value celest; + final Value dart; + final Value flutter; + final Value rowid; + const VersionInfoCompanion({ + this.celest = const Value.absent(), + this.dart = const Value.absent(), + this.flutter = const Value.absent(), + this.rowid = const Value.absent(), + }); + VersionInfoCompanion.insert({ + required String celest, + required String dart, + this.flutter = const Value.absent(), + this.rowid = const Value.absent(), + }) : celest = Value(celest), + dart = Value(dart); + static Insertable custom({ + Expression? celest, + Expression? dart, + Expression? flutter, + Expression? rowid, + }) { + return RawValuesInsertable({ + if (celest != null) 'celest': celest, + if (dart != null) 'dart': dart, + if (flutter != null) 'flutter': flutter, + if (rowid != null) 'rowid': rowid, + }); + } + + VersionInfoCompanion copyWith({ + Value? celest, + Value? dart, + Value? flutter, + Value? rowid, + }) { + return VersionInfoCompanion( + celest: celest ?? this.celest, + dart: dart ?? this.dart, + flutter: flutter ?? this.flutter, + rowid: rowid ?? this.rowid, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (celest.present) { + map['celest'] = Variable(celest.value); + } + if (dart.present) { + map['dart'] = Variable(dart.value); + } + if (flutter.present) { + map['flutter'] = Variable(flutter.value); + } + if (rowid.present) { + map['rowid'] = Variable(rowid.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('VersionInfoCompanion(') + ..write('celest: $celest, ') + ..write('dart: $dart, ') + ..write('flutter: $flutter, ') + ..write('rowid: $rowid') + ..write(')')) + .toString(); + } +} + +abstract class _$CacheDatabase extends GeneratedDatabase { + _$CacheDatabase(QueryExecutor e) : super(e); + $CacheDatabaseManager get managers => $CacheDatabaseManager(this); + late final AnalyzerByteStore analyzerByteStore = AnalyzerByteStore(this); + late final VersionInfo versionInfo = VersionInfo(this); + Selectable getVersionInfo() { + return customSelect( + 'SELECT * FROM version_info WHERE "rowid" = 1 LIMIT 1', + variables: [], + readsFrom: {versionInfo}, + ).asyncMap(versionInfo.mapFromRow); + } + + Future setVersionInfo({ + required String celest, + required String dart, + String? flutter, + }) { + return customInsert( + 'INSERT INTO version_info (celest, dart, flutter) VALUES (?1, ?2, ?3)', + variables: [ + Variable(celest), + Variable(dart), + Variable(flutter), + ], + updates: {versionInfo}, + ); + } + + Future updateVersionInfo({ + required String celest, + required String dart, + String? flutter, + }) { + return customUpdate( + 'UPDATE version_info SET celest = ?1, dart = ?2, flutter = ?3 WHERE "rowid" = 1', + variables: [ + Variable(celest), + Variable(dart), + Variable(flutter), + ], + updates: {versionInfo}, + updateKind: UpdateKind.update, + ); + } + + @override + Iterable> get allTables => + allSchemaEntities.whereType>(); + @override + List get allSchemaEntities => [ + analyzerByteStore, + versionInfo, + ]; +} + +typedef $AnalyzerByteStoreCreateCompanionBuilder = + AnalyzerByteStoreCompanion Function({ + required String cacheKey, + Value content, + Value rowid, + }); +typedef $AnalyzerByteStoreUpdateCompanionBuilder = + AnalyzerByteStoreCompanion Function({ + Value cacheKey, + Value content, + Value rowid, + }); + +class $AnalyzerByteStoreFilterComposer + extends Composer<_$CacheDatabase, AnalyzerByteStore> { + $AnalyzerByteStoreFilterComposer({ + required super.$db, + required super.$table, + super.joinBuilder, + super.$addJoinBuilderToRootComposer, + super.$removeJoinBuilderFromRootComposer, + }); + ColumnFilters get cacheKey => $composableBuilder( + column: $table.cacheKey, + builder: (column) => ColumnFilters(column), + ); + + ColumnFilters get content => $composableBuilder( + column: $table.content, + builder: (column) => ColumnFilters(column), + ); +} + +class $AnalyzerByteStoreOrderingComposer + extends Composer<_$CacheDatabase, AnalyzerByteStore> { + $AnalyzerByteStoreOrderingComposer({ + required super.$db, + required super.$table, + super.joinBuilder, + super.$addJoinBuilderToRootComposer, + super.$removeJoinBuilderFromRootComposer, + }); + ColumnOrderings get cacheKey => $composableBuilder( + column: $table.cacheKey, + builder: (column) => ColumnOrderings(column), + ); + + ColumnOrderings get content => $composableBuilder( + column: $table.content, + builder: (column) => ColumnOrderings(column), + ); +} + +class $AnalyzerByteStoreAnnotationComposer + extends Composer<_$CacheDatabase, AnalyzerByteStore> { + $AnalyzerByteStoreAnnotationComposer({ + required super.$db, + required super.$table, + super.joinBuilder, + super.$addJoinBuilderToRootComposer, + super.$removeJoinBuilderFromRootComposer, + }); + GeneratedColumn get cacheKey => + $composableBuilder(column: $table.cacheKey, builder: (column) => column); + + GeneratedColumn get content => + $composableBuilder(column: $table.content, builder: (column) => column); +} + +class $AnalyzerByteStoreTableManager + extends + RootTableManager< + _$CacheDatabase, + AnalyzerByteStore, + AnalyzerByteStoreData, + $AnalyzerByteStoreFilterComposer, + $AnalyzerByteStoreOrderingComposer, + $AnalyzerByteStoreAnnotationComposer, + $AnalyzerByteStoreCreateCompanionBuilder, + $AnalyzerByteStoreUpdateCompanionBuilder, + ( + AnalyzerByteStoreData, + BaseReferences< + _$CacheDatabase, + AnalyzerByteStore, + AnalyzerByteStoreData + >, + ), + AnalyzerByteStoreData, + PrefetchHooks Function() + > { + $AnalyzerByteStoreTableManager(_$CacheDatabase db, AnalyzerByteStore table) + : super( + TableManagerState( + db: db, + table: table, + createFilteringComposer: + () => $AnalyzerByteStoreFilterComposer($db: db, $table: table), + createOrderingComposer: + () => $AnalyzerByteStoreOrderingComposer($db: db, $table: table), + createComputedFieldComposer: + () => + $AnalyzerByteStoreAnnotationComposer($db: db, $table: table), + updateCompanionCallback: + ({ + Value cacheKey = const Value.absent(), + Value content = const Value.absent(), + Value rowid = const Value.absent(), + }) => AnalyzerByteStoreCompanion( + cacheKey: cacheKey, + content: content, + rowid: rowid, + ), + createCompanionCallback: + ({ + required String cacheKey, + Value content = const Value.absent(), + Value rowid = const Value.absent(), + }) => AnalyzerByteStoreCompanion.insert( + cacheKey: cacheKey, + content: content, + rowid: rowid, + ), + withReferenceMapper: + (p0) => + p0 + .map( + (e) => ( + e.readTable(table), + BaseReferences(db, table, e), + ), + ) + .toList(), + prefetchHooksCallback: null, + ), + ); +} + +typedef $AnalyzerByteStoreProcessedTableManager = + ProcessedTableManager< + _$CacheDatabase, + AnalyzerByteStore, + AnalyzerByteStoreData, + $AnalyzerByteStoreFilterComposer, + $AnalyzerByteStoreOrderingComposer, + $AnalyzerByteStoreAnnotationComposer, + $AnalyzerByteStoreCreateCompanionBuilder, + $AnalyzerByteStoreUpdateCompanionBuilder, + ( + AnalyzerByteStoreData, + BaseReferences< + _$CacheDatabase, + AnalyzerByteStore, + AnalyzerByteStoreData + >, + ), + AnalyzerByteStoreData, + PrefetchHooks Function() + >; +typedef $VersionInfoCreateCompanionBuilder = + VersionInfoCompanion Function({ + required String celest, + required String dart, + Value flutter, + Value rowid, + }); +typedef $VersionInfoUpdateCompanionBuilder = + VersionInfoCompanion Function({ + Value celest, + Value dart, + Value flutter, + Value rowid, + }); + +class $VersionInfoFilterComposer + extends Composer<_$CacheDatabase, VersionInfo> { + $VersionInfoFilterComposer({ + required super.$db, + required super.$table, + super.joinBuilder, + super.$addJoinBuilderToRootComposer, + super.$removeJoinBuilderFromRootComposer, + }); + ColumnFilters get celest => $composableBuilder( + column: $table.celest, + builder: (column) => ColumnFilters(column), + ); + + ColumnFilters get dart => $composableBuilder( + column: $table.dart, + builder: (column) => ColumnFilters(column), + ); + + ColumnFilters get flutter => $composableBuilder( + column: $table.flutter, + builder: (column) => ColumnFilters(column), + ); +} + +class $VersionInfoOrderingComposer + extends Composer<_$CacheDatabase, VersionInfo> { + $VersionInfoOrderingComposer({ + required super.$db, + required super.$table, + super.joinBuilder, + super.$addJoinBuilderToRootComposer, + super.$removeJoinBuilderFromRootComposer, + }); + ColumnOrderings get celest => $composableBuilder( + column: $table.celest, + builder: (column) => ColumnOrderings(column), + ); + + ColumnOrderings get dart => $composableBuilder( + column: $table.dart, + builder: (column) => ColumnOrderings(column), + ); + + ColumnOrderings get flutter => $composableBuilder( + column: $table.flutter, + builder: (column) => ColumnOrderings(column), + ); +} + +class $VersionInfoAnnotationComposer + extends Composer<_$CacheDatabase, VersionInfo> { + $VersionInfoAnnotationComposer({ + required super.$db, + required super.$table, + super.joinBuilder, + super.$addJoinBuilderToRootComposer, + super.$removeJoinBuilderFromRootComposer, + }); + GeneratedColumn get celest => + $composableBuilder(column: $table.celest, builder: (column) => column); + + GeneratedColumn get dart => + $composableBuilder(column: $table.dart, builder: (column) => column); + + GeneratedColumn get flutter => + $composableBuilder(column: $table.flutter, builder: (column) => column); +} + +class $VersionInfoTableManager + extends + RootTableManager< + _$CacheDatabase, + VersionInfo, + VersionInfoData, + $VersionInfoFilterComposer, + $VersionInfoOrderingComposer, + $VersionInfoAnnotationComposer, + $VersionInfoCreateCompanionBuilder, + $VersionInfoUpdateCompanionBuilder, + ( + VersionInfoData, + BaseReferences<_$CacheDatabase, VersionInfo, VersionInfoData>, + ), + VersionInfoData, + PrefetchHooks Function() + > { + $VersionInfoTableManager(_$CacheDatabase db, VersionInfo table) + : super( + TableManagerState( + db: db, + table: table, + createFilteringComposer: + () => $VersionInfoFilterComposer($db: db, $table: table), + createOrderingComposer: + () => $VersionInfoOrderingComposer($db: db, $table: table), + createComputedFieldComposer: + () => $VersionInfoAnnotationComposer($db: db, $table: table), + updateCompanionCallback: + ({ + Value celest = const Value.absent(), + Value dart = const Value.absent(), + Value flutter = const Value.absent(), + Value rowid = const Value.absent(), + }) => VersionInfoCompanion( + celest: celest, + dart: dart, + flutter: flutter, + rowid: rowid, + ), + createCompanionCallback: + ({ + required String celest, + required String dart, + Value flutter = const Value.absent(), + Value rowid = const Value.absent(), + }) => VersionInfoCompanion.insert( + celest: celest, + dart: dart, + flutter: flutter, + rowid: rowid, + ), + withReferenceMapper: + (p0) => + p0 + .map( + (e) => ( + e.readTable(table), + BaseReferences(db, table, e), + ), + ) + .toList(), + prefetchHooksCallback: null, + ), + ); +} + +typedef $VersionInfoProcessedTableManager = + ProcessedTableManager< + _$CacheDatabase, + VersionInfo, + VersionInfoData, + $VersionInfoFilterComposer, + $VersionInfoOrderingComposer, + $VersionInfoAnnotationComposer, + $VersionInfoCreateCompanionBuilder, + $VersionInfoUpdateCompanionBuilder, + ( + VersionInfoData, + BaseReferences<_$CacheDatabase, VersionInfo, VersionInfoData>, + ), + VersionInfoData, + PrefetchHooks Function() + >; + +class $CacheDatabaseManager { + final _$CacheDatabase _db; + $CacheDatabaseManager(this._db); + $AnalyzerByteStoreTableManager get analyzerByteStore => + $AnalyzerByteStoreTableManager(_db, _db.analyzerByteStore); + $VersionInfoTableManager get versionInfo => + $VersionInfoTableManager(_db, _db.versionInfo); +} diff --git a/apps/cli/lib/database/cache/schema/drift_schema_v1.json b/apps/cli/lib/database/cache/schema/drift_schema_v1.json new file mode 100644 index 000000000..ce09883d3 --- /dev/null +++ b/apps/cli/lib/database/cache/schema/drift_schema_v1.json @@ -0,0 +1 @@ +{"_meta":{"description":"This file contains a serialized version of schema entities for drift.","version":"1.2.0"},"options":{"store_date_time_values_as_text":false},"entities":[{"id":0,"references":[],"type":"table","data":{"name":"analyzer_byte_store","was_declared_in_moor":true,"columns":[{"name":"cache_key","getter_name":"cacheKey","moor_type":"string","nullable":false,"customConstraints":"NOT NULL PRIMARY KEY","default_dart":null,"default_client_dart":null,"dsl_features":["primary-key"]},{"name":"content","getter_name":"content","moor_type":"blob","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]}],"is_virtual":false,"without_rowid":false,"constraints":[]}},{"id":1,"references":[],"type":"table","data":{"name":"version_info","was_declared_in_moor":true,"columns":[{"name":"celest","getter_name":"celest","moor_type":"string","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"dart","getter_name":"dart","moor_type":"string","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"flutter","getter_name":"flutter","moor_type":"string","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]}],"is_virtual":false,"without_rowid":false,"constraints":[]}}]} \ No newline at end of file diff --git a/apps/cli/lib/database/project/project.drift b/apps/cli/lib/database/project/project.drift new file mode 100644 index 000000000..1c173f7fb --- /dev/null +++ b/apps/cli/lib/database/project/project.drift @@ -0,0 +1,95 @@ +-- Stores local project information for a single Celest project. +CREATE TABLE IF NOT EXISTS environments ( + -- The unique alias for the environment. + id TEXT NOT NULL PRIMARY KEY +); + +lookupEnvironment: +SELECT * FROM environments +WHERE id = :id +LIMIT 1; + +createEnvironment: +INSERT INTO environments (id) +VALUES (:id) +RETURNING *; + +upsertEnvironment: +INSERT INTO environments (id) +VALUES (:id) +ON CONFLICT (id) DO NOTHING +RETURNING *; + +-- Stores environment variable values for a single environment. +CREATE TABLE IF NOT EXISTS environment_variables ( + -- The environment that the variable belongs to. + environment_id TEXT NOT NULL, + + -- The name of the environment variable. + name TEXT NOT NULL, + + -- The value of the environment variable. + value TEXT NOT NULL, + + PRIMARY KEY (environment_id, name), + + CONSTRAINT fk_environment_variables_environment_id + FOREIGN KEY (environment_id) + REFERENCES environments(id) + ON UPDATE CASCADE ON DELETE CASCADE +); + +upsertEnvironmentVariable: +INSERT INTO environment_variables (environment_id, name, value) +VALUES (:environment_id, :name, :value) +ON CONFLICT (environment_id, name) DO UPDATE SET value = :value +RETURNING *; + +getEnvironmentVariables: +SELECT * FROM environment_variables +WHERE + environment_id = :environment_id AND + name IN :names; + +getEnvironmentVariable: +SELECT value FROM environment_variables +WHERE + environment_id = :environment_id AND + name = :name; + +-- Stores secrets for a single environment. +CREATE TABLE IF NOT EXISTS secrets ( + -- The environment that the secret belongs to. + environment_id TEXT NOT NULL, + + -- The name of the secret. + name TEXT NOT NULL, + + -- A reference to the value of the secret which is stored in secure storage. + value_ref TEXT NOT NULL, + + PRIMARY KEY (environment_id, name), + + CONSTRAINT fk_secrets_environment_id + FOREIGN KEY (environment_id) + REFERENCES environments(id) + ON UPDATE CASCADE ON DELETE CASCADE +); + +upsertSecret: +INSERT INTO secrets (environment_id, name, value_ref) +VALUES (:environment_id, :name, :value_ref) +ON CONFLICT (environment_id, name) DO UPDATE SET value_ref = :value_ref +RETURNING *; + +getSecrets: +SELECT * FROM secrets +WHERE + environment_id = :environment_id AND + name IN :names; + +getSecret: +SELECT value_ref FROM secrets +WHERE + environment_id = :environment_id AND + name = :name; diff --git a/apps/cli/lib/database/project/project.migrations.dart b/apps/cli/lib/database/project/project.migrations.dart new file mode 100644 index 000000000..718c999b5 --- /dev/null +++ b/apps/cli/lib/database/project/project.migrations.dart @@ -0,0 +1,17 @@ +// dart format width=80 +import 'package:drift/internal/versioned_schema.dart' as i0; +import 'package:drift/drift.dart' as i1; +import 'package:drift/drift.dart'; // ignore_for_file: type=lint,unused_import + +// GENERATED BY drift_dev, DO NOT MODIFY. +i0.MigrationStepWithVersion migrationSteps() { + return (currentVersion, database) async { + switch (currentVersion) { + default: + throw ArgumentError.value('Unknown migration from $currentVersion'); + } + }; +} + +i1.OnUpgrade stepByStep() => + i0.VersionedSchema.stepByStepHelper(step: migrationSteps()); diff --git a/apps/cli/lib/database/project/project_database.dart b/apps/cli/lib/database/project/project_database.dart new file mode 100644 index 000000000..fd782a766 --- /dev/null +++ b/apps/cli/lib/database/project/project_database.dart @@ -0,0 +1,136 @@ +import 'package:celest_cli/database/project/project.migrations.dart'; +import 'package:celest_cli/src/context.dart'; +import 'package:celest_cli/src/utils/typeid.dart'; +import 'package:drift/drift.dart'; +import 'package:drift/native.dart'; +import 'package:file/memory.dart'; +import 'package:pool/pool.dart'; +import 'package:sqlite3/sqlite3.dart'; + +part 'project_database.g.dart'; + +@DriftDatabase(include: {'project.drift'}) +final class ProjectDatabase extends _$ProjectDatabase { + ProjectDatabase({required String projectRoot, required bool verbose}) + : super(_openConnection(projectRoot, verbose: verbose)); + + ProjectDatabase.memory() : super(NativeDatabase.memory(setup: _setup)); + + @override + int get schemaVersion => 1; + + static final Pool _lock = Pool(1); + + @override + MigrationStrategy get migration { + return MigrationStrategy( + beforeOpen: + (details) => _lock.withResource(() async { + await customStatement('PRAGMA foreign_keys = ON'); + await customStatement('PRAGMA journal_mode = WAL'); + await customStatement('PRAGMA busy_timeout = 5000'); + await customStatement('PRAGMA synchronous = NORMAL'); + await customStatement('PRAGMA mmap_size = 30000000000'); + await customStatement('PRAGMA cache_size = 1000000000'); + await customStatement('PRAGMA page_size = 32768'); + await customStatement('PRAGMA temp_store = memory'); + }), + onCreate: + (m) => _lock.withResource(() async { + await m.createAll(); + }), + onUpgrade: + (m, from, to) => _lock.withResource(() async { + return stepByStep()(m, from, to); + }), + ); + } + + Future getEnvValue( + String name, { + required String environmentId, + }) async { + final query = + select(environmentVariables) + ..where( + (env) => + env.name.equals(name) & env.environmentId.equals(environmentId), + ) + ..limit(1); + final values = await query.get(); + return values.firstOrNull?.value; + } + + Future setEnvValue( + String name, + String value, { + required String environmentId, + }) async { + await into(environmentVariables).insert( + EnvironmentVariable( + environmentId: environmentId, + name: name, + value: value, + ), + ); + } +} + +void Function(Database) get _setup { + return (Database db) { + db.createFunction( + functionName: 'typeid', + argumentCount: const AllowedArgumentCount(1), + deterministic: false, + directOnly: false, + function: (List args) { + final type = args.first as String; + return typeId(type); + }, + ); + }; +} + +QueryExecutor _openConnection(String projectRoot, {required bool verbose}) { + return LazyDatabase(() async { + if (fileSystem is MemoryFileSystem) { + return NativeDatabase.memory( + logStatements: verbose, + cachePreparedStatements: true, + setup: _setup, + ); + } + final file = fileSystem.file( + p.join(projectRoot, '.dart_tool', 'celest', 'project.db'), + ); + await file.parent.create(recursive: true); + + // Ensure the file is only readable by the current user. + // + // On windows, we just leverage the sandboxing to achieve the same. + if (platform.isLinux || platform.isMacOS) { + final chmodRes = await processManager.run([ + 'chmod', + '600', + file.path, + ]); + if (chmodRes.exitCode != 0) { + performance.captureError( + 'Failed to set file permissions for ${file.path}', + extra: { + 'stdout': chmodRes.stdout.toString(), + 'stderr': chmodRes.stderr.toString(), + }, + ); + } + } + + return NativeDatabase( + file, + logStatements: verbose, + cachePreparedStatements: true, + enableMigrations: true, + setup: _setup, + ); + }); +} diff --git a/apps/cli/lib/database/project/project_database.g.dart b/apps/cli/lib/database/project/project_database.g.dart new file mode 100644 index 000000000..6adf9f099 --- /dev/null +++ b/apps/cli/lib/database/project/project_database.g.dart @@ -0,0 +1,1247 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'project_database.dart'; + +// ignore_for_file: type=lint +class Environments extends Table with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + Environments(this.attachedDatabase, [this._alias]); + late final GeneratedColumn id = GeneratedColumn( + 'id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL PRIMARY KEY', + ); + @override + List get $columns => [id]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'environments'; + @override + Set get $primaryKey => {id}; + @override + Environment map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return Environment( + id: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}id'], + )!, + ); + } + + @override + Environments createAlias(String alias) { + return Environments(attachedDatabase, alias); + } + + @override + bool get dontWriteConstraints => true; +} + +class Environment extends DataClass implements Insertable { + /// The unique alias for the environment. + final String id; + const Environment({required this.id}); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['id'] = Variable(id); + return map; + } + + factory Environment.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return Environment(id: serializer.fromJson(json['id'])); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return {'id': serializer.toJson(id)}; + } + + Environment copyWith({String? id}) => Environment(id: id ?? this.id); + Environment copyWithCompanion(EnvironmentsCompanion data) { + return Environment(id: data.id.present ? data.id.value : this.id); + } + + @override + String toString() { + return (StringBuffer('Environment(') + ..write('id: $id') + ..write(')')) + .toString(); + } + + @override + int get hashCode => id.hashCode; + @override + bool operator ==(Object other) => + identical(this, other) || (other is Environment && other.id == this.id); +} + +class EnvironmentsCompanion extends UpdateCompanion { + final Value id; + final Value rowid; + const EnvironmentsCompanion({ + this.id = const Value.absent(), + this.rowid = const Value.absent(), + }); + EnvironmentsCompanion.insert({ + required String id, + this.rowid = const Value.absent(), + }) : id = Value(id); + static Insertable custom({ + Expression? id, + Expression? rowid, + }) { + return RawValuesInsertable({ + if (id != null) 'id': id, + if (rowid != null) 'rowid': rowid, + }); + } + + EnvironmentsCompanion copyWith({Value? id, Value? rowid}) { + return EnvironmentsCompanion(id: id ?? this.id, rowid: rowid ?? this.rowid); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (id.present) { + map['id'] = Variable(id.value); + } + if (rowid.present) { + map['rowid'] = Variable(rowid.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('EnvironmentsCompanion(') + ..write('id: $id, ') + ..write('rowid: $rowid') + ..write(')')) + .toString(); + } +} + +class EnvironmentVariables extends Table + with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + EnvironmentVariables(this.attachedDatabase, [this._alias]); + late final GeneratedColumn environmentId = GeneratedColumn( + 'environment_id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn name = GeneratedColumn( + 'name', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn value = GeneratedColumn( + 'value', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + @override + List get $columns => [environmentId, name, value]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'environment_variables'; + @override + Set get $primaryKey => {environmentId, name}; + @override + EnvironmentVariable map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return EnvironmentVariable( + environmentId: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}environment_id'], + )!, + name: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}name'], + )!, + value: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}value'], + )!, + ); + } + + @override + EnvironmentVariables createAlias(String alias) { + return EnvironmentVariables(attachedDatabase, alias); + } + + @override + List get customConstraints => const [ + 'PRIMARY KEY(environment_id, name)', + 'CONSTRAINT fk_environment_variables_environment_id FOREIGN KEY(environment_id)REFERENCES environments(id)ON UPDATE CASCADE ON DELETE CASCADE', + ]; + @override + bool get dontWriteConstraints => true; +} + +class EnvironmentVariable extends DataClass + implements Insertable { + /// The environment that the variable belongs to. + final String environmentId; + + /// The name of the environment variable. + final String name; + + /// The value of the environment variable. + final String value; + const EnvironmentVariable({ + required this.environmentId, + required this.name, + required this.value, + }); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['environment_id'] = Variable(environmentId); + map['name'] = Variable(name); + map['value'] = Variable(value); + return map; + } + + factory EnvironmentVariable.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return EnvironmentVariable( + environmentId: serializer.fromJson(json['environment_id']), + name: serializer.fromJson(json['name']), + value: serializer.fromJson(json['value']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'environment_id': serializer.toJson(environmentId), + 'name': serializer.toJson(name), + 'value': serializer.toJson(value), + }; + } + + EnvironmentVariable copyWith({ + String? environmentId, + String? name, + String? value, + }) => EnvironmentVariable( + environmentId: environmentId ?? this.environmentId, + name: name ?? this.name, + value: value ?? this.value, + ); + EnvironmentVariable copyWithCompanion(EnvironmentVariablesCompanion data) { + return EnvironmentVariable( + environmentId: + data.environmentId.present + ? data.environmentId.value + : this.environmentId, + name: data.name.present ? data.name.value : this.name, + value: data.value.present ? data.value.value : this.value, + ); + } + + @override + String toString() { + return (StringBuffer('EnvironmentVariable(') + ..write('environmentId: $environmentId, ') + ..write('name: $name, ') + ..write('value: $value') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash(environmentId, name, value); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is EnvironmentVariable && + other.environmentId == this.environmentId && + other.name == this.name && + other.value == this.value); +} + +class EnvironmentVariablesCompanion + extends UpdateCompanion { + final Value environmentId; + final Value name; + final Value value; + final Value rowid; + const EnvironmentVariablesCompanion({ + this.environmentId = const Value.absent(), + this.name = const Value.absent(), + this.value = const Value.absent(), + this.rowid = const Value.absent(), + }); + EnvironmentVariablesCompanion.insert({ + required String environmentId, + required String name, + required String value, + this.rowid = const Value.absent(), + }) : environmentId = Value(environmentId), + name = Value(name), + value = Value(value); + static Insertable custom({ + Expression? environmentId, + Expression? name, + Expression? value, + Expression? rowid, + }) { + return RawValuesInsertable({ + if (environmentId != null) 'environment_id': environmentId, + if (name != null) 'name': name, + if (value != null) 'value': value, + if (rowid != null) 'rowid': rowid, + }); + } + + EnvironmentVariablesCompanion copyWith({ + Value? environmentId, + Value? name, + Value? value, + Value? rowid, + }) { + return EnvironmentVariablesCompanion( + environmentId: environmentId ?? this.environmentId, + name: name ?? this.name, + value: value ?? this.value, + rowid: rowid ?? this.rowid, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (environmentId.present) { + map['environment_id'] = Variable(environmentId.value); + } + if (name.present) { + map['name'] = Variable(name.value); + } + if (value.present) { + map['value'] = Variable(value.value); + } + if (rowid.present) { + map['rowid'] = Variable(rowid.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('EnvironmentVariablesCompanion(') + ..write('environmentId: $environmentId, ') + ..write('name: $name, ') + ..write('value: $value, ') + ..write('rowid: $rowid') + ..write(')')) + .toString(); + } +} + +class Secrets extends Table with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + Secrets(this.attachedDatabase, [this._alias]); + late final GeneratedColumn environmentId = GeneratedColumn( + 'environment_id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn name = GeneratedColumn( + 'name', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn valueRef = GeneratedColumn( + 'value_ref', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + @override + List get $columns => [environmentId, name, valueRef]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'secrets'; + @override + Set get $primaryKey => {environmentId, name}; + @override + Secret map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return Secret( + environmentId: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}environment_id'], + )!, + name: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}name'], + )!, + valueRef: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}value_ref'], + )!, + ); + } + + @override + Secrets createAlias(String alias) { + return Secrets(attachedDatabase, alias); + } + + @override + List get customConstraints => const [ + 'PRIMARY KEY(environment_id, name)', + 'CONSTRAINT fk_secrets_environment_id FOREIGN KEY(environment_id)REFERENCES environments(id)ON UPDATE CASCADE ON DELETE CASCADE', + ]; + @override + bool get dontWriteConstraints => true; +} + +class Secret extends DataClass implements Insertable { + /// The environment that the secret belongs to. + final String environmentId; + + /// The name of the secret. + final String name; + + /// A reference to the value of the secret which is stored in secure storage. + final String valueRef; + const Secret({ + required this.environmentId, + required this.name, + required this.valueRef, + }); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['environment_id'] = Variable(environmentId); + map['name'] = Variable(name); + map['value_ref'] = Variable(valueRef); + return map; + } + + factory Secret.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return Secret( + environmentId: serializer.fromJson(json['environment_id']), + name: serializer.fromJson(json['name']), + valueRef: serializer.fromJson(json['value_ref']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'environment_id': serializer.toJson(environmentId), + 'name': serializer.toJson(name), + 'value_ref': serializer.toJson(valueRef), + }; + } + + Secret copyWith({String? environmentId, String? name, String? valueRef}) => + Secret( + environmentId: environmentId ?? this.environmentId, + name: name ?? this.name, + valueRef: valueRef ?? this.valueRef, + ); + Secret copyWithCompanion(SecretsCompanion data) { + return Secret( + environmentId: + data.environmentId.present + ? data.environmentId.value + : this.environmentId, + name: data.name.present ? data.name.value : this.name, + valueRef: data.valueRef.present ? data.valueRef.value : this.valueRef, + ); + } + + @override + String toString() { + return (StringBuffer('Secret(') + ..write('environmentId: $environmentId, ') + ..write('name: $name, ') + ..write('valueRef: $valueRef') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash(environmentId, name, valueRef); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is Secret && + other.environmentId == this.environmentId && + other.name == this.name && + other.valueRef == this.valueRef); +} + +class SecretsCompanion extends UpdateCompanion { + final Value environmentId; + final Value name; + final Value valueRef; + final Value rowid; + const SecretsCompanion({ + this.environmentId = const Value.absent(), + this.name = const Value.absent(), + this.valueRef = const Value.absent(), + this.rowid = const Value.absent(), + }); + SecretsCompanion.insert({ + required String environmentId, + required String name, + required String valueRef, + this.rowid = const Value.absent(), + }) : environmentId = Value(environmentId), + name = Value(name), + valueRef = Value(valueRef); + static Insertable custom({ + Expression? environmentId, + Expression? name, + Expression? valueRef, + Expression? rowid, + }) { + return RawValuesInsertable({ + if (environmentId != null) 'environment_id': environmentId, + if (name != null) 'name': name, + if (valueRef != null) 'value_ref': valueRef, + if (rowid != null) 'rowid': rowid, + }); + } + + SecretsCompanion copyWith({ + Value? environmentId, + Value? name, + Value? valueRef, + Value? rowid, + }) { + return SecretsCompanion( + environmentId: environmentId ?? this.environmentId, + name: name ?? this.name, + valueRef: valueRef ?? this.valueRef, + rowid: rowid ?? this.rowid, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (environmentId.present) { + map['environment_id'] = Variable(environmentId.value); + } + if (name.present) { + map['name'] = Variable(name.value); + } + if (valueRef.present) { + map['value_ref'] = Variable(valueRef.value); + } + if (rowid.present) { + map['rowid'] = Variable(rowid.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('SecretsCompanion(') + ..write('environmentId: $environmentId, ') + ..write('name: $name, ') + ..write('valueRef: $valueRef, ') + ..write('rowid: $rowid') + ..write(')')) + .toString(); + } +} + +abstract class _$ProjectDatabase extends GeneratedDatabase { + _$ProjectDatabase(QueryExecutor e) : super(e); + $ProjectDatabaseManager get managers => $ProjectDatabaseManager(this); + late final Environments environments = Environments(this); + late final EnvironmentVariables environmentVariables = EnvironmentVariables( + this, + ); + late final Secrets secrets = Secrets(this); + Selectable lookupEnvironment({required String id}) { + return customSelect( + 'SELECT * FROM environments WHERE id = ?1 LIMIT 1', + variables: [Variable(id)], + readsFrom: {environments}, + ).asyncMap(environments.mapFromRow); + } + + Future> createEnvironment({required String id}) { + return customWriteReturning( + 'INSERT INTO environments (id) VALUES (?1) RETURNING *', + variables: [Variable(id)], + updates: {environments}, + ).then((rows) => Future.wait(rows.map(environments.mapFromRow))); + } + + Future> upsertEnvironment({required String id}) { + return customWriteReturning( + 'INSERT INTO environments (id) VALUES (?1) ON CONFLICT (id) DO NOTHING RETURNING *', + variables: [Variable(id)], + updates: {environments}, + ).then((rows) => Future.wait(rows.map(environments.mapFromRow))); + } + + Future> upsertEnvironmentVariable({ + required String environmentId, + required String name, + required String value, + }) { + return customWriteReturning( + 'INSERT INTO environment_variables (environment_id, name, value) VALUES (?1, ?2, ?3) ON CONFLICT (environment_id, name) DO UPDATE SET value = ?3 RETURNING *', + variables: [ + Variable(environmentId), + Variable(name), + Variable(value), + ], + updates: {environmentVariables}, + ).then((rows) => Future.wait(rows.map(environmentVariables.mapFromRow))); + } + + Selectable getEnvironmentVariables({ + required String environmentId, + required List names, + }) { + var $arrayStartIndex = 2; + final expandednames = $expandVar($arrayStartIndex, names.length); + $arrayStartIndex += names.length; + return customSelect( + 'SELECT * FROM environment_variables WHERE environment_id = ?1 AND name IN ($expandednames)', + variables: [ + Variable(environmentId), + for (var $ in names) Variable($), + ], + readsFrom: {environmentVariables}, + ).asyncMap(environmentVariables.mapFromRow); + } + + Selectable getEnvironmentVariable({ + required String environmentId, + required String name, + }) { + return customSelect( + 'SELECT value FROM environment_variables WHERE environment_id = ?1 AND name = ?2', + variables: [Variable(environmentId), Variable(name)], + readsFrom: {environmentVariables}, + ).map((QueryRow row) => row.read('value')); + } + + Future> upsertSecret({ + required String environmentId, + required String name, + required String valueRef, + }) { + return customWriteReturning( + 'INSERT INTO secrets (environment_id, name, value_ref) VALUES (?1, ?2, ?3) ON CONFLICT (environment_id, name) DO UPDATE SET value_ref = ?3 RETURNING *', + variables: [ + Variable(environmentId), + Variable(name), + Variable(valueRef), + ], + updates: {secrets}, + ).then((rows) => Future.wait(rows.map(secrets.mapFromRow))); + } + + Selectable getSecrets({ + required String environmentId, + required List names, + }) { + var $arrayStartIndex = 2; + final expandednames = $expandVar($arrayStartIndex, names.length); + $arrayStartIndex += names.length; + return customSelect( + 'SELECT * FROM secrets WHERE environment_id = ?1 AND name IN ($expandednames)', + variables: [ + Variable(environmentId), + for (var $ in names) Variable($), + ], + readsFrom: {secrets}, + ).asyncMap(secrets.mapFromRow); + } + + Selectable getSecret({ + required String environmentId, + required String name, + }) { + return customSelect( + 'SELECT value_ref FROM secrets WHERE environment_id = ?1 AND name = ?2', + variables: [Variable(environmentId), Variable(name)], + readsFrom: {secrets}, + ).map((QueryRow row) => row.read('value_ref')); + } + + @override + Iterable> get allTables => + allSchemaEntities.whereType>(); + @override + List get allSchemaEntities => [ + environments, + environmentVariables, + secrets, + ]; + @override + StreamQueryUpdateRules get streamUpdateRules => const StreamQueryUpdateRules([ + WritePropagation( + on: TableUpdateQuery.onTableName( + 'environments', + limitUpdateKind: UpdateKind.delete, + ), + result: [TableUpdate('environment_variables', kind: UpdateKind.delete)], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'environments', + limitUpdateKind: UpdateKind.update, + ), + result: [TableUpdate('environment_variables', kind: UpdateKind.update)], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'environments', + limitUpdateKind: UpdateKind.delete, + ), + result: [TableUpdate('secrets', kind: UpdateKind.delete)], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'environments', + limitUpdateKind: UpdateKind.update, + ), + result: [TableUpdate('secrets', kind: UpdateKind.update)], + ), + ]); +} + +typedef $EnvironmentsCreateCompanionBuilder = + EnvironmentsCompanion Function({required String id, Value rowid}); +typedef $EnvironmentsUpdateCompanionBuilder = + EnvironmentsCompanion Function({Value id, Value rowid}); + +class $EnvironmentsFilterComposer + extends Composer<_$ProjectDatabase, Environments> { + $EnvironmentsFilterComposer({ + required super.$db, + required super.$table, + super.joinBuilder, + super.$addJoinBuilderToRootComposer, + super.$removeJoinBuilderFromRootComposer, + }); + ColumnFilters get id => $composableBuilder( + column: $table.id, + builder: (column) => ColumnFilters(column), + ); +} + +class $EnvironmentsOrderingComposer + extends Composer<_$ProjectDatabase, Environments> { + $EnvironmentsOrderingComposer({ + required super.$db, + required super.$table, + super.joinBuilder, + super.$addJoinBuilderToRootComposer, + super.$removeJoinBuilderFromRootComposer, + }); + ColumnOrderings get id => $composableBuilder( + column: $table.id, + builder: (column) => ColumnOrderings(column), + ); +} + +class $EnvironmentsAnnotationComposer + extends Composer<_$ProjectDatabase, Environments> { + $EnvironmentsAnnotationComposer({ + required super.$db, + required super.$table, + super.joinBuilder, + super.$addJoinBuilderToRootComposer, + super.$removeJoinBuilderFromRootComposer, + }); + GeneratedColumn get id => + $composableBuilder(column: $table.id, builder: (column) => column); +} + +class $EnvironmentsTableManager + extends + RootTableManager< + _$ProjectDatabase, + Environments, + Environment, + $EnvironmentsFilterComposer, + $EnvironmentsOrderingComposer, + $EnvironmentsAnnotationComposer, + $EnvironmentsCreateCompanionBuilder, + $EnvironmentsUpdateCompanionBuilder, + ( + Environment, + BaseReferences<_$ProjectDatabase, Environments, Environment>, + ), + Environment, + PrefetchHooks Function() + > { + $EnvironmentsTableManager(_$ProjectDatabase db, Environments table) + : super( + TableManagerState( + db: db, + table: table, + createFilteringComposer: + () => $EnvironmentsFilterComposer($db: db, $table: table), + createOrderingComposer: + () => $EnvironmentsOrderingComposer($db: db, $table: table), + createComputedFieldComposer: + () => $EnvironmentsAnnotationComposer($db: db, $table: table), + updateCompanionCallback: + ({ + Value id = const Value.absent(), + Value rowid = const Value.absent(), + }) => EnvironmentsCompanion(id: id, rowid: rowid), + createCompanionCallback: + ({required String id, Value rowid = const Value.absent()}) => + EnvironmentsCompanion.insert(id: id, rowid: rowid), + withReferenceMapper: + (p0) => + p0 + .map( + (e) => ( + e.readTable(table), + BaseReferences(db, table, e), + ), + ) + .toList(), + prefetchHooksCallback: null, + ), + ); +} + +typedef $EnvironmentsProcessedTableManager = + ProcessedTableManager< + _$ProjectDatabase, + Environments, + Environment, + $EnvironmentsFilterComposer, + $EnvironmentsOrderingComposer, + $EnvironmentsAnnotationComposer, + $EnvironmentsCreateCompanionBuilder, + $EnvironmentsUpdateCompanionBuilder, + ( + Environment, + BaseReferences<_$ProjectDatabase, Environments, Environment>, + ), + Environment, + PrefetchHooks Function() + >; +typedef $EnvironmentVariablesCreateCompanionBuilder = + EnvironmentVariablesCompanion Function({ + required String environmentId, + required String name, + required String value, + Value rowid, + }); +typedef $EnvironmentVariablesUpdateCompanionBuilder = + EnvironmentVariablesCompanion Function({ + Value environmentId, + Value name, + Value value, + Value rowid, + }); + +class $EnvironmentVariablesFilterComposer + extends Composer<_$ProjectDatabase, EnvironmentVariables> { + $EnvironmentVariablesFilterComposer({ + required super.$db, + required super.$table, + super.joinBuilder, + super.$addJoinBuilderToRootComposer, + super.$removeJoinBuilderFromRootComposer, + }); + ColumnFilters get environmentId => $composableBuilder( + column: $table.environmentId, + builder: (column) => ColumnFilters(column), + ); + + ColumnFilters get name => $composableBuilder( + column: $table.name, + builder: (column) => ColumnFilters(column), + ); + + ColumnFilters get value => $composableBuilder( + column: $table.value, + builder: (column) => ColumnFilters(column), + ); +} + +class $EnvironmentVariablesOrderingComposer + extends Composer<_$ProjectDatabase, EnvironmentVariables> { + $EnvironmentVariablesOrderingComposer({ + required super.$db, + required super.$table, + super.joinBuilder, + super.$addJoinBuilderToRootComposer, + super.$removeJoinBuilderFromRootComposer, + }); + ColumnOrderings get environmentId => $composableBuilder( + column: $table.environmentId, + builder: (column) => ColumnOrderings(column), + ); + + ColumnOrderings get name => $composableBuilder( + column: $table.name, + builder: (column) => ColumnOrderings(column), + ); + + ColumnOrderings get value => $composableBuilder( + column: $table.value, + builder: (column) => ColumnOrderings(column), + ); +} + +class $EnvironmentVariablesAnnotationComposer + extends Composer<_$ProjectDatabase, EnvironmentVariables> { + $EnvironmentVariablesAnnotationComposer({ + required super.$db, + required super.$table, + super.joinBuilder, + super.$addJoinBuilderToRootComposer, + super.$removeJoinBuilderFromRootComposer, + }); + GeneratedColumn get environmentId => $composableBuilder( + column: $table.environmentId, + builder: (column) => column, + ); + + GeneratedColumn get name => + $composableBuilder(column: $table.name, builder: (column) => column); + + GeneratedColumn get value => + $composableBuilder(column: $table.value, builder: (column) => column); +} + +class $EnvironmentVariablesTableManager + extends + RootTableManager< + _$ProjectDatabase, + EnvironmentVariables, + EnvironmentVariable, + $EnvironmentVariablesFilterComposer, + $EnvironmentVariablesOrderingComposer, + $EnvironmentVariablesAnnotationComposer, + $EnvironmentVariablesCreateCompanionBuilder, + $EnvironmentVariablesUpdateCompanionBuilder, + ( + EnvironmentVariable, + BaseReferences< + _$ProjectDatabase, + EnvironmentVariables, + EnvironmentVariable + >, + ), + EnvironmentVariable, + PrefetchHooks Function() + > { + $EnvironmentVariablesTableManager( + _$ProjectDatabase db, + EnvironmentVariables table, + ) : super( + TableManagerState( + db: db, + table: table, + createFilteringComposer: + () => $EnvironmentVariablesFilterComposer($db: db, $table: table), + createOrderingComposer: + () => + $EnvironmentVariablesOrderingComposer($db: db, $table: table), + createComputedFieldComposer: + () => $EnvironmentVariablesAnnotationComposer( + $db: db, + $table: table, + ), + updateCompanionCallback: + ({ + Value environmentId = const Value.absent(), + Value name = const Value.absent(), + Value value = const Value.absent(), + Value rowid = const Value.absent(), + }) => EnvironmentVariablesCompanion( + environmentId: environmentId, + name: name, + value: value, + rowid: rowid, + ), + createCompanionCallback: + ({ + required String environmentId, + required String name, + required String value, + Value rowid = const Value.absent(), + }) => EnvironmentVariablesCompanion.insert( + environmentId: environmentId, + name: name, + value: value, + rowid: rowid, + ), + withReferenceMapper: + (p0) => + p0 + .map( + (e) => ( + e.readTable(table), + BaseReferences(db, table, e), + ), + ) + .toList(), + prefetchHooksCallback: null, + ), + ); +} + +typedef $EnvironmentVariablesProcessedTableManager = + ProcessedTableManager< + _$ProjectDatabase, + EnvironmentVariables, + EnvironmentVariable, + $EnvironmentVariablesFilterComposer, + $EnvironmentVariablesOrderingComposer, + $EnvironmentVariablesAnnotationComposer, + $EnvironmentVariablesCreateCompanionBuilder, + $EnvironmentVariablesUpdateCompanionBuilder, + ( + EnvironmentVariable, + BaseReferences< + _$ProjectDatabase, + EnvironmentVariables, + EnvironmentVariable + >, + ), + EnvironmentVariable, + PrefetchHooks Function() + >; +typedef $SecretsCreateCompanionBuilder = + SecretsCompanion Function({ + required String environmentId, + required String name, + required String valueRef, + Value rowid, + }); +typedef $SecretsUpdateCompanionBuilder = + SecretsCompanion Function({ + Value environmentId, + Value name, + Value valueRef, + Value rowid, + }); + +class $SecretsFilterComposer extends Composer<_$ProjectDatabase, Secrets> { + $SecretsFilterComposer({ + required super.$db, + required super.$table, + super.joinBuilder, + super.$addJoinBuilderToRootComposer, + super.$removeJoinBuilderFromRootComposer, + }); + ColumnFilters get environmentId => $composableBuilder( + column: $table.environmentId, + builder: (column) => ColumnFilters(column), + ); + + ColumnFilters get name => $composableBuilder( + column: $table.name, + builder: (column) => ColumnFilters(column), + ); + + ColumnFilters get valueRef => $composableBuilder( + column: $table.valueRef, + builder: (column) => ColumnFilters(column), + ); +} + +class $SecretsOrderingComposer extends Composer<_$ProjectDatabase, Secrets> { + $SecretsOrderingComposer({ + required super.$db, + required super.$table, + super.joinBuilder, + super.$addJoinBuilderToRootComposer, + super.$removeJoinBuilderFromRootComposer, + }); + ColumnOrderings get environmentId => $composableBuilder( + column: $table.environmentId, + builder: (column) => ColumnOrderings(column), + ); + + ColumnOrderings get name => $composableBuilder( + column: $table.name, + builder: (column) => ColumnOrderings(column), + ); + + ColumnOrderings get valueRef => $composableBuilder( + column: $table.valueRef, + builder: (column) => ColumnOrderings(column), + ); +} + +class $SecretsAnnotationComposer extends Composer<_$ProjectDatabase, Secrets> { + $SecretsAnnotationComposer({ + required super.$db, + required super.$table, + super.joinBuilder, + super.$addJoinBuilderToRootComposer, + super.$removeJoinBuilderFromRootComposer, + }); + GeneratedColumn get environmentId => $composableBuilder( + column: $table.environmentId, + builder: (column) => column, + ); + + GeneratedColumn get name => + $composableBuilder(column: $table.name, builder: (column) => column); + + GeneratedColumn get valueRef => + $composableBuilder(column: $table.valueRef, builder: (column) => column); +} + +class $SecretsTableManager + extends + RootTableManager< + _$ProjectDatabase, + Secrets, + Secret, + $SecretsFilterComposer, + $SecretsOrderingComposer, + $SecretsAnnotationComposer, + $SecretsCreateCompanionBuilder, + $SecretsUpdateCompanionBuilder, + (Secret, BaseReferences<_$ProjectDatabase, Secrets, Secret>), + Secret, + PrefetchHooks Function() + > { + $SecretsTableManager(_$ProjectDatabase db, Secrets table) + : super( + TableManagerState( + db: db, + table: table, + createFilteringComposer: + () => $SecretsFilterComposer($db: db, $table: table), + createOrderingComposer: + () => $SecretsOrderingComposer($db: db, $table: table), + createComputedFieldComposer: + () => $SecretsAnnotationComposer($db: db, $table: table), + updateCompanionCallback: + ({ + Value environmentId = const Value.absent(), + Value name = const Value.absent(), + Value valueRef = const Value.absent(), + Value rowid = const Value.absent(), + }) => SecretsCompanion( + environmentId: environmentId, + name: name, + valueRef: valueRef, + rowid: rowid, + ), + createCompanionCallback: + ({ + required String environmentId, + required String name, + required String valueRef, + Value rowid = const Value.absent(), + }) => SecretsCompanion.insert( + environmentId: environmentId, + name: name, + valueRef: valueRef, + rowid: rowid, + ), + withReferenceMapper: + (p0) => + p0 + .map( + (e) => ( + e.readTable(table), + BaseReferences(db, table, e), + ), + ) + .toList(), + prefetchHooksCallback: null, + ), + ); +} + +typedef $SecretsProcessedTableManager = + ProcessedTableManager< + _$ProjectDatabase, + Secrets, + Secret, + $SecretsFilterComposer, + $SecretsOrderingComposer, + $SecretsAnnotationComposer, + $SecretsCreateCompanionBuilder, + $SecretsUpdateCompanionBuilder, + (Secret, BaseReferences<_$ProjectDatabase, Secrets, Secret>), + Secret, + PrefetchHooks Function() + >; + +class $ProjectDatabaseManager { + final _$ProjectDatabase _db; + $ProjectDatabaseManager(this._db); + $EnvironmentsTableManager get environments => + $EnvironmentsTableManager(_db, _db.environments); + $EnvironmentVariablesTableManager get environmentVariables => + $EnvironmentVariablesTableManager(_db, _db.environmentVariables); + $SecretsTableManager get secrets => $SecretsTableManager(_db, _db.secrets); +} diff --git a/apps/cli/lib/database/project/schema/drift_schema_v1.json b/apps/cli/lib/database/project/schema/drift_schema_v1.json new file mode 100644 index 000000000..bb2c2d341 --- /dev/null +++ b/apps/cli/lib/database/project/schema/drift_schema_v1.json @@ -0,0 +1 @@ +{"_meta":{"description":"This file contains a serialized version of schema entities for drift.","version":"1.2.0"},"options":{"store_date_time_values_as_text":false},"entities":[{"id":0,"references":[],"type":"table","data":{"name":"environments","was_declared_in_moor":true,"columns":[{"name":"id","getter_name":"id","moor_type":"string","nullable":false,"customConstraints":"NOT NULL PRIMARY KEY","default_dart":null,"default_client_dart":null,"dsl_features":["primary-key"]}],"is_virtual":false,"without_rowid":false,"constraints":[]}},{"id":1,"references":[0],"type":"table","data":{"name":"environment_variables","was_declared_in_moor":true,"columns":[{"name":"environment_id","getter_name":"environmentId","moor_type":"string","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"name","getter_name":"name","moor_type":"string","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"value","getter_name":"value","moor_type":"string","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]}],"is_virtual":false,"without_rowid":false,"constraints":["PRIMARY KEY(environment_id, name)","CONSTRAINT fk_environment_variables_environment_id FOREIGN KEY(environment_id)REFERENCES environments(id)ON UPDATE CASCADE ON DELETE CASCADE"],"explicit_pk":["environment_id","name"]}},{"id":2,"references":[0],"type":"table","data":{"name":"secrets","was_declared_in_moor":true,"columns":[{"name":"environment_id","getter_name":"environmentId","moor_type":"string","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"name","getter_name":"name","moor_type":"string","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"value_ref","getter_name":"valueRef","moor_type":"string","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]}],"is_virtual":false,"without_rowid":false,"constraints":["PRIMARY KEY(environment_id, name)","CONSTRAINT fk_secrets_environment_id FOREIGN KEY(environment_id)REFERENCES environments(id)ON UPDATE CASCADE ON DELETE CASCADE"],"explicit_pk":["environment_id","name"]}}]} \ No newline at end of file diff --git a/apps/cli/lib/env/config_value_solver.dart b/apps/cli/lib/env/config_value_solver.dart new file mode 100644 index 000000000..da8d407ab --- /dev/null +++ b/apps/cli/lib/env/config_value_solver.dart @@ -0,0 +1,188 @@ +import 'package:built_collection/built_collection.dart'; +import 'package:celest_ast/celest_ast.dart' as ast; +import 'package:celest_cli/analyzer/resolver/config_value_resolver.dart'; +import 'package:celest_cli/ast/ast.dart'; +import 'package:celest_cli/database/project/project_database.dart'; +import 'package:celest_cli/env/firebase_config_value_solver.dart'; +import 'package:celest_cli/env/supabase_config_value_solver.dart'; +import 'package:celest_cli/src/context.dart'; +import 'package:meta/meta.dart'; + +enum ConfigValueType { + environmentVariable, + secret; + + String get displayName => switch (this) { + environmentVariable => 'environment variable', + secret => 'secret', + }; +} + +final class ConfigValueSolver { + const ConfigValueSolver({required this.project, required this.environmentId}); + + final ast.Project project; + final String environmentId; + + Map get defaultValues { + return {'CELEST_ENVIRONMENT': environmentId}; + } + + Future> solveAll() async { + final [envValues, secretValues] = await Future.wait([ + project.variables.retrieveValues(environmentId: environmentId), + project.secrets.retrieveValues(environmentId: environmentId), + ]); + final envManager = await celestProject.envManager.environment( + environmentId, + ); + final allConfigValues = + ConfigVarSet() + ..addAll(project.variables) + ..addAll(project.secrets); + final allConfigEntries = { + ...envValues, + ...secretValues, + ...await envManager.readAll(), + + // Static values + for (final envVar in project.variables) + if (envVar.value case final value?) envVar.name: value, + + // Default values + ...defaultValues, + }; + + // First, resolve Auth environment variables which may require special + // resolution logic. + final authVariables = project.auth?.variables; + final authSecrets = project.auth?.secrets; + final authConfigValues = BuiltListMultimap< + ast.AuthProviderType, + ast.ConfigurationVariable + >.build((b) { + authVariables?.forEach(b.add); + authSecrets?.forEach(b.add); + }); + for (final MapEntry(key: provider, value: configValues) + in authConfigValues.toMap().entries) { + for (final configValue in configValues) { + if (allConfigEntries.containsKey(configValue.name)) { + continue; + } + switch (provider) { + case ast.AuthProviderType.firebase: + final solver = FirebaseConfigValueSolver( + projectName: project.name, + environmentId: environmentId, + ); + final value = await solver.solve(configValue); + allConfigEntries[configValue.name] = value; + case ast.AuthProviderType.supabase: + final solver = SupabaseConfigValueSolver( + projectName: project.name, + environmentId: environmentId, + ); + final value = await solver.solve(configValue); + allConfigEntries[configValue.name] = value; + default: + break; + } + } + } + + final promptSolver = PromptConfigValueSolver( + projectName: project.name, + environmentId: environmentId, + ); + for (final configValue in allConfigValues) { + if (allConfigEntries.containsKey(configValue.name)) { + continue; + } + final value = await promptSolver.solve(configValue); + allConfigEntries[configValue.name] = value; + } + + return allConfigEntries; + } +} + +abstract base class BaseConfigValueSolver { + const BaseConfigValueSolver({ + required this.projectName, + required this.environmentId, + @visibleForTesting ProjectDatabase? projectDb, + }) : _projectDb = projectDb; + + final String projectName; + final String environmentId; + final ProjectDatabase? _projectDb; + + Future solve(ast.ConfigurationVariable configVar); + + Future storeVariable(String name, String value) async { + final projectDb = _projectDb ?? celestProject.projectDb; + await projectDb.withEnvironment(environmentId: environmentId, ( + environment, + ) async { + await projectDb.upsertEnvironmentVariable( + environmentId: environment.id, + name: name, + value: value, + ); + }); + return value; + } + + Future storeSecret(String name, String value) async { + final projectDb = _projectDb ?? celestProject.projectDb; + await projectDb.withEnvironment(environmentId: environmentId, ( + environment, + ) async { + final (scope, key) = ( + 'projects/$projectName/environments/${environment.id}', + name, + ); + secureStorage.scoped(scope).write(key, value); + await projectDb.upsertSecret( + environmentId: environment.id, + name: name, + valueRef: '$scope/$key', + ); + }); + return value; + } +} + +base class PromptConfigValueSolver extends BaseConfigValueSolver { + const PromptConfigValueSolver({ + required super.projectName, + required super.environmentId, + @visibleForTesting super.projectDb, + }); + + String prompt(String name, ConfigValueType type) { + cliLogger.info('Missing value for ${type.displayName} "$name"'); + + String? value; + while (value == null) { + value = cliLogger.prompt( + 'Enter the value for $name', + hidden: type == ConfigValueType.secret, + ); + } + return value; + } + + @override + Future solve(ast.ConfigurationVariable configVar) async { + switch (configVar) { + case ast.Variable(:final name): + final value = prompt(name, ConfigValueType.environmentVariable); + return storeVariable(name, value); + case ast.Secret(:final name): + final value = prompt(name, ConfigValueType.secret); + return storeSecret(name, value); + } + } +} diff --git a/apps/cli/lib/env/env_manager.dart b/apps/cli/lib/env/env_manager.dart new file mode 100644 index 000000000..47a673bd0 --- /dev/null +++ b/apps/cli/lib/env/env_manager.dart @@ -0,0 +1,268 @@ +import 'dart:async'; +import 'dart:io'; +import 'dart:isolate'; + +import 'package:celest_ast/celest_ast.dart' as ast; +import 'package:celest_cli/env/env_parser.dart'; +import 'package:celest_cli/src/context.dart'; +import 'package:logging/logging.dart'; +import 'package:source_span/source_span.dart'; +import 'package:stream_channel/isolate_channel.dart'; + +typedef _EnvRequest = + ({ + int id, + String? name, + String? value, + List<(ast.Variable, String)>? variables, + }); + +typedef EnvironmentID = String; + +final class EnvManager { + late final SingleEnvManager _base = SingleEnvManager(projectPaths.envFile); + final Map _environments = {}; + + static final Logger _logger = Logger('EnvManager'); + + Future environment(EnvironmentID environment) async { + if (_environments[environment] case final overlay?) { + final manager = OverlayEnvManager(_base, overlay); + return manager.spawn(); + } + final envFile = projectPaths.envFileFor(environment); + if (!fileSystem.file(envFile).existsSync()) { + _logger.fine( + 'Environment file does not exist for "$environment": $envFile', + ); + return _base.spawn(); + } + _logger.fine('Using environment file for "$environment": $envFile'); + final envManager = _environments[environment] = SingleEnvManager(envFile); + final overlay = OverlayEnvManager(_base, envManager); + return overlay.spawn(); + } +} + +abstract class EnvLoader { + Future spawn(); + Future valueFor(String key); + Future> readAll(); +} + +final class OverlayEnvManager implements EnvLoader { + OverlayEnvManager(this._base, this._overlay); + + final SingleEnvManager _base; + final SingleEnvManager? _overlay; + + @override + Future spawn() async { + await (_base.spawn(), Future.value(_overlay?.spawn())).wait; + return this; + } + + @override + Future valueFor(String key) async { + return await _overlay?.valueFor(key) ?? await _base.valueFor(key); + } + + @override + Future> readAll() async { + final (base, overlay) = + await (_base.readAll(), Future.value(_overlay?.readAll())).wait; + return {...base, ...overlay}; + } +} + +final class SingleEnvManager implements EnvLoader { + SingleEnvManager(this.envFile); + + final String envFile; + + Isolate? _isolate; + IsolateChannel<_EnvRequest>? _channel; + StreamSubscription? _listener; + final _pendingRequests = >{}; + var _closed = false; + Future? _spawned; + + var _currentRequestId = 0; + (int, Completer<_EnvRequest>) get _nextRequestId { + final id = _currentRequestId++; + final completer = Completer<_EnvRequest>.sync(); + _pendingRequests[id] = completer; + return (id, completer); + } + + @override + Future spawn() async { + _spawned ??= _spawn().then((_) { + _listener = _channel!.stream.listen( + (response) { + final completer = _pendingRequests.remove(response.id); + if (completer == null) { + throw StateError('Request already completed'); + } + completer.complete(response); + }, + onError: (Object e, StackTrace st) { + close(force: true); + Error.throwWithStackTrace(e, st); + }, + ); + }); + await _spawned; + return this; + } + + Future _spawn() async { + final port = ReceivePort(); + _channel = IsolateChannel<_EnvRequest>.connectReceive(port); + _isolate = await Isolate.spawn(_handleRequests, ( + port.sendPort, + envFile, + ), debugName: 'IsolatedEnvManager'); + } + + static Future _handleRequests( + (SendPort sendPort, String envFile) config, + ) async { + final (sendPort, envFile) = config; + final channel = IsolateChannel<_EnvRequest>.connectSend(sendPort); + final manager = _IsolatedEnvManager(envFile); + await for (final (:id, :name, variables: _, value: _) in channel.stream) { + final variables = manager.reload(); + channel.sink.add(( + id: id, + name: name, + value: name == null ? null : manager.get(name), + variables: variables, + )); + } + } + + final _cache = {}; + + String? cachedValueFor(String key) => _cache[key]; + + @override + Future valueFor(String key) async { + final resp = await _send(key: key); + return _cache[key] = resp.value; + } + + Future<_EnvRequest> _send({String? key}) async { + if (_closed) { + throw StateError('EnvManager is closed'); + } + final (id, completer) = _nextRequestId; + try { + _channel!.sink.add((id: id, name: key, value: null, variables: null)); + final response = await completer.future; + return response; + } finally { + _pendingRequests.remove(id); + } + } + + Future> get variables async { + final resp = await _send(); + final variables = resp.variables!; + for (final (envVar, value) in variables) { + _cache[envVar.name] = value; + } + return variables.map((it) => it.$1).toList(); + } + + @override + Future> readAll() async { + final variables = await this.variables; + final values = await Future.wait([ + for (final envVar in variables) + valueFor(envVar.name).then((value) => MapEntry(envVar.name, value!)), + ]); + return Map.fromEntries(values); + } + + Future close({bool force = false}) async { + if (_closed) { + return; + } + _closed = true; + try { + if (force) { + for (final pendingRequest in _pendingRequests.values) { + pendingRequest.completeError( + StateError('EnvManager closed unexpectedly'), + ); + } + } else { + await Future.wait([ + for (final pendingRequest in _pendingRequests.values) + pendingRequest.future, + ]); + } + } finally { + _pendingRequests.clear(); + unawaited(_listener?.cancel()); + _listener = null; + unawaited(_channel?.sink.close()); + _channel = null; + _isolate?.kill(); + _isolate = null; + } + } +} + +final class _IsolatedEnvManager { + _IsolatedEnvManager(String envFile) : _envFile = File(envFile); + + final File _envFile; + DateTime? _lastCached; + late Map _env; + late Map _spans; + final _changes = {}; + + Map get env => _env; + List<(ast.Variable, String)> get variables => + _env.entries + .map( + (entry) => ( + ast.Variable( + entry.key, + dartName: null, + location: _spans[entry.key]!, + ), + entry.value, + ), + ) + .toList(); + + List<(ast.Variable, String)> reload() { + final (env, spans) = _load(); + _env = env; + _spans = spans; + return variables; + } + + (Map env, Map spans) _load() { + if (!_envFile.existsSync()) { + return const ({}, {}); + } + final lastModified = _envFile.lastModifiedSync(); + if (_lastCached != null && lastModified.isBefore(_lastCached!)) { + return (_env, _spans); + } + _lastCached = _envFile.lastModifiedSync(); + final parser = EnvParser( + source: _envFile.readAsStringSync(), + sourceUri: _envFile.uri, + )..parse(); + return (parser.env, parser.spans); + } + + String? get(String key) => _changes[key] ?? _env[key]; + void set(String key, String value) => _changes[key] = value; + void remove(String key) => _env.remove(key); +} diff --git a/apps/cli/lib/env/env_parser.dart b/apps/cli/lib/env/env_parser.dart new file mode 100644 index 000000000..94fe11db9 --- /dev/null +++ b/apps/cli/lib/env/env_parser.dart @@ -0,0 +1,126 @@ +// Copied from: +// https://github.com/petercinibulk/envied/blob/79c204367be5bdfc4ad5939006b086dbaf557ed0/packages/envied_generator/lib/src/parser.dart + +import 'package:celest_cli/analyzer/analysis_error.dart'; +import 'package:source_span/source_span.dart'; + +typedef EnvValue = ({String key, String value, int start, int end}); + +/// Creates key-value pairs from strings formatted as environment +/// variable definitions. +final class EnvParser { + EnvParser({required this.source, required this.sourceUri}); + + static const String _singleQuot = "'"; + static final RegExp _leadingExport = RegExp(r'''^ *export ?'''); + static final RegExp _comment = RegExp(r'''#[^'"]*$'''); + static final RegExp _commentWithQuotes = RegExp(r'''#.*$'''); + static final RegExp _surroundQuotes = RegExp(r'''^(["'])(.*?[^\\])\1'''); + static final RegExp _bashVar = RegExp( + r'''(\\)?(\$)(?:{)?([a-zA-Z_][\w]*)+(?:})?''', + ); + + final String source; + final Uri sourceUri; + + var _offset = 0; + + late final SourceFile _sourceFile = SourceFile.fromString( + source, + url: sourceUri, + ); + + final Map env = {}; + final Map spans = {}; + + // TODO(dnys1): Record errors parsing instead of returning null. + final List errors = []; + + /// Creates a [Map](dart:core). + /// Duplicate keys are silently discarded. + Map parse() { + for (var i = 0; i < _sourceFile.lines; i++) { + _offset = _sourceFile.getOffset(i); + final line = _sourceFile.getText( + _offset, + i + 1 < _sourceFile.lines ? _sourceFile.getOffset(i + 1) : null, + ); + final kv = parseOne(line); + if (kv case (:final key, :final value, :final start, :final end)) { + final span = _sourceFile.span(_offset + start, _offset + end); + env.update(key, (_) { + errors.add( + CelestAnalysisError(message: 'Duplicate key: $key', location: span), + ); + return value; + }, ifAbsent: () => value); + spans.putIfAbsent(key, () => span); + } + } + return env; + } + + /// Parses a single line into a key-value pair. + static EnvValue? parseOne(final String line) { + final stripped = strip(line); + if (!_isValid(stripped)) return null; + + final idx = stripped.indexOf('='); + final lhs = stripped.substring(0, idx); + final k = swallow(lhs); + if (k.isEmpty) return null; + + final rhs = stripped.substring(idx + 1, stripped.length).trim(); + final quotChar = surroundingQuote(rhs); + var v = unquote(rhs); + if (quotChar == _singleQuot) { + v = v.replaceAll(r"\'", "'"); + } + if (quotChar == '"') { + v = v.replaceAll(r'\"', '"').replaceAll(r'\n', '\n'); + } + + final start = line.indexOf(k); + final end = start + line.length; + + return (key: k, value: v, start: start, end: end); + } + + /// Substitutes $bash_vars in [val] with values from [env]. + static String interpolate(String val, Map env) => + val.replaceAllMapped(_bashVar, (Match m) { + if ((m.group(1) ?? '') == r'\') { + return m.input.substring(m.start, m.end); + } else { + final k = m.group(3)!; + return _has(env, k) ? env[k]! : ''; + } + }); + + /// If [val] is wrapped in single or double quotes, returns the quote character. + /// Otherwise, returns the empty string. + static String surroundingQuote(String val) => + _surroundQuotes.hasMatch(val) + ? _surroundQuotes.firstMatch(val)!.group(1)! + : ''; + + /// Removes quotes (single or double) surrounding a value. + static String unquote(String val) => + _surroundQuotes.hasMatch(val) + ? _surroundQuotes.firstMatch(val)!.group(2)! + : strip(val, includeQuotes: true).trim(); + + /// Strips comments (trailing or whole-line). + static String strip(String line, {bool includeQuotes = false}) => + line.replaceAll(includeQuotes ? _commentWithQuotes : _comment, '').trim(); + + /// Omits 'export' keyword. + static String swallow(String line) => + line.replaceAll(_leadingExport, '').trim(); + + static bool _isValid(String s) => s.isNotEmpty && s.contains('='); + + /// [ null ] is a valid value in a Dart map, but the env var representation is empty string, not the string 'null' + static bool _has(Map map, String key) => + map.containsKey(key) && map[key] != null; +} diff --git a/apps/cli/lib/env/firebase_config_value_solver.dart b/apps/cli/lib/env/firebase_config_value_solver.dart new file mode 100644 index 000000000..38aedd00a --- /dev/null +++ b/apps/cli/lib/env/firebase_config_value_solver.dart @@ -0,0 +1,333 @@ +import 'dart:collection'; +import 'dart:convert'; +import 'dart:io' show ProcessResult; + +import 'package:celest_ast/src/ast.dart'; +import 'package:celest_cli/env/config_value_solver.dart'; +import 'package:celest_cli/src/context.dart'; +import 'package:collection/collection.dart'; +import 'package:file/file.dart'; +import 'package:logging/logging.dart'; +import 'package:meta/meta.dart'; +// ignore: implementation_imports +import 'package:process/src/interface/common.dart'; + +final class FirebaseConfigValueSolver extends PromptConfigValueSolver { + const FirebaseConfigValueSolver({ + required super.projectName, + required super.environmentId, + @visibleForTesting super.projectDb, + }); + + static final Logger _logger = Logger('FirebaseConfigValueSolver'); + + String? _pick(List projects) { + return cliLogger + .chooseOne( + 'Choose a Firebase project to associate with environment "$environmentId"', + choices: projects, + defaultValue: + projects.firstWhereOrNull((entry) => entry.active) ?? + projects.firstWhereOrNull( + (project) => project.alias == 'default', + ), + display: (entry) { + if (entry.alias case final alias?) { + return '${entry.projectId} ($alias)'; + } + return entry.projectId; + }, + ) + .projectId; + } + + Future _readFromGlobalConfig(Directory searchDir) async { + final globalConfig = await FirebaseConfiguration.load(); + if (globalConfig == null) { + _logger.finest('No Firebase projects found in global configuration'); + return null; + } + _logger.finest('Active Firebase projects: ${globalConfig.activeProjects}'); + return globalConfig.activeProjects[searchDir.path]; + } + + /// Reads all project IDs recorded in the `firebase.json` file. + Future> _readFromFirebaseJson( + Directory searchDir, + ) async { + try { + final firebaseJsonFile = searchDir.childFile('firebase.json'); + if (!firebaseJsonFile.existsSync()) { + _logger.finest('No firebase.json found in $searchDir'); + return const {}; + } + final firebaseJson = jsonDecode(await firebaseJsonFile.readAsString()); + if (firebaseJson case { + 'flutter': { + 'platforms': { + // Structure is { : { ... } } + 'dart': final Map dartConfiguration, + }, + }, + }) { + return { + for (final entry in dartConfiguration.entries) + if (entry.value case {'projectId': final String projectId}) + // This will only be the default project ID if there is a single + // entry in the Dart configuration map. + // + // The Flutterfire CLI creates a separate entry for each project ID + // but does not distinguish which environment/alias they map to. + // + // So this configuration is only useful to us if there is a single + // entry. + projectId: dartConfiguration.length == 1 ? 'default' : null, + }; + } + // The `platforms` map is useless for us since it only records a single + // `default` entry even in a project using multiple environments/aliases. + _logger.finest('No project IDs found in firebase.json'); + return const {}; + } on Object catch (e, st) { + _logger.fine('Failed to read firebase.json', e, st); + return const {}; + } + } + + /// Reads any project aliases from the `.firebaserc` file. + Future> _readFromFirebaseRc(Directory searchDir) async { + try { + final firebaseRcFile = searchDir.childFile('.firebaserc'); + if (!firebaseRcFile.existsSync()) { + _logger.finest('No .firebaserc found in $searchDir'); + return const {}; + } + final firebaseRc = jsonDecode(await firebaseRcFile.readAsString()); + return switch (firebaseRc) { + {'projects': final Map aliases} => { + // Reverse the map so that we get projectID -> alias. + for (final entry in aliases.entries) entry.value as String: entry.key, + }, + _ => const {}, + }; + } on Object catch (e, st) { + _logger.fine('Failed to read .firebaserc', e, st); + return const {}; + } + } + + /// Reads the list of all environments available to the user. + Future> _readFromFirebaseToolsCli() async { + try { + final firebaseToolsCli = getExecutablePath( + 'firebase', + null, + platform: platform, + fs: fileSystem, + throwOnFailure: false, + ); + if (firebaseToolsCli == null) { + _logger.finest('Firebase CLI not found'); + return const []; + } + final ProcessResult( + :exitCode, + :stdout as String, + :stderr as String, + ) = await processManager.run([ + firebaseToolsCli, + 'projects:list', + '--json', + '--non-interactive', + ]); + if (exitCode != 0) { + _logger.finer( + 'Failed to list Firebase projects using firebase-tools CLI', + '$stdout\n$stderr', + ); + return const []; + } + final resultJsonStart = stdout.indexOf('{'); + if (resultJsonStart == -1) { + _logger.finer( + 'Failed to parse Firebase projects list from firebase-tools CLI', + stdout, + ); + return const []; + } + final resultJson = stdout.substring(resultJsonStart).trimRight(); + return switch (jsonDecode(resultJson)) { + {'results': final List results} => + results + .map( + (result) => switch (result) { + {'projectId': final String projectId} => projectId, + _ => null, + }, + ) + .nonNulls + .toList(), + _ => const [], + }; + } on Object catch (e, st) { + _logger.fine( + 'Failed to list Firebase projects using firebase-tools CLI', + e, + st, + ); + return const []; + } + } + + Future?> searchLocalEnvironment() async { + // We search in both the parent project (if there is one) and the Celest + // project for Firebase configuration files. + final searchDirs = [ + if (celestProject.parentProject?.path case final parentPath?) + fileSystem.directory(parentPath), + fileSystem.directory(projectPaths.projectRoot), + ]; + + for (final searchDir in searchDirs) { + // A map of Firebase project IDs -> aliases. + final aliasesByProjectId = {}; + + // Read any aliases from the `.firebaserc` file. + aliasesByProjectId.addAll(await _readFromFirebaseRc(searchDir)); + _logger.finest('Aliases found in .firebaserc: $aliasesByProjectId'); + + // Read all project IDs from the `firebase.json` file. + final flutterfireConfig = await _readFromFirebaseJson(searchDir); + _logger.finest('Project IDs found in firebase.json: $flutterfireConfig'); + for (final MapEntry(key: projectId, value: alias) + in flutterfireConfig.entries) { + if (alias != null || !aliasesByProjectId.containsKey(projectId)) { + aliasesByProjectId[projectId] = alias; + } + } + + // Check for `firebase-tools.json` in global config. + // + // The file stores the active projects as a map of project paths to + // project IDs/aliases. + final activeProject = await _readFromGlobalConfig(searchDir); + _logger.finest('Active project found in global config: $activeProject'); + + // When there is an alias matching the environment ID, we always use that. + final matchingEnvironmentId = + aliasesByProjectId.entries + .firstWhereOrNull((entry) => entry.value == environmentId) + ?.key; + if (matchingEnvironmentId != null) { + _logger.finest( + 'Found project matching environment ID: $matchingEnvironmentId', + ); + return [ + ( + active: true, + projectId: matchingEnvironmentId, + alias: environmentId, + ), + ]; + } + + if (aliasesByProjectId.isNotEmpty) { + return [ + for (final entry in aliasesByProjectId.entries) + ( + // The `firebase-tools.json` file stores a mapping of project paths to + // either project IDs or project aliases. + // + // We only know if it's a project ID if it's not an alias. Aliases + // are stored separately per-project in the `.firebaserc` file. + active: + activeProject != null && + (entry.key == activeProject || entry.value == activeProject), + projectId: entry.key, + alias: entry.value, + ), + ]; + } else if (activeProject != null) { + // No aliases and no flutterfire config, so this is the only project. + return [(active: true, projectId: activeProject, alias: null)]; + } + } + + return null; + } + + @override + Future solve(ConfigurationVariable configVar) async { + // Search for Firebase projects in the local environment and FS. + var projects = await searchLocalEnvironment(); + _logger.finest('Found Firebase projects: $projects'); + + // A resolution to a single project indicates we are done searching. + if (projects case [final singleProject]) { + _logger.finest('Resolved to single project: ${singleProject.projectId}'); + return storeVariable(configVar.name, singleProject.projectId); + } + + // Otherwise, we use the `firebase-tools` CLI to list projects, if + // installed. + if (projects == null) { + projects = [ + for (final projectId in await _readFromFirebaseToolsCli()) + (active: false, projectId: projectId, alias: null), + ]; + _logger.finest( + 'Found Firebase projects using firebase-tools CLI: $projects', + ); + } + + // If multiple projects are available, prompt the user to choose one. + if (projects.isNotEmpty) { + if (_pick(projects) case final selected?) { + return storeVariable(configVar.name, selected); + } + } + + // Otherwise, we must prompt them to enter the project ID manually. + _logger.finest('No Firebase projects found in local environment'); + return super.solve(configVar); + } +} + +final class FirebaseConfiguration { + FirebaseConfiguration._({required Map activeProjects}) + : activeProjects = LinkedHashMap( + equals: (a, b) => p.equals(a, b), + hashCode: (a) => p.hash(a), + )..addAll(activeProjects); + + static Future load() async { + final home = switch (platform.operatingSystem) { + 'windows' => platform.environment['USERPROFILE'], + _ => platform.environment['HOME'], + }; + if (home == null) { + return null; + } + final path = p.join(home, '.config', 'configstore', 'firebase-tools.json'); + final firebaseToolsFile = fileSystem.file(path); + if (!firebaseToolsFile.existsSync()) { + return null; + } + try { + final firebaseToolsJson = jsonDecode( + await firebaseToolsFile.readAsString(), + ); + return switch (firebaseToolsJson) { + {'activeProjects': final Map activeProjects} => + FirebaseConfiguration._(activeProjects: activeProjects.cast()), + _ => null, + }; + } on Object { + return null; + } + } + + final Map activeProjects; +} + +typedef FirebaseProject = ({bool active, String projectId, String? alias}); diff --git a/apps/cli/lib/env/supabase_config_value_solver.dart b/apps/cli/lib/env/supabase_config_value_solver.dart new file mode 100644 index 000000000..df228ad27 --- /dev/null +++ b/apps/cli/lib/env/supabase_config_value_solver.dart @@ -0,0 +1,181 @@ +import 'dart:convert'; +import 'dart:io'; + +import 'package:celest_ast/celest_ast.dart'; +import 'package:celest_cli/env/config_value_solver.dart'; +import 'package:celest_cli/src/context.dart'; +import 'package:celest_cli/src/utils/run.dart'; +import 'package:file/file.dart'; +import 'package:logging/logging.dart'; +import 'package:meta/meta.dart'; +// ignore: implementation_imports +import 'package:process/src/interface/common.dart'; +import 'package:toml/toml.dart'; + +final class SupabaseConfigValueSolver extends PromptConfigValueSolver { + SupabaseConfigValueSolver({ + required super.projectName, + required super.environmentId, + @visibleForTesting super.projectDb, + }); + + static final Logger _logger = Logger('SupabaseConfigValueSolver'); + + Future _findSupabaseDir() async { + // We search in both the parent project (if there is one) and the Celest + // project for Supabase configuration files. + final searchDirs = [ + fileSystem.directory(projectPaths.projectRoot), + if (celestProject.parentProject?.path case final parentPath?) + fileSystem.directory(parentPath), + ]; + + for (final searchDir in searchDirs) { + final supabaseDir = searchDir.childDirectory('supabase'); + if (supabaseDir.existsSync()) { + _logger.finest('Found Supabase directory: $supabaseDir'); + return supabaseDir; + } + } + + _logger.finest('Supabase directory not found in $searchDirs'); + return null; + } + + Future? _supabaseDir; + Future get supabaseDir { + return _supabaseDir ??= _findSupabaseDir(); + } + + Future findLinkedProjectRef() async { + final supabaseDir = await this.supabaseDir; + if (supabaseDir == null) { + return null; + } + // The path used by Supabase CLI to store the linked project ref. + // https://github.com/supabase/cli/blob/333a2ca5522e493cd35a853f258e9fd9b5098558/internal/utils/misc.go#L133 + final projectRefFile = supabaseDir + .childDirectory('.temp') + .childFile('project-ref'); + if (!projectRefFile.existsSync()) { + _logger.finest('Supabase project ref not found in $supabaseDir'); + return null; + } + final projectRef = await projectRefFile.readAsString(); + return projectRef.trim(); + } + + Future findConfigUrl() async { + final supabaseDir = await this.supabaseDir; + if (supabaseDir == null) { + return null; + } + final configTomlFile = supabaseDir.childFile('config.toml'); + if (!configTomlFile.existsSync()) { + _logger.finest('Supabase config.toml not found in $supabaseDir'); + return null; + } + try { + final configTomlString = await configTomlFile.readAsString(); + final configToml = TomlDocument.parse(configTomlString); + return switch (configToml.toMap()) { + {'api': {'external_url': final String externalUrl}} => externalUrl, + _ => run(() { + _logger.fine('Supabase config.toml does not specify external_url'); + return null; + }), + }; + } on Object catch (e, st) { + _logger.fine('Failed to parse Supabase config.toml', e, st); + return null; + } + } + + /// Gets the status of the local Supabase server via `supabase status`. + Future getLocalServerStatus() async { + final supabaseDir = await this.supabaseDir; + if (supabaseDir == null) { + return null; + } + final supabaseCli = getExecutablePath( + 'supabase', + null, + fs: fileSystem, + platform: platform, + throwOnFailure: false, + ); + if (supabaseCli == null) { + _logger.finest('Supabase CLI not found'); + return null; + } + try { + final ProcessResult( + :exitCode, + :stdout as String, + :stderr as String, + ) = await processManager.run([ + supabaseCli, + 'status', + '--output', + 'json', + ], workingDirectory: supabaseDir.parent.path); + if (exitCode != 0) { + _logger.fine( + 'Supabase CLI failed with code $exitCode', + '$stdout\n$stderr', + ); + return null; + } + return switch (jsonDecode(stdout.trim())) { + { + 'API_URL': final String apiUrl, + 'JWT_SECRET': final String jwtSecret, + } => + SupabaseServerStatus(apiUrl: apiUrl, jwtSecret: jwtSecret), + _ => null, + }; + } on Object catch (e, st) { + _logger.fine('Failed to resolve JWT secret from Supabase CLI', e, st); + return null; + } + } + + @override + Future solve(ConfigurationVariable configVar) async { + // For the local environment, we use the output of `supabase status` to + // get the project URL. + if (environmentId == 'local') { + final serverStatus = await getLocalServerStatus(); + if (serverStatus != null) { + _logger.fine('Found local Supabase server: ${serverStatus.apiUrl}'); + return storeVariable(configVar.name, serverStatus.apiUrl); + } + } + + // Search for a Supabase config.toml and read the external URL from it. + final configUrl = await findConfigUrl(); + if (configUrl != null) { + _logger.fine('Found Supabase config URL: $configUrl'); + return storeVariable(configVar.name, configUrl); + } + + // Search for a Supabase directory and read the project ref from it. + final projectRef = await findLinkedProjectRef(); + if (projectRef != null) { + _logger.fine('Found Supabase project ref: $projectRef'); + return storeVariable(configVar.name, 'https://$projectRef.supabase.co'); + } + + // If we're not in the local environment, we need to find the project ref + return super.solve(configVar); + } +} + +final class SupabaseServerStatus { + const SupabaseServerStatus({required this.apiUrl, required this.jwtSecret}); + + final String apiUrl; + + @visibleForTesting + final String jwtSecret; +} diff --git a/apps/cli/lib/frontend/celest_frontend.dart b/apps/cli/lib/frontend/celest_frontend.dart new file mode 100644 index 000000000..65039b340 --- /dev/null +++ b/apps/cli/lib/frontend/celest_frontend.dart @@ -0,0 +1,641 @@ +import 'dart:async'; +import 'dart:io' as io show Platform; +import 'dart:io'; + +import 'package:async/async.dart'; +import 'package:celest_ast/celest_ast.dart' as ast; +import 'package:celest_ast/celest_ast.dart'; +import 'package:celest_cli/analyzer/analysis_error.dart'; +import 'package:celest_cli/analyzer/analysis_result.dart'; +import 'package:celest_cli/analyzer/celest_analyzer.dart'; +import 'package:celest_cli/ast/project_diff.dart'; +import 'package:celest_cli/codegen/api/dockerfile_generator.dart'; +import 'package:celest_cli/codegen/client_code_generator.dart'; +import 'package:celest_cli/codegen/cloud_code_generator.dart'; +import 'package:celest_cli/compiler/api/entrypoint_compiler.dart'; +import 'package:celest_cli/compiler/api/local_api_runner.dart'; +import 'package:celest_cli/env/config_value_solver.dart'; +import 'package:celest_cli/project/celest_project.dart'; +import 'package:celest_cli/project/project_resolver.dart'; +import 'package:celest_cli/src/context.dart'; +import 'package:celest_cli/src/exceptions.dart'; +import 'package:celest_cli/src/utils/json.dart'; +import 'package:logging/logging.dart'; +import 'package:mason_logger/mason_logger.dart' show Progress; +import 'package:stream_transform/stream_transform.dart'; +import 'package:watcher/watcher.dart'; + +enum RestartMode { hotReload, fullRestart } + +final class CelestFrontend { + factory CelestFrontend() => instance ??= CelestFrontend._(); + + CelestFrontend._() { + // Initialize immediately instead of lazily since _stopSub is never accessed + // directly until `close`. + _stopSub = StreamGroup.merge([ + ProcessSignal.sigint.watch(), + // SIGTERM is not supported on Windows. Attempting to register a SIGTERM + // handler raises an exception. + if (!io.Platform.isWindows) ProcessSignal.sigterm.watch(), + ]).listen((signal) { + logger.fine('Got exit signal: $signal'); + if (!_stopSignal.isCompleted) { + _stopSignal.complete(signal); + } + }); + // Windows doesn't support listening for SIGUSR1 and SIGUSR2 signals. + if (!platform.isWindows) { + _reloadStream = StreamQueue( + StreamGroup.mergeBroadcast([ + ProcessSignal.sigusr1.watch(), + ProcessSignal.sigusr2.watch(), + ]).sample(_readyForChanges.stream), + ); + } + } + + static CelestFrontend? instance; + static final Logger logger = Logger('CelestFrontend'); + final CelestAnalyzer analyzer = CelestAnalyzer(); + + int _logErrors(List errors) { + for (final error in errors) { + logger.severe(error.toString()); + } + return 1; + } + + void _logWarnings(List warnings) { + for (final warning in warnings) { + logger.warning(warning.toString()); + } + } + + /// Signals that Celest is ready for the next batch of [_watcherSub] changes. + /// + /// Used to buffer [_watcherSub] in the time while a project is being (re-)built. + final _readyForChanges = StreamController.broadcast(); + + /// Watches for filesystem changes in the project root. + DirectoryWatcher? _watcher; + + /// Queues changes detected by [_watcher]. + StreamQueue>? _watcherSub; + + /// The list of paths changed since the last frontend pass. + Set? _changedPaths; + + /// The pending operations of [_nextChangeSet]. + /// + /// Used to cancel in-progress operations in [close]. + final List> _pendingOperations = []; + + Future _cancelPendingOperations() async { + await Future.wait(_pendingOperations.map((op) => op.cancel())); + _pendingOperations.clear(); + } + + // TODO(dnys1): If pubspec.yaml changes, we should run pub get and create + // a new analysis context. + + /// Notifies the watcher that we're listening for filesystem changes. + Future _nextChangeSet() async { + logger.finer('Waiting for changes...'); + + // Initialize [_watcher] lazily since it's only needed after the first + // compile. + _watcher ??= DirectoryWatcher(projectPaths.projectRoot); + _watcherSub ??= StreamQueue( + _watcher!.events + // Ignore creation of new directories and files (they'll be empty) + .tap( + (event) => + logger.finest('Watcher event (${event.type}): ${event.path}'), + ) + .where((event) => event.type != ChangeType.ADD) + .where((event) { + final isReloadable = _isReloadablePath(event.path); + if (!isReloadable) { + logger.finest('Ignoring non-reloadable path: ${event.path}'); + } + return isReloadable; + }) + .buffer(_readyForChanges.stream), + ); + _readyForChanges.add(null); + + var reloading = false; + final reloadComplete = Completer(); + assert( + _pendingOperations.isEmpty, + 'No operations should be in progress when called', + ); + _pendingOperations.add( + _watcherSub!.cancelable((watcher) async { + final events = await watcher.next; + final changedPaths = events.map((event) => event.path).toSet(); + logger.finest( + '${events.length} watcher events since last compile: ', + changedPaths.join(io.Platform.lineTerminator), + ); + if (reloading) return; + reloading = true; + + try { + logger.finest('Reloading with watcher events'); + + // TODO(dnys1): Improve cache invalidation to only invalidate + // necessary types. + typeHelper.reset(); + _changedPaths = await _invalidateAllProjectFiles(); + reloadComplete.complete(); + } on Object catch (e, st) { + reloadComplete.completeError(e, st); + } + return null; + }), + ); + if (_reloadStream case final reloadStream?) { + _pendingOperations.add( + reloadStream.cancelable((reloadStream) async { + final signal = await reloadStream.next; + logger.finest('Got reload signal: $signal'); + if (reloading) return; + reloading = true; + + try { + logger.finest('Reloading with signal'); + _changedPaths = await _invalidateAllProjectFiles(); + reloadComplete.complete(); + } on Object catch (e, st) { + reloadComplete.completeError(e, st); + } + return null; + }), + ); + } + + await Future.any([reloadComplete.future, _stopSignal.future]); + await _cancelPendingOperations(); + } + + // TODO(dnys1): There is a marked difference in behavior when invalidating + // just the changed paths, vs invalidating all project files. To be + // safe, we invalidate all files on every reload. This is not ideal, but + // it's the safest option for now. + Future> _invalidateAllProjectFiles() async { + final allProjectFiles = + await fileSystem + .directory(projectPaths.projectRoot) + .list(recursive: true) + .whereType() + .toList(); + // Invalidate all paths. + typeHelper.reset(); + final toInvalidate = + allProjectFiles.map((f) => f.path).where(_isReloadablePath).toList(); + logger.finest('Invaliding paths: $toInvalidate'); + return {...toInvalidate, ...await celestProject.invalidate(toInvalidate)}; + } + + /// Whether [path] is eligible for watching and reloading. + bool _isReloadablePath(String path) { + // Ignore generated items. + if (p.isWithin(projectPaths.generatedDir, path)) { + return false; + } + // Reload top-level files. + if (p.equals(p.dirname(path), projectPaths.projectRoot)) { + return p.basename(path) == 'pubspec.yaml' || p.extension(path) == '.dart'; + } + // Otherwise, reload only handwritten backend code. + return p.isWithin(projectPaths.projectLib, path); + } + + /// Signals that a SIGINT or SIGTERM event has fired and the CLI needs to + /// shutdown. + final _stopSignal = Completer.sync(); + + /// Whether a SIGINT or SIGTERM signal has been received and the frontend + /// is no longer operational. + bool get stopped => _stopSignal.isCompleted; + + /// Subscription to [ProcessSignal.sigint] and [ProcessSignal.sigterm] which + /// forwards to [_stopSignal] when triggered. + late final StreamSubscription _stopSub; + + /// A broadcast stream of [ProcessSignal.sigusr1] and [ProcessSignal.sigusr2] + /// signals which triggers a hot reload. + /// + /// This mimicks the `flutter run` command which responds to these signals by + /// performing a hot reload (SIGUSR1) and a full restart (SIGUSR2). + StreamQueue? _reloadStream; + + LocalApiRunner? _localApiRunner; + var _didFirstCompile = false; + + /// The current project being compiled. + /// + /// Will be `null` if there are errors or if the project has not been + /// analyzed yet. + ast.Project? currentProject; + + Future run({ + required bool migrateProject, + required Progress? currentProgress, + }) async { + try { + while (!stopped) { + currentProgress ??= cliLogger.progress('Reloading Celest'); + + void fail(List errors) { + currentProgress?.fail( + 'Project has errors. Please fix them and save the ' + 'corresponding files.', + ); + currentProgress = null; + _logErrors(errors); + } + + final analysisResult = await _analyzeProject( + migrateProject: migrateProject, + ); + migrateProject = false; + + _logWarnings(analysisResult.warnings); + switch (analysisResult) { + case AnalysisFailureResult(:final errors): + fail(errors); + case AnalysisSuccessResult(:final project, :final errors) + when errors.isNotEmpty: + currentProject = project; + fail(errors); + case AnalysisSuccessResult(:final project): + var restartMode = RestartMode.hotReload; + if (currentProject case final currentProject?) { + // Diff the old and new projects to see if anything changed. + final differ = ProjectDiff(currentProject); + project.acceptWithArg(differ, ( + parent: project, + old: currentProject, + )); + if (differ.requiresRestart) { + restartMode = RestartMode.fullRestart; + } + } + logger.finest('Performing reload with mode: ${restartMode.name}'); + currentProject = project; + final resolvedProject = await _resolveProject( + project, + environmentId: 'local', + ); + final generatedOutputs = await _generateBackendCode( + project: project, + resolvedProject: resolvedProject, + ); + final Uri localUri; + try { + localUri = await _startLocalApi( + [ + ...generatedOutputs, + if (_changedPaths != null) + ..._changedPaths! + else + ...project.apis.values.map( + (api) => projectPaths.api(api.name), + ), + ], + environmentId: 'local', + resolvedProject: resolvedProject, + restartMode: restartMode, + port: + (await isolatedSecureStorage.getLocalUri( + project.name, + )).port, + ); + } on CompilationException catch (e, st) { + cliLogger.err( + 'Project has errors. Please fix them and save the ' + 'corresponding files.', + ); + performance.captureError(e, stackTrace: st); + break; + } + + await _generateClientCode( + project: project, + resolvedProject: resolvedProject, + projectUris: ( + localUri: await isolatedSecureStorage.setLocalUri( + project.name, + localUri, + ), + productionUri: await isolatedSecureStorage.getProductionUri( + project.name, + ), + ), + ); + + // Only clear changed paths once a full restart has been completed + // which included those changes. Replacing the changed paths before + // this happens could mean a loop where the changes are dropped + // because the project had errors. + _changedPaths = null; + + if (!_didFirstCompile) { + _didFirstCompile = true; + currentProgress!.complete( + 'Celest is running and watching for updates', + ); + cliLogger.detail('Local API running at: $localUri'); + } else { + currentProgress!.complete('Reloaded project'); + } + + currentProgress = null; + } + + await _nextChangeSet(); + } + return 0; + } on CancellationException { + return 0; + } finally { + currentProgress?.cancel(); + await close(); + } + } + + /// Builds the current project for deployment to the cloud. + Future build({ + required bool migrateProject, + required Progress currentProgress, + required String environmentId, + }) async { + try { + int fail(List errors) { + currentProgress.fail( + 'Project has errors. Please fix them and save the ' + 'corresponding files.', + ); + return _logErrors(errors); + } + + final analysisResult = await _analyzeProject( + migrateProject: migrateProject, + ); + migrateProject = false; + + _logWarnings(analysisResult.warnings); + switch (analysisResult) { + case AnalysisFailureResult(:final errors): + return fail(errors); + case AnalysisSuccessResult(:final errors) when errors.isNotEmpty: + return fail(errors); + case AnalysisSuccessResult(:final project): + final resolvedProject = await _resolveProject( + project, + environmentId: environmentId, + ); + await _generateBackendCode( + project: project, + resolvedProject: resolvedProject, + ); + try { + await _writeProjectOutputs( + project: project, + resolvedProject: resolvedProject, + environmentId: environmentId, + ); + } on CompilationException catch (e, st) { + cliLogger.err('Project has errors. Please fix them and try again.'); + performance.captureError(e, stackTrace: st); + return 1; + } + + currentProgress.complete( + 'Celest project has been built for deployment', + ); + + final buildDir = p.relative( + projectPaths.buildDir, + from: projectPaths.projectRoot, + ); + cliLogger.detail( + 'Outputs have been written to the `$buildDir` directory.', + ); + return 0; + } + } on CancellationException { + return 0; + } finally { + currentProgress.cancel(); + await close(); + } + } + + /// Analyzes the project and reports if there are any errors. + Future _analyzeProject({ + required bool migrateProject, + }) => performance.trace('CelestFrontend', 'analyzeProject', () async { + logger.fine('Analyzing project...'); + final result = await analyzer.analyzeProject( + migrateProject: migrateProject, + ); + if (stopped) { + throw const CancellationException('Celest was stopped'); + } + return result; + }); + + /// Generates code for [project] and writes to the output directory. + /// + /// Returns the list of paths generated. + Future> _generateBackendCode({ + required ast.Project project, + required ast.ResolvedProject resolvedProject, + }) => performance.trace('CelestFrontend', 'generateBackendCode', () async { + logger.fine('Generating backend code...'); + final codeGenerator = CloudCodeGenerator( + project: project, + resolvedProject: resolvedProject, + ); + final outputs = codeGenerator.generate(); + final outputsDir = Directory(projectPaths.outputsDir); + if (outputsDir.existsSync() && !_didFirstCompile) { + await outputsDir.delete(recursive: true); + } + if (stopped) { + throw const CancellationException('Celest was stopped'); + } + await (outputs.write(), celestProject.invalidate(outputs.keys)).wait; + if (stopped) { + throw const CancellationException('Celest was stopped'); + } + return codeGenerator.fileOutputs.keys.toList(); + }); + + /// Resolves the project AST applying transformations for things such as authorization. + Future _resolveProject( + ast.Project project, { + required String environmentId, + }) => performance.trace('CelestFrontend', 'resolveProject', () async { + logger.fine('Resolving configuration values...'); + final configValues = + await ConfigValueSolver( + project: project, + environmentId: environmentId, + ).solveAll(); + logger.fine('Resolving project...'); + final projectResolver = ProjectResolver( + configValues: configValues, + environmentId: environmentId, + ); + project.acceptWithArg(projectResolver, project); + return projectResolver.resolvedProject; + }); + + Future _writeProjectOutputs({ + required Project project, + required ResolvedProject resolvedProject, + required String environmentId, + }) async { + final entrypointCompiler = EntrypointCompiler( + logger: logger, + verbose: verbose, + enabledExperiments: celestProject.analysisOptions.enabledExperiments, + ); + final kernel = await entrypointCompiler.compile( + resolvedProject: resolvedProject, + entrypointPath: projectPaths.localApiEntrypoint, + ); + + final buildOutputs = fileSystem.directory(projectPaths.buildDir); + if (!buildOutputs.existsSync()) { + await buildOutputs.create(recursive: true); + } + + await buildOutputs + .childFile('celest.aot.dill') + .writeAsBytes(kernel.outputDill); + + final dockerfile = DockerfileGenerator(project: project); + await buildOutputs + .childFile('Dockerfile') + .writeAsString(dockerfile.generate()); + + await buildOutputs + .childFile('celest.json') + .writeAsString( + prettyPrintJson(resolvedProject.toProto().toProto3Json()), + ); + } + + Future _startLocalApi( + List invalidatedPaths, { + required String environmentId, + required ResolvedProject resolvedProject, + RestartMode restartMode = RestartMode.hotReload, + required int? port, + }) async { + final configValues = { + for (final env in resolvedProject.variables) env.name: env.value, + for (final secret in resolvedProject.secrets) secret.name: secret.value, + }; + if (_localApiRunner == null) { + await performance.trace('LocalApiRunner', 'start', () async { + _localApiRunner = await LocalApiRunner.start( + resolvedProject: resolvedProject, + path: projectPaths.localApiEntrypoint, + environmentId: environmentId, + configValues: configValues, + verbose: verbose, + port: port, + ); + }); + } else { + switch (restartMode) { + case RestartMode.hotReload: + await performance.trace('LocalApiRunner', 'hotReload', () async { + await _localApiRunner!.hotReload(invalidatedPaths); + }); + case RestartMode.fullRestart: + await performance.trace('LocalApiRunner', 'fullRestart', () async { + logger.fine('Restarting local API...'); + await _localApiRunner!.close(); + _localApiRunner = await LocalApiRunner.start( + resolvedProject: resolvedProject, + path: projectPaths.localApiEntrypoint, + environmentId: environmentId, + port: _localApiRunner?.port, + configValues: configValues, + verbose: verbose, + ); + }); + } + } + if (stopped) { + throw const CancellationException('Celest was stopped'); + } + return Uri.parse('http://localhost:${_localApiRunner!.port}'); + } + + Future _generateClientCode({ + required ast.Project project, + required ast.ResolvedProject resolvedProject, + required CelestProjectUris projectUris, + }) => performance.trace('CelestFrontend', 'generateClientCode', () async { + logger.fine('Generating client code...'); + final generator = ClientCodeGenerator( + project: project, + resolvedProject: resolvedProject, + projectUris: projectUris, + ); + await generator.generate().write(); + if (celestProject.parentProject case ParentProject( + type: ast.SdkType.flutter, + :final path, + ) when project.databases.isNotEmpty) { + final webDir = fileSystem.directory(path).childDirectory('web'); + if (webDir.existsSync()) { + final sqliteWasm = webDir.childFile('sqlite3.wasm'); + if (!sqliteWasm.existsSync()) { + final downloadedSqliteWasm = celestProject.config.configDir.childFile( + 'sqlite3.wasm', + ); + if (downloadedSqliteWasm.existsSync()) { + await downloadedSqliteWasm.copy(sqliteWasm.path); + } else { + cliLogger.warn(''' +To use Celest Data in your Flutter Web project, follow the steps in the Drift +documentation to add the SQLite3 WASM file to your project: + +https://drift.simonbinder.eu/web/ +'''); + } + } + } + } + }); + + Future close() => + performance.trace('CelestFrontend', 'close', () async { + logger.finest('Stopping Celest frontend...'); + // Cancel any pending operations which depend on StreamQueues + // before trying to close stream queues. + // + // If these operations are not first canceled, then `queue.cancel` + // will hang forever. + await _cancelPendingOperations(); + // Cancel subscriptions in order of dependencies + await _readyForChanges.close(); + await Future.wait([ + _stopSub.cancel(), + Future.value(_reloadStream?.cancel()), + Future.value(_watcherSub?.cancel()), + Future.value(_localApiRunner?.close()), + ]); + logger.finest('Stopped Celest frontend'); + }); +} diff --git a/apps/cli/lib/frontend/resident_compiler.dart b/apps/cli/lib/frontend/resident_compiler.dart new file mode 100644 index 000000000..2dd702c9f --- /dev/null +++ b/apps/cli/lib/frontend/resident_compiler.dart @@ -0,0 +1,73 @@ +import 'dart:io'; + +import 'package:celest_cli/src/context.dart'; +import 'package:celest_cli/src/sdk/dart_sdk.dart'; +import 'package:celest_cli/src/utils/cli.dart'; +import 'package:file/file.dart'; +import 'package:logging/logging.dart'; + +final class ResidentCompiler { + ResidentCompiler._(this.infoFile); + + static final Logger logger = Logger('ResidentCompiler'); + + static String get infoFilePath { + final infoFileDir = fileSystem.directory(projectPaths.projectCacheDir); + infoFileDir.createSync(recursive: true); + return infoFileDir.childFile('resident-compiler-info').path; + } + + final File infoFile; + + static Future ensureRunning() async { + final infoFile = fileSystem.file(infoFilePath); + Socket? socket; + if (infoFile.existsSync()) { + try { + // Try to connect to the resident compiler server. + final info = await infoFile.readAsString(); + final {'address': address, 'port': port} = Map.fromEntries( + info.trim().split(' ').map((part) { + final [key, value] = part.split(':'); + return MapEntry(key, value); + }), + ); + logger.finest( + 'Connecting to resident compiler server at $address:$port', + ); + socket = await Socket.connect(address, int.parse(port)); + logger.finer('Resident compiler server already running.'); + return ResidentCompiler._(infoFile); + } catch (e) { + logger.finest('Unable to connect to resident compiler server.', e); + // The resident compiler server is not running but an info files exist. + // Ensure the info files are deleted before restarting. + try { + await infoFile.delete(); + } catch (_) {} + } finally { + await socket?.close(); + } + } + logger.fine('Starting resident compiler server...'); + final frontendServerProcess = await processManager.start([ + Sdk.current.dart, + 'compilation-server', + 'start', + '--resident-compiler-info-file=${infoFile.path}', + ]); + frontendServerProcess.captureStdout( + sink: logger.finest, + prefix: '[stdout] ', + ); + frontendServerProcess.captureStderr( + sink: logger.finest, + prefix: '[stderr] ', + ); + if (await frontendServerProcess.exitCode != 0) { + logger.finest('Failed to start resident compiler server.'); + return null; + } + return ResidentCompiler._(infoFile); + } +} diff --git a/apps/cli/lib/github/device_flow.dart b/apps/cli/lib/github/device_flow.dart new file mode 100644 index 000000000..c4fc73168 --- /dev/null +++ b/apps/cli/lib/github/device_flow.dart @@ -0,0 +1,156 @@ +import 'dart:async'; +import 'dart:convert'; + +import 'package:celest_cli/src/context.dart'; +import 'package:http/http.dart'; +import 'package:json_annotation/json_annotation.dart'; + +part 'device_flow.g.dart'; + +const _serializable = JsonSerializable(fieldRename: FieldRename.snake); +final _baseUri = Uri.parse('https://github.com'); +const _clientId = 'Iv1.6682bfee173396ad'; + +/// Implements the GitHub Device Flow contract as outlined here: +/// https://docs.github.com/en/apps/oauth-apps/building-oauth-apps/authorizing-oauth-apps#device-flow +abstract final class DeviceFlowClient { + static Future start() async { + final url = _baseUri.resolve('/login/device/code'); + final response = await httpClient.post( + url, + body: jsonEncode( + const DeviceFlowStart( + clientId: _clientId, + scope: 'user:email', + ).toJson(), + ), + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + }, + ); + if (response.statusCode != 200 || + response.headers['content-type'] != 'application/json') { + throw ClientException( + 'Failed to start device flow (${response.statusCode})\n' + '${response.body}', + ); + } + final body = jsonDecode(response.body) as Map; + return DeviceFlow.fromJson(body); + } +} + +@_serializable +final class DeviceFlowStart { + const DeviceFlowStart({required this.clientId, this.scope}); + + factory DeviceFlowStart.fromJson(Map json) => + _$DeviceFlowStartFromJson(json); + + final String clientId; + final String? scope; + + Map toJson() => _$DeviceFlowStartToJson(this); +} + +@_serializable +final class DeviceFlow { + const DeviceFlow({ + required this.deviceCode, + required this.userCode, + required this.verificationUri, + required this.expiresIn, + required this.interval, + }); + + factory DeviceFlow.fromJson(Map json) => + _$DeviceFlowFromJson(json); + + final String deviceCode; + final String userCode; + final Uri verificationUri; + final int expiresIn; + final int interval; + + Future wait() async { + final timeout = Duration(seconds: expiresIn - 5); + final stopwatch = Stopwatch()..start(); + final url = _baseUri.resolve('/login/oauth/access_token'); + while (stopwatch.elapsed < timeout) { + await Future.delayed(Duration(seconds: interval)); + final pollResult = await httpClient.post( + url, + body: jsonEncode( + DeviceFlowPoll(clientId: _clientId, deviceCode: deviceCode).toJson(), + ), + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + }, + ); + final body = jsonDecode(pollResult.body) as Map; + switch (pollResult.statusCode) { + case 200: + return GitHubCredentials.fromJson(body); + case 400: + if (body case {'error': final String error}) { + switch (error) { + case 'authorization_pending': + continue; + case 'slow_down': + // Wait one extra duration + await Future.delayed(Duration(seconds: interval)); + continue; + default: + break; + } + } + } + throw ClientException( + 'Failed to poll device flow (${pollResult.statusCode})\n' + '${pollResult.body}', + ); + } + throw TimeoutException( + 'Timed out after waiting for device code entry', + timeout, + ); + } + + Map toJson() => _$DeviceFlowToJson(this); +} + +@_serializable +final class DeviceFlowPoll { + const DeviceFlowPoll({required this.clientId, required this.deviceCode}); + + factory DeviceFlowPoll.fromJson(Map json) => + _$DeviceFlowPollFromJson(json); + + final String clientId; + final String deviceCode; + + @JsonKey(includeToJson: true) + String get grantType => 'urn:ietf:params:oauth:grant-type:device_code'; + + Map toJson() => _$DeviceFlowPollToJson(this); +} + +@_serializable +final class GitHubCredentials { + const GitHubCredentials({ + required this.accessToken, + required this.tokenType, + required this.scope, + }); + + factory GitHubCredentials.fromJson(Map json) => + _$GitHubCredentialsFromJson(json); + + final String accessToken; + final String tokenType; + final String scope; + + Map toJson() => _$GitHubCredentialsToJson(this); +} diff --git a/apps/cli/lib/github/device_flow.g.dart b/apps/cli/lib/github/device_flow.g.dart new file mode 100644 index 000000000..96e61e429 --- /dev/null +++ b/apps/cli/lib/github/device_flow.g.dart @@ -0,0 +1,60 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'device_flow.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +DeviceFlowStart _$DeviceFlowStartFromJson(Map json) => + DeviceFlowStart( + clientId: json['client_id'] as String, + scope: json['scope'] as String?, + ); + +Map _$DeviceFlowStartToJson(DeviceFlowStart instance) => + {'client_id': instance.clientId, 'scope': instance.scope}; + +DeviceFlow _$DeviceFlowFromJson(Map json) => DeviceFlow( + deviceCode: json['device_code'] as String, + userCode: json['user_code'] as String, + verificationUri: Uri.parse(json['verification_uri'] as String), + expiresIn: (json['expires_in'] as num).toInt(), + interval: (json['interval'] as num).toInt(), +); + +Map _$DeviceFlowToJson(DeviceFlow instance) => + { + 'device_code': instance.deviceCode, + 'user_code': instance.userCode, + 'verification_uri': instance.verificationUri.toString(), + 'expires_in': instance.expiresIn, + 'interval': instance.interval, + }; + +DeviceFlowPoll _$DeviceFlowPollFromJson(Map json) => + DeviceFlowPoll( + clientId: json['client_id'] as String, + deviceCode: json['device_code'] as String, + ); + +Map _$DeviceFlowPollToJson(DeviceFlowPoll instance) => + { + 'client_id': instance.clientId, + 'device_code': instance.deviceCode, + 'grant_type': instance.grantType, + }; + +GitHubCredentials _$GitHubCredentialsFromJson(Map json) => + GitHubCredentials( + accessToken: json['access_token'] as String, + tokenType: json['token_type'] as String, + scope: json['scope'] as String, + ); + +Map _$GitHubCredentialsToJson(GitHubCredentials instance) => + { + 'access_token': instance.accessToken, + 'token_type': instance.tokenType, + 'scope': instance.scope, + }; diff --git a/apps/cli/lib/init/migrations/add_analyzer_plugin.dart b/apps/cli/lib/init/migrations/add_analyzer_plugin.dart new file mode 100644 index 000000000..3752002c6 --- /dev/null +++ b/apps/cli/lib/init/migrations/add_analyzer_plugin.dart @@ -0,0 +1,78 @@ +import 'package:celest_cli/init/project_migration.dart'; +import 'package:celest_cli/src/context.dart'; +import 'package:yaml/yaml.dart'; +import 'package:yaml_edit/yaml_edit.dart'; + +final class AddAnalyzerPlugin extends ProjectMigration { + AddAnalyzerPlugin(super.projectRoot, this.appRoot); + + final String appRoot; + + @override + bool get needsMigration => + !fileSystem + .directory(appRoot) + .childFile('analysis_options.yaml') + .readAsStringSync() + .contains('celest'); + + @override + String get name => 'core.project.add_analyzer_plugin'; + + @override + Future create() async { + final parentAnalysisOptionsFile = fileSystem + .directory(appRoot) + .childFile('analysis_options.yaml'); + if (parentAnalysisOptionsFile.existsSync()) { + final editor = YamlEditor(await parentAnalysisOptionsFile.readAsString()); + + var hasAnalyzer = true; + final analyzer = + editor.parseAt( + ['analyzer'], + orElse: () { + hasAnalyzer = false; + return YamlMap(); + }, + ) + as YamlMap; + final existingPlugins = + analyzer.containsKey('plugins') + ? analyzer.nodes['plugins'] as YamlList + : null; + final hasPlugins = existingPlugins != null; + if ((existingPlugins ?? []).contains('celest')) { + return const ProjectMigrationSuccess(); + } + if (!hasAnalyzer) { + // Probably just an `include` line. Don't use editor because it will + // put the `analyzer` block before `include` which looks dumb. + await parentAnalysisOptionsFile.writeAsString(''' +${editor.toString().trim()} + +analyzer: + plugins: + - celest +'''); + return const ProjectMigrationSuccess(); + } + if (!hasPlugins) { + editor.update(['analyzer', 'plugins'], ['celest']); + await parentAnalysisOptionsFile.writeAsString(editor.toString()); + } else { + // Don't update a list that's already present since only one plugin + // can be added at a time. + return const ProjectMigrationSuccess(); + } + } else { + await parentAnalysisOptionsFile.writeAsString(''' +analyzer: + plugins: + - celest +'''); + } + + return const ProjectMigrationSuccess(); + } +} diff --git a/apps/cli/lib/init/migrations/add_generated_folder.dart b/apps/cli/lib/init/migrations/add_generated_folder.dart new file mode 100644 index 000000000..b70d8124c --- /dev/null +++ b/apps/cli/lib/init/migrations/add_generated_folder.dart @@ -0,0 +1,46 @@ +// ignore_for_file: constant_identifier_names + +import 'package:celest_cli/init/project_migration.dart'; +import 'package:celest_cli/src/context.dart'; +import 'package:file/file.dart'; + +final class GeneratedFolder extends ProjectMigration { + const GeneratedFolder(super.projectRoot); + + @override + bool get needsMigration => false; + + @override + String get name => 'core.layout.generated'; + + @override + Future create() async { + final generatedDir = fileSystem + .directory(projectRoot) + .childDirectory('generated'); + await _createIfNotExists( + generatedDir.childFile('README.md'), + generated_README, + ); + return const ProjectMigrationSuccess(); + } +} + +Future _createIfNotExists(File file, String content) async { + if (!file.existsSync()) { + await file.create(recursive: true); + await file.writeAsString(content); + } +} + +const generated_README = ''' +# Generated Celest code + +This directory contains code generated by the Celest CLI to assist in building +your backend. + +This code can be safely checked into version control, but it should not be +modified directly. + +It is planned to replace this directory with macros when they become stable. +'''; diff --git a/apps/cli/lib/init/migrations/macos_entitlements.dart b/apps/cli/lib/init/migrations/macos_entitlements.dart new file mode 100644 index 000000000..6cff6d7e6 --- /dev/null +++ b/apps/cli/lib/init/migrations/macos_entitlements.dart @@ -0,0 +1,81 @@ +import 'dart:async'; +import 'dart:convert'; + +import 'package:celest_cli/init/project_migration.dart'; +import 'package:celest_cli/src/context.dart'; +import 'package:file/file.dart'; +import 'package:logging/logging.dart'; +import 'package:stream_transform/stream_transform.dart'; + +/// Updates the macOS entitlements plist to include the network client +/// capability. +final class MacOsEntitlements extends ProjectMigration { + const MacOsEntitlements(super.projectRoot, this.appRoot); + + final String appRoot; + + static final _logger = Logger('MacOsEntitlements'); + + @override + String get name => 'core.flutter.macos_entitlements'; + + @override + bool get needsMigration => + platform.isMacOS && + fileSystem.directory(appRoot).childDirectory('macos').existsSync(); + + @override + Future create() async { + if (!platform.isMacOS) { + return const ProjectMigrationSkipped(); + } + final macosDir = fileSystem.directory(appRoot).childDirectory('macos'); + if (!macosDir.existsSync()) { + _logger.finest('No macos directory. Skipping entitlements update.'); + return const ProjectMigrationSkipped(); + } + final entitlementFiles = + await macosDir + .list() + .whereType() + .asyncExpand( + (dir) => dir.list().whereType().where( + (file) => p.extension(file.path) == '.entitlements', + ), + ) + .toList(); + + _logger.finest(() { + final entitlementFileNames = entitlementFiles + .map((e) => p.relative(e.path, from: macosDir.path)) + .join(', '); + return 'Found ${entitlementFiles.length} entitlements files: ' + '$entitlementFileNames'; + }); + for (final entitlements in entitlementFiles) { + _logger.fine('Updating entitlements file at ${entitlements.path}...'); + final add = await processManager.run( + [ + '/usr/libexec/PlistBuddy', + '-c', + 'Add :com.apple.security.network.client bool true', + entitlements.path, + ], + stdoutEncoding: utf8, + stderrEncoding: utf8, + ); + if (add.exitCode != 0) { + if (add.stderr.toString().contains('Entry Already Exists')) { + _logger.fine('Network client entitlement already exists.'); + } else { + performance.captureError( + 'Failed to add network client entitlement to ${entitlements.path}: ' + '${add.stdout}\n${add.stderr}', + ); + } + continue; + } + } + return const ProjectMigrationSuccess(); + } +} diff --git a/apps/cli/lib/init/migrations/pubspec_updater.dart b/apps/cli/lib/init/migrations/pubspec_updater.dart new file mode 100644 index 000000000..6511fccd3 --- /dev/null +++ b/apps/cli/lib/init/migrations/pubspec_updater.dart @@ -0,0 +1,224 @@ +import 'package:celest_cli/init/project_migration.dart'; +import 'package:celest_cli/project/celest_project.dart'; +import 'package:celest_cli/pub/project_dependency.dart'; +import 'package:celest_cli/pub/pub_action.dart'; +import 'package:celest_cli/pub/pub_environment.dart'; +import 'package:celest_cli/pub/pubspec.dart'; +import 'package:celest_cli/src/context.dart'; +import 'package:celest_cli/src/utils/recase.dart'; +import 'package:file/file.dart'; +import 'package:logging/logging.dart'; +import 'package:pub_semver/pub_semver.dart'; +import 'package:pubspec_parse/pubspec_parse.dart'; +import 'package:yaml_edit/yaml_edit.dart' hide SourceEdit; + +final class PubspecUpdater extends ProjectMigration { + const PubspecUpdater(super.projectRoot, this.parentProject, this.projectName); + + static final _logger = Logger('PubspecUpdater'); + + final ParentProject? parentProject; + final String projectName; + + @override + String get name => 'core.project.pubspec'; + + @override + bool get needsMigration => true; + + // TODO(dnys1): Update project names when we can update all Dart code which + /// currently references `celest_backend`. + // ignore: unused_element + Future _updateProjectName({ + required Pubspec pubspec, + required String pubspecYaml, + required File pubspecFile, + }) async { + if (pubspec.name.startsWith('api_')) { + _logger.fine('Project name is already in the correct format.'); + return; + } + final oldPubspecName = pubspec.name; + final pubspecName = 'api_${projectName.snakeCase}'; + _logger.fine('Updating project name...'); + pubspec = pubspec.copyWith(name: pubspecName); + pubspecYaml = pubspec.toYaml(source: pubspecYaml); + await pubspecFile.writeAsString(pubspecYaml); + + if (parentProject?.path case final appRoot?) { + final appRootPubspec = fileSystem.file(p.join(appRoot, 'pubspec.yaml')); + final appEditor = YamlEditor(await appRootPubspec.readAsString()); + appEditor + ..remove(['dependencies', oldPubspecName]) + ..update(['dependencies', pubspecName], {'path': 'celest/'}); + } + } + + /// Returns the version updated from. + Future _updateBackendDependencies({ + required Pubspec pubspec, + required String pubspecYaml, + required File pubspecFile, + }) async { + final currentSdkVersion = pubspec.environment['sdk']; + final requiredSdkVersion = PubEnvironment.dartSdkConstraint; + if (ProjectDependency.backendDependencies.upToDate(pubspec) && + currentSdkVersion == requiredSdkVersion) { + _logger.fine('Project dependencies are up to date.'); + return null; + } + final fromVersion = switch (pubspec.dependencies['celest']) { + final HostedDependency hosted => switch (hosted.version) { + final Version version => version, + final VersionRange range => range.min, + _ => Version.none, + }, + _ => Version.none, + }; + _logger.fine('Updating project dependencies to latest versions...'); + pubspec = pubspec.copyWith( + environment: {'sdk': PubEnvironment.dartSdkConstraint}, + dependencies: { + ...pubspec.dependencies, + ...ProjectDependency.backendDependencies.toPub(), + }, + devDependencies: { + ...pubspec.devDependencies, + ...ProjectDependency.devDependencies.toPub(), + }, + dependencyOverrides: { + ...pubspec.dependencyOverrides, + ...?ProjectDependency.localDependencyOverrides( + projectRoot: projectRoot, + ), + }, + ); + pubspecYaml = pubspec.toYaml(source: pubspecYaml); + await pubspecFile.writeAsString(pubspecYaml); + return fromVersion; + } + + Future _updateClientDependencies({ + required Directory clientRoot, + required Pubspec pubspec, + required String pubspecYaml, + required File pubspecFile, + }) async { + final currentSdkVersion = pubspec.environment['sdk']; + final requiredSdkVersion = PubEnvironment.dartSdkConstraint; + if (ProjectDependency.clientDependencies.upToDate(pubspec) && + currentSdkVersion == requiredSdkVersion) { + _logger.fine('Project dependencies are up to date.'); + return false; + } + _logger.fine('Updating client dependencies to latest versions...'); + pubspec = pubspec.copyWith( + environment: {'sdk': PubEnvironment.dartSdkConstraint}, + dependencies: { + ...pubspec.dependencies, + ...ProjectDependency.clientDependencies.toPub(), + }, + devDependencies: { + ...pubspec.devDependencies, + ...ProjectDependency.devDependencies.toPub(), + }, + dependencyOverrides: { + ...pubspec.dependencyOverrides, + ...?ProjectDependency.localDependencyOverrides( + projectRoot: clientRoot.path, + ), + }, + ); + pubspecYaml = pubspec.toYaml(source: pubspecYaml); + await pubspecFile.writeAsString(pubspecYaml); + return true; + } + + /// Ensures app has dependency on celest project + Future _updateAppPubspec() async { + final parentProject = this.parentProject; + if (parentProject == null) { + return; + } + final projectPubspecName = '${projectName.snakeCase}_client'; + final pubspec = parentProject.pubspec; + final missingClient = !pubspec.dependencies.containsKey(projectPubspecName); + final legacyBackend = pubspec.dependencies.containsKey('celest_backend'); + final needsMigration = missingClient || legacyBackend; + if (!needsMigration) { + return; + } + _logger.fine('Updating app pubspec...'); + final editor = YamlEditor(parentProject.pubspecYaml); + if (legacyBackend) { + editor.remove(['dependencies', 'celest_backend']); + } + if (missingClient) { + editor.update( + ['dependencies', projectPubspecName], + {'path': 'celest/client/'}, + ); + } + await fileSystem + .directory(parentProject.path) + .childFile('pubspec.yaml') + .writeAsString(editor.toString()); + } + + @override + Future create() async { + _logger.fine('Updating project pubspec...'); + + var needsAnalyzerMigration = false; + final operations = >[]; + + // Update backend dependencies + { + final pubspecFile = fileSystem.file(p.join(projectRoot, 'pubspec.yaml')); + final pubspecYaml = await pubspecFile.readAsString(); + final pubspec = Pubspec.parse(pubspecYaml); + final fromVersion = await _updateBackendDependencies( + pubspec: pubspec, + pubspecYaml: pubspecYaml, + pubspecFile: pubspecFile, + ); + // await _updateProjectName(); + needsAnalyzerMigration |= + fromVersion != null && fromVersion < Version(1, 0, 0).firstPreRelease; + if (needsAnalyzerMigration) { + operations.add( + runPub(action: PubAction.get, workingDirectory: projectRoot), + ); + } + _logger.fine('Backend pubspec updated'); + } + + // Update client dependencies + final clientRoot = fileSystem.directory(projectPaths.clientRoot); + final clientPubspecFile = clientRoot.childFile('pubspec.yaml'); + if (clientPubspecFile.existsSync()) { + final clientPubspecYaml = await clientPubspecFile.readAsString(); + final clientPubspec = Pubspec.parse(clientPubspecYaml); + final clientNeedsMigration = await _updateClientDependencies( + clientRoot: clientRoot, + pubspec: clientPubspec, + pubspecYaml: clientPubspecYaml, + pubspecFile: clientPubspecFile, + ); + needsAnalyzerMigration |= clientNeedsMigration; + if (clientNeedsMigration) { + operations.add( + runPub(action: PubAction.get, workingDirectory: clientRoot.path), + ); + } + _logger.fine('Client pubspec updated'); + } + + // Update app pubspec + await _updateAppPubspec(); + + return ProjectMigrationSuccess( + needsAnalyzerMigration: needsAnalyzerMigration, + ); + } +} diff --git a/apps/cli/lib/init/migrations/v1_folder_structure.dart b/apps/cli/lib/init/migrations/v1_folder_structure.dart new file mode 100644 index 000000000..bfafa33c0 --- /dev/null +++ b/apps/cli/lib/init/migrations/v1_folder_structure.dart @@ -0,0 +1,347 @@ +import 'dart:io'; + +import 'package:celest_cli/init/project_migration.dart'; +import 'package:celest_cli/project/celest_project.dart'; +import 'package:celest_cli/src/context.dart'; +import 'package:celest_cli/src/exceptions.dart'; +import 'package:celest_cli/src/utils/error.dart'; +import 'package:celest_cli/src/utils/recase.dart'; +import 'package:file/file.dart'; +import 'package:git/git.dart'; +import 'package:logging/logging.dart'; + +/// Migrates the project folder structure to V1's layout. +/// +/// Pre-V1, the structure of a Celest project was: +/// +/// celest/ +/// pubspec.yaml +/// project.dart +/// functions/ +/// hello_world.dart +/// lib/ +/// client.dart +/// models/ +/// exceptions/ +/// +/// where client code was generated into the `lib` directory. This created +/// confusion because it meant that generated code like `client.dart` was +/// mixed with hand-written code like `models`. +/// +/// In V1, there is a clean and explicit separation between generated client +/// code and backend code. We introduce a new `client` folder which holds +/// the generated client. The structure of a V1 Celest project is: +/// +/// celest/ +/// pubspec.yaml +/// client/ +/// pubspec.yaml +/// lib/ +/// client.dart +/// lib/ +/// src/ +/// project.dart +/// functions/ +/// hello_world.dart +/// models/ +/// +/// To workaround Dart limitations, customers see the following folder +/// structure (no `lib/` folder), but all of the top-level folders (functions, +/// models, etc.) are actually symlinks into the `lib/src` folder. This +/// allows us complete control over that folder (since we need to generate +/// some backend code too) while providing a clean separation between the +/// different parts. +final class V1FolderStructure extends ProjectMigration { + V1FolderStructure(super.projectRoot, this.projectName, this.parentProject); + + final String projectName; + final ParentProject? parentProject; + + @override + String get name => 'core.layout.v1'; + + static final _logger = Logger('V1FolderStructure'); + + final _operations = >[]; + + late final legacyClientEntities = [ + projectDir.childDirectory('lib').childFile('client.dart'), + fileSystem.directory(projectPaths.legacyClientOutputsDir), + ]; + + late final symlinkdDirs = [ + ( + projectDir.childDirectory('functions'), + projectDir + .childDirectory('lib') + .childDirectory('src') + .childDirectory('functions'), + ), + ( + projectDir.childDirectory('generated'), + projectDir + .childDirectory('lib') + .childDirectory('src') + .childDirectory('generated'), + ), + ]; + + late final symlinkdFiles = [ + ( + projectDir.childFile('project.dart'), + projectDir + .childDirectory('lib') + .childDirectory('src') + .childFile('project.dart'), + ), + ]; + + late final symlinkdEntities = [...symlinkdDirs, ...symlinkdFiles]; + + @override + bool get needsMigration { + for (final entity in legacyClientEntities) { + if (entity.existsSync()) { + return true; + } + } + for (final entity in symlinkdEntities) { + if (!entity.$2.existsSync()) { + return true; + } + } + if (!projectDir.childDirectory('client').existsSync()) { + return true; + } + if (fileSystem.file(projectPaths.legacyAuthDart).existsSync()) { + return true; + } + return false; + } + + @override + Future create() async { + final rootDir = fileSystem.directory(projectRoot); + // Start by removing all pre-V1 generated client code. + for (final entity in legacyClientEntities) { + if (entity.existsSync()) { + _logger.finest('Removing ${entity.path}...'); + _operations.add(entity.delete(recursive: true)); + } + } + + // Create the new client folder layout. + final clientMigration = ProjectFile.client(projectRoot, projectName); + if (clientMigration.needsMigration) { + _operations.add(clientMigration.create()); + } + + // Move `functions` to `lib/src` and create symlinks. + final moveOperations = >[]; + for (final (from, to) in symlinkdDirs) { + if (!from.existsSync()) { + continue; + } + if (to.existsSync() && to.listSync().isNotEmpty) { + if (fileSystem.isLinkSync(from.path)) { + moveOperations.add(from.delete()); + } else { + throw const CliException( + 'Project in partial migration state. Please follow the migration ' + 'guide at https://celest.dev/docs/v1-migration before continuing.', + ); + } + } else { + moveOperations.add(_move(from, to)); + } + } + for (final (from, to) in symlinkdFiles) { + if (!from.existsSync()) { + continue; + } + if (fileSystem.isLinkSync(from.path)) { + final link = fileSystem.link(from.path); + moveOperations.add(link.delete()); + continue; + } + if (to.existsSync()) { + continue; + } + moveOperations.add( + from.copy(to.path).then((_) async { + await from.delete(); + }), + ); + } + if (moveOperations.isNotEmpty) { + _operations.add( + Future.wait(moveOperations).then((links) { + return _stageChangesInGit(rootDir); + }), + ); + } + + final fixDataFile = fileSystem.file( + p.join(projectRoot, 'lib', 'fix_data', 'v1_migration.yaml'), + ); + if (!fixDataFile.existsSync()) { + final now = DateTime.now(); + final date = + '${now.year}-' + '${now.month.toString().padLeft(2, '0')}-' + '${now.day.toString().padLeft(2, '0')}'; + final clientPackageName = '${projectName.snakeCase}_client'; + _operations.add( + fixDataFile.parent + .create(recursive: true) + .then( + (_) => fixDataFile.writeAsString(''' +# Generated by Celest. Do not modify. +version: 1 +transforms: + - title: "Updates the import of the Celest client" + date: $date + element: + uris: ["client.dart"] + variable: celest + changes: + - kind: replacedBy + newElement: + uris: ["package:$clientPackageName/$clientPackageName.dart"] + variable: celest +'''), + ), + ); + } + + // Move legacy Auth contents if present. + final legacyAuthFile = fileSystem.file(projectPaths.legacyAuthDart); + if (legacyAuthFile.existsSync()) { + _operations.add( + Future.wait(moveOperations).then((_) { + return _moveAuthContentsToProjectDart(legacyAuthFile); + }), + ); + } + + if (_operations.isEmpty) { + return const ProjectMigrationSkipped(); + } + + await Future.wait(_operations); + return const ProjectMigrationSuccess(needsAnalyzerMigration: true); + } + + /// Moves one directory to another. + /// + /// Returns the new symlink. + Future _move(Directory from, Directory to) async { + await for (final file in from.list(recursive: true, followLinks: false)) { + final relativePath = p.relative(file.path, from: from.path); + final destination = to.childFile(relativePath); + switch (file) { + case File(): + await destination.parent.create(recursive: true); + await file.rename(destination.path); + case Link(): + await destination.parent.create(recursive: true); + await file.rename(destination.path); + case Directory(): + break; + default: + unreachable('Unexpected file type: $file'); + } + } + await from.delete(recursive: true); + if (p.basename(from.path) == 'generated') { + final resourcesDart = to.childFile('resources.dart'); + if (resourcesDart.existsSync()) { + await resourcesDart.delete(); + } + } + } + + Future _moveAuthContentsToProjectDart(File authDart) async { + final contents = await authDart.readAsLines(); + final nonImports = contents.skipWhile( + (line) => line.startsWith('import') || line.trim().isEmpty, + ); + if (nonImports.isNotEmpty) { + if (!nonImports.first.startsWith('const')) { + _logger.finest('Unknown format in legacy auth.dart', nonImports.first); + return; + } + await fileSystem + .file(projectPaths.projectDart) + .writeAsString( + ['', ...nonImports, ''].join(Platform.lineTerminator), + mode: FileMode.writeOnlyAppend, + ); + await celestProject.invalidate([projectPaths.projectDart]); + } + await authDart.delete(); + final authDir = authDart.parent; + final authEntities = await authDir.list(recursive: true).toList(); + if (authEntities.whereType().isNotEmpty) { + return _move( + authDir, + projectDir + .childDirectory('lib') + .childDirectory('src') + .childDirectory('auth'), + ); + } else { + await authDir.delete(recursive: true); + } + } + + /// The creation of symbolic links really throws git for a loop in VSCode. + /// + /// In projects with a `.git` directory, `git add .` seems to work fine so + /// we just do that for them. + Future _stageChangesInGit(Directory projectDir) async { + var gitRoot = projectDir; + while (gitRoot.parent != gitRoot) { + if (gitRoot.childDirectory('.git').existsSync()) { + break; + } + gitRoot = gitRoot.parent; + } + if (!await GitDir.isGitDir(gitRoot.path)) { + _logger.fine('No .git directory found. Skipping git operations.'); + return; + } + + final result = await processManager.run([ + 'git', + 'add', + '.', + ], workingDirectory: projectDir.path); + if (result.exitCode != 0) { + _logger.warning( + 'Failed to stage changes in git. status=${result.exitCode}', + result.stderr, + ); + } + } +} + +final class RemoveResourcesDartFile extends ProjectMigration { + RemoveResourcesDartFile(super.projectRoot); + + late final oldResourcesFile = fileSystem.file( + p.join(projectRoot, 'lib', 'src', 'generated', 'resources.dart'), + ); + + @override + Future create() async { + await oldResourcesFile.delete(); + return const ProjectMigrationSuccess(needsAnalyzerMigration: false); + } + + @override + String get name => 'core.layout.v1.remove_resources_dart'; + + @override + bool get needsMigration => oldResourcesFile.existsSync(); +} diff --git a/apps/cli/lib/init/project_generator.dart b/apps/cli/lib/init/project_generator.dart new file mode 100644 index 000000000..767f12666 --- /dev/null +++ b/apps/cli/lib/init/project_generator.dart @@ -0,0 +1,47 @@ +import 'package:celest_cli/init/migrations/add_analyzer_plugin.dart'; +import 'package:celest_cli/init/migrations/macos_entitlements.dart'; +import 'package:celest_cli/init/project_migration.dart'; +import 'package:celest_cli/project/celest_project.dart'; +import 'package:celest_cli/src/sdk/dart_sdk.dart'; + +/// Manages the generation of a new Celest project. +class ProjectGenerator { + ProjectGenerator({ + required this.projectName, + required this.parentProject, + required this.projectRoot, + }); + + /// The name of the project to initialize, as chosen by the user + /// when running `celest start` for the first time. + final String projectName; + + /// The root directory of the enclosing Flutter project. + /// + /// This will become the parent directory of the initialized + /// Celest project and the project which receives the generated + /// Flutter code. + final ParentProject? parentProject; + + /// The root directory of the initialized Celest project. + final String projectRoot; + + /// Generates a new Celest project. + Future generate() async { + await Future.wait( + [ + ProjectFile.gitIgnore(projectRoot), + ProjectFile.analysisOptions(projectRoot), + ProjectFile.pubspec(projectRoot, projectName, parentProject), + ProjectTemplate.hello(projectRoot, projectName), + if (parentProject case ParentProject( + path: final appRoot, + :final type, + )) ...[ + AddAnalyzerPlugin(projectRoot, appRoot), + if (type == SdkType.flutter) MacOsEntitlements(projectRoot, appRoot), + ], + ].map((item) => item.create()), + ); + } +} diff --git a/apps/cli/lib/init/project_migration.dart b/apps/cli/lib/init/project_migration.dart new file mode 100644 index 000000000..4915da3ff --- /dev/null +++ b/apps/cli/lib/init/project_migration.dart @@ -0,0 +1,445 @@ +import 'package:celest_cli/init/migrations/add_generated_folder.dart'; +import 'package:celest_cli/project/celest_project.dart'; +import 'package:celest_cli/pub/project_dependency.dart'; +import 'package:celest_cli/pub/pub_action.dart'; +import 'package:celest_cli/pub/pub_environment.dart'; +import 'package:celest_cli/pub/pubspec.dart'; +import 'package:celest_cli/src/context.dart'; +import 'package:celest_cli/src/utils/error.dart'; +import 'package:celest_cli/src/utils/path.dart'; +import 'package:celest_cli/src/utils/recase.dart'; +import 'package:celest_cli/src/utils/run.dart'; +import 'package:file/file.dart'; +import 'package:logging/logging.dart'; +import 'package:pubspec_parse/pubspec_parse.dart'; +import 'package:yaml/yaml.dart'; +import 'package:yaml_edit/yaml_edit.dart'; + +sealed class ProjectMigrationResult { + const ProjectMigrationResult(); + + bool get needsAnalyzerMigration => false; + + ProjectMigrationResult operator &(ProjectMigrationResult other); +} + +final class ProjectMigrationSuccess extends ProjectMigrationResult { + const ProjectMigrationSuccess({this.needsAnalyzerMigration = false}); + + @override + final bool needsAnalyzerMigration; + + @override + ProjectMigrationResult operator &(ProjectMigrationResult other) { + return switch (other) { + ProjectMigrationSkipped() => this, + ProjectMigrationSuccess(:final needsAnalyzerMigration) => + ProjectMigrationSuccess( + needsAnalyzerMigration: + this.needsAnalyzerMigration || needsAnalyzerMigration, + ), + }; + } + + @override + String toString() => + 'ProjectMigrationSuccess(needsAnalyzerMigration: $needsAnalyzerMigration)'; +} + +final class ProjectMigrationSkipped extends ProjectMigrationResult { + const ProjectMigrationSkipped(); + + @override + ProjectMigrationResult operator &(ProjectMigrationResult other) => other; + + @override + String toString() => 'ProjectMigrationSkipped()'; +} + +final class ProjectMigrationReport { + ProjectMigrationReport(); + + final Map migrations = {}; + + ProjectMigrationResult get result { + return migrations.values.fold( + const ProjectMigrationSkipped(), + (result, migration) => result & migration, + ); + } + + @override + String toString() { + final buffer = StringBuffer('ProjectMigrationReport(\n'); + for (final entry in migrations.entries) { + final value = switch (entry.value) { + ProjectMigrationSuccess(needsAnalyzerMigration: false) => 'success', + ProjectMigrationSuccess(needsAnalyzerMigration: true) => 'partial', + ProjectMigrationSkipped() => 'skipped', + }; + buffer.writeln(' ${entry.key}: $value,'); + } + buffer.write(')'); + return buffer.toString(); + } +} + +abstract class ProjectMigration { + const ProjectMigration(this.projectRoot); + + String get name; + bool get needsMigration; + + final String projectRoot; + Directory get projectDir => fileSystem.directory(projectRoot); + + /// Creates the item in the given [projectRoot]. + Future create(); +} + +sealed class ProjectFile extends ProjectMigration { + const ProjectFile(super.projectRoot); + + const factory ProjectFile.gitIgnore(String projectRoot) = _GitIgnore; + + const factory ProjectFile.analysisOptions(String projectRoot) = + _AnalysisOptions; + + const factory ProjectFile.pubspec( + String projectRoot, + String projectName, + ParentProject? parentProject, + ) = PubspecFile; + + factory ProjectFile.client(String projectRoot, String projectName) = + ProjectClient; + + @override + String get name => 'core.project.file["$relativePath"]'; + + /// The relative path of the item from the project root. + String get relativePath; + + @override + bool get needsMigration { + final entity = + relativePath.endsWith('/') + ? projectDir.childDirectory + : projectDir.childFile; + return !entity(relativePath).existsSync(); + } +} + +final class _GitIgnore extends ProjectFile { + const _GitIgnore(super.projectRoot); + + @override + String get relativePath => '.gitignore'; + + @override + bool get needsMigration => true; + + @override + Future create() async { + await _createFile(p.join(projectRoot, relativePath), ''' +# Dart +.dart_tool/ +pubspec.lock + +# Celest +build/ +.env +.env.* +'''); + return const ProjectMigrationSuccess(); + } +} + +final class _AnalysisOptions extends ProjectFile { + const _AnalysisOptions(super.projectRoot); + + @override + String get relativePath => 'analysis_options.yaml'; + + @override + Future create() async { + await _createFile(p.join(projectRoot, relativePath), ''' +include: package:lints/recommended.yaml + +analyzer: + errors: + depend_on_referenced_packages: ignore +'''); + return const ProjectMigrationSuccess(); + } +} + +final class PubspecFile extends ProjectFile { + const PubspecFile(super.projectRoot, this.projectName, this.parentProject); + + final String projectName; + final ParentProject? parentProject; + + static final logger = Logger('PubspecUpdater'); + + @override + String get relativePath => 'pubspec.yaml'; + + /// Ensures app has dependency on celest project + Future _updateAppPubspec() async { + final parentProject = this.parentProject; + if (parentProject == null) { + return; + } + final projectPubspecName = '${projectName.snakeCase}_client'; + Object? updatedPubspec; + if (parentProject.pubspec.dependencies.isEmpty) { + final pubspecYaml = loadYamlNode(parentProject.pubspecYaml) as YamlMap; + final replaceStart = switch (parentProject.pubspecYaml.indexOf( + 'dependencies:', + )) { + // Barebones pubspec, probably created by hand. + -1 => + pubspecYaml.nodes['environment']?.span.end.offset ?? + unreachable('No environment section in pubspec'), + // Empty dependencies section generated by `dart create`. Replace with + // ours. + final dependenciesStart => dependenciesStart, + }; + final replaceEnd = switch (parentProject.pubspecYaml.indexOf( + 'dev_dependencies:', + )) { + -1 => null, + final devDependenciesStart => devDependenciesStart, + }; + updatedPubspec = + StringBuffer(parentProject.pubspecYaml.substring(0, replaceStart)) + ..writeln() + ..writeln('dependencies:') + ..writeln(' $projectPubspecName:') + ..writeln(' path: celest/client/') + ..writeln( + replaceEnd?.let(parentProject.pubspecYaml.substring) ?? '', + ); + } else if (!parentProject.pubspec.dependencies.containsKey( + projectPubspecName, + )) { + final existingDependency = + parentProject.pubspec.dependencies[projectPubspecName]; + if (existingDependency + case null || PathDependency(path: != 'celest/client/')) { + updatedPubspec = YamlEditor(parentProject.pubspecYaml)..update( + ['dependencies', projectPubspecName], + {'path': 'celest/client/'}, + ); + } + } + if (updatedPubspec != null) { + await fileSystem + .directory(parentProject.path) + .childFile('pubspec.yaml') + .writeAsString(updatedPubspec.toString()); + } + } + + @override + Future create() async { + final file = fileSystem.file(p.join(projectRoot, relativePath)); + await file.create(recursive: true); + + final pubspec = Pubspec( + 'celest_backend', + // '${projectName.snakeCase}_backend', + description: 'The Celest backend for $projectName.', + publishTo: 'none', + environment: {'sdk': PubEnvironment.dartSdkConstraint}, + dependencies: ProjectDependency.backendDependencies.toPub(), + devDependencies: ProjectDependency.devDependencies.toPub(), + dependencyOverrides: ProjectDependency.localDependencyOverrides( + projectRoot: projectRoot, + ), + ); + await file.writeAsString(pubspec.toYaml()); + await _updateAppPubspec(); + return const ProjectMigrationSuccess(); + } +} + +final class ProjectClient extends ProjectFile { + ProjectClient(super.projectRoot, this.projectName); + + final String projectName; + final _operations = >[]; + + static final _logger = Logger('ProjectClient'); + + @override + String get relativePath => 'client/'; + + @override + bool get needsMigration { + final file = fileSystem + .directory(projectPaths.clientRoot) + .childFile('pubspec.yaml'); + return !file.existsSync(); + } + + @override + Future create() async { + final clientRoot = fileSystem.directory(projectPaths.clientRoot); + if (!clientRoot.existsSync()) { + await clientRoot.create(recursive: true); + } + + // pubspec.yaml + final pubspecFile = clientRoot.childFile('pubspec.yaml'); + if (!pubspecFile.existsSync()) { + final pubspec = Pubspec( + '${projectName.snakeCase}_client', + publishTo: 'none', + description: 'The Celest client for $projectName.', + environment: {'sdk': PubEnvironment.dartSdkConstraint}, + dependencies: { + 'celest_backend': PathDependency( + p.url.relative( + projectRoot.to(p.url), + from: clientRoot.path.to(p.url), + ), + ), + ...ProjectDependency.clientDependencies.toPub(), + }, + dependencyOverrides: ProjectDependency.localDependencyOverrides( + projectRoot: clientRoot.path, + ), + ); + final pubspecYaml = pubspec.toYaml(); + _logger.finest('Writing pubspec.yaml to ${pubspecFile.path}...'); + _logger.finest(pubspecYaml); + _operations.add( + pubspecFile.writeAsString(pubspecYaml, flush: true).then((_) { + return runPub( + action: PubAction.get, + workingDirectory: clientRoot.path, + ); + }), + ); + } + + // Create `lib/src` in the client folder. + _operations.add( + clientRoot + .childDirectory('lib') + .childDirectory('src') + .create(recursive: true), + ); + + await Future.wait(_operations); + return const ProjectMigrationSuccess(); + } +} + +sealed class ProjectTemplate extends ProjectMigration { + const ProjectTemplate(super.projectRoot); + + factory ProjectTemplate.hello(String projectRoot, String projectName) = + _HelloProject; +} + +final class _HelloProject extends ProjectTemplate { + _HelloProject(super.projectRoot, this.projectName); + + @override + String get name => 'core.template.hello'; + + @override + bool get needsMigration => true; + + final String projectName; + + @override + Future create() async { + await Future.wait([ + _createFile(projectPaths.projectDart, ''' +import 'package:celest/celest.dart'; + +const project = Project( + name: '$projectName', +); +'''), + _createFile(p.join(projectPaths.apisDir, 'greeting.dart'), r''' +// Cloud functions are top-level Dart functions defined in the `functions/` +// folder of your Celest project. + +import 'package:celest/celest.dart'; + +/// Says hello to a [person]. +@cloud +Future sayHello({required Person person}) async { + if (person.name.isEmpty) { + // Throw a custom exception and catch it on the frontend. + throw BadNameException('Name cannot be empty'); + } + + // Logging is handled automatically when you print to the console. + print('Saying hello to ${person.name}'); + + return 'Hello, ${person.name}!'; +} + +/// A person who can be greeted. +class Person { + const Person({required this.name}); + + final String name; +} + +/// Thrown when a [Person] has an invalid name. +class BadNameException implements Exception { + const BadNameException(this.message); + + final String message; + + @override + String toString() => 'BadNameException: $message'; +} +'''), + _createFile( + p.join(projectRoot, 'test', 'functions', 'greeting_test.dart'), + ''' +import 'package:celest_backend/src/functions/greeting.dart'; +import 'package:test/test.dart'; + +void main() { + group('greeting', () { + test('sayHello', () async { + expect(await sayHello(person: Person(name: 'Celest')), 'Hello, Celest!'); + }); + test('sayHello (empty name)', () async { + expect( + sayHello(person: Person(name: '')), + throwsA(isA()), + ); + }); + }); +} +''', + ), + + // Generated + _createFile( + p.join(projectPaths.generatedDir, 'README.md'), + generated_README, + ), + + // Client + ProjectFile.client(projectRoot, projectName).create(), + ]); + return const ProjectMigrationSuccess(); + } +} + +Future _createFile(String path, String contents) async { + final file = fileSystem.file(path); + await file.create(recursive: true); + await file.writeAsString(contents); +} diff --git a/apps/cli/lib/init/project_migrator.dart b/apps/cli/lib/init/project_migrator.dart new file mode 100644 index 000000000..4a4181012 --- /dev/null +++ b/apps/cli/lib/init/project_migrator.dart @@ -0,0 +1,70 @@ +import 'package:celest_ast/celest_ast.dart'; +import 'package:celest_cli/init/migrations/add_analyzer_plugin.dart'; +import 'package:celest_cli/init/migrations/macos_entitlements.dart'; +import 'package:celest_cli/init/migrations/pubspec_updater.dart'; +import 'package:celest_cli/init/migrations/v1_folder_structure.dart'; +import 'package:celest_cli/init/project_migration.dart'; +import 'package:celest_cli/project/celest_project.dart'; +import 'package:logging/logging.dart'; + +/// Manages the migration of a Celest project to the latest version. +class ProjectMigrator { + ProjectMigrator({ + required this.projectRoot, + required this.projectName, + required this.parentProject, + }); + + /// The root directory of the enclosing Flutter project. + /// + /// This will become the parent directory of the initialized + /// Celest project and the project which receives the generated + /// Flutter code. + final ParentProject? parentProject; + + /// The root directory of the initialized Celest project. + final String projectRoot; + + /// The name of the project, as defined by the user. + final String projectName; + + static final Logger _logger = Logger('ProjectMigrator'); + + /// Generates a new Celest project. + /// + /// Returns `true` if the project needs further migration by the analyzer. + Future migrate() async { + final migrations = [ + PubspecUpdater(projectRoot, parentProject, projectName), + V1FolderStructure(projectRoot, projectName, parentProject), + RemoveResourcesDartFile(projectRoot), + if (parentProject case ParentProject( + path: final appRoot, + :final type, + )) ...[ + AddAnalyzerPlugin(projectRoot, appRoot), + if (type == SdkType.flutter) MacOsEntitlements(projectRoot, appRoot), + ], + ]; + final report = ProjectMigrationReport(); + final needsMigration = >[]; + for (final migration in migrations) { + if (!migration.needsMigration) { + report.migrations[migration.name] = const ProjectMigrationSkipped(); + continue; + } + needsMigration.add( + migration.create().then((result) { + report.migrations[migration.name] = result; + return result; + }), + ); + } + if (needsMigration.isEmpty) { + return const ProjectMigrationSkipped(); + } + await Future.wait(needsMigration); + _logger.fine('Project migration report: $report'); + return report.result; + } +} diff --git a/apps/cli/lib/project/celest_project.dart b/apps/cli/lib/project/celest_project.dart new file mode 100644 index 000000000..7ffe34f6c --- /dev/null +++ b/apps/cli/lib/project/celest_project.dart @@ -0,0 +1,300 @@ +import 'dart:io'; +import 'dart:isolate'; + +import 'package:analyzer/dart/analysis/analysis_context.dart'; +import 'package:analyzer/dart/analysis/results.dart'; +import 'package:analyzer/dart/ast/ast.dart'; +import 'package:analyzer/src/dart/analysis/analysis_context_collection.dart'; +import 'package:analyzer/src/dart/analysis/byte_store.dart'; +import 'package:analyzer/src/dart/analysis/driver_based_analysis_context.dart'; +import 'package:celest/src/runtime/serve.dart'; +import 'package:celest_ast/celest_ast.dart' as ast; +import 'package:celest_cli/analyzer/analysis_options.dart'; +import 'package:celest_cli/config/celest_config.dart'; +import 'package:celest_cli/database/cache/cache_database.dart'; +import 'package:celest_cli/database/project/project_database.dart'; +import 'package:celest_cli/env/env_manager.dart'; +import 'package:celest_cli/project/project_paths.dart'; +import 'package:celest_cli/pub/cached_pubspec.dart'; +import 'package:celest_cli/src/context.dart'; +import 'package:celest_cli/src/sdk/dart_sdk.dart'; +import 'package:celest_cli/src/utils/run.dart'; +import 'package:logging/logging.dart'; +import 'package:meta/meta.dart'; +import 'package:native_storage/native_storage.dart'; +import 'package:package_config/package_config.dart'; +import 'package:pubspec_parse/pubspec_parse.dart'; + +final class ParentProject { + const ParentProject({ + required this.name, + required this.path, + required this.pubspec, + required this.pubspecYaml, + required this.type, + }); + + static Future load(String path) async { + return Isolate.run(() => loadSync(path)); + } + + static ParentProject? loadSync(String path) { + final dir = fileSystem.directory(path); + final pubspecFile = dir.childFile('pubspec.yaml'); + if (!pubspecFile.existsSync()) { + return null; + } + final pubspecYaml = pubspecFile.readAsStringSync(); + final pubspec = Pubspec.parse(pubspecYaml, sourceUrl: pubspecFile.uri); + return ParentProject( + name: pubspec.name, + path: path, + pubspec: pubspec, + pubspecYaml: pubspecYaml, + type: switch (pubspec.dependencies.containsKey('flutter')) { + true => ast.SdkType.flutter, + false => ast.SdkType.dart, + }, + ); + } + + final String name; + final String path; + final Pubspec pubspec; + final String pubspecYaml; + final ast.SdkType type; +} + +/// Static information about the current Celest project. +final class CelestProject { + CelestProject._({ + required this.projectPaths, + required AnalysisOptions analysisOptions, + required this.config, + required this.parentProject, + required this.cacheDb, + required ByteStore byteStore, + ProjectDatabase? projectDb, + }) : _analysisOptions = analysisOptions, + _byteStore = byteStore, + _projectDb = projectDb; + + static final _logger = Logger('CelestProject'); + + static Future init({ + required String projectRoot, + ParentProject? parentProject, + String? configHome, + String? clientDir, + String? outputsDir, + @visibleForTesting CacheDatabase? cacheDb, + @visibleForTesting ByteStore? byteStore, + @visibleForTesting ProjectDatabase? projectDb, + }) async { + _logger.finest('Loading celest project at root: "$projectRoot"...'); + final projectPaths = ProjectPaths( + projectRoot, + parentAppRoot: parentProject?.path, + clientDir: clientDir, + outputsDir: outputsDir, + ); + final [ + config as CelestConfig, + analysisOptions as AnalysisOptions, + ] = await Future.wait([ + CelestConfig.load(configHome: configHome?.let(fileSystem.directory)), + AnalysisOptions.load(projectPaths.analysisOptionsYaml), + ]); + _logger + ..finest('Loaded analysis options: $analysisOptions') + ..finest('Loaded Celest config: $config'); + _logger.finest('Spawned env manager'); + cacheDb ??= await CacheDatabase.open(projectRoot, verbose: verbose); + byteStore ??= MemoryCachingByteStore( + cacheDb.byteStore, + 1 << 30, // 1 GB + ); + final project = CelestProject._( + projectPaths: projectPaths, + analysisOptions: analysisOptions, + config: config, + parentProject: parentProject, + cacheDb: cacheDb, + byteStore: byteStore, + ); + return project; + } + + String get packageName => 'celest_backend'; + + final ProjectPaths projectPaths; + AnalysisOptions _analysisOptions; + AnalysisOptions get analysisOptions => _analysisOptions; + + final ByteStore _byteStore; + late final _analysisContextCollection = AnalysisContextCollectionImpl( + includedPaths: [projectPaths.projectRoot], + sdkPath: Sdk.current.sdkPath, + // Needed for collecting subtypes. + enableIndex: true, + byteStore: _byteStore, + ); + + Future determineProjectType() async { + final packageConfigFile = fileSystem.file(projectPaths.packagesConfig); + if (packageConfigFile.existsSync()) { + final packageConfig = await loadPackageConfig(packageConfigFile); + for (final package in packageConfig.packages) { + if (package.name == 'flutter' || package.name == 'sky_engine') { + return ast.SdkType.flutter; + } + } + return ast.SdkType.dart; + } + final pubspec = Pubspec.parse( + await fileSystem.file(projectPaths.pubspecYaml).readAsString(), + sourceUrl: p.toUri(projectPaths.pubspecYaml), + ); + return switch (pubspec.dependencies.containsKey('flutter')) { + true => ast.SdkType.flutter, + false => ast.SdkType.dart, + }; + } + + final EnvManager envManager = EnvManager(); + final ParentProject? parentProject; + + /// The [AnalysisContext] for the current project. + late final DriverBasedAnalysisContext analysisContext = + _analysisContextCollection.contextFor( + p.join(projectPaths.projectRoot, 'project.dart'), + ); + + /// The [CelestConfig] for the current project. + final CelestConfig config; + + /// The [CacheDatabase] for the current project. + final CacheDatabase cacheDb; + + /// The [ProjectDatabase] for the current project. + ProjectDatabase get projectDb => + _projectDb ??= ProjectDatabase( + projectRoot: projectPaths.projectRoot, + verbose: verbose, + ); + ProjectDatabase? _projectDb; + + late final _cachedPubspec = CachedPubspec( + fileSystem.file(projectPaths.pubspecYaml), + ); + Pubspec get pubspec => _cachedPubspec.pubspec; + String get pubspecYaml => _cachedPubspec.pubspecYaml; + + late final _cachedClientPubspec = CachedPubspec( + fileSystem.directory(projectPaths.clientRoot).childFile('pubspec.yaml'), + ); + Pubspec get clientPubspec => _cachedClientPubspec.pubspec; + String get clientPubspecYaml => _cachedClientPubspec.pubspecYaml; + + Future> invalidate(Iterable files) async { + for (final file in files) { + if (p.basename(file) == 'analysis_options.yaml') { + _analysisOptions = await AnalysisOptions.load(file); + } + if (p.extension(file) == '.dart') { + // Change the file in the analysis context. + analysisContext.changeFile(file); + } + } + final changedFiles = await analysisContext.applyPendingFileChanges(); + _logger.finest( + 'Changed files: ${changedFiles.join(Platform.lineTerminator)}', + ); + return changedFiles.toSet(); + } + + /// The name of the project as declared in the `project.dart` file. + /// + /// We parse the `project.dart` file to retrieve it since it is cheap and + /// follows a consistent pattern. + String get projectName { + final projectDartFiles = [ + projectPaths.projectDart, + projectPaths.projectDartLegacy, + ].map(fileSystem.file); + File? projectDart; + for (final projectDartFile in projectDartFiles) { + if (projectDartFile.existsSync()) { + projectDart = projectDartFile; + break; + } + } + if (projectDart == null) { + // Shouldn't ever happen since we shouldn't be requesting this before + // the project is generated. + throw StateError('No project.dart file found in the project root.'); + } + final projectLibrary = analysisContext.currentSession.getParsedLibrary( + projectDart.path, + ); + switch (projectLibrary) { + case ParsedLibraryResult(:final units): + final declarations = units + .expand((unit) => unit.unit.declarations) + .whereType() + .expand((declaration) => declaration.variables.variables); + for (final declaration in declarations) { + if (declaration.initializer case MethodInvocation( + methodName: SimpleIdentifier(name: 'Project'), + :final argumentList, + )) { + for (final argument in argumentList.arguments) { + if (argument case NamedExpression( + name: Label(label: SimpleIdentifier(name: 'name')), + expression: SimpleStringLiteral(value: final projectName), + )) { + return projectName; + } + } + } + } + throw StateError('No Project(name: "name") found in project.dart'); + default: + throw StateError('Failed to parse project.dart'); + } + } + + Future close() async { + await Future.wait([ + _analysisContextCollection.dispose(forTesting: true), + cacheDb.close(), + ]); + _logger.finest('Closed Celest project'); + } +} + +typedef CelestProjectUris = ({Uri localUri, Uri? productionUri}); + +extension CelestProjectUriStorage on IsolatedNativeStorage { + Future getUri(String key) async => switch (await read(key)) { + final uri? => Uri.parse(uri), + _ => null, + }; + + Future getProductionUri(String projectName) => + getUri('$projectName.productionUri'); + Future setProductionUri(String projectName, Uri uri) async { + await write('$projectName.productionUri', uri.toString()); + return uri; + } + + Future getLocalUri(String projectName) async { + final uri = await getUri('$projectName.localUri'); + return uri ?? Uri.parse('http://localhost:$defaultCelestPort'); + } + + Future setLocalUri(String projectName, Uri uri) async { + await write('$projectName.localUri', uri.toString()); + return uri; + } +} diff --git a/apps/cli/lib/project/project_paths.dart b/apps/cli/lib/project/project_paths.dart new file mode 100644 index 000000000..6d969d241 --- /dev/null +++ b/apps/cli/lib/project/project_paths.dart @@ -0,0 +1,151 @@ +import 'package:celest_cli/src/context.dart'; +import 'package:celest_cli/src/types/type_checker.dart'; +import 'package:celest_cli/src/utils/path.dart'; + +final class ProjectPaths { + ProjectPaths( + this.projectRoot, { + this.parentAppRoot, + String? clientDir, + String? outputsDir, + }) : clientRoot = clientDir ?? p.join(outputsDir ?? projectRoot, 'client'), + outputsDir = + outputsDir ?? p.join(projectRoot, '.dart_tool', 'celest', 'outputs'); + + final String projectRoot; + final String outputsDir; + + final String? parentAppRoot; + String get celestConfig => celestProject.config.configDir.path; + + late final String packageRoot = p.join(projectRoot, 'lib'); + late final String packagesConfig = p.join( + projectRoot, + '.dart_tool', + 'package_config.json', + ); + late final String pubspecYaml = p.join(projectRoot, 'pubspec.yaml'); + late final String analysisOptionsYaml = p.join( + projectRoot, + 'analysis_options.yaml', + ); + late final String projectDart = p.join( + projectRoot, + 'lib', + 'src', + 'project.dart', + ); + late final String projectDartLegacy = p.join(projectRoot, 'project.dart'); + late final String projectLib = p.join(projectRoot, 'lib'); + late final String localApiEntrypoint = p.join(outputsDir, 'api.local.dart'); + late final String legacyClientOutputsDir = p.join( + projectRoot, + 'lib', + 'src', + 'client', + ); + final String clientRoot; + late final String clientPackageRoot = p.join(clientRoot, 'lib'); + late final String clientOutputsDir = p.join(clientRoot, 'lib', 'src'); + late final String projectCacheDir = p.join( + projectRoot, + '.dart_tool', + 'celest', + ); + + // Generated + late final String generatedDir = p.join( + projectRoot, + 'lib', + 'src', + 'generated', + ); + late final String buildDir = p.join(projectRoot, 'build'); + + late final String apisDir = p.join(projectRoot, 'lib', 'src', 'functions'); + late final String legacyApisDir = p.join(projectRoot, 'functions'); + late final String configDir = p.join(projectRoot, 'config'); + + String get envFile { + final legacyEnvFile = fileSystem.file( + p.join(projectRoot, 'config', '.env'), + ); + if (legacyEnvFile.existsSync()) { + return legacyEnvFile.path; + } + return p.join(projectRoot, '.env'); + } + + String envFileFor(String environment) => + p.join(p.dirname(envFile), '.env.$environment'); + + late final String modelsDir = p.join(projectRoot, 'lib', 'models'); + late final String modelsDart = p.join(projectRoot, 'lib', 'models.dart'); + late final String exceptionsDir = p.join(projectRoot, 'lib', 'exceptions'); + late final String exceptionsDart = p.join( + projectRoot, + 'lib', + 'exceptions.dart', + ); + + late final String authDart = p.join(projectRoot, 'auth.dart'); + late final String legacyAuthDart = p.join(projectRoot, 'auth', 'auth.dart'); + + String api(String apiName) => p.join(legacyApisDir, '$apiName.dart'); + String apiOutput(String apiName) => p.join(outputsDir, 'functions', apiName); + String functionEntrypoint(String apiName, String functionName) => + p.join(apiOutput(apiName), '$functionName.dart'); + + Uri normalizeUri(Uri uri) { + return switch (uri) { + Uri(scheme: 'file' || '', :final path) => fileToPackageUri(path), + Uri(scheme: 'dart') => normalizeDartUrl(uri), + Uri(scheme: 'package') => uri, + _ => uri, + }; + } + + Uri denormalizeUri(Uri uri) { + return switch (uri) { + Uri( + scheme: 'package', + pathSegments: [final package, ...final pathSegments], + ) + when package == 'celest_backend' || + package == celestProject.clientPubspec.name => + packageToFileUri(package, pathSegments), + _ => uri, + }; + } + + Uri fileToPackageUri(String path) { + if (!p.isRelative(path)) { + path = p.absolute(path); + } + if (p.isWithin(packageRoot, path)) { + path = p.relative(path, from: packageRoot).to(p.url); + return Uri( + scheme: 'package', + pathSegments: ['celest_backend', ...p.url.split(path)], + ); + } + if (p.isWithin(clientPackageRoot, path)) { + path = p.relative(path, from: clientPackageRoot).to(p.url); + return Uri( + scheme: 'package', + pathSegments: [celestProject.clientPubspec.name, ...p.url.split(path)], + ); + } + return p.toUri(path); + } + + Uri packageToFileUri(String package, List pathSegments) { + if (package == 'celest_backend') { + return Uri.file(p.joinAll([packageRoot, ...pathSegments])); + } + if (package == celestProject.clientPubspec.name) { + return Uri.file(p.joinAll([clientPackageRoot, ...pathSegments])); + } + throw ArgumentError('Cannot denormalize package $package'); + } +} diff --git a/apps/cli/lib/project/project_resolver.dart b/apps/cli/lib/project/project_resolver.dart new file mode 100644 index 000000000..e36ac44cb --- /dev/null +++ b/apps/cli/lib/project/project_resolver.dart @@ -0,0 +1,340 @@ +import 'package:cedar/ast.dart'; +import 'package:cedar/cedar.dart'; +import 'package:celest_ast/celest_ast.dart'; +import 'package:celest_cli/src/utils/error.dart'; +import 'package:celest_cli/src/utils/run.dart'; + +extension on CloudFunction { + EntityUid get uid => EntityUid.of('Celest::Function', '$apiName/$name'); +} + +extension on Api { + EntityUid get uid => EntityUid.of('Celest::Api', name); +} + +extension on AstNode { + EntityUid get uid => switch (this) { + final CloudFunction function => function.uid, + final Api api => api.uid, + _ => unreachable(), + }; + ResourceConstraint get resource => switch (this) { + final Api api => ResourceIn(api.uid), + final CloudFunction function => ResourceEquals(function.uid), + _ => unreachable(), + }; +} + +extension on ApiAuth { + String get tag => switch (this) { + ApiPublic() => 'public', + ApiAuthenticated() => 'authenticated', + }; + + String get templateId => 'cloud.functions.$tag'; + + void appendPolicies(AstNode node, PolicySetBuilder builder) { + final policyId = '${node.uid.id}.$tag'; + final templateLink = TemplateLink( + templateId: templateId, + newId: policyId, + values: {SlotId.resource: node.uid}, + ); + builder.templateLinks.add(templateLink); + if (this is ApiAuthenticated) { + // Add a forbid policy for `@authenticated` so that it overrides + // any other allow policies, e.g. if the library has `@public`. + builder.policies['${policyId}_restrict'] = Policy( + effect: Effect.forbid, + principal: const PrincipalAll(), + action: const ActionEquals(EntityUid.of('Celest::Action', 'invoke')), + resource: node.resource, + conditions: [ + Condition( + kind: ConditionKind.unless, + body: Expr.in_( + left: const Expr.variable(CedarVariable.principal), + right: Expr.value( + Value.entity(uid: EntityUid.of('Celest::Role', tag)), + ), + ), + ), + ], + ); + } + } +} + +final class ProjectResolver extends AstVisitorWithArg { + ProjectResolver({ + required Map configValues, + required String environmentId, + this.driftSchemas = const {}, + }) : configValues = {...configValues, 'CELEST_ENVIRONMENT': environmentId}; + + final _resolvedProject = ResolvedProjectBuilder(); + late final ResolvedProject resolvedProject = run(() { + final celestConfigValues = configValues.keys.toSet().difference( + _seenConfigValues, + ); + for (final name in celestConfigValues) { + _resolvedProject.variables.add( + ResolvedVariable(name: name, value: configValues[name]!), + ); + } + return _resolvedProject.build(); + }); + + final Map configValues; + final Set _seenConfigValues = {}; + final Map? driftSchemas; + + @override + ResolvedProject visitProject(Project project, AstNode context) { + _resolvedProject + ..projectId = project.name + ..environmentId = project.environment + ..sdkConfig.replace(project.sdkConfig); + for (final variable in project.variables) { + _resolvedProject.variables.add(visitVariable(variable, project)); + } + for (final secret in project.secrets) { + _resolvedProject.secrets.add(visitSecret(secret, project)); + } + for (final api in project.apis.values) { + _resolvedProject.apis[api.name] = visitApi(api, project); + } + if (project.auth case final auth?) { + _resolvedProject.auth.replace(visitAuth(auth, project)); + } + for (final database in project.databases.values) { + _resolvedProject.databases[database.name] = visitDatabase( + database, + project, + ); + } + return resolvedProject; + } + + @override + ResolvedApi visitApi(Api api, Project context) { + return ResolvedApi.build((resolvedApi) { + resolvedApi.apiId = api.name; + for (final f in api.functions.values) { + resolvedApi.functions[f.name] = visitFunction(f, api); + } + final apiAuth = api.metadata.whereType().singleOrNull; + if (apiAuth != null) { + apiAuth.appendPolicies(api, resolvedApi.policySet); + } + }); + } + + @override + Node? visitApiAuthenticated(ApiAuthenticated annotation, Api context) { + return null; + } + + @override + Node? visitApiPublic(ApiPublic annotation, AstNode context) { + return null; + } + + @override + Node? visitApiMiddleware(ApiMiddleware annotation, AstNode context) { + return null; + } + + @override + ResolvedCloudFunction visitFunction(CloudFunction function, Api context) { + return ResolvedCloudFunction.build((resolvedFunction) { + resolvedFunction + ..functionId = function.name + ..apiId = function.apiName + ..httpConfig.route.path = function.route + ..streamConfig.type = function.streamType; + + final funcHttpMetadata = [ + ...context.metadata.whereType(), + ...function.metadata.whereType(), + ]; + for (final metadata in funcHttpMetadata) { + switch (metadata) { + case ApiHttpConfig(:final method, :final statusCode): + resolvedFunction.httpConfig + ..status = statusCode + ..route.method = method; + case ApiHttpError(:final type, :final statusCode): + resolvedFunction.httpConfig.statusMappings[type] = statusCode; + } + } + final functionAuth = function.metadata.whereType().singleOrNull; + if (functionAuth != null) { + functionAuth.appendPolicies(function, resolvedFunction.policySet); + } + + for (final parameter in function.parameters) { + switch (parameter.references) { + case NodeReference(type: NodeType.variable, :final name): + resolvedFunction.variables.add(name); + case NodeReference(type: NodeType.secret, :final name): + resolvedFunction.secrets.add(name); + } + } + }); + } + + @override + Node? visitParameter( + CloudFunctionParameter parameter, + CloudFunction context, + ) { + return null; + } + + @override + ResolvedVariable visitVariable(Variable variable, AstNode context) { + final name = variable.name; + _seenConfigValues.add(name); + final value = configValues[name]; + if (value == null) { + // Should have been caught before this. + unreachable('Missing value for environment variable: $name'); + } + return ResolvedVariable(name: name, value: value); + } + + @override + ResolvedSecret visitSecret(Secret secret, covariant AstNode context) { + final name = secret.name; + _seenConfigValues.add(name); + final value = configValues[name]; + if (value == null) { + // Should have been caught before this. + unreachable('Missing value for secret: $name'); + } + return ResolvedSecret(name: name, value: value); + } + + @override + ResolvedAuth visitAuth(Auth auth, Project context) { + return ResolvedAuth.build((b) { + for (final authProvider in auth.providers) { + b.providers.add(visitAuthProvider(authProvider, auth)); + } + for (final externalAuthProvider in auth.externalProviders) { + b.externalProviders.add( + visitExternalAuthProvider(externalAuthProvider, auth), + ); + } + }); + } + + @override + ResolvedAuthProvider visitAuthProvider(AuthProvider provider, Auth context) { + switch (provider) { + case EmailAuthProvider(:final name): + return ResolvedEmailAuthProvider(authProviderId: name); + case SmsAuthProvider(:final name): + return ResolvedSmsAuthProvider(authProviderId: name); + case GoogleAuthProvider( + :final name, + :final clientId, + :final clientSecret, + ): + return ResolvedGoogleAuthProvider( + authProviderId: name, + clientId: visitSecret(clientId, context), + clientSecret: visitSecret(clientSecret, context), + ); + case GitHubAuthProvider( + :final name, + :final clientId, + :final clientSecret, + ): + return ResolvedGitHubAuthProvider( + authProviderId: name, + clientId: visitSecret(clientId, context), + clientSecret: visitSecret(clientSecret, context), + ); + case AppleAuthProvider( + :final name, + :final clientId, + :final teamId, + :final keyId, + :final privateKey, + ): + return ResolvedAppleAuthProvider( + authProviderId: name, + clientId: visitSecret(clientId, context), + teamId: visitSecret(teamId, context), + keyId: visitSecret(keyId, context), + privateKey: visitSecret(privateKey, context), + ); + } + } + + @override + ResolvedExternalAuthProvider visitExternalAuthProvider( + ExternalAuthProvider provider, + covariant AstNode context, + ) { + return switch (provider) { + FirebaseExternalAuthProvider(:final name, :final projectId) => + ResolvedFirebaseExternalAuthProvider( + authProviderId: name, + projectId: visitVariable(projectId, context), + ), + SupabaseExternalAuthProvider( + :final name, + :final projectUrl, + :final jwtSecret, + ) => + ResolvedSupabaseExternalAuthProvider( + authProviderId: name, + projectUrl: visitVariable(projectUrl, context), + jwtSecret: jwtSecret?.let((secret) => visitSecret(secret, context)), + ), + }; + } + + @override + Node? visitApiHttpMetadata(ApiHttpMetadata metadata, AstNode context) { + return null; + } + + @override + ResolvedDatabase visitDatabase(Database database, Project context) { + return ResolvedDatabase.build((b) { + b.databaseId = database.name; + b.config = switch (database.config) { + CelestDatabaseConfig(:final hostname, :final token) => + ResolvedCelestDatabaseConfig( + // The deployed environments, values for these are filled in only + // after the project is deployed. + // + // For local environments, the values are never needed. + hostname: ResolvedVariable(name: hostname.name, value: ''), + token: ResolvedSecret(name: token.name, value: ''), + ), + }; + b.schema = switch (database.schema) { + // TODO(dnys1): Use drift_dev to resolve the schema. + DriftDatabaseSchema() => ResolvedDriftDatabaseSchema( + databaseSchemaId: database.name, + version: 1, + schemaJson: {}, + ), + }; + }); + } + + @override + ResolvedDatabaseSchema visitDatabaseSchema( + DatabaseSchema schema, + Database context, + ) { + // TODO: implement visitSchema + throw UnimplementedError(); + } +} diff --git a/apps/cli/lib/pub/cached_pubspec.dart b/apps/cli/lib/pub/cached_pubspec.dart new file mode 100644 index 000000000..9e15cf140 --- /dev/null +++ b/apps/cli/lib/pub/cached_pubspec.dart @@ -0,0 +1,36 @@ +import 'package:file/file.dart'; +import 'package:pubspec_parse/pubspec_parse.dart'; + +final class CachedPubspec { + CachedPubspec(this._file); + + final File _file; + + DateTime? _lastCached; + DateTime get _lastModified => _file.lastModifiedSync(); + + void _recache() { + _lastCached = DateTime.now(); + _pubspecYaml = _file.readAsStringSync(); + _pubspec = Pubspec.parse(_pubspecYaml, sourceUrl: _file.uri); + } + + bool get _needsRecache { + if (_lastCached case final lastCached?) { + return _lastModified.isAfter(lastCached); + } + return true; + } + + late String _pubspecYaml; + String get pubspecYaml { + if (_needsRecache) _recache(); + return _pubspecYaml; + } + + late Pubspec _pubspec; + Pubspec get pubspec { + if (_needsRecache) _recache(); + return _pubspec; + } +} diff --git a/apps/cli/lib/pub/project_dependency.dart b/apps/cli/lib/pub/project_dependency.dart new file mode 100644 index 000000000..874f89306 --- /dev/null +++ b/apps/cli/lib/pub/project_dependency.dart @@ -0,0 +1,237 @@ +import 'package:celest_cli/pub/pubspec.dart'; +import 'package:celest_cli/src/context.dart'; +import 'package:celest_cli/src/utils/error.dart'; +import 'package:celest_cli/src/utils/path.dart'; +import 'package:celest_cli/src/version.dart'; +import 'package:pub_semver/pub_semver.dart'; +import 'package:pubspec_parse/pubspec_parse.dart'; + +final Version currentMinorVersion = () { + final currentVersion = Version.parse(packageVersion); + if (currentVersion.isPreRelease) { + return Version(currentVersion.major, currentVersion.minor, 0, pre: '0'); + } + return Version(currentVersion.major, currentVersion.minor, 0); +}(); + +final class ProjectDependency { + const ProjectDependency._(this.name, this.type, this.pubDependency); + + final String name; + final DependencyType type; + final HostedDependency pubDependency; + + static Map? localDependencyOverrides({ + required String projectRoot, + }) { + final localPath = celestLocalPath; + if (localPath == null) { + return null; + } + + String packagePath(String packageName) { + return p.url.relative( + p.join(localPath, 'packages', packageName).to(p.url), + from: projectRoot.to(p.url), + ); + } + + const packages = [ + 'celest', + 'celest_ast', + 'celest_auth', + 'celest_core', + 'celest_cloud', + ]; + + String servicePath(String serviceName) { + return p.url.relative( + p.join(localPath, 'services', serviceName).to(p.url), + from: projectRoot.to(p.url), + ); + } + + const services = ['celest_cloud_auth']; + + return { + for (final packageName in packages) + packageName: PathDependency(packagePath(packageName)), + for (final serviceName in services) + serviceName: PathDependency(servicePath(serviceName)), + }; + } + + static final Map all = { + celest.name: celest, + celestAst.name: celestAst, + celestCloudAuth.name: celestCloudAuth, + celestCore.name: celestCore, + firebaseAuth.name: firebaseAuth, + driftHrana.name: driftHrana, + gotrue.name: gotrue, + http.name: http, + meta.name: meta, + nativeStorage.name: nativeStorage, + streamTransform.name: streamTransform, + lints.name: lints, + test.name: test, + }; + + static final ProjectDependency celest = ProjectDependency._( + 'celest', + DependencyType.dependency, + HostedDependency( + version: VersionConstraint.compatibleWith(currentMinorVersion), + ), + ); + + static final ProjectDependency celestAst = ProjectDependency._( + 'celest_ast', + DependencyType.dependency, + HostedDependency( + version: VersionConstraint.compatibleWith(Version.parse('0.1.0')), + ), + ); + + static final ProjectDependency celestCloudAuth = ProjectDependency._( + 'celest_cloud_auth', + DependencyType.dependency, + HostedDependency( + version: VersionConstraint.compatibleWith(Version.parse('0.1.0')), + ), + ); + + static final ProjectDependency celestCore = ProjectDependency._( + 'celest_core', + DependencyType.dependency, + HostedDependency( + version: VersionConstraint.compatibleWith(currentMinorVersion), + ), + ); + + static final ProjectDependency driftHrana = ProjectDependency._( + 'drift_hrana', + DependencyType.dependency, + HostedDependency( + version: VersionConstraint.compatibleWith(Version.parse('1.0.2')), + ), + ); + + static final ProjectDependency firebaseAuth = ProjectDependency._( + 'firebase_auth', + DependencyType.dependency, + HostedDependency( + version: VersionConstraint.compatibleWith(Version.parse('5.2.0')), + ), + ); + + static final ProjectDependency gotrue = ProjectDependency._( + 'gotrue', + DependencyType.dependency, + HostedDependency( + version: VersionConstraint.compatibleWith(Version.parse('2.8.0')), + ), + ); + + static final ProjectDependency http = ProjectDependency._( + 'http', + DependencyType.dependency, + HostedDependency( + version: VersionConstraint.compatibleWith(Version.parse('1.0.0')), + ), + ); + + static final ProjectDependency meta = ProjectDependency._( + 'meta', + DependencyType.dependency, + HostedDependency( + version: VersionConstraint.compatibleWith(Version.parse('1.12.0')), + ), + ); + + static final ProjectDependency nativeStorage = ProjectDependency._( + 'native_storage', + DependencyType.dependency, + HostedDependency( + version: VersionConstraint.compatibleWith(Version.parse('0.2.2')), + ), + ); + + static final ProjectDependency streamTransform = ProjectDependency._( + 'stream_transform', + DependencyType.dependency, + HostedDependency( + version: VersionConstraint.compatibleWith(Version.parse('2.1.0')), + ), + ); + + static final ProjectDependency lints = ProjectDependency._( + 'lints', + DependencyType.devDependency, + HostedDependency( + version: VersionConstraint.compatibleWith(Version.parse('4.0.0')), + ), + ); + + static final ProjectDependency test = ProjectDependency._( + 'test', + DependencyType.devDependency, + HostedDependency( + version: VersionConstraint.compatibleWith(Version.parse('1.25.0')), + ), + ); + + static final Map backendDependencies = { + celest.name: celest, + celestCore.name: celestCore, + meta.name: meta, + }; + + static final Map clientDependencies = { + celest.name: celest, + celestCore.name: celestCore, + http.name: http, + nativeStorage.name: nativeStorage, + }; + + static final Map devDependencies = { + lints.name: lints, + test.name: test, + }; + + bool upToDate(Pubspec pubspec) { + final (expected, actual) = switch (type) { + DependencyType.dependency when pubspec.name == 'celest_backend' => ( + backendDependencies, + pubspec.dependencies, + ), + DependencyType.dependency => (clientDependencies, pubspec.dependencies), + DependencyType.devDependency => ( + devDependencies, + pubspec.devDependencies, + ), + _ => unreachable(), + }; + final expectedVersion = expected[name]!.pubDependency.version; + return switch (actual[name]) { + // Add the dependency + null => false, + + // Compare to existing constraint + final HostedDependency actual => expectedVersion == actual.version, + + // Don't overwrite path/git dependencies + _ => true, + }; + } +} + +extension DependencyMap on Map { + bool upToDate(Pubspec pubspec) { + return values.every((dep) => dep.upToDate(pubspec)); + } + + Map toPub() { + return map((key, value) => MapEntry(key, value.pubDependency)); + } +} diff --git a/apps/cli/lib/pub/pub_action.dart b/apps/cli/lib/pub/pub_action.dart new file mode 100644 index 000000000..e96ef41f4 --- /dev/null +++ b/apps/cli/lib/pub/pub_action.dart @@ -0,0 +1,128 @@ +import 'dart:async'; + +import 'package:celest_cli/src/context.dart'; +import 'package:celest_cli/src/exceptions.dart'; +import 'package:celest_cli/src/sdk/dart_sdk.dart'; +import 'package:celest_core/_internal.dart'; +import 'package:cli_script/cli_script.dart'; +import 'package:logging/logging.dart'; + +enum PubAction { + get, + upgrade; + + /// Matcher for output of `pub `. + /// + /// From: https://github.com/dart-lang/pub/blob/f8b23495666acb275016850f6fd4206a38ad0eb5/test/test_pub.dart#L96 + RegExp get matcher => switch (this) { + get => RegExp(r'Got dependencies!|Changed \d+ dependenc(y|ies)!'), + upgrade => RegExp(r''' +(No dependencies changed\.|Changed \d+ dependenc(y|ies)!)($| +\d+ packages? (has|have) newer versions incompatible with dependency constraints. +Try `dart pub outdated` for more information.$)'''), + }; +} + +final Logger _logger = Logger('pub'); + +Future dumpPackageConfig() async { + try { + final packageConfig = + await fileSystem.file(projectPaths.packagesConfig).readAsString(); + _logger.finest('Package config:\n$packageConfig'); + } on Object catch (e, st) { + _logger.finest('Failed to read package config.', e, st); + } + try { + final pubspec = + await fileSystem.file(projectPaths.pubspecYaml).readAsString(); + _logger.finest('Pubspec:\n$pubspec'); + } on Object catch (e, st) { + _logger.finest('Failed to read pubspec.', e, st); + } +} + +Future runPub({ + String? exe, + required PubAction action, + required String workingDirectory, +}) async { + exe ??= + kDebugMode + ? platform.resolvedExecutable + : (await celestProject.determineProjectType()).name; + + final command = [exe, 'pub', action.name]; + final logger = Logger(command.join(' ')); + logger.fine('Running `${command.join(' ')}` in "$workingDirectory"...'); + final process = await processManager.start( + command, + environment: { + if (Sdk.current.flutterSdkRoot case final flutterSdkRoot?) + 'FLUTTER_ROOT': flutterSdkRoot, + }, + workingDirectory: workingDirectory, + ); + + // TODO(dnys1): Remove when fixed in pub https://github.com/dart-lang/sdk/issues/55289 + // and we can rely on the exit code taking a reasonable amount of time. + + // Must be sync so that completer only completes once before `finally` block + // cancels subscription. + final completer = Completer.sync(); + final stdout = process.stdout.lines.listen((line) { + logger.finest('stdout: $line'); + if (action.matcher.hasMatch(line)) { + if (completer.isCompleted) { + logger.finest('Got matching line after completion: $line'); + return; + } + completer.complete(); + } + }); + final stderr = process.stderr.lines.listen((line) { + logger.finest('stderr: $line'); + if (line.trim().startsWith('Waiting for another flutter command')) { + return; + } + if (!completer.isCompleted) { + completer.completeError( + CliException( + 'Failed to run `pub ${action.name}`. Please run `$exe pub ${action.name}` ' + 'manually in $workingDirectory and try again.', + additionalContext: {'error': line}, + ), + ); + } + }); + try { + await Future.any([ + process.exitCode.then((exitCode) { + if (exitCode != 0) { + throw CliException( + 'Failed to run `pub get`. Please run `$exe pub get` manually in ' + '$workingDirectory and try again.', + ); + } + _logger.finer( + '`$exe pub ${action.name}` completed successfully in ' + '"$workingDirectory"', + ); + }), + completer.future, + ]); + final packageConfig = fileSystem + .directory(workingDirectory) + .childDirectory('.dart_tool') + .childFile('package_config.json'); + while (!await packageConfig.exists()) { + await Future.delayed(const Duration(milliseconds: 50)); + } + } on Object { + // await dumpPackageConfig(); + rethrow; + } finally { + unawaited(stdout.cancel()); + unawaited(stderr.cancel()); + } +} diff --git a/apps/cli/lib/pub/pub_cache.dart b/apps/cli/lib/pub/pub_cache.dart new file mode 100644 index 000000000..71132e26f --- /dev/null +++ b/apps/cli/lib/pub/pub_cache.dart @@ -0,0 +1,221 @@ +import 'dart:io'; + +import 'package:celest_cli/pub/project_dependency.dart'; +import 'package:celest_cli/src/context.dart'; +import 'package:celest_cli/src/sdk/dart_sdk.dart'; +import 'package:celest_cli/src/utils/cli.dart'; +import 'package:collection/collection.dart'; +import 'package:file/file.dart'; +import 'package:logging/logging.dart'; +import 'package:meta/meta.dart'; +import 'package:path/path.dart' as p; +import 'package:pub_semver/pub_semver.dart'; +import 'package:pubspec_parse/pubspec_parse.dart'; +import 'package:stream_transform/stream_transform.dart'; +import 'package:yaml_edit/yaml_edit.dart'; + +/// Pub cache utilities +final pubCache = PubCache(); + +final class PubCache { + static final packagesToFix = { + // This is the only syntax that reliably works with both dart/flutter + 'native_storage': '>=0.2.2 <1.0.0', + 'native_authentication': '>=0.1.0 <1.0.0', + 'jni': '>=0.11.0 <1.0.0', + 'celest_auth': '>=$currentMinorVersion <2.0.0', + 'celest': '>=$currentMinorVersion <2.0.0', + 'celest_core': '>=$currentMinorVersion <2.0.0', + 'objective_c': '>=2.0.0', + }; + static final _logger = Logger('PubCache'); + + String? _cachePath; + + // Adapted from `package:pub/src/system_cache.dart` + String? findCachePath() { + if (platform.environment['PUB_CACHE'] case final cacheDir?) { + return p.absolute(cacheDir); + } + if (platform.isWindows) { + // %LOCALAPPDATA% is used as the cache location over %APPDATA%, because + // the latter is synchronised between devices when the user roams between + // them, whereas the former is not. + final localAppData = platform.environment['LOCALAPPDATA']; + if (localAppData == null) { + _logger.finest( + 'Could not find the pub cache. No `LOCALAPPDATA` environment variable exists.', + ); + return null; + } + return p.join(localAppData, 'Pub', 'Cache'); + } + final home = platform.environment['HOME']; + if (home == null) { + _logger.finest( + 'Could not find the pub cache. No `HOME` environment variable exists.', + ); + return null; + } + return p.join(home, '.pub-cache'); + } + + String? latestVersionPath(String packageName) { + final cachePath = _cachePath ??= findCachePath(); + if (cachePath == null) { + return null; + } + final packageDir = localFileSystem + .directory(cachePath) + .childDirectory('hosted') + .childDirectory('pub.dev'); + if (!packageDir.existsSync()) { + return null; + } + final packageVersions = packageDir.listSync().whereType(); + final allVersions = []; + for (final packageVersion in packageVersions) { + final basename = p.basename(packageVersion.path); + if (!basename.startsWith(packageName)) { + continue; + } + final versionString = basename.substring(packageName.length + 1 /* - */); + allVersions.add(Version.parse(versionString)); + } + if (allVersions.isEmpty) { + return null; + } + final latestVersion = maxBy(allVersions, (v) => v)!; + final path = p.join( + packageDir.path, + '$packageName-${latestVersion.canonicalizedVersion}', + ); + return '$path/'; // Ensure it ends with a slash + } + + /// Runs `pub cache add` for each package in [packagesToFix]. + /// + /// Returns the exit codes and output for each package. + Future> hydrate() async { + final results = <(int, String)>[]; + for (final package in packagesToFix.entries) { + // Run serially to avoid flutter lock + final result = await processManager + .start([ + Sdk.current.sdkType.name, + 'pub', + 'cache', + 'add', + package.key, + '--version', + package.value, + '--all', + ]) + .then((process) async { + final combinedOutput = StringBuffer(); + process.captureStdout( + sink: (line) { + _logger.finest(line); + combinedOutput.writeln(line); + }, + ); + process.captureStderr( + sink: (line) { + _logger.finest(line); + combinedOutput.writeln(line); + }, + ); + return (await process.exitCode, combinedOutput.toString()); + }); + results.add(result); + } + return results; + } + + /// Fixes the pubspec for each package in [packagesToFix]. + /// + /// Returns the number of packages fixed. + Future fix({@visibleForTesting bool throwOnError = false}) async { + final cachePath = _cachePath ??= findCachePath(); + if (cachePath == null) { + if (throwOnError) { + throw Exception('Could not find the pub cache.'); + } + _logger.finest('No pub cache found. Skipping fix.'); + return 0; + } + _logger.finest('Pub cache found at $cachePath'); + final cacheDir = localFileSystem.directory(cachePath); + if (!cacheDir.existsSync()) { + if (throwOnError) { + throw Exception('No pub cache found at $cachePath.'); + } + _logger.finest('No pub cache found at $cachePath. Skipping fix.'); + return 0; + } + final hostedPubDevDir = cacheDir + .childDirectory('hosted') + .childDirectory('pub.dev'); + if (!hostedPubDevDir.existsSync()) { + if (throwOnError) { + throw Exception('No pub cache found at ${hostedPubDevDir.path}.'); + } + _logger.finest( + 'No pub cache found at ${hostedPubDevDir.path}. ' + 'Skipping fix.', + ); + return 0; + } + var fixed = 0; + await for (final packageDir + in hostedPubDevDir.list().whereType()) { + var fixPackage = false; + for (final packageToFix in packagesToFix.keys) { + if (p.basename(packageDir.path).startsWith('$packageToFix-')) { + fixPackage = true; + break; + } + } + if (!fixPackage) { + continue; + } + final pubspecFile = packageDir.childFile('pubspec.yaml'); + if (!pubspecFile.existsSync()) { + if (throwOnError) { + throw Exception('No pubspec found in ${packageDir.path}.'); + } + _logger.finest('No pubspec found in ${packageDir.path}. Skipping fix.'); + continue; + } + final pubspecYaml = await pubspecFile.readAsString(); + final pubspec = Pubspec.parse(pubspecYaml); + if (!packagesToFix.containsKey(pubspec.name)) { + if (throwOnError) { + throw Exception('Pubspec for ${pubspec.name} does not need fixing.'); + } + continue; + } + final needsEnvFix = pubspec.environment.containsKey('flutter'); + final needsDepsFix = pubspec.dependencies.containsKey('flutter'); + if (!needsEnvFix && !needsDepsFix) { + continue; + } + final editor = YamlEditor(pubspecYaml); + if (needsEnvFix) { + editor.remove(['environment', 'flutter']); + } + if (needsDepsFix) { + editor.remove(['dependencies', 'flutter']); + } + await pubspecFile.writeAsString(editor.toString()); + _logger.finest('Fixed pubspec for ${pubspec.name} in ${packageDir.path}'); + fixed++; + } + return fixed; + } + + @visibleForTesting + Future repair() async { + return processManager.run([Sdk.current.dart, 'pub', 'cache', 'repair']); + } +} diff --git a/apps/cli/lib/pub/pub_dependency.dart b/apps/cli/lib/pub/pub_dependency.dart new file mode 100644 index 000000000..256c95dec --- /dev/null +++ b/apps/cli/lib/pub/pub_dependency.dart @@ -0,0 +1,61 @@ +import 'package:pub_semver/pub_semver.dart'; +import 'package:pub_semver/src/version_range.dart'; +import 'package:pubspec_parse/pubspec_parse.dart'; +import 'package:yaml/yaml.dart'; +import 'package:yaml_edit/yaml_edit.dart'; + +extension DependencyToYaml on Dependency { + YamlNode toYaml() => switch (this) { + HostedDependency(:final version, :final hosted?) => _map({ + 'version': version.toYaml(), + 'hosted': YamlMap.wrap({ + 'name': hosted.name, + if (hosted.url case final url?) 'url': url.toString(), + }), + }), + HostedDependency(:final version) => version.toYaml(), + PathDependency(:final path) => _map({ + 'path': YamlScalar.wrap( + path, + style: + path.contains(' ') ? ScalarStyle.SINGLE_QUOTED : ScalarStyle.PLAIN, + ), + }), + SdkDependency(:final sdk) => _map({'sdk': sdk}), + GitDependency(:final url, :final ref, :final path) => _map({ + 'git': _map({ + 'url': url.toString(), + if (ref != null) 'ref': ref, + if (path != null) 'path': path, + }), + }), + }; + + YamlMap _map(Map nodes) { + return wrapAsYamlNode( + nodes.map( + (key, value) => MapEntry( + key is YamlNode ? key : YamlScalar.wrap(key), + switch (value) { + YamlScalar(value: List() || Map()) => value.value, + YamlScalar(value: YamlScalar()) => value.value, + _ => value, + }, + ), + ), + collectionStyle: CollectionStyle.BLOCK, + ) + as YamlMap; + } +} + +extension VersionConstraintToYaml on VersionConstraint { + YamlScalar toYaml() => YamlScalar.wrap( + toString(), + style: switch (this) { + CompatibleWithVersionRange() || Version() => ScalarStyle.PLAIN, + VersionRange() => ScalarStyle.SINGLE_QUOTED, + _ => ScalarStyle.PLAIN, + }, + ); +} diff --git a/apps/cli/lib/pub/pub_environment.dart b/apps/cli/lib/pub/pub_environment.dart new file mode 100644 index 000000000..0d71458e1 --- /dev/null +++ b/apps/cli/lib/pub/pub_environment.dart @@ -0,0 +1,9 @@ +import 'package:celest_cli/src/sdk/versions.dart'; +import 'package:pub_semver/pub_semver.dart'; + +abstract final class PubEnvironment { + /// The version of the Dart SDK that this version of the CLI is compatible + /// with. + static final VersionConstraint dartSdkConstraint = + VersionConstraint.compatibleWith(minSupportedDartSdk); +} diff --git a/apps/cli/lib/pub/pubspec.dart b/apps/cli/lib/pub/pubspec.dart new file mode 100644 index 000000000..237d4644c --- /dev/null +++ b/apps/cli/lib/pub/pubspec.dart @@ -0,0 +1,135 @@ +import 'package:celest_cli/pub/pub_dependency.dart'; +import 'package:collection/collection.dart'; +import 'package:pub_semver/pub_semver.dart'; +import 'package:pubspec_parse/pubspec_parse.dart'; +import 'package:yaml/yaml.dart'; +import 'package:yaml_edit/yaml_edit.dart'; + +enum DependencyType { + dependency('dependencies'), + dependencyOverride('dependency_overrides'), + devDependency('dev_dependencies'); + + const DependencyType(this.key); + + final String key; +} + +extension PubspecCopyWith on Pubspec { + Pubspec copyWith({ + String? name, + Version? version, + String? description, + String? publishTo, + Uri? repository, + Uri? issueTracker, + Map? environment, + Map? dependencies, + Map? devDependencies, + Map? dependencyOverrides, + Map? flutter, + }) { + return Pubspec( + name ?? this.name, + version: version ?? this.version, + description: description ?? this.description, + repository: repository ?? this.repository, + issueTracker: issueTracker ?? this.issueTracker, + publishTo: publishTo ?? this.publishTo, + environment: environment ?? this.environment, + dependencies: dependencies ?? this.dependencies, + devDependencies: devDependencies ?? this.devDependencies, + dependencyOverrides: dependencyOverrides ?? this.dependencyOverrides, + flutter: flutter ?? this.flutter, + ); + } + + Pubspec addDeps({ + Map? dependencies, + Map? devDependencies, + Map? dependencyOverrides, + }) { + return copyWith( + dependencies: {...this.dependencies, ...?dependencies}, + devDependencies: {...this.devDependencies, ...?devDependencies}, + dependencyOverrides: { + ...this.dependencyOverrides, + ...?dependencyOverrides, + }, + ); + } +} + +extension PubspecToYaml on Pubspec { + String toYaml({String? source}) { + final pubspecYaml = StringBuffer(''' +name: $name +'''); + if (description != null) { + pubspecYaml.writeln('description: $description'); + } + if (publishTo != null) { + pubspecYaml.writeln('publish_to: $publishTo'); + } + final yaml = StringBuffer(''' +$pubspecYaml +environment: + sdk: + +dependencies: +'''); + if (devDependencies.isNotEmpty) { + yaml.writeln(); + yaml.writeln('dev_dependencies:'); + } + if (dependencyOverrides.isNotEmpty) { + yaml + ..writeln() + ..writeln('dependency_overrides:'); + } + final editor = YamlEditor(source ?? yaml.toString()); + for (final key in environment.keys.sorted()) { + editor.update(['environment', key], environment[key]!.toYaml()); + } + + void addConstraints( + Map constraints, + DependencyType type, + ) { + final dependencyMap = {}; + for (final dependency in constraints.keys.sorted()) { + var hasDependency = true; + final currentValue = + editor + .parseAt( + [type.key, dependency], + orElse: () { + hasDependency = false; + return YamlScalar.wrap(null); + }, + ) + .value; + + // Fixes an issue where if a dependency was specified with a null + // constraint, e.g. `test:` instead of `test: ^1.0.0`, the edit + // operation will produce invalid YAML. + if (hasDependency && currentValue == null) { + editor.remove([type.key, dependency]); + } + dependencyMap[dependency] = constraints[dependency]!.toYaml(); + } + + editor.update([ + type.key, + ], wrapAsYamlNode(dependencyMap, collectionStyle: CollectionStyle.BLOCK)); + } + + addConstraints(dependencies, DependencyType.dependency); + addConstraints(devDependencies, DependencyType.devDependency); + if (dependencyOverrides.isNotEmpty) { + addConstraints(dependencyOverrides, DependencyType.dependencyOverride); + } + + return editor.toString(); + } +} diff --git a/apps/cli/lib/serialization/common.dart b/apps/cli/lib/serialization/common.dart new file mode 100644 index 000000000..05120d860 --- /dev/null +++ b/apps/cli/lib/serialization/common.dart @@ -0,0 +1,61 @@ +import 'package:analyzer/dart/element/type.dart'; +import 'package:celest_cli/src/context.dart'; +import 'package:celest_cli/src/types/dart_types.dart'; +import 'package:celest_cli/src/types/type_checker.dart'; +import 'package:code_builder/code_builder.dart'; + +/// Supported Dart SDK + core types which have built-in serialization support. +final builtInTypeChecker = TypeChecker.any([ + DartTypes.core.bigInt.checker, + DartTypes.core.dateTime.checker, + DartTypes.core.duration.checker, + DartTypes.core.regExp.checker, + DartTypes.core.stackTrace.checker, + DartTypes.core.uri.checker, + DartTypes.core.uriData.checker, + DartTypes.typedData.uint8List.checker, + // TODO(dnys1): Allow passing raw Request/Response objects. + // DartTypes.shelf.request.checker, + // DartTypes.shelf.response.checker, +]); + +/// Built-in types with their corresponding [Reference]s. +Map get builtInTypeToReference => { + typeHelper.coreTypes.coreBigIntType: DartTypes.core.bigInt, + typeHelper.coreTypes.dateTimeType: DartTypes.core.dateTime, + typeHelper.coreTypes.durationType: DartTypes.core.duration, + typeHelper.coreTypes.coreRegExpType: DartTypes.core.regExp, + typeHelper.coreTypes.coreStackTraceType: DartTypes.core.stackTrace, + typeHelper.coreTypes.coreUriType: DartTypes.core.uri, + typeHelper.coreTypes.coreUriDataType: DartTypes.core.uriData, + typeHelper.coreTypes.typedDataUint8ListType: DartTypes.typedData.uint8List, +}; + +/// Built-in types with their corresponding [DartType]s. +Map get builtInReferenceToType => { + DartTypes.core.bigInt: typeHelper.coreTypes.coreBigIntType, + DartTypes.core.dateTime: typeHelper.coreTypes.dateTimeType, + DartTypes.core.duration: typeHelper.coreTypes.durationType, + DartTypes.core.regExp: typeHelper.coreTypes.coreRegExpType, + DartTypes.core.stackTrace: typeHelper.coreTypes.coreStackTraceType, + DartTypes.core.uri: typeHelper.coreTypes.coreUriType, + DartTypes.core.uriData: typeHelper.coreTypes.coreUriDataType, + DartTypes.typedData.uint8List: typeHelper.coreTypes.typedDataUint8ListType, +}; + +/// The [DartType] of `Map`. +DartType get jsonMapType => typeHelper.typeProvider.mapType( + typeHelper.typeProvider.stringType, + typeHelper.typeProvider.objectQuestionType, +); + +/// Valid types for injected env variables. +final validEnvTypes = TypeChecker.any([ + DartTypes.core.bool.checker, + DartTypes.core.double.checker, + DartTypes.core.int.checker, + DartTypes.core.num.checker, + DartTypes.core.string.checker, + DartTypes.core.uri.checker, + DartTypes.typedData.uint8List.checker, +]); diff --git a/apps/cli/lib/serialization/from_string_generator.dart b/apps/cli/lib/serialization/from_string_generator.dart new file mode 100644 index 000000000..20ef0068d --- /dev/null +++ b/apps/cli/lib/serialization/from_string_generator.dart @@ -0,0 +1,84 @@ +import 'package:analyzer/dart/element/type.dart'; +import 'package:celest_cli/src/context.dart'; +import 'package:celest_cli/src/types/dart_types.dart'; +import 'package:celest_cli/src/utils/error.dart'; +import 'package:celest_cli/src/utils/reference.dart'; +import 'package:code_builder/code_builder.dart'; + +Expression _fromString(Reference type, Expression ref) { + final dartType = typeHelper.fromReference(type); + if (dartType.isDartCoreBool) { + return DartTypes.core.bool.property('parse').call([ref]); + } + if (dartType.isDartCoreDouble) { + return DartTypes.core.double.property('parse').call([ref]); + } + if (dartType.isDartCoreInt) { + return DartTypes.core.int.property('parse').call([ref]); + } + if (dartType.isDartCoreNum) { + return DartTypes.core.num.property('parse').call([ref]); + } + if (dartType.isDartCoreString) { + return ref; + } + if (dartType.isDartCoreObject) { + return ref; + } + if (type.symbol == 'Uri') { + return DartTypes.core.uri.property('parse').call([ref]); + } + if (type.symbol == 'DateTime') { + return DartTypes.core.dateTime.property('parse').call([ref]); + } + unreachable('Unsupported type: $type'); +} + +Expression fromString( + Reference type, + Expression ref, { + Expression? defaultValue, +}) { + var fromString = _fromString(type, ref); + if (defaultValue != null) { + fromString = fromString.parenthesized.ifNullThen(defaultValue); + } + return fromString; +} + +Expression _toString(Reference type, Expression ref) { + final dartType = typeHelper.fromReference(type); + if (dartType.isDartCoreList) { + if ((dartType as InterfaceType).typeArguments.first.isDartCoreString) { + return ref; + } + return ref + .property('map') + .call([ + Method( + (m) => + m + ..requiredParameters.add(Parameter((p) => p..name = 'el')) + ..body = + _toString( + type.toTypeReference.types.single, + refer('el'), + ).code + ..lambda = true, + ).closure, + ]) + .property('toList') + .call([]); + } + if (type.symbol == 'DateTime') { + return ref.property('toIso8601String').call([]); + } + if (dartType.isDartCoreString) { + return ref; + } + return ref.property('toString').call([]); +} + +Expression generateToString(Reference type, Expression ref) { + return _toString(type, ref); +} diff --git a/apps/cli/lib/serialization/is_serializable.dart b/apps/cli/lib/serialization/is_serializable.dart new file mode 100644 index 000000000..a44fc6c8a --- /dev/null +++ b/apps/cli/lib/serialization/is_serializable.dart @@ -0,0 +1,1260 @@ +import 'dart:collection'; + +import 'package:analyzer/dart/element/element.dart'; +import 'package:analyzer/dart/element/nullability_suffix.dart'; +import 'package:analyzer/dart/element/type.dart'; +import 'package:analyzer/dart/element/type_visitor.dart'; +import 'package:analyzer/src/dart/element/inheritance_manager3.dart'; +import 'package:analyzer/src/dart/element/member.dart'; +import 'package:analyzer/src/dart/element/type_algebra.dart'; +import 'package:celest_cli/serialization/common.dart'; +import 'package:celest_cli/serialization/serialization_spec.dart'; +import 'package:celest_cli/serialization/serialization_verdict.dart'; +import 'package:celest_cli/src/context.dart'; +import 'package:celest_cli/src/types/type_checker.dart'; +import 'package:celest_cli/src/utils/analyzer.dart'; +import 'package:celest_cli/src/utils/error.dart'; +import 'package:celest_cli/src/utils/run.dart'; +import 'package:collection/collection.dart'; + +enum TypePosition { parameter, return$ } + +/// Determines whether a [DartType] can be serialized to/from JSON. +/// +/// - Be a simple JSON type (bool, double, int, String, null, Object) +/// - Be an enum +/// - Be a supported Dart SDK type +/// - Be a class with a constructor named `fromJson` that takes a single +/// required parameter whose type is `Map`. +/// - Be a class with a method named `toJson` that takes no required parameters. +/// - Be a class which: has fields of the above types, has a constructor with +/// all fields present. For these classes, we generate custom serialization +/// code. +final class IsSerializable extends TypeVisitor { + const IsSerializable(); + + Verdict? _isSimpleJson(DartType type) { + if (type is! InterfaceType) { + // Cannot make a verdict. + return null; + } + if (type.isDartCoreBool || + type.isDartCoreDouble || + type.isDartCoreInt || + type.isDartCoreNum || // TODO(dnys1): test + type.isDartCoreString || + type.isDartCoreNull) { + return const Verdict.yes(); + } + if (type.isDartCoreEnum) { + return const VerdictNo([ + VerdictReason('Untyped enums are not supported'), + ]); + } + if (type.isDartCoreSet) { + return const VerdictNo([VerdictReason('Set types are not supported')]); + } + if (type.isDartCoreSymbol) { + return const VerdictNo([VerdictReason('Symbol types are not supported')]); + } + if (type.isDartCoreType) { + return const VerdictNo([ + VerdictReason('Type literals are not supported'), + ]); + } + // Cannot make a verdict. + return null; + } + + Verdict _isJson(DartType type) { + const invalidJson = VerdictNo([VerdictReason('Type is not valid JSON')]); + if (type is! InterfaceType) { + return invalidJson; + } + if (_isSimpleJson(type) case final verdict?) { + return verdict; + } + if (type.isDartCoreObject) { + return const Verdict.yes(); + } + if (type.isDartCoreIterable || type.isDartCoreList) { + return _isJson(type.typeArguments.single); + } + if (type.isDartCoreMap) { + final [keyType, valueType] = type.typeArguments; + if (!keyType.isDartCoreString) { + return const VerdictNo([VerdictReason('Map keys must be strings')]); + } + return switch (valueType) { + // This is the only case where `Object`/`dynamic` are allowed. + InterfaceType(isDartCoreObject: true) || + DynamicType() => const Verdict.yes(), + _ => _isJson(valueType), + }; + } + return invalidJson; + } + + @override + Verdict visitDynamicType(DynamicType type) => const VerdictYes(); + + @override + Verdict visitFunctionType(FunctionType type) => + const VerdictNo([VerdictReason('Function types are not supported')]); + + // Most logic for `_checkCustomDeserializer` and `_checkCustomSerializer` is + // pulled from `package:json_serializable/src/type_helpers/json_helper.dart`. + + Verdict _checkCustomDeserializer( + InterfaceType type, + ExecutableElement fromJsonCtor, + DartType wireType, + ) { + if (fromJsonCtor is! ConstructorElement) { + if (!identical(fromJsonCtor.returnType, type)) { + return Verdict.no( + 'The return type of ${type.element.name}\'s fromJson constructor ' + 'must be ${type.element.name}.', + ); + } + } + + // Using the `declaration` here so we get the original definition – + // and not one with the generics already populated. + // + // For example, if `type` is `IList`, then `fromJsonCtor` will + // have its parameter with type `Object Function(String) fromJsonT` and + // `fromJsonCtor.declaration` will have its parameter with type + // `Object Function(T) fromJsonT`. + fromJsonCtor = fromJsonCtor.declaration; + + final positionalParameters = + fromJsonCtor.parameters + .where((parameter) => parameter.isPositional) + .toList(); + final namedParameters = + fromJsonCtor.parameters + .where((parameter) => parameter.isNamed) + .toList(); + if (positionalParameters.isEmpty) { + final functionSignature = + 'factory ${type.element.name}.fromJson(${wireType.getDisplayString()} json)'; + return Verdict.no( + 'The fromJson constructor of type ${type.element.name} must have ' + 'one required, positional parameter whose type matches the return ' + 'type of its toJson method, e.g. $functionSignature', + location: fromJsonCtor.sourceLocation, + ); + } + final requiredNamedParameters = namedParameters.where((p) => p.isRequired); + if (requiredNamedParameters.isNotEmpty) { + final parameter = requiredNamedParameters.first; + return Verdict.no( + 'The fromJson constructor of ${type.element.name} has an unexpected ' + 'parameter: ${parameter.name}. FromJson constructors can only have ' + 'positional parameters or optional named parameters.', + location: parameter.sourceLocation, + ); + } + + String fromJsonForName(String genericType) => 'fromJson$genericType'; + + final parameters = Queue.of(fromJsonCtor.parameters); + final requiredParam = parameters.removeFirst(); + if (requiredParam.isOptional) { + return Verdict.no( + 'The fromJson constructor of type ${type.element.name} must have ' + 'one required, positional parameter.', + location: fromJsonCtor.sourceLocation, + ); + } + switch (wireType) { + case DartType(isDartCoreObject: true) || DynamicType(): + case _ + when typeHelper.typeSystem.isAssignableTo( + wireType, + requiredParam.type, + ): + // OK, will cast in serializer. + break; + default: + return Verdict.no( + 'The parameter type of ${type.element.name}\'s fromJson constructor ' + 'must be assignable to $wireType.', + location: fromJsonCtor.sourceLocation, + ); + } + + var verdict = const Verdict.yes(); + for (final parameter in parameters.where((p) => p.isPositional)) { + switch (parameter.type) { + case FunctionType( + returnType: final TypeParameterType funcReturnType, + normalParameterTypes: [ + DynamicType() || + DartType( + isDartCoreObject: true, + nullabilitySuffix: NullabilitySuffix.question, + ), + ], + ): + final expectedCtorParamName = fromJsonForName( + funcReturnType.element.name, + ); + if (parameter.name != expectedCtorParamName) { + verdict &= Verdict.no( + 'The parameter "${parameter.name}" of ${type.element.name}\'s ' + 'fromJson constructor must be named "$expectedCtorParamName".', + location: parameter.sourceLocation, + ); + } + default: + return Verdict.no( + 'The fromJson constructor of ${type.element.name} has an unexpected ' + 'parameter: ${parameter.name}. The only extra parameters allowed are ' + 'functions of the form `T Function(Object?) fromJsonT` where `T` is ' + 'a type parameter of ${type.element.name}.', + location: parameter.sourceLocation, + ); + } + } + + return verdict; + } + + Verdict _checkCustomSerializer( + InterfaceType type, + MethodElement toJsonMethod, + ) { + String toJsonForName(String genericType) => 'toJson$genericType'; + + // Using the `declaration` here so we get the original definition – + // and not one with the generics already populated. + // + // For example, if `type` is `IList`, then `toJsonMethod` will + // be `Object Function(String) toJsonT` and `toJsonMethod.declaration` + // will be `Object Function(T) toJsonT`. + toJsonMethod = toJsonMethod.declaration; + + var verdict = const Verdict.yes(); + for (final parameter in toJsonMethod.parameters) { + switch (parameter.type) { + case FunctionType( + returnType: DartType(isDartCoreObject: true) || DynamicType(), + normalParameterTypes: [final TypeParameterType funcParameterType], + ): + final expectedFuncParamName = toJsonForName( + funcParameterType.element.name, + ); + if (parameter.name != expectedFuncParamName) { + verdict &= Verdict.no( + 'The parameter "${parameter.name}" of ${type.element.name}\'s ' + 'toJson method must be named "$expectedFuncParamName".', + location: parameter.sourceLocation, + ); + } + case _ when parameter.isPositional || parameter.isRequired: + return Verdict.no( + 'The toJson method of ${type.element.name} has an unexpected ' + 'parameter: ${parameter.name}. The only parameters allowed are ' + 'functions of the form `Object Function(T) toJsonT` where `T` is ' + 'a type parameter of ${type.element.name}.', + location: parameter.sourceLocation, + ); + } + } + final returnType = toJsonMethod.returnType; + verdict &= switch (_isJson(returnType)) { + VerdictYes() => const Verdict.yes(), + _ => Verdict.no( + 'Invalid return type of ${type.element.name}\'s toJson method: ' + '$returnType. Only simple JSON types are allowed.', + location: toJsonMethod.sourceLocation, + ), + }; + return verdict; + } + + Verdict _visitExtensionType( + InterfaceType type, + ExtensionTypeElement element, + ) { + final erasureType = type.extensionTypeErasure; + // Do not go through type helper since it will swap out `erasureType` for + // the extension type override (`type`) if there is one, causing stack overflow. + var erasureVerdict = erasureType.accept(this); + // If it's a no but only because it is not allowed as a raw JSON type, then + // allow it if it's a JsonX type from package:celest. + if (erasureVerdict is VerdictNo) { + final jsonVerdict = _isJson(erasureType); + if (jsonVerdict is VerdictYes && type.isJsonExtensionType) { + erasureVerdict = jsonVerdict; + } + } + switch (erasureVerdict) { + case VerdictNo(): + return VerdictNo([ + VerdictReason( + 'The representation type of ${element.name} is not serializable', + location: element.sourceLocation, + ), + ...erasureVerdict.reasons, + ]); + case VerdictYes(primarySpec: final erasurePrimaySpec): + if (erasurePrimaySpec != null) { + final verdict = _visitCustomInterfaceType(type); + return switch (verdict) { + VerdictNo() => verdict, + // ignore: unnecessary_null_checks + VerdictYes(:final primarySpec!, :final additionalSpecs) => + Verdict.yes( + primarySpec: + primarySpec..representationType = erasurePrimaySpec.erased, + additionalSpecs: { + // Create a representation type spec which has no fromJson/toJson + // methods but which carries the correct wire type. + if (!type.isOverridden) + erasurePrimaySpec.copyWith( + wireType: primarySpec.wireType, + castType: primarySpec.castType, + toJsonType: null, + fromJsonType: null, + fromJsonParameters: const [], + ), + ...additionalSpecs, + ...erasureVerdict.additionalSpecs, + }, + ), + }; + } + // If primarySpec is null, then this is a builtin interface type and + // we must create the serialization spec for it. + ConstructorElement? constructor; + if (element.primaryConstructor.name.isEmpty && + !element.primaryConstructor.isPrivate) { + constructor = element.primaryConstructor; + } else { + constructor = element.constructors.firstWhereOrNull((ctor) { + if (ctor.name.isNotEmpty || ctor.isPrivate) { + return false; + } + if (ctor.parameters case [final parameter] + when TypeChecker.fromStatic( + parameter.type, + ).isExactlyType(erasureType)) { + return true; + } + return false; + }); + } + final (:toJsonMethod, :fromJsonCtor, wireType: _) = + type.interfaceMembers; + // The representation type is either a built-in or a primitive at + // this point. + final wireType = + builtInTypeToReference[erasureType] ?? + typeHelper.toReference(erasureType); + return erasureVerdict.withPrimarySpec( + SerializationSpec( + type: type, + wireType: wireType, + fields: [ + if (element.representation.isPublic) + FieldSpec( + name: element.representation.name, + type: element.representation.type, + ), + ], + wireConstructor: constructor, + constructorParameters: constructor.parameterSpecs, + fromJsonParameters: fromJsonCtor.parameterSpecs, + fromJsonType: fromJsonCtor?.returnType as InterfaceType?, + toJsonType: + (toJsonMethod?.enclosingElement3 as InterfaceElement?) + ?.thisType, + representationType: SerializationSpec( + type: erasureType, + wireType: wireType, + wireConstructor: null, + fromJsonType: null, + toJsonType: null, + ), + ), + ); + } + } + + Verdict _visitCustomInterfaceType(InterfaceType type) { + final element = type.element; + final (:toJsonMethod, :fromJsonCtor, :wireType) = type.interfaceMembers; + + // Check if non-SDK class is serializable. + // + // Either it has its own fromJson/toJson methods, or it meets the + // requirements needed to generate implementations. + var verdict = const Verdict.yes(); + + // Check type arguments + // TODO(dnys1): Check bad arguments + for (final typeArgument in type.typeArguments) { + verdict &= typeHelper.isSerializable(typeArgument); + } + + // Check toJson + final hasToJson = toJsonMethod != null; + if (hasToJson) { + verdict &= _checkCustomSerializer(type, toJsonMethod); + } else if (!type.extensionTypeErasure.isEnumLike) { + // When no toJson method is provided, we must check the representation + // type's fields and constructor, even if this is an extension type, since + // we will just cast into the extension type at the end, but we only have + // access to all fields and constructors on the representation type. + verdict &= type.extensionTypeErasure.accept( + const _IsSerializableClass(TypePosition.return$), + ); + } + + // Check fromJson + final hasFromJson = fromJsonCtor != null; + if (hasFromJson) { + verdict &= _checkCustomDeserializer(type, fromJsonCtor, wireType); + } else if (!type.extensionTypeErasure.isEnumLike) { + // Same rationale as the toJson check re: erasure type. + verdict &= type.extensionTypeErasure.accept( + const _IsSerializableClass(TypePosition.parameter), + ); + } + final wireConstructor = type.wireConstructor; + if (wireConstructor == null && fromJsonCtor == null && !type.isEnumLike) { + return verdict & + Verdict.no( + 'Class ${element.displayName} must have an unnamed constructor ' + 'with the same number of parameters as fields or a `fromJson` ' + 'constructor.', + location: element.sourceLocation, + isBecauseOfFlutter: type.isFlutterType, + ); + } + + final spec = SerializationSpec( + type: type, + wireType: typeHelper.toReference(wireType), + castType: fromJsonCtor?.parameters.first.type.let(typeHelper.toReference), + fields: type.fieldSpecs, + wireConstructor: wireConstructor, + constructorParameters: wireConstructor.parameterSpecs, + fromJsonParameters: fromJsonCtor.parameterSpecs, + fromJsonType: fromJsonCtor?.returnType as InterfaceType?, + toJsonType: + (toJsonMethod?.enclosingElement3 as InterfaceElement?)?.thisType, + ); + verdict = verdict.withPrimarySpec(spec); + + if (type.isEnumLike) { + return verdict; + } + + InterfaceType instantiateSubtype(InterfaceType subtype) { + final superParameters = type.element.typeParameters; + final superArguments = type.typeArguments; + assert(superParameters.length == superArguments.length); + for (final subtypeSupertype in subtype.allSupertypes) { + if (subtypeSupertype.element.declaration == type.element) { + final substitutionMap = {}; + final subtypeSuperArgs = subtypeSupertype.typeArguments; + for (var i = 0; i < subtypeSuperArgs.length; i++) { + final subParameter = subtypeSuperArgs[i].element; + if (subParameter is TypeParameterElement) { + substitutionMap[subParameter] = superArguments[i]; + } + } + return Substitution.fromMap( + substitutionMap, + ).mapInterfaceType(subtype); + } + } + unreachable(); + } + + final subtypes = [ + for (final subtype + in typeHelper.subtypes[type.element] ?? const []) + switch (subtype) { + InterfaceType(:final typeArguments) when typeArguments.isNotEmpty => + instantiateSubtype(subtype), + _ => subtype, + }, + ]; + for (final subtype in subtypes) { + final subtypeVerdict = typeHelper.isSerializable(subtype); + switch (subtypeVerdict) { + case VerdictNo(): + verdict &= subtypeVerdict; + case VerdictYes(:final primarySpec, :final additionalSpecs): + final serializationSpecs = [ + if (primarySpec != null) primarySpec, + ...additionalSpecs, + ]; + for (final subtypeSpec in serializationSpecs) { + if (subtypes.contains(subtypeSpec.type)) { + final subtypeWireType = typeHelper.fromReference( + subtypeSpec.wireType, + ); + if (!TypeChecker.fromStatic( + jsonMapType, + ).isExactlyType(subtypeWireType)) { + verdict &= Verdict.no( + 'All classes in a sealed class hierarchy must use ' + 'Map as their wire type but ' + '${subtypeSpec.type.element!.name!} uses ' + '${subtypeWireType.getDisplayString()}', + ); + } + spec.subtypes.add(subtypeSpec..parent = spec); + } else { + verdict = verdict.withAdditionalSpec(subtypeSpec); + } + } + } + } + + return verdict; + } + + @override + Verdict visitInterfaceType(InterfaceType type) { + // TODO(dnys1): Test private aliases + if (type.element.isPrivate) { + return Verdict.no( + 'Private types are not supported', + location: type.element.sourceLocation, + ); + } + + // Extension types are always represented as an InterfaceType over their + // erasure, which may not be an interface type. + if (type.element case final ExtensionTypeElement extensionType) { + return _visitExtensionType(type, extensionType); + } + + if (_isSimpleJson(type) case final verdict?) { + return verdict; + } + + if (type.isDartCoreObject) { + return const Verdict.yes(); + } + if (type.isDartCoreIterable || type.isDartCoreList) { + return typeHelper.isSerializable(type.typeArguments.single); + } + if (type.isDartCoreMap) { + final [keyType, valueType] = type.typeArguments; + if (!keyType.isDartCoreString) { + return Verdict.no('Map keys must be strings'); + } + return switch (valueType) { + // This is the only case where `Object`/`dynamic` are allowed. + // + // Even though we have `JsonMap` type now, `package:json_serializable` + // and others allow Map and this allows for a cleaner + // migration path from using those types with Celest. + InterfaceType(isDartCoreObject: true) || + DynamicType() => const Verdict.yes(), + _ => typeHelper.isSerializable(valueType), + }; + } + if (type.isDartAsyncStream) { + return const VerdictNo([ + VerdictReason('Stream types are not supported in this position'), + ]); + } + + // TODO(dnys1): Test + // TODO(dnys1): Test for extends/implements these types + // TODO(dnys1): Test for extends/implements these types w/ custom serde + if (builtInTypeChecker.isExactlyType(type)) { + return const Verdict.yes(); + } + + if (!typeHelper.seen.add(type)) { + // Cycle detected. If there is a level of indirection, this is okay. + // We have this check to prevent stack overflow, and ensure a proper level + // of indirection in [_IsSerializableClass] below. + return const Verdict.yes(); + } + + return _visitCustomInterfaceType(type); + } + + @override + Verdict visitInvalidType(InvalidType type) => + const VerdictNo([VerdictReason('Invalid type')]); + + @override + Verdict visitNeverType(NeverType type) => + const VerdictNo([VerdictReason('Never types are not supported')]); + + @override + Verdict visitRecordType(RecordType type) { + if (type.positionalFields.isNotEmpty) { + // TODO(dnys1): Remove this limitation. Follow package:json_serializable format. + return Verdict.no( + 'Positional fields are not supported in record types', + location: type.alias?.element.sourceLocation, + ); + } + var verdict = Verdict.yes( + primarySpec: SerializationSpec( + type: type, + wireType: typeHelper.toReference(jsonMapType), + fields: [ + for (final field in type.namedFields) + FieldSpec(name: field.name, type: field.type), + ], + wireConstructor: null, + constructorParameters: [ + for (final field in type.namedFields) + ParameterSpec( + name: field.name, + type: field.type, + isPositional: false, + isNamed: true, + isOptional: false, + defaultValue: null, + ), + ], + fromJsonType: null, + toJsonType: null, + ), + ); + for (final field in type.namedFields) { + verdict &= typeHelper.isSerializable(field.type); + } + return verdict; + } + + @override + Verdict visitTypeParameterType(TypeParameterType type) { + // TODO(dnys1): Tests for different branches + switch (type.bound) { + case InterfaceType(:final ClassElement element) when element.isSealed: + analytics.capture( + 'type_parameter', + properties: {'type': type.getDisplayString(), 'bound': 'sealed'}, + ); + return typeHelper.isSerializable(type.bound); + case DynamicType(): + analytics.capture( + 'type_parameter', + properties: {'type': type.getDisplayString(), 'bound': 'unbounded'}, + ); + return const Verdict.yes(); + default: + analytics.capture( + 'type_parameter', + properties: {'type': type.getDisplayString(), 'bound': 'other'}, + ); + return VerdictNo([ + VerdictReason( + 'Unsupported generic bound: ${type.bound}. Only sealed classes ' + 'can be used as bounds.', + location: type.element.sourceLocation, + ), + ]); + } + } + + @override + Verdict visitVoidType(VoidType type) => + Verdict.no('Void types are not supported'); +} + +final class _IsSerializableClass extends TypeVisitor { + const _IsSerializableClass(this.position); + + final TypePosition position; + + @override + Verdict visitDynamicType(DynamicType type) => unreachable('Not a class type'); + + @override + Verdict visitFunctionType(FunctionType type) => + unreachable('Not a class type'); + + Verdict _visitClass(InterfaceType type, ClassElement element) { + var verdict = const Verdict.yes(); + final unnamedConstructor = type.wireConstructor; + var constructorVerdict = const Verdict.yes(); + + if (unnamedConstructor == null) { + constructorVerdict &= Verdict.no( + 'Class ${element.displayName} must have an unnamed constructor with ' + 'the same number of parameters as fields.', + location: element.sourceLocation, + isBecauseOfFlutter: type.isFlutterType, + ); + } else if (element.isAbstract && + !element.isSealed && + !unnamedConstructor.isFactory) { + constructorVerdict &= Verdict.no( + 'Class ${element.displayName} is abstract and must have an unnamed factory ' + 'or fromJson factory constructor to be used.', + location: element.sourceLocation, + isBecauseOfFlutter: type.isFlutterType, + ); + } + + // If the class is abstract and/or its primary constructor is redirecting, + // we need to check the fields of the redirected class since that is what + // will be instantiated. + final fields = switch (unnamedConstructor) { + ConstructorElement( + redirectedConstructor: Element( + // TODO(dnys1): This is missing some edge cases. For example, a class + // could redirect to another redirecting constructor. + enclosingElement3: final ClassElement redirectedClass, + ), + ) => + redirectedClass.sortedFields(redirectedClass.thisType), + // Special case for Exception which is basically a redirecting constructor + // but uses `=>` syntax. + _ when element.name == 'Exception' && element.library.isDartCore => + element.library + .getClass('_Exception')! + .let((impl) => impl.sortedFields(impl.thisType)), + _ => element.sortedFields(type), + }; + var fieldsVerdict = const Verdict.yes(); + for (final field in List.of(fields)) { + final (:ignoreFromJson, :ignoreToJson) = type._ignoredByJsonKey(field); + final ignore = switch (position) { + TypePosition.parameter => ignoreFromJson, + TypePosition.return$ => ignoreToJson, + }; + if (ignore) { + continue; + } + + if (const DartTypeEquality().equals(type, field.type)) { + fieldsVerdict &= Verdict.no( + 'Classes are not allowed to have fields of their own type.', + location: field.sourceLocation, + ); + continue; + } + final fieldVerdict = typeHelper.isSerializable(field.type); + switch (fieldVerdict) { + case VerdictYes(): + fieldsVerdict &= fieldVerdict; + case VerdictNo(): + // Ignore, we can't serialize. If later we determine the getter is + // needed to construct the object, we'll error then. + if (field.isSynthetic) { + fields.remove(field); + continue; + } + fieldsVerdict &= Verdict.no( + 'Field "${field.displayName}" of type "${element.displayName}" is ' + 'not serializable: $fieldVerdict', + location: field.sourceLocation, + isBecauseOfFlutter: type.isFlutterType, + ); + } + } + if (position == TypePosition.return$) { + verdict &= fieldsVerdict; + } + + if (constructorVerdict is VerdictYes) { + final parameters = unnamedConstructor!.parameters; + for (final parameter in parameters) { + final parameterField = parameter.fieldFormal(fields); + if (parameterField == null && parameter.isRequired) { + constructorVerdict &= Verdict.no( + 'Required parameter "${parameter.displayName}" cannot be ' + 'populated because it has no matching fields. Available fields: ' + '${fields.map((field) => field.name).join(', ')}', + location: parameter.sourceLocation, + isBecauseOfFlutter: type.isFlutterType, + ); + continue; + } + + final hasField = fields.any((field) { + if (parameter.name.startsWith('_')) { + return field.name == parameter.name.substring(1); + } + return field.name == parameter.name; + }); + if (!hasField) { + constructorVerdict &= Verdict.no( + 'Constructor parameter "${parameter.displayName}" is not ' + 'a field of the class ${element.displayName}.', + location: parameter.sourceLocation, + isBecauseOfFlutter: type.isFlutterType, + ); + continue; + } + } + } + + if (position == TypePosition.parameter) { + verdict &= constructorVerdict; + } + return verdict; + } + + @override + Verdict visitInterfaceType(InterfaceType type) { + final element = type.element; + if (element is! ClassElement) { + unreachable('Only classes should reach here'); + } + return _visitClass(type, element); + } + + @override + Verdict visitInvalidType(InvalidType type) => unreachable('Not a class type'); + + @override + Verdict visitNeverType(NeverType type) => unreachable('Not a class type'); + + @override + Verdict visitRecordType(RecordType type) => unreachable('Not a class type'); + + @override + Verdict visitTypeParameterType(TypeParameterType type) => + unreachable('Not a class type'); + + @override + Verdict visitVoidType(VoidType type) => unreachable('Not a class type'); +} + +typedef InterfaceMembers = + ({ + MethodElement? toJsonMethod, + ExecutableElement? fromJsonCtor, + DartType wireType, + }); + +extension on InterfaceType { + MethodElement? get toJsonMethod => switch (element) { + // Extension types always reset the toJson method to the representation + // type. + ExtensionTypeElement() => getMethod('toJson'), + _ => lookUpMethod2('toJson', element.library), + }; + + ExecutableElement? get fromJsonCtor => + lookUpConstructor('fromJson', element.library) ?? + switch (getMethod('fromJson')) { + final method? when method.isStatic => method, + _ => null, + }; + + DartType get wireType => toJsonMethod?.returnType ?? defaultWireType!; + + ConstructorElement? get wireConstructor { + if (!isOverridden) { + return constructors.firstWhereOrNull((ctor) => ctor.name.isEmpty); + } + ConstructorElement? unnamedConstructor; + final overriddenAs = asOverriden.element as ExtensionTypeElement; + unnamedConstructor = overriddenAs.constructors.firstWhereOrNull( + (ctor) => ctor.name.isEmpty && ctor != overriddenAs.primaryConstructor, + ); + final representationElement = extensionTypeErasure.element as ClassElement; + unnamedConstructor ??= representationElement.constructors.firstWhereOrNull( + (ctor) => ctor.name.isEmpty, + ); + return unnamedConstructor; + } + + /// Checks if a field is ignored by `@JsonKey(ignore: true)` or one of + /// `@JsonKey(includeToJson: false)` or `@JsonKey(includeFromJson: false)`. + ({bool ignoreToJson, bool ignoreFromJson}) _ignoredByJsonKey( + FieldElement field, + ) { + // Collect all metadata on the field up the ancestor chain. + // + // We only include the element itself, any mixins, and all superclasses. + // We do not include interfaces (e.g. `implements X`) because classes do + // not inherit metadata from interfaces. + final allMetadata = { + ...field.metadata, + if (field.getter case final getter?) ...getter.metadata, + }; + + void addMixins(InterfaceElement element) { + allMetadata.addAll( + element.mixins.expand((mixin) sync* { + final mixinField = mixin.element.getField(field.name); + if (mixinField == null) { + return; + } + yield* mixinField.metadata; + if (mixinField.getter case final getter?) { + yield* getter.metadata; + } + }), + ); + } + + addMixins(element); + + var enclosingElement = element.supertype?.element; + while (enclosingElement != null) { + if (enclosingElement.getField(field.name) case final field?) { + allMetadata.addAll(field.metadata); + if (field.getter case final getter?) { + allMetadata.addAll(getter.metadata); + } + } + addMixins(enclosingElement); + enclosingElement = enclosingElement.supertype?.element; + } + + // Check for `@JsonKey` annotations from `package:json_annotation`. + for (final annotation in allMetadata) { + final value = annotation.computeConstantValue(); + if (value == null) { + continue; + } + final isJsonKey = switch (value.type) { + final type? => identical( + type, + typeHelper.coreTypes.jsonKeyElement?.thisType, + ), + _ => false, + }; + if (!isJsonKey) { + continue; + } + // Ignore as requested. If later we determine the field is needed to + // construct the object, we'll error then. + if (value.getField('ignore')?.toBoolValue() case final ignore?) { + return (ignoreToJson: ignore, ignoreFromJson: ignore); + } + final (includeFromJson, includeToJson) = ( + value.getField('includeFromJson')?.toBoolValue() ?? true, + value.getField('includeToJson')?.toBoolValue() ?? true, + ); + return (ignoreToJson: !includeToJson, ignoreFromJson: !includeFromJson); + } + + return (ignoreToJson: false, ignoreFromJson: false); + } + + List get fieldSpecs => switch (element) { + final ClassElement element => [ + for (final field in element.sortedFields(this)) + run(() { + final (:ignoreToJson, :ignoreFromJson) = _ignoredByJsonKey(field); + return FieldSpec( + name: field.displayName, + type: field.type, + ignore: ignoreToJson || field.type.isDartCoreNull, + ); + }), + ], + EnumElement() => const [], + ExtensionTypeElement(:final representation) => [ + FieldSpec(name: representation.name, type: representation.type), + ], + _ => unreachable(), + }; + + InterfaceMembers get interfaceMembers { + switch (element) { + case EnumElement(): + return ( + toJsonMethod: toJsonMethod, + fromJsonCtor: fromJsonCtor, + wireType: wireType, + ); + case MixinElement(): + unreachable('Mixins are not supported'); + case final ClassElement _: + final serializedType = + isOverridden ? asOverriden as InterfaceType : this; + return ( + toJsonMethod: serializedType.toJsonMethod, + fromJsonCtor: serializedType.fromJsonCtor, + wireType: serializedType.wireType, + ); + case final ExtensionTypeElement _: + final representationType = extensionTypeErasure; + if (representationType is! InterfaceType) { + unreachable('Extension type erasure is not an interface type'); + } + final members = ( + // fields: [ + // // if (isOverridden) + // // ...(representationType.element as ClassElement).sortedFields(this) + // // else + // element.representation, + // ], + toJsonMethod: toJsonMethod, + fromJsonCtor: fromJsonCtor, + wireType: wireType, + ); + analytics.capture( + 'extension_type', + properties: { + 'type': getDisplayString(), + 'representationType': representationType.getDisplayString(), + 'hasToJson': members.toJsonMethod != null, + 'hasFromJson': members.fromJsonCtor != null, + }, + ); + return members; + case final unknownElement: + unreachable( + 'Unknown interface element (${unknownElement.runtimeType}): ' + '$unknownElement', + ); + } + } +} + +// Below is copied from `package:json_serializable`. + +extension on ClassElement { + static final _coreObjectUri = Uri.parse('dart:core#Object'); + static final _coreErrorUri = Uri.parse('dart:core#Error'); + + /// Fields from dart:core types which should never be serialized. + static final _coreFields = [ + Name(_coreObjectUri, 'hashCode'), + Name(_coreObjectUri, 'runtimeType'), + Name(_coreErrorUri, 'stackTrace'), + ]; + + /// Returns a [List] of all instance [FieldElement] items for this class and + /// super classes, sorted first by their location in the inheritance hierarchy + /// (super first) and then by their location in the source file. + List sortedFields(InterfaceType type) { + // Get all of the fields that need to be assigned + final elementInstanceFields = Map.fromEntries( + this.fields.where((e) => !e.isStatic && !e.isPrivate).map((e) { + final member = inheritanceManager.getMember( + type, + Name(e.library.source.uri, e.name), + ); + if (member case final PropertyAccessorMember member + when member.isGetter) { + assert(member.variable2 is FieldElement); + return MapEntry(e.name, member.variable2 as FieldElement); + } + return MapEntry(e.name, e); + }), + ); + + final inheritedFields = {}; + + const dartCoreObject = TypeChecker.fromUrl('dart:core#Object'); + if (dartCoreObject.isExactly(this)) { + return const []; + } + + final coreErrorType = TypeChecker.fromStatic( + typeHelper.coreTypes.coreErrorType, + ); + + for (final v + in inheritanceManager.getInheritedConcreteMap2(type.element).values) { + assert(v is! FieldElement); + if (dartCoreObject.isExactly(v.enclosingElement3)) { + continue; + } + if (coreErrorType.isExactly(v.enclosingElement3)) { + continue; + } + + if (v.isPrivate) { + continue; + } + + if (v is PropertyAccessorElement && v.isGetter) { + assert(v.variable2 is FieldElement); + final variable = v.variable2 as FieldElement; + assert(!inheritedFields.containsKey(variable.name)); + inheritedFields[variable.name] = variable; + } + } + + final overriddenFields = {}; + + if (thisType.isOverridden) { + final extensionType = thisType.asOverriden; + assert(extensionType.isExtensionType); + final overrideElement = extensionType.element as ExtensionTypeElement; + for (final field in overrideElement.fields) { + if (field.isStatic) { + continue; + } + assert(!overriddenFields.containsKey(field.name)); + overriddenFields[field.name] = field; + } + } + + // Get the list of all fields for `element` + final allFields = elementInstanceFields.keys.toSet().union( + inheritedFields.keys.toSet(), + ); + + final fields = + allFields + .map( + (e) => _FieldSet( + overriddenFields[e], + elementInstanceFields[e], + inheritedFields[e], + ), + ) + .toList() + ..sort(); + + // Remove fields which are synthetic and not serializable. + final filtered = []; + + filter: + for (final field in fields) { + if (!field.field.isSynthetic) { + filtered.add(field.field); + continue; + } + for (final coreField in _coreFields) { + if (coreField.name != field.field.name) { + continue; + } + final overriddenFields = + inheritanceManager.getOverridden2(this, coreField) ?? const []; + if (overriddenFields.isNotEmpty) { + // Skip, it's a core field. + continue filter; + } + } + switch (typeHelper.isSerializable(field.field.type)) { + case VerdictYes(): + filtered.add(field.field); + case VerdictNo(): + // Skip, not serializable. + } + } + + return filtered; + } +} + +class _FieldSet implements Comparable<_FieldSet> { + factory _FieldSet( + FieldElement? overrideField, + FieldElement? classField, + FieldElement? superField, + ) { + // At least one of these will != null, perhaps all. + final fields = [overrideField, classField, superField].nonNulls.toList(); + + // Prefer the class field over the inherited field when sorting. + final sortField = fields.first; + + return _FieldSet._(sortField); + } + + _FieldSet._(this.field); + + final FieldElement field; + + @override + int compareTo(_FieldSet other) => _sortByLocation(field, other.field); + + static int _sortByLocation(FieldElement a, FieldElement b) { + final checkerA = TypeChecker.fromStatic( + (a.enclosingElement3 as InterfaceElement).thisType, + ); + + if (!checkerA.isExactly(b.enclosingElement3)) { + // in this case, you want to prioritize the enclosingElement that is more + // "super". + + if (checkerA.isAssignableFrom(b.enclosingElement3)) { + return -1; + } + + final checkerB = TypeChecker.fromStatic( + (b.enclosingElement3 as InterfaceElement).thisType, + ); + + if (checkerB.isAssignableFrom(a.enclosingElement3)) { + return 1; + } + } + + /// Returns the offset of given field/property in its source file – with a + /// preference for the getter if it's defined. + int offsetFor(FieldElement e) { + if (e.isSynthetic) { + return (e.getter ?? e.setter)!.nameOffset; + } + return e.nameOffset; + } + + return offsetFor(a).compareTo(offsetFor(b)); + } +} + +extension on ParameterElement { + FieldElement? fieldFormal(List fields) { + return switch (this) { + FieldFormalParameterElement(:final field?) => field, + SuperFormalParameterElement(:final superConstructorParameter?) => + superConstructorParameter.fieldFormal(fields), + _ => fields.firstWhereOrNull((field) => field.name == name), + }; + } +} + +extension on ExecutableElement? { + List get parameterSpecs { + final parameters = this?.parameters; + if (parameters == null) { + return const []; + } + final specs = []; + final fields = switch (this) { + ParameterElement( + enclosingElement3: Element( + enclosingElement3: final ClassElement enclosingElement, + ), + ) => + enclosingElement.sortedFields(enclosingElement.thisType), + _ => const [], + }; + for (final parameter in parameters) { + final fieldFormal = parameter.fieldFormal(fields); + final (:ignoreFromJson, ignoreToJson: _) = switch (parameter) { + ParameterElement( + enclosingElement3: Element( + enclosingElement3: final ClassElement enclosingElement, + ), + ) + when fieldFormal != null => + enclosingElement.thisType._ignoredByJsonKey(fieldFormal), + _ => (ignoreFromJson: false, ignoreToJson: false), + }; + specs.add( + ParameterSpec( + name: parameter.displayName, + type: parameter.type, + isPositional: parameter.isPositional, + isOptional: parameter.isOptional, + isNamed: parameter.isNamed, + defaultValue: parameter.declaration.defaultToExpression, + ignore: ignoreFromJson, + ), + ); + } + return specs; + } +} diff --git a/apps/cli/lib/serialization/json_generator.dart b/apps/cli/lib/serialization/json_generator.dart new file mode 100644 index 000000000..bf3e01a23 --- /dev/null +++ b/apps/cli/lib/serialization/json_generator.dart @@ -0,0 +1,235 @@ +import 'package:analyzer/dart/element/type.dart'; +import 'package:celest_cli/serialization/serialization_verdict.dart'; +import 'package:celest_cli/src/context.dart'; +import 'package:celest_cli/src/types/dart_types.dart'; +import 'package:celest_cli/src/utils/analyzer.dart'; +import 'package:celest_cli/src/utils/error.dart'; +import 'package:celest_cli/src/utils/reference.dart'; +import 'package:code_builder/code_builder.dart'; + +final class JsonGenerator { + JsonGenerator({Expression? serializers}) + : _serializers = + serializers ?? DartTypes.celest.serializers.property('instance'); + + final Expression _serializers; + + Expression toJson(Reference type, Expression ref) { + final dartType = typeHelper.fromReference(type); + if (dartType.isDartAsyncFuture || dartType.isDartAsyncFutureOr) { + unreachable( + 'Must pass the flattened type so that nullability is correctly handled', + ); + } + if (dartType.isDartCoreBool || + dartType.isDartCoreDouble || + dartType.isDartCoreInt || + dartType.isDartCoreNum || + dartType.isDartCoreString || + dartType.isDartCoreObject || + dartType.isDartCoreNull || + dartType is DynamicType) { + return ref; + } + if (dartType.isDartCoreEnum || dartType.isDartCoreSet) { + unreachable('Should have been caught in checker'); + } + if (dartType.isDartCoreIterable || dartType.isDartCoreList) { + final element = refer('el'); + final serializedElement = toJson( + type.toTypeReference.types.single, + element, + ); + if (element == serializedElement) { + return ref; + } + return ref + .nullableProperty('map', type.isNullableOrFalse) + .call([ + Method( + (m) => + m + ..requiredParameters.add(Parameter((p) => p..name = 'el')) + ..body = serializedElement.code + ..lambda = true, + ).closure, + ]) + .property('toList') + .call([]); + } + if (dartType.isDartCoreMap) { + final [keyType, valueType] = type.toTypeReference.types.toList(); + final dartKeyType = typeHelper.fromReference(keyType); + if (!dartKeyType.isDartCoreString) { + throw unreachable('Should have been caught in checker'); + } + final value = refer('value'); + if (valueType.isDynamic || valueType.isDartCoreObject) { + return ref; + } + final serializedValue = toJson(valueType, value); + if (value == serializedValue) { + return ref; + } + return ref.nullableProperty('map', type.isNullableOrFalse).call([ + Method( + (m) => + m + ..requiredParameters.add(Parameter((p) => p..name = 'key')) + ..requiredParameters.add(Parameter((p) => p..name = 'value')) + ..body = + DartTypes.core.mapEntry.newInstance([ + refer('key'), + serializedValue, + ]).code + ..lambda = true, + ).closure, + ]); + } + final serializationVerdict = typeHelper.isSerializable(dartType); + assert( + serializationVerdict is VerdictYes, + 'Should not have passed analyzer if no', + ); + return _serializers + .property('serialize') + .call( + [ref, if (dartType.typeToken case final typeToken?) typeToken], + {}, + [type.noBound], + ); + } + + Expression fromJson( + Reference type, + Expression ref, { + required bool inNullableContext, + Expression? defaultValue, + }) { + type = type.withNullability(type.isNullableOrFalse || defaultValue != null); + var fromJson = _fromJson(type, ref, inNullableContext: inNullableContext); + if (defaultValue != null) { + fromJson = fromJson.parenthesized.ifNullThen(defaultValue); + } + return fromJson; + } + + Expression _fromJson( + Reference type, + Expression ref, { + required bool inNullableContext, + }) { + final dartType = typeHelper.fromReference(type); + if (dartType is DynamicType) { + return ref; + } + if (dartType.isDartCoreObject) { + if (!type.isNullableOrFalse && inNullableContext) { + return ref.nullChecked; + } + return ref; + } + if (dartType.isDartCoreBool || + dartType.isDartCoreNum || + dartType.isDartCoreString || + dartType.isDartCoreNull) { + return ref.asA(type); + } + // JSON numbers get confused between int/double. We always deserialize as + // num and cast to the correct type. + if (dartType.isDartCoreDouble) { + return ref + .asA(DartTypes.core.num.withNullability(type.isNullableOrFalse)) + .nullableProperty('toDouble', type.isNullableOrFalse) + .call([]); + } + if (dartType.isDartCoreInt) { + return ref + .asA(DartTypes.core.num.withNullability(type.isNullableOrFalse)) + .nullableProperty('toInt', type.isNullableOrFalse) + .call([]); + } + if (dartType.isDartCoreEnum || dartType.isDartCoreSet) { + throw unreachable('Should have been caught in checker'); + } + if (dartType.isDartCoreIterable || dartType.isDartCoreList) { + final cast = ref.asA( + DartTypes.core + .iterable(DartTypes.core.object.nullable) + .withNullability(type.isNullableOrFalse), + ); + final element = refer('el'); + final elementType = type.toTypeReference.types.single; + final serializedElement = fromJson( + elementType, + element, + inNullableContext: true, + ); + if (element == serializedElement) { + return cast.nullableProperty('toList', type.isNullableOrFalse).call([]); + } + return cast + .nullableProperty('map', type.isNullableOrFalse) + .call([ + Method( + (m) => + m + ..requiredParameters.add(Parameter((p) => p..name = 'el')) + ..body = serializedElement.code, + ).closure, + ]) + .property('toList') + .call([]); + } + if (dartType.isDartCoreMap) { + final [keyType, valueType] = type.toTypeReference.types.toList(); + final dartKeyType = typeHelper.fromReference(keyType); + if (!dartKeyType.isDartCoreString) { + throw unreachable('Should have been caught in checker'); + } + final cast = ref.asA( + DartTypes.core + .map(DartTypes.core.string, DartTypes.core.object.nullable) + .withNullability(type.isNullableOrFalse), + ); + final value = refer('value'); + // Special handling for Map and Map + late Expression serializedValue; + if (valueType.isDartCoreObject && !valueType.isNullableOrFalse) { + serializedValue = value.nullChecked; + } else if (valueType.isDynamic || valueType.isDartCoreObject) { + return cast; + } else { + serializedValue = fromJson(valueType, value, inNullableContext: true); + } + if (value == serializedValue) { + return cast; + } + return cast.nullableProperty('map', type.isNullableOrFalse).call([ + Method( + (m) => + m + ..requiredParameters.add(Parameter((p) => p..name = 'key')) + ..requiredParameters.add(Parameter((p) => p..name = 'value')) + ..body = + DartTypes.core.mapEntry.newInstance([ + refer('key'), + serializedValue, + ]).code, + ).closure, + ]); + } + // final serializationVerdict = typeHelper.isSerializable(dartType); + // assert( + // serializationVerdict is VerdictYes, + // 'Should not have passed analyzer if no: $serializationVerdict', + // ); + return _serializers + .property('deserialize') + .call( + [ref, if (dartType.typeToken case final typeToken?) typeToken], + {}, + [type.noBound], + ); + } +} diff --git a/apps/cli/lib/serialization/serialization_spec.dart b/apps/cli/lib/serialization/serialization_spec.dart new file mode 100644 index 000000000..4b2bb8e73 --- /dev/null +++ b/apps/cli/lib/serialization/serialization_spec.dart @@ -0,0 +1,221 @@ +import 'package:analyzer/dart/element/element.dart'; +import 'package:analyzer/dart/element/type.dart'; +import 'package:celest_cli/src/context.dart'; +import 'package:celest_cli/src/utils/analyzer.dart'; +import 'package:celest_cli/src/utils/run.dart'; +import 'package:code_builder/code_builder.dart' as code_builder; +import 'package:collection/collection.dart'; +import 'package:meta/meta.dart'; + +final class SerializationSpec { + SerializationSpec({ + required this.type, + required this.wireType, + code_builder.Reference? castType, + this.fields = const [], + required this.wireConstructor, + this.constructorParameters = const [], + this.fromJsonParameters = const [], + required this.fromJsonType, + required this.toJsonType, + SerializationSpec? representationType, + }) : castType = castType ?? wireType, + _representationType = representationType; + + final DartType type; + + /// The type returned by the `toJson` method. + final code_builder.Reference wireType; + + /// The type expected by the `fromJson` constructor, if a `fromJson` + /// constructor is provided. + /// + /// Otherwise, the class is constructed directly and this defaults to the + /// [wireType]. + final code_builder.Reference castType; + + final List fields; + + final ConstructorElement? wireConstructor; + final List constructorParameters; + final List fromJsonParameters; + + List get parameters => + fromJsonType == null ? constructorParameters : fromJsonParameters; + + final DartType? fromJsonType; + final DartType? toJsonType; + + SerializationSpec? parent; + final List subtypes = []; + SerializationSpec? _representationType; + + set representationType(SerializationSpec? value) { + _representationType = value; + } + + SerializationSpec get representationType => _representationType ?? this; + + bool get isExtensionType => _representationType != null; + + SerializationSpec get erased { + // Extension types are never erased. They either override another type or + // have their own unique global identity. In either case, they retain their + // identity for the purpose of serialization. + if (isExtensionType) { + return this; + } + final erased = SerializationSpec( + type: type, + wireType: type.defaultWireType?.let(typeHelper.toReference) ?? wireType, + castType: type.defaultWireType?.let(typeHelper.toReference) ?? castType, + fields: fields, + wireConstructor: wireConstructor, + constructorParameters: constructorParameters, + fromJsonParameters: const [], + toJsonType: null, + fromJsonType: null, + representationType: _representationType, + ); + for (final subtype in subtypes) { + erased.subtypes.add(subtype.erased); + } + return erased; + } + + SerializationSpec copyWith({ + DartType? type, + code_builder.Reference? wireType, + code_builder.Reference? castType, + List? fields, + List? constructorParameters, + List? fromJsonParameters, + Object? fromJsonType = const Object(), + Object? toJsonType = const Object(), + }) => SerializationSpec( + type: type ?? this.type, + wireType: wireType ?? this.wireType, + castType: castType ?? this.castType, + fields: fields ?? this.fields, + wireConstructor: wireConstructor, + constructorParameters: constructorParameters ?? this.constructorParameters, + fromJsonParameters: fromJsonParameters ?? this.fromJsonParameters, + fromJsonType: switch (fromJsonType) { + null => null, + final DartType type => type, + _ => this.fromJsonType, + }, + toJsonType: switch (toJsonType) { + null => null, + final DartType type => type, + _ => this.toJsonType, + }, + representationType: _representationType, + ); + + @override + bool operator ==(Object other) { + if (identical(this, other)) return true; + return other is SerializationSpec && + const DartTypeEquality().equals(type, other.type) && + wireType == other.wireType && + castType == other.castType && + const ListEquality().equals(fields, other.fields) && + const ListEquality().equals( + constructorParameters, + other.constructorParameters, + ) && + const ListEquality().equals( + fromJsonParameters, + other.fromJsonParameters, + ) && + const DartTypeEquality().equals(fromJsonType, other.fromJsonType) && + const DartTypeEquality().equals(toJsonType, other.toJsonType) && + parent?.type == other.parent?.type && + const ListEquality().equals( + subtypes, + other.subtypes, + ) && + _representationType == other._representationType; + } + + @override + int get hashCode => Object.hash( + const DartTypeEquality().hash(type), + wireType, + castType, + const ListEquality().hash(fields), + const ListEquality().hash(constructorParameters), + const ListEquality().hash(fromJsonParameters), + const DartTypeEquality().hash(fromJsonType), + const DartTypeEquality().hash(toJsonType), + parent == null ? null : const DartTypeEquality().hash(parent!.type), + const ListEquality().hash(subtypes), + _representationType, + ); +} + +@immutable +final class FieldSpec { + const FieldSpec({ + required this.name, + required this.type, + this.ignore = false, + }); + + final String name; + final DartType type; + final bool ignore; + + @override + bool operator ==(Object other) { + if (identical(this, other)) return true; + return other is FieldSpec && + name == other.name && + const DartTypeEquality().equals(type, other.type); + } + + @override + int get hashCode => Object.hash(name, const DartTypeEquality().hash(type)); +} + +@immutable +final class ParameterSpec { + const ParameterSpec({ + required this.name, + required this.type, + required this.isPositional, + required this.isOptional, + required this.isNamed, + required this.defaultValue, + this.ignore = false, + }); + + final String name; + final DartType type; + final bool isPositional; + final bool isOptional; + final bool isNamed; + final code_builder.Expression? defaultValue; + final bool ignore; + + @override + bool operator ==(Object other) { + if (identical(this, other)) return true; + return other is ParameterSpec && + name == other.name && + const DartTypeEquality().equals(type, other.type) && + isPositional == other.isPositional && + isOptional == other.isOptional && + isNamed == other.isNamed; + } + + @override + int get hashCode => Object.hash( + name, + const DartTypeEquality().hash(type), + isPositional, + isOptional, + isNamed, + ); +} diff --git a/apps/cli/lib/serialization/serialization_verdict.dart b/apps/cli/lib/serialization/serialization_verdict.dart new file mode 100644 index 000000000..3f4ed29f4 --- /dev/null +++ b/apps/cli/lib/serialization/serialization_verdict.dart @@ -0,0 +1,128 @@ +import 'package:celest_cli/serialization/serialization_spec.dart'; +import 'package:source_span/source_span.dart'; + +sealed class Verdict { + const Verdict(); + + const factory Verdict.yes({ + SerializationSpec? primarySpec, + Set additionalSpecs, + }) = VerdictYes; + factory Verdict.no( + String reason, { + FileSpan? location, + bool isBecauseOfFlutter, + }) = VerdictNo.single; + + bool get isSerializable; + List get reasons; + + Verdict operator &(Verdict other) => switch ((this, other)) { + ( + VerdictYes( + primarySpec: final primarySpecThis, + additionalSpecs: final additionalSpecsThis, + ), + VerdictYes( + primarySpec: final primarySpecOther, + additionalSpecs: final additionalSpecsOther, + ), + ) => + Verdict.yes( + primarySpec: primarySpecThis, + additionalSpecs: { + if (primarySpecOther != null) primarySpecOther, + ...additionalSpecsThis, + ...additionalSpecsOther, + }, + ), + (VerdictYes(), final VerdictNo no) || + (final VerdictNo no, VerdictYes()) => no, + ( + VerdictNo(reasons: final reasonsThis), + VerdictNo(reasons: final reasonsOther), + ) => + VerdictNo([...reasonsThis, ...reasonsOther]), + }; + + Verdict withPrimarySpec(SerializationSpec spec); + Verdict withAdditionalSpec(SerializationSpec spec); +} + +final class VerdictYes extends Verdict { + const VerdictYes({this.primarySpec, this.additionalSpecs = const {}}); + + @override + bool get isSerializable => true; + + final SerializationSpec? primarySpec; + final Set additionalSpecs; + + @override + Verdict withPrimarySpec(SerializationSpec spec) => + Verdict.yes(primarySpec: spec, additionalSpecs: additionalSpecs); + + @override + Verdict withAdditionalSpec(SerializationSpec spec) => Verdict.yes( + primarySpec: primarySpec, + additionalSpecs: {...additionalSpecs, spec}, + ); + + @override + List get reasons => const []; +} + +final class VerdictNo extends Verdict { + const VerdictNo(this._reasons); + + VerdictNo.single( + String reason, { + FileSpan? location, + bool isBecauseOfFlutter = false, + }) : _reasons = [ + VerdictReason( + reason, + location: location, + isBecauseOfFlutter: isBecauseOfFlutter, + ), + ]; + + @override + bool get isSerializable { + // if (reasons.every((r) => r.isBecauseOfFlutter)) { + // return true; + // } + return false; + } + + final List _reasons; + + @override + List get reasons => + // _reasons.where((reason) => !reason.isBecauseOfFlutter).toList(); + _reasons; + + @override + Verdict withPrimarySpec(SerializationSpec spec) => this; + + @override + Verdict withAdditionalSpec(SerializationSpec spec) => this; + + @override + String toString() => reasons.join('; '); +} + +final class VerdictReason { + const VerdictReason( + this.reason, { + this.location, + this.isBecauseOfFlutter = false, + }); + + final bool isBecauseOfFlutter; + final String reason; + final FileSpan? location; + + @override + String toString() => reason; +} diff --git a/apps/cli/lib/serialization/serializer_generator.dart b/apps/cli/lib/serialization/serializer_generator.dart new file mode 100644 index 000000000..158a87293 --- /dev/null +++ b/apps/cli/lib/serialization/serializer_generator.dart @@ -0,0 +1,817 @@ +import 'package:analyzer/dart/element/element.dart'; +import 'package:analyzer/dart/element/type.dart' as ast; +import 'package:analyzer/dart/element/type_visitor.dart' as ast; +import 'package:celest_cli/serialization/common.dart'; +import 'package:celest_cli/serialization/json_generator.dart'; +import 'package:celest_cli/serialization/serialization_spec.dart'; +import 'package:celest_cli/src/context.dart'; +import 'package:celest_cli/src/types/dart_types.dart'; +import 'package:celest_cli/src/types/type_checker.dart'; +import 'package:celest_cli/src/utils/analyzer.dart'; +import 'package:celest_cli/src/utils/error.dart'; +import 'package:celest_cli/src/utils/reference.dart'; +import 'package:celest_cli/src/utils/run.dart'; +import 'package:code_builder/code_builder.dart'; + +final class SerializerDefinition { + SerializerDefinition({ + required this.serialize, + required this.deserialize, + required this.type, + required this.dartType, + required this.generics, + required this.wireType, + required this.customSerializers, + }); + + final Code serialize; + final Code deserialize; + final Reference type; + final ast.DartType dartType; + Expression? get typeToken => dartType.typeToken; + final Set generics; + final Reference wireType; + final Code? customSerializers; + + bool get isConst => customSerializers == null; + bool get hasClass => generics.isNotEmpty || customSerializers != null; + + Expression _init(Expression serializer, [Expression? typeToken]) { + return DartTypes.celest.serializers + .property('instance') + .property('put') + .call([serializer, if (typeToken != null) typeToken]); + } + + Code get initAll { + return Block((b) { + if (!hasClass) { + b.addExpression(_init(define(), typeToken)); + return; + } + + final serializerClass = refer(_serializerClassName); + final constructor = + isConst ? serializerClass.constInstance : serializerClass.newInstance; + + // Instantiate to bounds first + b.addExpression(_init(constructor([]), typeToken)); + + // Monomorphize for all combinations of bound subclasses. + final subtypeCombos = _combinations(generics.map(_subtypes)).toList(); + for (final subtypes in subtypeCombos) { + final instance = constructor([], {}, subtypes.references); + b.addExpression(_init(instance)); + } + }); + } + + late final _serializerClassName = '${dartType.classNamePrefix}Serializer'; + Class? get serializerClass { + if (!hasClass) { + return null; + } + return Class((b) { + b + ..modifier = ClassModifier.final$ + ..name = _serializerClassName + ..extend = DartTypes.celest.serializer(type) + ..types.addAll(generics); + + // Create unnamed constant constructor when we can. + + b.constructors.add( + Constructor( + (c) => + c + ..constant = isConst + ..body = customSerializers, + ), + ); + + if (customSerializers != null) { + b.fields.add( + Field( + (f) => + f + ..name = r'$serializers' + ..modifier = FieldModifier.final$ + ..type = DartTypes.celest.serializers + ..assignment = + DartTypes.celest.serializers.newInstance([]).code, + ), + ); + } + + // Create `deserialize` and `serialize` overrides + b.methods.addAll([ + Method( + (b) => + b + ..name = 'deserialize' + ..returns = type + ..requiredParameters.add( + Parameter( + (b) => + b + ..name = r'$value' + ..type = DartTypes.core.object.nullable, + ), + ) + ..annotations.add(DartTypes.core.override) + ..body = Block((b) { + b.addExpression( + declareFinal(r'$serialized').assign( + refer( + 'assertWireType', + ).call([refer(r'$value')], {}, [wireType]), + ), + ); + b.statements.add(deserialize); + }), + ), + Method( + (b) => + b + ..name = 'serialize' + ..returns = DartTypes.core.object.nullable + ..requiredParameters.add( + Parameter( + (b) => + b + ..name = r'$value' + ..type = type, + ), + ) + ..annotations.add(DartTypes.core.override) + ..body = serialize, + ), + ]); + }); + } + + /// Constructs a `Serializer` instance using `Serializer.define`. + Expression define() { + return DartTypes.celest.serializer().newInstanceNamed( + 'define', + [], + { + 'serialize': + Method( + (b) => + b + ..requiredParameters.add( + Parameter((b) => b..name = r'$value'), + ) + ..body = serialize, + ).closure, + 'deserialize': + Method( + (b) => + b + ..requiredParameters.add( + Parameter((b) => b..name = r'$serialized'), + ) + ..body = deserialize, + ).closure, + }, + [type, wireType], + ); + } +} + +final class SerializerGenerator { + SerializerGenerator( + this.serializationSpec, { + this.additionalSerializationSpecs = const [], + Expression? serializers, + }) { + _serializers = + serializers ?? + (_customSerializers != null + ? refer(r'$serializers') + : DartTypes.celest.serializers.property('instance')); + } + + final SerializationSpec serializationSpec; + final Iterable additionalSerializationSpecs; + late final Expression _serializers; + + late final bool _isExtensionType = serializationSpec.isExtensionType; + late final bool _isOverridden = type.isOverridden; + + // Overridden types are extension types but their serializers should apply + // at the global level so that all instances of the representation type + // are serialized the same. + late final bool _isExtensionTypeWithIdentity = + _isExtensionType && !_isOverridden; + + late final SerializationSpec? _parent = serializationSpec.parent; + late final Set _generics = _collectGenerics(); + + late final jsonGenerator = JsonGenerator(serializers: _serializers); + + Set _collectGenerics() { + final collector = _GenericsCollector(); + serializationSpec.type.accept(collector); + return collector.generics; + } + + bool get isSubtype => _parent != null; + + /// The `fromJson` method to use and whether it is inherited from a parent. + (Expression fromJson, bool usesParent, bool requiresNullCheck)? get fromJson { + Reference? typeReference; + var usesParent = false; + if (serializationSpec.fromJsonType case final fromJsonType?) { + typeReference = typeHelper.toReference(fromJsonType); + usesParent = + !const DartTypeEquality( + ignoreNullability: true, + ).equals(fromJsonType, type); + } + var parent = _parent; + while (typeReference == null && parent != null) { + if (parent.fromJsonType case final fromJsonType?) { + typeReference = typeHelper.toReference(fromJsonType); + usesParent = true; + } + parent = parent.parent; + } + if (typeReference == null) { + return null; + } + return ( + typeReference.nonNullable.property('fromJson'), + usesParent, + typeReference.isNullableOrFalse, + ); + } + + bool get hasToJson { + if (serializationSpec.toJsonType != null) { + return true; + } + var parent = _parent; + while (parent != null) { + if (parent.toJsonType != null) { + return true; + } + parent = parent.parent; + } + return false; + } + + late final type = serializationSpec.type; + late final typeReference = typeHelper.toReference(type).nonNullable.noBound; + late final wireType = serializationSpec.wireType; + late final castType = serializationSpec.castType; + + late final representationType = type.extensionTypeErasure; + late final representationTypeRef = typeHelper.toReference(representationType); + + late final Code? _customSerializers = run(() { + if (!_isExtensionTypeWithIdentity) { + return null; + } + final interfaceSpecs = additionalSerializationSpecs.where( + (spec) => spec.type is ast.InterfaceType, + ); + if (interfaceSpecs.isEmpty) { + return null; + } + Expression serializers = refer(r'$serializers'); + for (final spec in interfaceSpecs) { + final serializer = + SerializerGenerator( + spec, + serializers: refer(r'$serializers'), + ).build().first; + serializers = serializers.cascade('put').call([serializer.define()]); + } + return serializers.statement; + }); + + List build() { + final serialize = _serialize(r'$value').code; + + final parameters = serializationSpec.parameters; + final mayBeAbsent = + (parameters.isEmpty || parameters.every((p) => p.isOptional)) && + serializationSpec.subtypes.isEmpty; + final wireType = switch (type) { + ast.InterfaceType(isEnumLike: true) => this.wireType, + _ => castType.withNullability(mayBeAbsent), + }; + final deserialize = _deserialize(r'$serialized', mayBeAbsent: mayBeAbsent); + + final serializerDefinitions = []; + + serializerDefinitions.add( + SerializerDefinition( + serialize: serialize, + deserialize: deserialize, + type: typeReference, + dartType: type, + generics: _generics, + wireType: wireType, + customSerializers: _customSerializers, + ), + ); + + if (!_isExtensionTypeWithIdentity) { + for (final subtype in serializationSpec.subtypes) { + serializerDefinitions.addAll( + SerializerGenerator(subtype, serializers: _serializers).build(), + ); + } + for (final additionalSpec in additionalSerializationSpecs) { + serializerDefinitions.addAll( + SerializerGenerator( + additionalSpec, + serializers: _serializers, + ).build(), + ); + } + } + + return serializerDefinitions; + } + + Expression _serialize(String from) { + final Expression ref = _reference(from, isNullable: false); + if (hasToJson) { + final genericSerializers = []; + if (type case ast.InterfaceType(:final typeArguments)) { + for (final typeArgument in typeArguments) { + genericSerializers.add( + Method( + (m) => + m + ..requiredParameters.add( + Parameter((p) => p..name = 'value'), + ) + ..body = + jsonGenerator + .toJson( + typeHelper.toReference(typeArgument), + refer('value'), + ) + .code, + ).closure, + ); + } + } + final serialized = ref.property('toJson').call(genericSerializers); + + // If we're using a base class's custom toJson method, then we + // always inject the type discriminator regardless if it also + // has a custom fromJson. By always providing the discriminator, + // devs can rely on its presence even when writing custom fromJson + // constructors and just focus on the logic of serialization, not + // discrimination. + if (serializationSpec.subtypes.isNotEmpty) { + return literalMap({ + literalSpread(): serialized, + // TODO(dnys1): Ensure subclasses are not private + literalString(r'$type', raw: true): CodeExpression( + Block((b) { + b.statements.addAll([ + const Code('switch ('), + ref.code, + const Code(') {'), + ]); + for (final subtype in serializationSpec.subtypes) { + final subtypeRef = typeHelper.toReference(subtype.type); + b.statements.addAll([ + Code.scope((alloc) => '${alloc(subtypeRef)}() => '), + literalString(subtype.type.element!.name!, raw: true).code, + const Code(','), + ]); + } + b.statements.add(const Code('}')); + }), + ), + }); + } + return serialized; + } + if (serializationSpec.subtypes.isNotEmpty) { + final serialize = _serializers.property('serialize'); + return CodeExpression( + Block((b) { + for (final subtype in serializationSpec.subtypes) { + final subtypeRef = typeHelper.toReference(subtype.type).noBound; + final subtypeCase = serialize( + [ref], + {}, + [subtypeRef], + ).asA(wireType); + final serialized = literalMap({ + literalSpread(): subtypeCase, + literalString(r'$type', raw: true): literalString( + subtype.type.element!.name!, + raw: true, + ), + }); + b.statements.add( + serialized.returned.wrapWithBlockIf(ref.isA(subtypeRef)), + ); + } + b.addExpression( + DartTypes.celest.serializationException.newInstance([ + DartTypes.core.stringBuffer + .newInstance([literalString('Unknown subtype of ')]) + .cascade('write') + .call([literalString(type.element!.name!, raw: true)]) + .cascade('write') + .call([literalString(r': ')]) + .cascade('write') + .call([ref.property('runtimeType')]) + .parenthesized + .property('toString') + .call([]), + ]).thrown, + ); + }), + ); + } + if (type.isEnum) { + return ref.property('name'); + } else if (type.isEnumLike) { + return ref.property('toString').call([]); + } + if (_isExtensionTypeWithIdentity) { + return jsonGenerator.toJson( + representationTypeRef, + type.implementsRepresentationType + ? ref + : switch (serializationSpec.fields) { + [final field] => ref.property(field.name), + // No public field to reference. Just cast into representation. + _ => ref.asA(representationTypeRef), + }, + ); + } + final serialized = {}; + for (final field in serializationSpec.representationType.fields) { + if (field.ignore) { + continue; + } + final variableName = field.name; + final fieldTypeRef = typeHelper.toReference(field.type); + final serializedField = jsonGenerator.toJson( + fieldTypeRef, + ref.property(field.name), + ); + if (fieldTypeRef.isNullableOrFalse) { + final binding = nullCheckBind(variableName, serializedField); + final key = mapIf(binding, literalString(field.name, raw: true)); + serialized[key] = refer(variableName); + } else { + serialized[literalString(field.name, raw: true)] = serializedField; + } + } + return (serialized.isEmpty ? literalConstMap : literalMap)( + serialized, + DartTypes.core.string, + DartTypes.core.object.nullable, + ); + } + + Code _deserialize(String from, {required bool mayBeAbsent}) { + if (fromJson + case (final fromJson, final usesParent, final requiresNullCheck)?) { + Expression ref = _reference(from, isNullable: false); + if (mayBeAbsent) { + ref = ref.ifNullThen(literalConstMap({})); + } + final genericDeserializers = []; + if (type case ast.InterfaceType(:final typeArguments)) { + for (final typeArgument in typeArguments) { + final typeArgumentRef = typeHelper.toReference(typeArgument); + genericDeserializers.add( + Method( + (m) => + m + ..requiredParameters.add( + Parameter((p) => p..name = 'value'), + ) + ..body = + jsonGenerator + .fromJson( + typeArgumentRef, + refer('value'), + inNullableContext: + typeArgumentRef.isNullableOrFalse, + ) + .code, + ).closure, + ); + } + } + var deserialized = fromJson([ + // If a subtype uses a parent's fromJson method, then the discriminator + // key is needed so that the parent's fromJson method can distinguish the + // map. + if (usesParent && !_isExtensionType) + literalMap({ + literalString(r'$type', raw: true): literalString( + typeReference.symbol!, + raw: true, + ), + literalSpread(): ref, + }) + else + ref, + ...genericDeserializers, + ]); + if (requiresNullCheck) { + deserialized = deserialized.nullChecked; + } + if (usesParent) { + return deserialized.asA(typeReference).returned.statement; + } + return deserialized.returned.statement; + } + if (serializationSpec.subtypes.isNotEmpty) { + assert(!mayBeAbsent, 'Classes with subtypes must have a map'); + final ref = _reference(from, isNullable: false); + final deserialize = _serializers.property('deserialize'); + return Block((b) { + final type = ref.index(literalString(r'$type', raw: true)); + for (final subtype in serializationSpec.subtypes) { + final subtypeName = subtype.type.element!.name; + final subtypeRef = typeHelper.toReference(subtype.type).noBound; + final subtypeCase = deserialize([ref], {}, [subtypeRef]); + b.statements.add( + subtypeCase.returned.wrapWithBlockIf( + type.equalTo(literalString(subtypeName!, raw: true)), + ), + ); + } + b.addExpression( + DartTypes.celest.serializationException.newInstance([ + DartTypes.core.stringBuffer + .newInstance([literalString('Unknown subtype of ')]) + .cascade('write') + .call([literalString(this.type.element!.name!, raw: true)]) + .cascade('write') + .call([literalString(r': ')]) + .cascade('write') + .call([type]) + .parenthesized + .property('toString') + .call([]), + ]).thrown, + ); + }); + } + final ref = _reference(from, isNullable: mayBeAbsent); + if (type.isEnum) { + return typeReference.nonNullable + .property('values') + .property('byName') + .call([ref]) + .returned + .statement; + } else if (type.isEnumLike) { + return typeReference.nonNullable + .property('values') + .property('firstWhere') + .call([ + Method( + (m) => + m + ..requiredParameters.add(Parameter((p) => p..name = 'el')) + ..body = + ref + .equalTo(refer('el').property('toString').call([])) + .code, + ).closure, + ]) + .returned + .statement; + } + if (_isExtensionTypeWithIdentity) { + final deserialized = jsonGenerator.fromJson( + representationTypeRef, + ref, + inNullableContext: mayBeAbsent, + ); + // No params means no constructor. Just cast into the extension type. + if (serializationSpec.parameters.isEmpty) { + return deserialized.asA(typeReference).returned.statement; + } + return typeReference.nonNullable + .newInstance([deserialized]) + .returned + .statement; + } + final deserializedPositional = []; + final deserializedNamed = {}; + for (final parameter in serializationSpec.parameters) { + if (parameter.ignore) { + continue; + } + final parameterWireName = parameter.name.nonPrivate; + final reference = typeHelper.toReference(parameter.type); + final (serialized, inNullableContext) = + typeHelper.fromReference(serializationSpec.wireType).isDartCoreMap + ? (ref.index(literalString(parameterWireName, raw: true)), true) + : (ref, mayBeAbsent); + final deserialized = jsonGenerator.fromJson( + reference, + serialized, + defaultValue: parameter.defaultValue, + inNullableContext: inNullableContext, + ); + if (parameter.isPositional) { + deserializedPositional.add(deserialized); + } else { + deserializedNamed[parameterWireName] = deserialized; + } + } + return switch (type) { + ast.InterfaceType() => () { + // TODO(dnys1): Find a less hacky way to do this + var constructor = typeReference; + var cast = false; + if (_isOverridden) { + if (serializationSpec.wireConstructor!.enclosingElement3 != + type.element) { + constructor = representationTypeRef; + cast = true; + } + } + final instance = constructor.newInstance( + deserializedPositional, + deserializedNamed, + ); + if (cast) { + return instance.asA(typeReference); + } + return instance; + }(), + ast.RecordType() => literalRecord( + deserializedPositional, + deserializedNamed, + ), + _ => unreachable('Unsupported type: $type'), + }.returned.statement; + } + + Reference _reference(String variable, {required bool isNullable}) { + if (!TypeChecker.fromStatic( + typeHelper.fromReference(serializationSpec.wireType), + ).isExactlyType(jsonMapType)) { + return refer(variable); + } + return switch (isNullable) { + true => refer('$variable?'), + false => refer(variable), + }; + } +} + +final class _GenericsCollector extends ast.TypeVisitor { + _GenericsCollector(); + + final Set generics = {}; + final Set _seen = {}; + + @override + void visitInterfaceType(ast.InterfaceType type) { + if (!_seen.add(type)) { + return; + } + for (final typeArgument in type.typeArguments) { + typeArgument.accept(this); + } + } + + @override + void visitTypeParameterType(ast.TypeParameterType type) { + if (!_seen.add(type)) { + return; + } + generics.add(typeHelper.toReference(type)); + } + + @override + void visitDynamicType(ast.DynamicType type) {} + + @override + void visitFunctionType(ast.FunctionType type) {} + + @override + void visitInvalidType(ast.InvalidType type) {} + + @override + void visitNeverType(ast.NeverType type) {} + + @override + void visitRecordType(ast.RecordType type) { + // TODO(dnys1): Generic records + } + + @override + void visitVoidType(ast.VoidType type) {} +} + +extension on ast.DartType { + String get classNamePrefix { + return switch (this) { + ast.InterfaceType(:final typeArguments, :final element) => () { + final name = StringBuffer(element.name); + if (typeArguments.isNotEmpty) { + name + ..write('_') + ..write(typeArguments.map((t) => t.classNamePrefix).join('_')); + } + return name.toString(); + }(), + final ast.RecordType recordType => recordType.symbol, + ast.TypeParameterType(:final element, :final bound) => StringBuffer().let( + (buf) { + buf.write(element.name); + if (bound.classNamePrefix case final boundPrefix + when boundPrefix.isNotEmpty) { + buf + ..write('_') + ..write(boundPrefix); + } + return buf.toString(); + }, + ), + _ => '', + }; + } +} + +List<_Reference> _subtypes(Reference typeParameter) { + final typeParameterType = + typeHelper.fromReference(typeParameter) as ast.TypeParameterType; + final typeParameterBound = + typeParameterType.bound.element as InterfaceElement; + final subtypes = <_Reference>{ + _BoundReference(typeHelper.toReference(typeParameterType.bound)), + }; + for (final subtype in typeHelper.subtypes[typeParameterBound]!) { + subtypes.add(_SubtypeReference(typeHelper.toReference(subtype))); + } + return subtypes.toList(); +} + +Iterable> _combinations( + Iterable> types, +) sync* { + if (types.isEmpty) { + return; + } + if (types.length == 1) { + yield* types.first.map((t) => [t]); + return; + } + final type = types.first; + final rest = types.skip(1); + for (final t in type) { + for (final r in _combinations(rest)) { + yield [t, ...r]; + } + } +} + +sealed class _Reference { + const _Reference(this.reference); + + final Reference reference; +} + +final class _SubtypeReference extends _Reference { + _SubtypeReference(super.reference); + + @override + bool operator ==(Object other) => + identical(this, other) || + other is _SubtypeReference && reference == other.reference; + + @override + int get hashCode => reference.hashCode; +} + +final class _BoundReference extends _Reference { + _BoundReference(super.reference); + + @override + bool operator ==(Object other) => + identical(this, other) || + other is _BoundReference && reference == other.reference; + + @override + int get hashCode => reference.hashCode; +} + +extension on Iterable<_Reference> { + List get references => map((r) => r.reference).toList(); +} diff --git a/apps/cli/lib/src/analytics/interface.dart b/apps/cli/lib/src/analytics/interface.dart new file mode 100644 index 000000000..e5526f009 --- /dev/null +++ b/apps/cli/lib/src/analytics/interface.dart @@ -0,0 +1,14 @@ +abstract base class Analytics { + const Analytics(); + + void capture( + String eventName, { + Map properties = const {}, + }); + + void identifyUser({ + String? distinctId, + Map? set, + Map? setOnce, + }); +} diff --git a/apps/cli/lib/src/analytics/noop.dart b/apps/cli/lib/src/analytics/noop.dart new file mode 100644 index 000000000..a7dc117e0 --- /dev/null +++ b/apps/cli/lib/src/analytics/noop.dart @@ -0,0 +1,35 @@ +import 'package:celest_cli/src/analytics/interface.dart'; +import 'package:celest_cli/src/utils/json.dart'; +import 'package:logging/logging.dart'; + +final class NoopAnalytics extends Analytics { + const NoopAnalytics(); + + static final _logger = Logger('NoopAnalytics'); + + @override + Future capture( + String eventName, { + Map properties = const {}, + }) async { + _logger.finer('$eventName: ${prettyPrintJson(properties)}'); + } + + @override + Future identifyUser({ + String? distinctId, + Map? set, + Map? setOnce, + }) async { + assert( + distinctId != null || set != null || setOnce != null, + 'Must provide at least one of: distinctId, set, setOnce', + ); + final event = { + if (distinctId != null) 'distinct_id': distinctId, + if (set != null) r'$set': set, + if (setOnce != null) r'$set_once': setOnce, + }; + _logger.finer('identifyUser: ${prettyPrintJson(event)}'); + } +} diff --git a/apps/cli/lib/src/analytics/posthog.dart b/apps/cli/lib/src/analytics/posthog.dart new file mode 100644 index 000000000..6fc68547b --- /dev/null +++ b/apps/cli/lib/src/analytics/posthog.dart @@ -0,0 +1,116 @@ +import 'dart:async'; +import 'dart:convert'; + +import 'package:celest_cli/src/analytics/interface.dart'; +import 'package:celest_cli/src/context.dart' show kCliEnvironment; +import 'package:celest_cli/src/storage/storage.dart'; +import 'package:http/http.dart' as http; +import 'package:logging/logging.dart'; +import 'package:native_storage/native_storage.dart'; + +typedef PostHogConfig = ({String apiHost, String apiKey}); + +final class PostHog extends Analytics { + PostHog({ + required NativeStorage storage, + required PostHogConfig config, + http.Client? client, + }) : _storage = storage, + _apiKey = config.apiKey, + _apiHost = config.apiHost, + _client = client ?? http.Client(); + + final NativeStorage _storage; + final String _apiKey; + final String _apiHost; + final http.Client _client; + + static final _logger = Logger('PostHog'); + + @override + Future capture( + String eventName, { + Map properties = const {}, + }) async { + final uri = Uri.parse('$_apiHost/capture/'); + final result = CaptureResult( + event: eventName, + properties: {...properties, 'environment': kCliEnvironment}, + ); + final request = jsonEncode({ + 'api_key': _apiKey, + 'distinct_id': await _storage.readDistinctId(), + ...result.toJson(), + }); + try { + final response = await _client.post( + uri, + headers: {'Content-Type': 'application/json'}, + body: request, + ); + if (response.statusCode != 200) { + _logger.fine( + 'Failed to capture event $eventName', + response.body, + StackTrace.current, + ); + } + } on Object catch (e, st) { + _logger.fine('Failed to capture event $eventName', e, st); + } + } + + @override + Future identifyUser({ + String? distinctId, + Map? set, + Map? setOnce, + }) async { + assert( + distinctId != null || set != null || setOnce != null, + 'Must provide at least one of: distinctId, set, setOnce', + ); + if (distinctId != null) { + await _storage.writeDistinctId(distinctId); + return capture( + r'$identify', + properties: { + 'distinct_id': distinctId, + // Previous distinct ID + r'$anon_distinct_id': await _storage.readDeviceId(), + if (set != null) r'$set': set, + if (setOnce != null) r'$set_once': setOnce, + }, + ); + } else { + return capture( + r'$set', + properties: { + if (set != null) r'$set': set, + if (setOnce != null) r'$set_once': setOnce, + }, + ); + } + } +} + +final class CaptureResult { + CaptureResult({ + required this.event, + required this.properties, + this.$set, + this.$setOnce, + }); + + final String event; + final Map properties; + final Map? $set; + final Map? $setOnce; + + Map toJson() => { + 'event': event, + 'properties': properties, + if ($set != null) r'$set': $set, + if ($setOnce != null) r'$set_once': $setOnce, + }; +} diff --git a/apps/cli/lib/src/cli.dart b/apps/cli/lib/src/cli.dart new file mode 100644 index 000000000..409e65326 --- /dev/null +++ b/apps/cli/lib/src/cli.dart @@ -0,0 +1,406 @@ +import 'dart:async'; +import 'dart:io' as io show Platform; +import 'dart:io' hide Platform; + +import 'package:args/args.dart'; +import 'package:args/command_runner.dart'; +import 'package:async/async.dart'; +import 'package:celest_cli/commands/celest_command.dart'; +import 'package:celest_cli/src/analytics/noop.dart'; +import 'package:celest_cli/src/analytics/posthog.dart'; +import 'package:celest_cli/src/context.dart' as ctx; +import 'package:celest_cli/src/exceptions.dart'; +import 'package:celest_cli/src/logging/cli_json_logger.dart'; +import 'package:celest_cli/src/logging/log_event.dart'; +import 'package:celest_cli/src/performance/local_perf.dart'; +import 'package:celest_cli/src/performance/sentry_perf.dart'; +import 'package:celest_cli/src/process/logging_process_manager.dart'; +import 'package:celest_cli/src/sdk/dart_sdk.dart'; +import 'package:celest_cli/src/sdk/sdk_finder.dart'; +import 'package:celest_cli/src/sdk/versions.dart'; +import 'package:celest_cli/src/storage/storage.dart'; +import 'package:celest_cli/src/utils/json.dart'; +import 'package:celest_core/_internal.dart'; +import 'package:file/file.dart'; +import 'package:file/local.dart'; +import 'package:http/http.dart' as http; +import 'package:io/ansi.dart'; +import 'package:logging/logging.dart'; +import 'package:native_storage/native_storage.dart'; +import 'package:platform/platform.dart'; +import 'package:process/process.dart'; +import 'package:sentry/sentry.dart'; +import 'package:sentry_logging/sentry_logging.dart'; +import 'package:stack_trace/stack_trace.dart'; + +final class Cli { + Cli( + this.name, + this.description, { + required this.version, + this.sentryConfig, + this.postHogConfig, + }) { + _loggerQueue = StreamQueue(Logger.root.onRecord); + } + + final String name; + final String description; + final String version; + final SentryConfig? sentryConfig; + final PostHogConfig? postHogConfig; + + late final CommandRunner _runner = CommandRunner(name, description); + StreamSubscription? _loggerSub; + IOSink? _logFile; + + /// Buffers log records until after CLI is configured. + late final StreamQueue _loggerQueue; + + static final Logger _logger = Logger('Cli'); + + static Future configure({ + required bool verbose, + bool jsonOutput = false, + String? sentryDsn, + PostHogConfig? postHogConfig, + FileSystem? fileSystem, + Platform? platform, + http.Client? httpClient, + ProcessManager? processManager, + Storage? storage, + }) async { + hierarchicalLoggingEnabled = true; + Logger.root.level = Level.ALL; // Filtered later, but needed for Sentry. + ctx.kCliLogLevel = verbose ? Level.ALL : Level.INFO; + ctx.verbose = verbose; + if (jsonOutput) { + ctx.cliLogger = CliJsonLogger(); + } + ctx.processManager = processManager ?? const LoggingProcessManager(); + ctx.fileSystem = fileSystem ?? const LocalFileSystem(); + ctx.platform = platform ?? const LocalPlatform(); + ctx.httpClient = + httpClient ?? + (sentryDsn == null + ? ctx.httpClient + : SentryHttpClient(client: ctx.httpClient)); + ctx.performance = + (sentryDsn == null || + io.Platform.environment.containsKey('CELEST_NO_ANALYTICS')) + ? const CelestPerformance() + : const SentryPerformance(); + ctx.storage = storage ?? Storage(); + + try { + _logger.finest('Initializing secure storage'); + await ctx.secureStorage.init(); + } on Object catch (e, st) { + _logger.fine('Failed to initialize storage', e, st); + // TODO(dnys1): Need glib/gio linked on Linux. + if (kReleaseMode) { + if (ctx.platform.isLinux) { + throw const CliException( + 'libsecret is not installed. Please run `apt-get install libsecret-1-dev` ' + 'or equivalent before running Celest.', + ); + } + // This shouldn't happen in release mode, since permissioning should + // be set up correctly via signing. + rethrow; + } + // Fallback to in memory storage. + // + // This allows, for example, running the CLI without signing on macOS. + // TODO(dnys1): Add a persistent storage fallback. + ctx.secureStorage = NativeMemoryStorage(namespace: Storage.cliNamespace); + } + + ctx.analytics = + postHogConfig == null || + io.Platform.environment.containsKey('CELEST_NO_ANALYTICS') + ? const NoopAnalytics() + : PostHog( + config: postHogConfig, + client: ctx.httpClient, + storage: ctx.secureStorage, + ); + + if (kReleaseMode) { + ctx.analytics.identifyUser(setOnce: {'local_iterations_mvp': true}); + } + + const sdkFinder = DartSdkFinder(); + final result = await sdkFinder.findSdk(); + Sdk.current = Sdk( + result.sdk.path, + sdkType: result.sdk.type, + version: result.sdk.version, + ); + } + + void _setVersion(CelestCommand command) { + command.version = version; + for (final subcommand + in command.subcommands.values.whereType()) { + _setVersion(subcommand); + } + } + + void addCommand(CelestCommand command) { + _setVersion(command); + _runner.addCommand(command); + } + + Future run(List args) async { + var verbose = ctx.platform.environment.containsKey('CELEST_VERBOSE'); + var jsonOutput = false; + _runner.argParser + ..addFlag( + 'verbose', + abbr: 'v', + help: 'Enable verbose logging', + negatable: false, + defaultsTo: false, + callback: (v) => verbose = v, + ) + ..addFlag( + 'json', + negatable: false, + help: 'Run CLI with JSON input/output', + hide: true, + callback: (j) => jsonOutput = j, + ) + ..addFlag( + 'version', + negatable: false, + help: 'Print the version of Celest', + ); + final argResults = _runner.parse(args); + + await configure( + verbose: verbose, + jsonOutput: jsonOutput, + sentryDsn: sentryConfig?.dsn, + postHogConfig: postHogConfig, + ); + + return overrideAnsiOutput(ctx.ansiColorsEnabled, () async { + if (sentryConfig == null) { + return _run(argResults); + } + return Sentry.init( + (options) { + if (const String.fromEnvironment('gitSha') case final gitSha + when gitSha.isNotEmpty) { + options.dist = gitSha; + } + options + ..dsn = sentryConfig!.dsn + ..release = '$name@$version' + ..environment = ctx.kCliEnvironment + ..debug = verbose + ..tracesSampleRate = + 1 // TODO: Lower as needed + ..sampleRate = + 1 // TODO: Lower as needed + ..attachStacktrace = true + ..sendDefaultPii = + true // TODO: Turn off for compliance + ..attachThreads = true + ..captureFailedRequests = true + ..httpClient = ctx.httpClient + ..markAutomaticallyCollectedErrorsAsFatal = true + ..enableDeduplication = true + ..beforeSend = (SentryEvent event, Hint hint) async { + event = + sentryConfig!.beforeSend?.call(event, hint: hint) ?? event; + final (:distinctId, :deviceId) = await ctx.secureStorage.init(); + return event.copyWith( + user: SentryUser( + id: deviceId, + data: {'distinct_id': distinctId}, + ), + ); + } + ..addIntegration( + // Only using for breadcrumbs. + LoggingIntegration( + minBreadcrumbLevel: Level.ALL, + minEventLevel: LogEvent.level, + ), + ); + }, + appRunner: () => _run(argResults), + // ignore: invalid_use_of_internal_member + callAppRunnerInRunZonedGuarded: false, + ); + }); + } + + Future _run(ArgResults argResults) async { + if (ctx.platform.environment['CELEST_LOG_FILE'] case final logFilepath?) { + // Try writing to path to make sure it is valid + final testLogFile = ctx.fileSystem.file(logFilepath); + try { + testLogFile.writeAsStringSync('', mode: FileMode.append); + _logFile = testLogFile.openWrite(mode: FileMode.append); + } on Object { + // Invalid log file + _logger.finest('Could not open log file at $logFilepath'); + } + } + + try { + _loggerSub = _loggerQueue.rest.listen((record) { + // Create non-verbose message + final message = StringBuffer()..write(record.message); + if (record.error case final error?) { + message.write(': $error'); + } + + // Create verbose message + final verboseMessage = StringBuffer(); + if (record.loggerName != name) { + verboseMessage.write('[${record.loggerName}] '); + } + verboseMessage.write('${record.level.name}: ${record.message}'); + if (record.error case final error?) { + verboseMessage.write('\n$error'); + } + if (record.stackTrace case final stackTrace?) { + verboseMessage.write('\n$stackTrace'); + } + _logFile?.write(switch (verboseMessage.toString()) { + final message when message.endsWith(io.Platform.lineTerminator) => + message, + final message => '$message${io.Platform.lineTerminator}', + }); + + if (record.level < ctx.kCliLogLevel) { + return; + } + + final cliMessage = + ctx.verbose ? verboseMessage.toString() : message.toString(); + switch (record.level) { + case Level.FINEST || + Level.FINER || + Level.FINE || + Level.CONFIG || + LogEvent.level: + ctx.cliLogger.detail(cliMessage); + case Level.WARNING: + ctx.cliLogger.warn(cliMessage); + case Level.SEVERE || Level.SHOUT: + ctx.cliLogger.err(cliMessage); + case Level.INFO: + ctx.cliLogger.info(cliMessage); + default: + throw UnimplementedError('Unknown log level: ${record.level}'); + } + }); + + final sdk = Sdk.current; + final sdkInfo = + StringBuffer() + ..writeln('Celest version: $version') + ..writeln('Dart SDK version: ${sdk.version} (${sdk.dart})'); + if ((sdk.flutterVersion, sdk.flutterSdkRoot) case ( + final flutterVersion?, + final flutterRoot?, + )) { + sdkInfo.writeln('Flutter SDK version: $flutterVersion ($flutterRoot)'); + } + + if (argResults.wasParsed('version') && argResults['version'] as bool) { + stdout.write(ctx.verbose ? sdkInfo : version); + return; + } + + if (sdk.version < minSupportedDartSdk) { + throw CliException( + 'Celest requires Dart $minSupportedDartSdk or later, but you are ' + 'using Dart ${sdk.version}.', + ); + } + + final configuration = {'verbose': ctx.verbose}; + _logger + ..finest('Running with config: ${prettyPrintJson(configuration)}') + ..finest(sdkInfo); + + var failed = false; + final result = await Chain.capture( + () => _runner.runCommand(argResults), + // By attaching an `onError` callback to `Chain.capture` we can create + // an error zone which can handle otherwise unhandled exceptions. + // + // However, control flow is fundamentally broken when an unhandled + // exception is raised, and even though we await the `Chain.capture` + // future, all code following the `await` will never be called since the + // returned future is scrubbed of listeners when an unhandled exception + // is raised. + // + // The `onError` callback is the only oppoortunity to capture the error + // and perform cleanup. + // + // See: https://api.dart.dev/stable/3.3.3/dart-async/Zone/errorZone.html + onError: (error, stackTrace) async { + // onError can be called multiple times. But we only want to handle + // the first error. + if (failed) return; + failed = true; + await _handleError(error, stackTrace); + // If onError is called, execution of the main body will be stopped + // since all callbacks attached to the Future are removed. + await _cleanUp(); + }, + ); + exitCode = result ?? 0; + } on Object catch (e, st) { + await _handleError(e, st); + } finally { + await _cleanUp(); + } + } + + Future _handleError(Object error, StackTrace stackTrace) async { + switch (error) { + case UsageException(): + stderr.writeln(error); + exitCode = 1; + case CliException(): + _logFile + ?..writeln(error) + ..writeln(stackTrace); + ctx.cliLogger.err(error.message); + if (ctx.verbose) { + stderr + ..writeln(error) + ..writeln(stackTrace); + } + exitCode = 1; + default: + _logFile + ?..writeln(error) + ..writeln(stackTrace); + ctx.cliLogger + ..err(error.toString()) + ..detail(stackTrace.toString()); + } + } + + /// Free up resources before exiting. + Future _cleanUp() async { + await Future.wait([ + for (final command in _runner.commands.values.whereType()) + command.close(), + ]); + await _loggerSub?.cancel(); + await _logFile?.flush(); + await _logFile?.close(); + ctx.httpClient.close(); + exit(exitCode); + } +} diff --git a/apps/cli/lib/src/context.dart b/apps/cli/lib/src/context.dart new file mode 100644 index 000000000..c2e7c48d6 --- /dev/null +++ b/apps/cli/lib/src/context.dart @@ -0,0 +1,207 @@ +import 'dart:io'; + +import 'package:analyzer/src/dart/analysis/byte_store.dart'; +import 'package:analyzer/src/dart/element/inheritance_manager3.dart'; +import 'package:celest_cli/database/cache/cache_database.dart'; +import 'package:celest_cli/database/project/project_database.dart'; +import 'package:celest_cli/project/celest_project.dart'; +import 'package:celest_cli/project/project_paths.dart'; +import 'package:celest_cli/serialization/json_generator.dart'; +import 'package:celest_cli/src/analytics/interface.dart'; +import 'package:celest_cli/src/analytics/noop.dart'; +import 'package:celest_cli/src/logging/cli_logger.dart'; +import 'package:celest_cli/src/performance/local_perf.dart'; +import 'package:celest_cli/src/process/logging_process_manager.dart'; +import 'package:celest_cli/src/storage/storage.dart'; +import 'package:celest_cli/src/types/type_helper.dart'; +import 'package:celest_core/_internal.dart'; +import 'package:file/file.dart'; +import 'package:file/local.dart'; +import 'package:http/http.dart' as http; +import 'package:http/io_client.dart' as http; +import 'package:http/retry.dart' as http; +import 'package:io/ansi.dart' show ansiOutputEnabled; +import 'package:logging/logging.dart'; +import 'package:mason_logger/mason_logger.dart' as mason_logger; +import 'package:meta/meta.dart'; +import 'package:native_storage/native_storage.dart'; +import 'package:path/path.dart' as path; +import 'package:platform/platform.dart'; +import 'package:process/process.dart'; + +extension PlatformContext on path.Context { + path.Context get url => path.url; + path.Context get windows => path.windows; + path.Context get posix => path.posix; + path.Context get project => + path.Context(current: projectPaths.projectRoot, style: style); +} + +Future init({ + required String projectRoot, + ParentProject? parentProject, + String? configHome, + String? clientDir, + String? outputsDir, + @visibleForTesting CacheDatabase? cacheDb, + @visibleForTesting ByteStore? byteStore, + @visibleForTesting ProjectDatabase? projectDb, +}) async { + celestProject = await CelestProject.init( + projectRoot: projectRoot, + parentProject: parentProject, + configHome: configHome, + clientDir: clientDir, + outputsDir: outputsDir, + // ignore: invalid_use_of_visible_for_testing_member + cacheDb: cacheDb, + // ignore: invalid_use_of_visible_for_testing_member + byteStore: byteStore, + // ignore: invalid_use_of_visible_for_testing_member + projectDb: projectDb, + ); + return celestProject.projectPaths; +} + +late CelestProject celestProject; + +ProjectPaths? _projectPaths; +ProjectPaths get projectPaths => _projectPaths ?? celestProject.projectPaths; + +@visibleForTesting +set projectPaths(ProjectPaths? value) { + _projectPaths = value; +} + +// Need a new instance of InheritanceManager3 for each invocation since it +// has a builtin cache. +InheritanceManager3 get inheritanceManager => InheritanceManager3(); +final TypeHelper typeHelper = TypeHelper(); +final JsonGenerator jsonGenerator = JsonGenerator(); + +String? _celestLocalPath; + +@visibleForTesting +set celestLocalPath(String? value) { + _celestLocalPath = value; +} + +/// The path to the local checkout of the `celest-dev/celest` repo, if set. +String? get celestLocalPath { + if (_celestLocalPath case final localPathOverride?) { + return localPathOverride; + } + var celestLocalPath = platform.environment['CELEST_LOCAL_PATH']; + if (celestLocalPath != null) { + celestLocalPath = p.canonicalize(p.normalize(celestLocalPath)); + if (fileSystem.directory(celestLocalPath).existsSync()) { + Logger.root.finest('Using local Celest at $celestLocalPath'); + } else { + Logger.root.warning( + 'CELEST_LOCAL_PATH is set to $celestLocalPath, but the directory ' + 'does not exist. Ignoring.', + ); + celestLocalPath = null; + } + } + return celestLocalPath; +} + +/// The identifier for the current CLI environment. +/// +/// This should be used in Sentry/PostHog to identify events. +const String kCliEnvironment = kReleaseMode ? 'release' : 'debug'; + +/// Whether the current terminal supports ANSI output. +/// +/// See: https://bixense.com/clicolors/ +bool get ansiColorsEnabled { + if (platform.environment.containsKey('NO_COLOR')) { + return false; + } + if (platform.environment.containsKey('CLICOLOR_FORCE')) { + return true; + } + return ansiOutputEnabled; +} + +/// The base URL for the Celest control plane. +Uri baseUri = Uri.parse( + platform.environment['CELEST_API_URI'] ?? 'https://cloud.celest.dev', +); + +/// Global CLI (mason) logger. +/// +/// Set by [Cli.configure]. +mason_logger.Logger cliLogger = CliLogger(); + +/// Global CLI log level. +/// +/// Set by [Cli.configure]. +Level kCliLogLevel = Level.INFO; + +/// Global verbosity setting. +/// +/// Set by [Cli.configure]. +late bool verbose; + +/// Whether Celest is being tested. +/// +/// Defaults to `false`. +bool kCelestTest = false; + +/// Global HTTP client. +/// +/// Set by [Cli.configure]. +http.Client httpClient = http.RetryClient( + http.IOClient( + HttpClient() + ..userAgent = 'Celest/CLI' + ..connectionTimeout = const Duration(seconds: 4), + ), + whenError: (e, _) => e is SocketException, +); + +/// Global analytics instance. +/// +/// Set by [Cli.configure]. +Analytics analytics = const NoopAnalytics(); + +/// Global performance tracker. +/// +/// Set by [Cli.configure]. +CelestPerformance performance = const CelestPerformance(); + +/// Global process manager. +/// +/// Set by [Cli.configure]. +ProcessManager processManager = const LoggingProcessManager(); + +/// Global file system interface. +/// +/// Set by [Cli.configure]. +FileSystem fileSystem = const LocalFileSystem(); + +/// Global local file system. +FileSystem get localFileSystem => const LocalFileSystem(); + +/// Global path context. +path.Context get p => fileSystem.path; + +/// Global platform. +/// +/// Set by [Cli.configure]. +Platform platform = const LocalPlatform(); + +/// Global storage interface. +/// +/// Set by [Cli.configure]. +Storage storage = Storage(); + +/// Global secure storage interface. +/// +/// Set by [Cli.configure]. +NativeSecureStorage secureStorage = storage.secure; + +/// The isolated [secureStorage] interface. +IsolatedNativeStorage get isolatedSecureStorage => secureStorage.isolated; diff --git a/apps/cli/lib/src/exceptions.dart b/apps/cli/lib/src/exceptions.dart new file mode 100644 index 000000000..8194cd2f9 --- /dev/null +++ b/apps/cli/lib/src/exceptions.dart @@ -0,0 +1,29 @@ +final class CliException implements Exception { + const CliException(this.message, {this.additionalContext}); + + final String message; + final Map? additionalContext; + + @override + String toString() { + final buffer = StringBuffer(message); + if (additionalContext != null) { + buffer + ..writeln() + ..writeln('Additional context:'); + for (final entry in additionalContext!.entries) { + buffer.writeln('${entry.key}: ${entry.value}'); + } + } + return buffer.toString(); + } +} + +final class CancellationException implements Exception { + const CancellationException([this.message = '']); + + final String message; + + @override + String toString() => 'CancellationException: $message'; +} diff --git a/apps/cli/lib/src/logging/cli_json_logger.dart b/apps/cli/lib/src/logging/cli_json_logger.dart new file mode 100644 index 000000000..af445c436 --- /dev/null +++ b/apps/cli/lib/src/logging/cli_json_logger.dart @@ -0,0 +1,328 @@ +import 'dart:convert'; +import 'dart:io'; + +import 'package:celest_cli/src/logging/log_message.dart'; +import 'package:mason_logger/mason_logger.dart' as mason_logger; + +void _writeLog(LogMessage log) { + stdout.writeln(jsonEncode(log.toJson())); +} + +/// An interface which conforms to the [mason_logger.Logger] interface, but +/// which uses JSON input and output. +class CliJsonLogger implements mason_logger.Logger { + @override + mason_logger.Level level = mason_logger.Level.verbose; + + @override + mason_logger.ProgressOptions progressOptions = + const mason_logger.ProgressOptions(); + + final _queue = []; + + String? _readLine() => stdin.readLineSync(); + + String _readLineHidden() { + const lineFeed = 10; + const carriageReturn = 13; + const delete = 127; + final value = []; + + try { + stdin + ..echoMode = false + ..lineMode = false; + int char; + do { + char = stdin.readByteSync(); + if (char != lineFeed && char != carriageReturn) { + final shouldDelete = char == delete && value.isNotEmpty; + shouldDelete ? value.removeLast() : value.add(char); + } + } while (char != lineFeed && char != carriageReturn); + } finally { + stdin + ..lineMode = true + ..echoMode = true; + } + stdout.writeln(); + return utf8.decode(value); + } + + @override + void alert(String? message, {mason_logger.LogStyle? style}) { + if (message == null) { + return; + } + _writeLog(LogMessage.alert(message: message)); + } + + @override + List chooseAny( + String? message, { + required List choices, + List? defaultValues, + String Function(T choice)? display, + }) { + if (message == null) { + throw ArgumentError.notNull('message'); + } + String displayChoice(T choice) { + if (display != null) { + return display(choice); + } + return choice.toString(); + } + + final options = choices.map(displayChoice).toList(); + final defaults = defaultValues?.map(displayChoice).toList(); + _writeLog( + LogMessage.chooseAny( + message: message, + choices: options, + defaultValues: defaults, + ), + ); + final selection = _readLine(); + if (selection == null || selection.isEmpty) { + if (defaultValues != null) { + return defaultValues; + } + throw Exception('Required to choose at least one option'); + } + final selectedJson = jsonDecode(selection); + if (selectedJson is! List) { + throw Exception('Expected a JSON-encoded list of selections'); + } + final selectedOptions = selectedJson.cast(); + final selectedChoices = {}; + for (final selected in selectedOptions) { + final option = options.indexOf(selected); + if (option == -1) { + throw Exception('Unknown selection: $selected'); + } + selectedChoices.add(choices[option]); + } + return selectedChoices.toList(); + } + + @override + T chooseOne( + String? message, { + required List choices, + T? defaultValue, + String Function(T choice)? display, + }) { + if (message == null) { + throw ArgumentError.notNull('message'); + } + String displayChoice(T choice) { + if (display != null) { + return display(choice); + } + return choice.toString(); + } + + final options = choices.map(displayChoice).toList(); + final defaultOption = + defaultValue != null ? displayChoice(defaultValue) : null; + _writeLog( + LogMessage.chooseOne( + message: message, + choices: options, + defaultValue: defaultOption, + ), + ); + final selectedOption = _readLine(); + if (selectedOption == null || selectedOption.isEmpty) { + if (defaultValue != null) { + return defaultValue; + } + throw Exception('Required to choose an option'); + } + for (final choice in choices) { + if (displayChoice(choice) == selectedOption) { + return choice; + } + } + throw Exception('Unknown selection: $selectedOption'); + } + + @override + bool confirm(String? message, {bool defaultValue = false}) { + if (message == null) { + throw ArgumentError.notNull('message'); + } + _writeLog(LogMessage.confirm(message: message, defaultValue: defaultValue)); + final response = _readLine(); + if (response == null || response.isEmpty) { + return defaultValue; + } + return response.toLowerCase().startsWith('y'); + } + + @override + void delayed(String? message) { + _queue.add(message); + } + + @override + void detail(String? message, {mason_logger.LogStyle? style}) { + if (message == null) { + return; + } + _writeLog(LogMessage.detail(message: message)); + } + + @override + void err(String? message, {mason_logger.LogStyle? style}) { + if (message == null) { + return; + } + _writeLog(LogMessage.err(message: message)); + } + + @override + void flush([void Function(String? p1)? print]) { + final writeln = print ?? info; + for (final message in _queue) { + writeln(message); + } + _queue.clear(); + } + + @override + void info(String? message, {mason_logger.LogStyle? style}) { + if (message == null) { + return; + } + _writeLog(LogMessage.info(message: message)); + } + + @override + mason_logger.Progress progress( + String message, { + mason_logger.ProgressOptions? options, + }) { + return _JsonProgress(message); + } + + @override + String prompt(String? message, {Object? defaultValue, bool hidden = false}) { + if (message == null) { + throw ArgumentError.notNull('message'); + } + _writeLog( + LogMessage.prompt( + message: message, + defaultValue: defaultValue?.toString(), + ), + ); + final response = hidden ? _readLineHidden() : _readLine(); + if (response == null || response.isEmpty) { + if (defaultValue != null) { + return defaultValue.toString(); + } + throw Exception('Required to provide a response'); + } + return response; + } + + @override + List promptAny(String? message, {String separator = ','}) { + if (message == null) { + throw ArgumentError.notNull('message'); + } + _writeLog(LogMessage.promptAny(message: message)); + final response = _readLine(); + if (response == null || response.isEmpty) { + throw Exception('Required to provide at least one response'); + } + final selectedJson = jsonDecode(response); + if (selectedJson is! List) { + throw Exception('Expected a JSON-encoded list of responses'); + } + return selectedJson.cast(); + } + + @override + void success(String? message, {mason_logger.LogStyle? style}) { + if (message == null) { + return; + } + _writeLog(LogMessage.success(message: message)); + } + + @override + mason_logger.LogTheme get theme => const mason_logger.LogTheme(); + + @override + void warn( + String? message, { + String tag = 'WARN', + mason_logger.LogStyle? style, + }) { + if (message == null) { + return; + } + _writeLog(LogMessage.warn(message: message)); + } + + @override + void write(String? message) { + if (message == null) { + return; + } + _writeLog(LogMessage.info(message: message)); + } +} + +final class _JsonProgress implements mason_logger.Progress { + _JsonProgress(this.initialMessage) { + _writeLog( + LogMessage.progress( + message: initialMessage, + progress: ProgressAction.start, + ), + ); + } + + final String initialMessage; + + @override + void cancel() { + _writeLog( + LogMessage.progress( + progress: ProgressAction.cancel, + message: initialMessage, + ), + ); + } + + @override + void complete([String? update]) { + _writeLog( + LogMessage.progress( + progress: ProgressAction.complete, + message: update ?? initialMessage, + ), + ); + } + + @override + void fail([String? update]) { + _writeLog( + LogMessage.progress( + progress: ProgressAction.fail, + message: update ?? initialMessage, + ), + ); + } + + @override + void update(String update) { + _writeLog( + LogMessage.progress(progress: ProgressAction.update, message: update), + ); + } +} diff --git a/apps/cli/lib/src/logging/cli_logger.dart b/apps/cli/lib/src/logging/cli_logger.dart new file mode 100644 index 000000000..036df4204 --- /dev/null +++ b/apps/cli/lib/src/logging/cli_logger.dart @@ -0,0 +1,301 @@ +import 'dart:convert'; +import 'dart:io'; + +import 'package:celest_cli/src/context.dart'; +import 'package:cli_util/cli_logging.dart' as cli_logging; +import 'package:dcli/dcli.dart'; +import 'package:mason_logger/mason_logger.dart' as mason_logger; + +/// An interface which conforms to the [mason_logger.Logger] interface, but +/// which properly accounts for [ansiColorsEnabled]. +class CliLogger implements mason_logger.Logger { + CliLogger({ + this.theme = const mason_logger.LogTheme(), + this.progressOptions = const mason_logger.ProgressOptions(), + }); + + @override + final mason_logger.LogTheme theme; + + @override + mason_logger.Level level = mason_logger.Level.verbose; + + @override + mason_logger.ProgressOptions progressOptions = + const mason_logger.ProgressOptions(); + + late final mason_logger.Logger _logger = mason_logger.Logger( + theme: theme, + level: level, + progressOptions: progressOptions, + ); + + @override + void alert(String? message, {mason_logger.LogStyle? style}) { + if (ansiColorsEnabled) { + return _logger.alert(message, style: style); + } + stderr.writeln(message); + } + + @override + List chooseAny( + String? message, { + required List choices, + List? defaultValues, + String Function(T choice)? display, + }) { + if (ansiColorsEnabled) { + return _logger.chooseAny( + message, + choices: choices, + defaultValues: defaultValues, + display: display, + ); + } + throw UnimplementedError('chooseAny is not implemented yet'); + } + + @override + T chooseOne( + String? message, { + required List choices, + T? defaultValue, + String Function(T choice)? display, + }) { + if (ansiColorsEnabled) { + return _logger.chooseOne( + message, + choices: choices, + defaultValue: defaultValue, + display: display, + ); + } + throw UnimplementedError('chooseOne is not implemented yet'); + } + + @override + bool confirm(String? message, {bool defaultValue = false}) { + if (!stdin.hasTerminal) { + return true; + } + if (ansiColorsEnabled) { + return _logger.confirm(message, defaultValue: defaultValue); + } + final suffix = ' ${defaultValue.toYesNo()}'; + final resolvedMessage = '$message$suffix '; + stdout.write(resolvedMessage); + String? input; + try { + input = stdin.readLineSync(); + } on FormatException catch (_) { + // FormatExceptions can occur due to utf8 decoding errors + // so we treat them as the user pressing enter (e.g. use `defaultValue`). + stdout.writeln(); + } + return input == null || input.isEmpty + ? defaultValue + : input.toBoolean() ?? defaultValue; + } + + @override + void delayed(String? message) { + throw UnimplementedError("Don't use delayed"); + } + + @override + void detail(String? message, {mason_logger.LogStyle? style}) { + if (ansiColorsEnabled) { + return _logger.detail(message, style: style); + } + stdout.writeln(message); + } + + @override + void err(String? message, {mason_logger.LogStyle? style}) { + if (ansiColorsEnabled) { + return _logger.err(message, style: style); + } + stderr.writeln(message); + } + + @override + void flush([void Function(String? p1)? print]) { + if (ansiColorsEnabled) { + return _logger.flush(print); + } + stdout.flush().ignore(); + stderr.flush().ignore(); + } + + @override + void info(String? message, {mason_logger.LogStyle? style}) { + if (ansiColorsEnabled) { + return _logger.info(message, style: style); + } + stdout.writeln(message); + } + + @override + mason_logger.Progress progress( + String message, { + mason_logger.ProgressOptions? options, + }) { + if (ansiColorsEnabled) { + return _logger.progress(message, options: options); + } + final ci = platform.environment['CI'] ?? ''; + return _CliProgress( + useAnsi: ci.toBoolean() ?? false, + message: '$message...', + ); + } + + @override + String prompt(String? message, {Object? defaultValue, bool hidden = false}) { + if (ansiColorsEnabled) { + return ask( + message.toString(), + defaultValue: defaultValue?.toString(), + hidden: hidden, + ); + } + final resolvedDefaultValue = switch (defaultValue) { + final defaultValue? when '$defaultValue'.isNotEmpty => ' ($defaultValue)', + _ => ':', + }; + final resolvedMessage = '$message$resolvedDefaultValue '; + stdout.write(resolvedMessage); + final input = hidden ? _readLineHiddenSync() : stdin.readLineSync()?.trim(); + return input == null || input.isEmpty ? resolvedDefaultValue : input; + } + + @override + List promptAny(String? message, {String separator = ','}) { + if (ansiColorsEnabled) { + return _logger.promptAny(message, separator: separator); + } + throw UnimplementedError('promptAny is not implemented yet'); + } + + @override + void success(String? message, {mason_logger.LogStyle? style}) { + if (ansiColorsEnabled) { + return _logger.success(message, style: style); + } + stdout.writeln(message); + } + + @override + void warn(String? message, {String tag = '', mason_logger.LogStyle? style}) { + if (ansiColorsEnabled) { + return _logger.warn(message, tag: tag, style: style); + } + stderr.writeln(message); + } + + @override + void write(String? message) { + if (ansiColorsEnabled) { + return _logger.write(message); + } + stdout.write(message); + } + + String _readLineHiddenSync() { + const lineFeed = 10; + const carriageReturn = 13; + const delete = 127; + final value = []; + + try { + stdin + ..echoMode = false + ..lineMode = false; + int char; + do { + char = stdin.readByteSync(); + if (char != lineFeed && char != carriageReturn) { + final shouldDelete = char == delete && value.isNotEmpty; + shouldDelete ? value.removeLast() : value.add(char); + } + } while (char != lineFeed && char != carriageReturn); + } finally { + stdin + ..lineMode = true + ..echoMode = true; + } + stdout.writeln(); + return utf8.decode(value); + } +} + +final class _CliProgress implements mason_logger.Progress { + _CliProgress({required bool useAnsi, required String message}) + : _progress = + useAnsi + ? cli_logging.AnsiProgress(cli_logging.Ansi(true), message) + : null { + if (!useAnsi) { + stdout.writeln(message); + } + } + + final cli_logging.Progress? _progress; + + @override + void cancel() { + _progress?.cancel(); + } + + @override + void complete([String? update]) { + if (_progress != null) { + return _progress.finish(message: update); + } + if (update != null) { + stdout.writeln(update); + } + } + + @override + void fail([String? update]) { + if (_progress != null) { + return _progress.finish(message: update); + } + if (update != null) { + stderr.writeln(update); + } + } + + @override + void update(String update) { + stdout.writeln(update); + } +} + +extension on bool { + String toYesNo() { + return this == true ? 'Y/n' : 'y/N'; + } +} + +extension on String { + bool? toBoolean() { + switch (toLowerCase()) { + case 'y': + case 'yea': + case 'yeah': + case 'yep': + case 'yes': + case 'yup': + return true; + case 'n': + case 'no': + case 'nope': + return false; + default: + return null; + } + } +} diff --git a/apps/cli/lib/src/logging/log_event.dart b/apps/cli/lib/src/logging/log_event.dart new file mode 100644 index 000000000..cff516283 --- /dev/null +++ b/apps/cli/lib/src/logging/log_event.dart @@ -0,0 +1,12 @@ +import 'package:logging/logging.dart'; + +extension LogEvent on Logger { + static const Level level = Level('EVENT', 1500); + + /// Log message at [level]. + /// + /// See [log] for information on how non-String [message] arguments are + /// handled. + void event(Object? message, [Object? error, StackTrace? stackTrace]) => + log(level, message, error, stackTrace); +} diff --git a/apps/cli/lib/src/logging/log_message.dart b/apps/cli/lib/src/logging/log_message.dart new file mode 100644 index 000000000..747881857 --- /dev/null +++ b/apps/cli/lib/src/logging/log_message.dart @@ -0,0 +1,324 @@ +import 'dart:convert'; + +enum LogType { + alert, + chooseAny, + chooseOne, + confirm, + detail, + err, + info, + progress, + prompt, + promptAny, + success, + warn, +} + +enum ProgressAction { + start, + cancel, + complete, + fail, + update, +} + +final class LogMessageProgress extends LogMessage { + const LogMessageProgress({ + required this.progress, + required super.message, + }) : super._(type: LogType.progress); + + factory LogMessageProgress.fromJson(Map json) { + final progress = ProgressAction.values.byName( + json.remove('progress') as String, + ); + return LogMessageProgress( + progress: progress, + message: _expectMessage(json), + ); + } + + final ProgressAction progress; + + @override + Map toJson() => { + ...super.toJson(), + 'progress': progress.name, + }; +} + +final class LogMessageAlert extends LogMessage { + const LogMessageAlert({ + required super.message, + }) : super._(type: LogType.alert); + + factory LogMessageAlert.fromJson(Map json) { + return LogMessageAlert(message: json['message'] as String); + } +} + +final class LogMessageChooseAny extends LogMessage { + const LogMessageChooseAny({ + required super.message, + required this.choices, + this.defaultValues, + }) : super._(type: LogType.chooseAny); + + factory LogMessageChooseAny.fromJson(Map json) { + final choices = (json.remove('choices') as List).cast(); + final defaultValues = json.remove('defaultValues') as List?; + return LogMessageChooseAny( + message: _expectMessage(json), + choices: choices, + defaultValues: defaultValues?.cast(), + ); + } + + final List choices; + final List? defaultValues; + + @override + Map toJson() => { + ...super.toJson(), + 'choices': choices, + if (defaultValues case final defaultValues?) + 'defaultValues': defaultValues, + }; +} + +final class LogMessageChooseOne extends LogMessage { + const LogMessageChooseOne({ + required super.message, + required this.choices, + this.defaultValue, + }) : super._(type: LogType.chooseOne); + + factory LogMessageChooseOne.fromJson(Map json) { + final choices = (json.remove('choices') as List).cast(); + final defaultValue = json.remove('defaultValue') as String?; + return LogMessageChooseOne( + message: _expectMessage(json), + choices: choices, + defaultValue: defaultValue, + ); + } + + final List choices; + final String? defaultValue; + + @override + Map toJson() => { + ...super.toJson(), + 'choices': choices, + if (defaultValue case final defaultValue?) 'defaultValue': defaultValue, + }; +} + +final class LogMessageConfirm extends LogMessage { + const LogMessageConfirm({ + required super.message, + required this.defaultValue, + }) : super._(type: LogType.confirm); + + factory LogMessageConfirm.fromJson(Map json) { + final defaultValue = json.remove('defaultValue') as bool; + return LogMessageConfirm( + message: _expectMessage(json), + defaultValue: defaultValue, + ); + } + + final bool defaultValue; + + @override + Map toJson() => { + ...super.toJson(), + 'defaultValue': defaultValue, + }; +} + +final class LogMessageDetail extends LogMessage { + const LogMessageDetail({ + required super.message, + }) : super._(type: LogType.detail); + + factory LogMessageDetail.fromJson(Map json) { + return LogMessageDetail(message: _expectMessage(json)); + } +} + +final class LogMessageErr extends LogMessage { + const LogMessageErr({ + required super.message, + }) : super._(type: LogType.err); + + factory LogMessageErr.fromJson(Map json) { + return LogMessageErr(message: _expectMessage(json)); + } +} + +final class LogMessageInfo extends LogMessage { + const LogMessageInfo({ + required super.message, + }) : super._(type: LogType.info); + + factory LogMessageInfo.fromJson(Map json) { + return LogMessageInfo(message: _expectMessage(json)); + } +} + +final class LogMessagePrompt extends LogMessage { + const LogMessagePrompt({ + required super.message, + this.defaultValue, + }) : super._(type: LogType.prompt); + + factory LogMessagePrompt.fromJson(Map json) { + final defaultValue = json.remove('defaultValue') as String?; + return LogMessagePrompt( + message: _expectMessage(json), + defaultValue: defaultValue, + ); + } + + final String? defaultValue; + + @override + Map toJson() => { + ...super.toJson(), + if (defaultValue case final defaultValue?) 'defaultValue': defaultValue, + }; +} + +final class LogMessagePromptAny extends LogMessage { + const LogMessagePromptAny({ + required super.message, + }) : super._(type: LogType.promptAny); + + factory LogMessagePromptAny.fromJson(Map json) { + return LogMessagePromptAny(message: _expectMessage(json)); + } +} + +final class LogMessageSuccess extends LogMessage { + const LogMessageSuccess({ + required super.message, + }) : super._(type: LogType.success); + + factory LogMessageSuccess.fromJson(Map json) { + return LogMessageSuccess(message: _expectMessage(json)); + } +} + +final class LogMessageWarn extends LogMessage { + const LogMessageWarn({ + required super.message, + }) : super._(type: LogType.warn); + + factory LogMessageWarn.fromJson(Map json) { + return LogMessageWarn(message: _expectMessage(json)); + } +} + +sealed class LogMessage { + factory LogMessage.fromJson(Map json) { + json = Map.of(json); + final type = LogType.values.byName(json.remove('type') as String); + return switch (type) { + LogType.alert => LogMessageAlert.fromJson(json), + LogType.chooseAny => LogMessageChooseAny.fromJson(json), + LogType.chooseOne => LogMessageChooseOne.fromJson(json), + LogType.confirm => LogMessageConfirm.fromJson(json), + LogType.detail => LogMessageDetail.fromJson(json), + LogType.err => LogMessageErr.fromJson(json), + LogType.info => LogMessageInfo.fromJson(json), + LogType.prompt => LogMessagePrompt.fromJson(json), + LogType.promptAny => LogMessagePromptAny.fromJson(json), + LogType.progress => LogMessageProgress.fromJson(json), + LogType.success => LogMessageSuccess.fromJson(json), + LogType.warn => LogMessageWarn.fromJson(json), + }; + } + const factory LogMessage.alert({ + required String message, + }) = LogMessageAlert; + + const factory LogMessage.chooseAny({ + required String message, + required List choices, + List? defaultValues, + }) = LogMessageChooseAny; + + const factory LogMessage.chooseOne({ + required String message, + required List choices, + String? defaultValue, + }) = LogMessageChooseOne; + + const factory LogMessage.confirm({ + required String message, + required bool defaultValue, + }) = LogMessageConfirm; + + const factory LogMessage.detail({ + required String message, + }) = LogMessageDetail; + + const factory LogMessage.err({ + required String message, + }) = LogMessageErr; + + const factory LogMessage.info({ + required String message, + }) = LogMessageInfo; + + const factory LogMessage.progress({ + required ProgressAction progress, + required String message, + }) = LogMessageProgress; + + const factory LogMessage.prompt({ + required String message, + String? defaultValue, + }) = LogMessagePrompt; + + const factory LogMessage.promptAny({ + required String message, + }) = LogMessagePromptAny; + + const factory LogMessage.success({ + required String message, + }) = LogMessageSuccess; + + const factory LogMessage.warn({ + required String message, + }) = LogMessageWarn; + + const LogMessage._({ + required this.type, + required this.message, + }); + + final LogType type; + final String message; + + Map toJson() => { + 'type': type.name, + 'message': message, + }; + + @override + String toString() => jsonEncode(toJson()); +} + +String _expectMessage(Map json) { + final message = json.remove('message') as String; + if (json.isNotEmpty) { + throw FormatException( + 'Invalid log message JSON: $json. ' + 'Unexpected keys: ${json.keys.join(', ')}', + ); + } + return message; +} diff --git a/apps/cli/lib/src/logging/with_progress.dart b/apps/cli/lib/src/logging/with_progress.dart new file mode 100644 index 000000000..644e48a51 --- /dev/null +++ b/apps/cli/lib/src/logging/with_progress.dart @@ -0,0 +1,24 @@ +import 'package:celest_cli/src/context.dart'; +import 'package:mason_logger/mason_logger.dart'; + +/// Runs [callback] with a [Progress] instance. +Future withProgress( + String message, + Future Function(Progress progress) callback, { + String? onSuccess, + String? onError, +}) async { + final progress = cliLogger.progress(message); + try { + final result = await callback(progress); + progress.complete(onSuccess); + return result; + } on Object { + if (onError != null) { + progress.fail(onError); + } else { + progress.cancel(); + } + rethrow; + } +} diff --git a/apps/cli/lib/src/models.dart b/apps/cli/lib/src/models.dart new file mode 100644 index 000000000..15913e3fd --- /dev/null +++ b/apps/cli/lib/src/models.dart @@ -0,0 +1,13 @@ +import 'package:pub_semver/pub_semver.dart'; + +class PubVersionInfo { + const PubVersionInfo(this.allVersions); + + final List allVersions; + + Version? get latestVersion => + allVersions.where((version) => !version.isPreRelease).lastOrNull; + + Version? get latestPrerelease => + allVersions.where((version) => version.isPreRelease).lastOrNull; +} diff --git a/apps/cli/lib/src/performance/local_perf.dart b/apps/cli/lib/src/performance/local_perf.dart new file mode 100644 index 000000000..27d0e1ab3 --- /dev/null +++ b/apps/cli/lib/src/performance/local_perf.dart @@ -0,0 +1,42 @@ +import 'package:logging/logging.dart'; +import 'package:meta/meta.dart'; +import 'package:timing/timing.dart'; +import 'package:uuid/uuid.dart'; + +base class CelestPerformance { + const CelestPerformance(); + + static final _logger = Logger('CelestPerformance'); + + void captureError( + Object error, { + StackTrace? stackTrace, + Map? extra, + }) => + innerCaptureError(error, stackTrace: stackTrace, extra: extra).ignore(); + + @internal + Future innerCaptureError( + Object error, { + StackTrace? stackTrace, + Map? extra, + }) async { + // Matches Sentry error id format + return const Uuid().v4().replaceAll('-', ''); + } + + Future trace( + String name, + String operation, + Future Function() fn, { + String? description, + }) async { + // TODO(dnys1): Sync time tracker support as well? + final tracker = AsyncTimeTracker(); + final result = await tracker.track(fn); + _logger.finest( + '$name.$operation: duration=${tracker.duration.inMilliseconds}ms', + ); + return result; + } +} diff --git a/apps/cli/lib/src/performance/sentry_perf.dart b/apps/cli/lib/src/performance/sentry_perf.dart new file mode 100644 index 000000000..95df42ec1 --- /dev/null +++ b/apps/cli/lib/src/performance/sentry_perf.dart @@ -0,0 +1,57 @@ +import 'package:celest_cli/src/performance/local_perf.dart'; +import 'package:celest_core/src/util/let.dart'; +import 'package:sentry/sentry.dart'; + +final class SentryConfig { + const SentryConfig({required this.dsn, this.beforeSend}); + + final String dsn; + final SentryEvent Function(SentryEvent event, {Hint? hint})? beforeSend; +} + +base class SentryPerformance extends CelestPerformance { + const SentryPerformance(); + + @override + Future innerCaptureError( + Object error, { + StackTrace? stackTrace, + Map? extra, + }) async { + if (!Sentry.isEnabled) { + return super.innerCaptureError( + error, + stackTrace: stackTrace, + extra: extra, + ); + } + final result = await Sentry.captureException( + error, + stackTrace: stackTrace, + hint: extra?.let((extra) => Hint()..addAll(extra)), + ); + return result.toString(); + } + + @override + Future trace( + String name, + String operation, + Future Function() fn, { + String? description, + }) async { + if (!Sentry.isEnabled) { + return super.trace(name, operation, fn, description: description); + } + final transaction = Sentry.startTransaction( + name, + operation, + description: description, + ); + try { + return await super.trace(name, operation, fn, description: description); + } finally { + await transaction.finish(); + } + } +} diff --git a/apps/cli/lib/src/platform/macos_bindings.g.dart b/apps/cli/lib/src/platform/macos_bindings.g.dart new file mode 100644 index 000000000..2bc54e08f --- /dev/null +++ b/apps/cli/lib/src/platform/macos_bindings.g.dart @@ -0,0 +1,22328 @@ +// ignore_for_file: type=lint +// ignore_for_file: return_of_invalid_type + +// AUTO GENERATED FILE, DO NOT EDIT. +// +// Generated by `package:ffigen`. +import 'dart:ffi' as ffi; +import 'package:ffi/ffi.dart' as pkg_ffi; + +/// Bindings for Foundation and supporting frameworks (AppKit/IOKit). +/// +/// Regenerate bindings with `dart run ffigen --config=ffigen.macos.yaml`. +/// +class NativeMacOsFramework { + /// Holds the symbol lookup function. + final ffi.Pointer Function(String symbolName) + _lookup; + + /// The symbols are looked up in [dynamicLibrary]. + NativeMacOsFramework(ffi.DynamicLibrary dynamicLibrary) + : _lookup = dynamicLibrary.lookup; + + /// The symbols are looked up with [lookup]. + NativeMacOsFramework.fromLookup( + ffi.Pointer Function(String symbolName) + lookup) + : _lookup = lookup; + + int uname( + ffi.Pointer arg0, + ) { + return _uname( + arg0, + ); + } + + late final _unamePtr = + _lookup)>>( + 'uname'); + late final _uname = + _unamePtr.asFunction)>(); + + /// This is a synonym for NULL, if you'd rather use a named constant. + late final ffi.Pointer> _kCFAllocatorDefault = + _lookup>('kCFAllocatorDefault'); + + ffi.Pointer<__CFAllocator> get kCFAllocatorDefault => + _kCFAllocatorDefault.value; + + set kCFAllocatorDefault(ffi.Pointer<__CFAllocator> value) => + _kCFAllocatorDefault.value = value; + + void CFRelease( + CFTypeRef cf, + ) { + return _CFRelease( + cf, + ); + } + + late final _CFReleasePtr = + _lookup>('CFRelease'); + late final _CFRelease = _CFReleasePtr.asFunction(); + + ffi.Pointer CFDictionaryCreate( + ffi.Pointer<__CFAllocator> allocator, + ffi.Pointer> keys, + ffi.Pointer> values, + int numValues, + ffi.Pointer keyCallBacks, + ffi.Pointer valueCallBacks, + ) { + return _CFDictionaryCreate( + allocator, + keys, + values, + numValues, + keyCallBacks, + valueCallBacks, + ); + } + + late final _CFDictionaryCreatePtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer<__CFAllocator>, + ffi.Pointer>, + ffi.Pointer>, + ffi.Long, + ffi.Pointer, + ffi.Pointer)>>('CFDictionaryCreate'); + late final _CFDictionaryCreate = _CFDictionaryCreatePtr.asFunction< + ffi.Pointer Function( + ffi.Pointer<__CFAllocator>, + ffi.Pointer>, + ffi.Pointer>, + int, + ffi.Pointer, + ffi.Pointer)>(); + + ffi.Pointer CFDataCreate( + ffi.Pointer<__CFAllocator> allocator, + ffi.Pointer bytes, + int length, + ) { + return _CFDataCreate( + allocator, + bytes, + length, + ); + } + + late final _CFDataCreatePtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer<__CFAllocator>, + ffi.Pointer, ffi.Long)>>('CFDataCreate'); + late final _CFDataCreate = _CFDataCreatePtr.asFunction< + ffi.Pointer Function( + ffi.Pointer<__CFAllocator>, ffi.Pointer, int)>(); + + ffi.Pointer CFDataGetBytePtr( + ffi.Pointer theData, + ) { + return _CFDataGetBytePtr( + theData, + ); + } + + late final _CFDataGetBytePtrPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer)>>('CFDataGetBytePtr'); + late final _CFDataGetBytePtr = _CFDataGetBytePtrPtr.asFunction< + ffi.Pointer Function(ffi.Pointer)>(); + + ffi.Pointer CFStringCreateWithCString( + ffi.Pointer<__CFAllocator> alloc, + ffi.Pointer cStr, + int encoding, + ) { + return _CFStringCreateWithCString( + alloc, + cStr, + encoding, + ); + } + + late final _CFStringCreateWithCStringPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer<__CFAllocator>, + ffi.Pointer, + ffi.UnsignedInt)>>('CFStringCreateWithCString'); + late final _CFStringCreateWithCString = + _CFStringCreateWithCStringPtr.asFunction< + ffi.Pointer Function( + ffi.Pointer<__CFAllocator>, ffi.Pointer, int)>(); + + int CFStringGetLength( + ffi.Pointer theString, + ) { + return _CFStringGetLength( + theString, + ); + } + + late final _CFStringGetLengthPtr = + _lookup)>>( + 'CFStringGetLength'); + late final _CFStringGetLength = + _CFStringGetLengthPtr.asFunction)>(); + + int CFStringGetCString( + ffi.Pointer theString, + ffi.Pointer buffer, + int bufferSize, + int encoding, + ) { + return _CFStringGetCString( + theString, + buffer, + bufferSize, + encoding, + ); + } + + late final _CFStringGetCStringPtr = _lookup< + ffi.NativeFunction< + ffi.UnsignedChar Function( + ffi.Pointer, + ffi.Pointer, + ffi.Long, + ffi.UnsignedInt)>>('CFStringGetCString'); + late final _CFStringGetCString = _CFStringGetCStringPtr.asFunction< + int Function(ffi.Pointer, ffi.Pointer, int, int)>(); + + ffi.Pointer CFStringGetCStringPtr( + ffi.Pointer theString, + int encoding, + ) { + return _CFStringGetCStringPtr1( + theString, + encoding, + ); + } + + late final _CFStringGetCStringPtrPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.UnsignedInt)>>('CFStringGetCStringPtr'); + late final _CFStringGetCStringPtr1 = _CFStringGetCStringPtrPtr.asFunction< + ffi.Pointer Function(ffi.Pointer, int)>(); + + int CFStringGetMaximumSizeForEncoding( + int length, + int encoding, + ) { + return _CFStringGetMaximumSizeForEncoding( + length, + encoding, + ); + } + + late final _CFStringGetMaximumSizeForEncodingPtr = + _lookup>( + 'CFStringGetMaximumSizeForEncoding'); + late final _CFStringGetMaximumSizeForEncoding = + _CFStringGetMaximumSizeForEncodingPtr.asFunction< + int Function(int, int)>(); + + /// The bundle identifier (for CFBundleGetBundleWithIdentifier()) + late final ffi.Pointer> _kCFBundleVersionKey = + _lookup>('kCFBundleVersionKey'); + + ffi.Pointer get kCFBundleVersionKey => _kCFBundleVersionKey.value; + + set kCFBundleVersionKey(ffi.Pointer value) => + _kCFBundleVersionKey.value = value; + + ffi.Pointer _registerName1(String name) { + final cstr = name.toNativeUtf8(); + final sel = _sel_registerName(cstr.cast()); + pkg_ffi.calloc.free(cstr); + return sel; + } + + ffi.Pointer _sel_registerName( + ffi.Pointer str, + ) { + return __sel_registerName( + str, + ); + } + + late final __sel_registerNamePtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer)>>('sel_registerName'); + late final __sel_registerName = __sel_registerNamePtr + .asFunction Function(ffi.Pointer)>(); + + ffi.Pointer _getClass1(String name) { + final cstr = name.toNativeUtf8(); + final clazz = _objc_getClass(cstr.cast()); + pkg_ffi.calloc.free(cstr); + if (clazz == ffi.nullptr) { + throw Exception('Failed to load Objective-C class: $name'); + } + return clazz; + } + + ffi.Pointer _objc_getClass( + ffi.Pointer str, + ) { + return __objc_getClass( + str, + ); + } + + late final __objc_getClassPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer)>>('objc_getClass'); + late final __objc_getClass = __objc_getClassPtr + .asFunction Function(ffi.Pointer)>(); + + ffi.Pointer _objc_retain( + ffi.Pointer value, + ) { + return __objc_retain( + value, + ); + } + + late final __objc_retainPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer)>>('objc_retain'); + late final __objc_retain = __objc_retainPtr + .asFunction Function(ffi.Pointer)>(); + + void _objc_release( + ffi.Pointer value, + ) { + return __objc_release( + value, + ); + } + + late final __objc_releasePtr = + _lookup)>>( + 'objc_release'); + late final __objc_release = + __objc_releasePtr.asFunction)>(); + + late final _objc_releaseFinalizer2 = + ffi.NativeFinalizer(__objc_releasePtr.cast()); + late final _class_NSObject1 = _getClass1("NSObject"); + late final _sel_load1 = _registerName1("load"); + void _objc_msgSend_1( + ffi.Pointer obj, + ffi.Pointer sel, + ) { + return __objc_msgSend_1( + obj, + sel, + ); + } + + late final __objc_msgSend_1Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_1 = __objc_msgSend_1Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer)>(); + + late final _sel_initialize1 = _registerName1("initialize"); + late final _sel_init1 = _registerName1("init"); + instancetype _objc_msgSend_2( + ffi.Pointer obj, + ffi.Pointer sel, + ) { + return __objc_msgSend_2( + obj, + sel, + ); + } + + late final __objc_msgSend_2Ptr = _lookup< + ffi.NativeFunction< + instancetype Function( + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_2 = __objc_msgSend_2Ptr.asFunction< + instancetype Function(ffi.Pointer, ffi.Pointer)>(); + + late final _sel_new1 = _registerName1("new"); + late final _sel_allocWithZone_1 = _registerName1("allocWithZone:"); + instancetype _objc_msgSend_3( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer<_NSZone> zone, + ) { + return __objc_msgSend_3( + obj, + sel, + zone, + ); + } + + late final __objc_msgSend_3Ptr = _lookup< + ffi.NativeFunction< + instancetype Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer<_NSZone>)>>('objc_msgSend'); + late final __objc_msgSend_3 = __objc_msgSend_3Ptr.asFunction< + instancetype Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer<_NSZone>)>(); + + late final _sel_alloc1 = _registerName1("alloc"); + late final _sel_dealloc1 = _registerName1("dealloc"); + late final _sel_finalize1 = _registerName1("finalize"); + late final _sel_copy1 = _registerName1("copy"); + late final _sel_mutableCopy1 = _registerName1("mutableCopy"); + late final _sel_copyWithZone_1 = _registerName1("copyWithZone:"); + late final _sel_mutableCopyWithZone_1 = + _registerName1("mutableCopyWithZone:"); + late final _sel_instancesRespondToSelector_1 = + _registerName1("instancesRespondToSelector:"); + bool _objc_msgSend_4( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer aSelector, + ) { + return __objc_msgSend_4( + obj, + sel, + aSelector, + ); + } + + late final __objc_msgSend_4Ptr = _lookup< + ffi.NativeFunction< + ffi.Bool Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_4 = __objc_msgSend_4Ptr.asFunction< + bool Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); + + bool _objc_msgSend_0( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer clazz, + ) { + return __objc_msgSend_0( + obj, + sel, + clazz, + ); + } + + late final __objc_msgSend_0Ptr = _lookup< + ffi.NativeFunction< + ffi.Bool Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_0 = __objc_msgSend_0Ptr.asFunction< + bool Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); + + late final _sel_isKindOfClass_1 = _registerName1("isKindOfClass:"); + late final _class_Protocol1 = _getClass1("Protocol"); + late final _sel_conformsToProtocol_1 = _registerName1("conformsToProtocol:"); + bool _objc_msgSend_5( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer protocol, + ) { + return __objc_msgSend_5( + obj, + sel, + protocol, + ); + } + + late final __objc_msgSend_5Ptr = _lookup< + ffi.NativeFunction< + ffi.Bool Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_5 = __objc_msgSend_5Ptr.asFunction< + bool Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); + + late final _sel_methodForSelector_1 = _registerName1("methodForSelector:"); + ffi.Pointer> _objc_msgSend_6( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer aSelector, + ) { + return __objc_msgSend_6( + obj, + sel, + aSelector, + ); + } + + late final __objc_msgSend_6Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer> Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_6 = __objc_msgSend_6Ptr.asFunction< + ffi.Pointer> Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>(); + + late final _sel_instanceMethodForSelector_1 = + _registerName1("instanceMethodForSelector:"); + late final _sel_doesNotRecognizeSelector_1 = + _registerName1("doesNotRecognizeSelector:"); + void _objc_msgSend_7( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer aSelector, + ) { + return __objc_msgSend_7( + obj, + sel, + aSelector, + ); + } + + late final __objc_msgSend_7Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_7 = __objc_msgSend_7Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); + + late final _sel_forwardingTargetForSelector_1 = + _registerName1("forwardingTargetForSelector:"); + ffi.Pointer _objc_msgSend_8( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer aSelector, + ) { + return __objc_msgSend_8( + obj, + sel, + aSelector, + ); + } + + late final __objc_msgSend_8Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_8 = __objc_msgSend_8Ptr.asFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>(); + + late final _class_NSInvocation1 = _getClass1("NSInvocation"); + late final _sel_forwardInvocation_1 = _registerName1("forwardInvocation:"); + void _objc_msgSend_9( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer anInvocation, + ) { + return __objc_msgSend_9( + obj, + sel, + anInvocation, + ); + } + + late final __objc_msgSend_9Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_9 = __objc_msgSend_9Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); + + late final _class_NSMethodSignature1 = _getClass1("NSMethodSignature"); + late final _sel_methodSignatureForSelector_1 = + _registerName1("methodSignatureForSelector:"); + ffi.Pointer _objc_msgSend_10( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer aSelector, + ) { + return __objc_msgSend_10( + obj, + sel, + aSelector, + ); + } + + late final __objc_msgSend_10Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_10 = __objc_msgSend_10Ptr.asFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>(); + + late final _sel_instanceMethodSignatureForSelector_1 = + _registerName1("instanceMethodSignatureForSelector:"); + late final _sel_allowsWeakReference1 = _registerName1("allowsWeakReference"); + bool _objc_msgSend_11( + ffi.Pointer obj, + ffi.Pointer sel, + ) { + return __objc_msgSend_11( + obj, + sel, + ); + } + + late final __objc_msgSend_11Ptr = _lookup< + ffi.NativeFunction< + ffi.Bool Function( + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_11 = __objc_msgSend_11Ptr.asFunction< + bool Function(ffi.Pointer, ffi.Pointer)>(); + + late final _sel_retainWeakReference1 = _registerName1("retainWeakReference"); + late final _sel_isSubclassOfClass_1 = _registerName1("isSubclassOfClass:"); + late final _sel_resolveClassMethod_1 = _registerName1("resolveClassMethod:"); + late final _sel_resolveInstanceMethod_1 = + _registerName1("resolveInstanceMethod:"); + late final _sel_hash1 = _registerName1("hash"); + int _objc_msgSend_12( + ffi.Pointer obj, + ffi.Pointer sel, + ) { + return __objc_msgSend_12( + obj, + sel, + ); + } + + late final __objc_msgSend_12Ptr = _lookup< + ffi.NativeFunction< + ffi.UnsignedLong Function( + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_12 = __objc_msgSend_12Ptr.asFunction< + int Function(ffi.Pointer, ffi.Pointer)>(); + + late final _sel_superclass1 = _registerName1("superclass"); + late final _sel_class1 = _registerName1("class"); + late final _class_NSString1 = _getClass1("NSString"); + late final _sel_length1 = _registerName1("length"); + late final _sel_characterAtIndex_1 = _registerName1("characterAtIndex:"); + int _objc_msgSend_13( + ffi.Pointer obj, + ffi.Pointer sel, + int index, + ) { + return __objc_msgSend_13( + obj, + sel, + index, + ); + } + + late final __objc_msgSend_13Ptr = _lookup< + ffi.NativeFunction< + ffi.UnsignedShort Function(ffi.Pointer, + ffi.Pointer, ffi.UnsignedLong)>>('objc_msgSend'); + late final __objc_msgSend_13 = __objc_msgSend_13Ptr.asFunction< + int Function(ffi.Pointer, ffi.Pointer, int)>(); + + late final _class_NSCoder1 = _getClass1("NSCoder"); + late final _sel_encodeValueOfObjCType_at_1 = + _registerName1("encodeValueOfObjCType:at:"); + void _objc_msgSend_14( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer type, + ffi.Pointer addr, + ) { + return __objc_msgSend_14( + obj, + sel, + type, + addr, + ); + } + + late final __objc_msgSend_14Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_14 = __objc_msgSend_14Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, ffi.Pointer)>(); + + late final _class_NSData1 = _getClass1("NSData"); + late final _sel_bytes1 = _registerName1("bytes"); + ffi.Pointer _objc_msgSend_15( + ffi.Pointer obj, + ffi.Pointer sel, + ) { + return __objc_msgSend_15( + obj, + sel, + ); + } + + late final __objc_msgSend_15Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_15 = __objc_msgSend_15Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); + + late final _sel_encodeDataObject_1 = _registerName1("encodeDataObject:"); + void _objc_msgSend_16( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer data, + ) { + return __objc_msgSend_16( + obj, + sel, + data, + ); + } + + late final __objc_msgSend_16Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_16 = __objc_msgSend_16Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); + + late final _sel_decodeDataObject1 = _registerName1("decodeDataObject"); + ffi.Pointer _objc_msgSend_17( + ffi.Pointer obj, + ffi.Pointer sel, + ) { + return __objc_msgSend_17( + obj, + sel, + ); + } + + late final __objc_msgSend_17Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_17 = __objc_msgSend_17Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); + + late final _sel_decodeValueOfObjCType_at_size_1 = + _registerName1("decodeValueOfObjCType:at:size:"); + void _objc_msgSend_18( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer type, + ffi.Pointer data, + int size, + ) { + return __objc_msgSend_18( + obj, + sel, + type, + data, + size, + ); + } + + late final __objc_msgSend_18Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.UnsignedLong)>>('objc_msgSend'); + late final __objc_msgSend_18 = __objc_msgSend_18Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, ffi.Pointer, int)>(); + + late final _sel_versionForClassName_1 = + _registerName1("versionForClassName:"); + int _objc_msgSend_19( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer className, + ) { + return __objc_msgSend_19( + obj, + sel, + className, + ); + } + + late final __objc_msgSend_19Ptr = _lookup< + ffi.NativeFunction< + ffi.Long Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_19 = __objc_msgSend_19Ptr.asFunction< + int Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); + + late final _sel_encodeObject_1 = _registerName1("encodeObject:"); + void _objc_msgSend_20( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer object, + ) { + return __objc_msgSend_20( + obj, + sel, + object, + ); + } + + late final __objc_msgSend_20Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_20 = __objc_msgSend_20Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); + + late final _sel_encodeRootObject_1 = _registerName1("encodeRootObject:"); + void _objc_msgSend_21( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer rootObject, + ) { + return __objc_msgSend_21( + obj, + sel, + rootObject, + ); + } + + late final __objc_msgSend_21Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_21 = __objc_msgSend_21Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); + + late final _sel_encodeBycopyObject_1 = _registerName1("encodeBycopyObject:"); + late final _sel_encodeByrefObject_1 = _registerName1("encodeByrefObject:"); + late final _sel_encodeConditionalObject_1 = + _registerName1("encodeConditionalObject:"); + late final _sel_encodeValuesOfObjCTypes_1 = + _registerName1("encodeValuesOfObjCTypes:"); + void _objc_msgSend_22( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer types, + ) { + return __objc_msgSend_22( + obj, + sel, + types, + ); + } + + late final __objc_msgSend_22Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_22 = __objc_msgSend_22Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); + + late final _sel_encodeArrayOfObjCType_count_at_1 = + _registerName1("encodeArrayOfObjCType:count:at:"); + void _objc_msgSend_23( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer type, + int count, + ffi.Pointer array, + ) { + return __objc_msgSend_23( + obj, + sel, + type, + count, + array, + ); + } + + late final __objc_msgSend_23Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.UnsignedLong, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_23 = __objc_msgSend_23Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, int, ffi.Pointer)>(); + + late final _sel_encodeBytes_length_1 = _registerName1("encodeBytes:length:"); + void _objc_msgSend_24( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer byteaddr, + int length, + ) { + return __objc_msgSend_24( + obj, + sel, + byteaddr, + length, + ); + } + + late final __objc_msgSend_24Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, ffi.UnsignedLong)>>('objc_msgSend'); + late final __objc_msgSend_24 = __objc_msgSend_24Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, int)>(); + + late final _sel_decodeObject1 = _registerName1("decodeObject"); + ffi.Pointer _objc_msgSend_25( + ffi.Pointer obj, + ffi.Pointer sel, + ) { + return __objc_msgSend_25( + obj, + sel, + ); + } + + late final __objc_msgSend_25Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_25 = __objc_msgSend_25Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); + + late final _class_NSError1 = _getClass1("NSError"); + late final _sel_decodeTopLevelObjectAndReturnError_1 = + _registerName1("decodeTopLevelObjectAndReturnError:"); + ffi.Pointer _objc_msgSend_26( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer> error, + ) { + return __objc_msgSend_26( + obj, + sel, + error, + ); + } + + late final __objc_msgSend_26Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer>)>>('objc_msgSend'); + late final __objc_msgSend_26 = __objc_msgSend_26Ptr.asFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer>)>(); + + late final _sel_decodeValuesOfObjCTypes_1 = + _registerName1("decodeValuesOfObjCTypes:"); + late final _sel_decodeArrayOfObjCType_count_at_1 = + _registerName1("decodeArrayOfObjCType:count:at:"); + late final _sel_decodeBytesWithReturnedLength_1 = + _registerName1("decodeBytesWithReturnedLength:"); + ffi.Pointer _objc_msgSend_27( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer lengthp, + ) { + return __objc_msgSend_27( + obj, + sel, + lengthp, + ); + } + + late final __objc_msgSend_27Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_27 = __objc_msgSend_27Ptr.asFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>(); + + late final _sel_encodePropertyList_1 = _registerName1("encodePropertyList:"); + late final _sel_decodePropertyList1 = _registerName1("decodePropertyList"); + late final _sel_setObjectZone_1 = _registerName1("setObjectZone:"); + void _objc_msgSend_28( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer<_NSZone> zone, + ) { + return __objc_msgSend_28( + obj, + sel, + zone, + ); + } + + late final __objc_msgSend_28Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer<_NSZone>)>>('objc_msgSend'); + late final __objc_msgSend_28 = __objc_msgSend_28Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer<_NSZone>)>(); + + late final _sel_objectZone1 = _registerName1("objectZone"); + ffi.Pointer<_NSZone> _objc_msgSend_29( + ffi.Pointer obj, + ffi.Pointer sel, + ) { + return __objc_msgSend_29( + obj, + sel, + ); + } + + late final __objc_msgSend_29Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer<_NSZone> Function( + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_29 = __objc_msgSend_29Ptr.asFunction< + ffi.Pointer<_NSZone> Function( + ffi.Pointer, ffi.Pointer)>(); + + late final _sel_systemVersion1 = _registerName1("systemVersion"); + int _objc_msgSend_30( + ffi.Pointer obj, + ffi.Pointer sel, + ) { + return __objc_msgSend_30( + obj, + sel, + ); + } + + late final __objc_msgSend_30Ptr = _lookup< + ffi.NativeFunction< + ffi.UnsignedInt Function( + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_30 = __objc_msgSend_30Ptr.asFunction< + int Function(ffi.Pointer, ffi.Pointer)>(); + + late final _sel_allowsKeyedCoding1 = _registerName1("allowsKeyedCoding"); + late final _sel_encodeObject_forKey_1 = + _registerName1("encodeObject:forKey:"); + void _objc_msgSend_31( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer object, + ffi.Pointer key, + ) { + return __objc_msgSend_31( + obj, + sel, + object, + key, + ); + } + + late final __objc_msgSend_31Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_31 = __objc_msgSend_31Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, ffi.Pointer)>(); + + late final _sel_encodeConditionalObject_forKey_1 = + _registerName1("encodeConditionalObject:forKey:"); + late final _sel_encodeBool_forKey_1 = _registerName1("encodeBool:forKey:"); + void _objc_msgSend_32( + ffi.Pointer obj, + ffi.Pointer sel, + bool value, + ffi.Pointer key, + ) { + return __objc_msgSend_32( + obj, + sel, + value, + key, + ); + } + + late final __objc_msgSend_32Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Bool, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_32 = __objc_msgSend_32Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, bool, + ffi.Pointer)>(); + + late final _sel_encodeInt_forKey_1 = _registerName1("encodeInt:forKey:"); + void _objc_msgSend_33( + ffi.Pointer obj, + ffi.Pointer sel, + int value, + ffi.Pointer key, + ) { + return __objc_msgSend_33( + obj, + sel, + value, + key, + ); + } + + late final __objc_msgSend_33Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Int, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_33 = __objc_msgSend_33Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, int, + ffi.Pointer)>(); + + late final _sel_encodeInt32_forKey_1 = _registerName1("encodeInt32:forKey:"); + void _objc_msgSend_34( + ffi.Pointer obj, + ffi.Pointer sel, + int value, + ffi.Pointer key, + ) { + return __objc_msgSend_34( + obj, + sel, + value, + key, + ); + } + + late final __objc_msgSend_34Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Int32, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_34 = __objc_msgSend_34Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, int, + ffi.Pointer)>(); + + late final _sel_encodeInt64_forKey_1 = _registerName1("encodeInt64:forKey:"); + void _objc_msgSend_35( + ffi.Pointer obj, + ffi.Pointer sel, + int value, + ffi.Pointer key, + ) { + return __objc_msgSend_35( + obj, + sel, + value, + key, + ); + } + + late final __objc_msgSend_35Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Int64, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_35 = __objc_msgSend_35Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, int, + ffi.Pointer)>(); + + late final _sel_encodeFloat_forKey_1 = _registerName1("encodeFloat:forKey:"); + void _objc_msgSend_36( + ffi.Pointer obj, + ffi.Pointer sel, + double value, + ffi.Pointer key, + ) { + return __objc_msgSend_36( + obj, + sel, + value, + key, + ); + } + + late final __objc_msgSend_36Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Float, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_36 = __objc_msgSend_36Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, double, + ffi.Pointer)>(); + + late final _sel_encodeDouble_forKey_1 = + _registerName1("encodeDouble:forKey:"); + void _objc_msgSend_37( + ffi.Pointer obj, + ffi.Pointer sel, + double value, + ffi.Pointer key, + ) { + return __objc_msgSend_37( + obj, + sel, + value, + key, + ); + } + + late final __objc_msgSend_37Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Double, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_37 = __objc_msgSend_37Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, double, + ffi.Pointer)>(); + + late final _sel_encodeBytes_length_forKey_1 = + _registerName1("encodeBytes:length:forKey:"); + void _objc_msgSend_38( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer bytes, + int length, + ffi.Pointer key, + ) { + return __objc_msgSend_38( + obj, + sel, + bytes, + length, + key, + ); + } + + late final __objc_msgSend_38Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.UnsignedLong, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_38 = __objc_msgSend_38Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, int, ffi.Pointer)>(); + + late final _sel_containsValueForKey_1 = + _registerName1("containsValueForKey:"); + bool _objc_msgSend_39( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer key, + ) { + return __objc_msgSend_39( + obj, + sel, + key, + ); + } + + late final __objc_msgSend_39Ptr = _lookup< + ffi.NativeFunction< + ffi.Bool Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_39 = __objc_msgSend_39Ptr.asFunction< + bool Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); + + late final _sel_decodeObjectForKey_1 = _registerName1("decodeObjectForKey:"); + ffi.Pointer _objc_msgSend_40( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer key, + ) { + return __objc_msgSend_40( + obj, + sel, + key, + ); + } + + late final __objc_msgSend_40Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_40 = __objc_msgSend_40Ptr.asFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>(); + + late final _sel_decodeTopLevelObjectForKey_error_1 = + _registerName1("decodeTopLevelObjectForKey:error:"); + ffi.Pointer _objc_msgSend_41( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer key, + ffi.Pointer> error, + ) { + return __objc_msgSend_41( + obj, + sel, + key, + error, + ); + } + + late final __objc_msgSend_41Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer>)>>('objc_msgSend'); + late final __objc_msgSend_41 = __objc_msgSend_41Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer>)>(); + + late final _sel_decodeBoolForKey_1 = _registerName1("decodeBoolForKey:"); + late final _sel_decodeIntForKey_1 = _registerName1("decodeIntForKey:"); + int _objc_msgSend_42( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer key, + ) { + return __objc_msgSend_42( + obj, + sel, + key, + ); + } + + late final __objc_msgSend_42Ptr = _lookup< + ffi.NativeFunction< + ffi.Int Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_42 = __objc_msgSend_42Ptr.asFunction< + int Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); + + late final _sel_decodeInt32ForKey_1 = _registerName1("decodeInt32ForKey:"); + int _objc_msgSend_43( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer key, + ) { + return __objc_msgSend_43( + obj, + sel, + key, + ); + } + + late final __objc_msgSend_43Ptr = _lookup< + ffi.NativeFunction< + ffi.Int32 Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_43 = __objc_msgSend_43Ptr.asFunction< + int Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); + + late final _sel_decodeInt64ForKey_1 = _registerName1("decodeInt64ForKey:"); + int _objc_msgSend_44( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer key, + ) { + return __objc_msgSend_44( + obj, + sel, + key, + ); + } + + late final __objc_msgSend_44Ptr = _lookup< + ffi.NativeFunction< + ffi.Int64 Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_44 = __objc_msgSend_44Ptr.asFunction< + int Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); + + late final _sel_decodeFloatForKey_1 = _registerName1("decodeFloatForKey:"); + double _objc_msgSend_45( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer key, + ) { + return __objc_msgSend_45( + obj, + sel, + key, + ); + } + + late final __objc_msgSend_45Ptr = _lookup< + ffi.NativeFunction< + ffi.Float Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>>('objc_msgSend_fpret'); + late final __objc_msgSend_45 = __objc_msgSend_45Ptr.asFunction< + double Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); + + late final _sel_decodeDoubleForKey_1 = _registerName1("decodeDoubleForKey:"); + double _objc_msgSend_46( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer key, + ) { + return __objc_msgSend_46( + obj, + sel, + key, + ); + } + + late final __objc_msgSend_46Ptr = _lookup< + ffi.NativeFunction< + ffi.Double Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>>('objc_msgSend_fpret'); + late final __objc_msgSend_46 = __objc_msgSend_46Ptr.asFunction< + double Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); + + late final _sel_decodeBytesForKey_returnedLength_1 = + _registerName1("decodeBytesForKey:returnedLength:"); + ffi.Pointer _objc_msgSend_47( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer key, + ffi.Pointer lengthp, + ) { + return __objc_msgSend_47( + obj, + sel, + key, + lengthp, + ); + } + + late final __objc_msgSend_47Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_47 = __objc_msgSend_47Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>(); + + late final _sel_encodeInteger_forKey_1 = + _registerName1("encodeInteger:forKey:"); + void _objc_msgSend_48( + ffi.Pointer obj, + ffi.Pointer sel, + int value, + ffi.Pointer key, + ) { + return __objc_msgSend_48( + obj, + sel, + value, + key, + ); + } + + late final __objc_msgSend_48Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Long, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_48 = __objc_msgSend_48Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, int, + ffi.Pointer)>(); + + late final _sel_decodeIntegerForKey_1 = + _registerName1("decodeIntegerForKey:"); + late final _sel_requiresSecureCoding1 = + _registerName1("requiresSecureCoding"); + late final _sel_decodeObjectOfClass_forKey_1 = + _registerName1("decodeObjectOfClass:forKey:"); + ffi.Pointer _objc_msgSend_49( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer aClass, + ffi.Pointer key, + ) { + return __objc_msgSend_49( + obj, + sel, + aClass, + key, + ); + } + + late final __objc_msgSend_49Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_49 = __objc_msgSend_49Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>(); + + late final _sel_decodeTopLevelObjectOfClass_forKey_error_1 = + _registerName1("decodeTopLevelObjectOfClass:forKey:error:"); + ffi.Pointer _objc_msgSend_50( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer aClass, + ffi.Pointer key, + ffi.Pointer> error, + ) { + return __objc_msgSend_50( + obj, + sel, + aClass, + key, + error, + ); + } + + late final __objc_msgSend_50Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer>)>>('objc_msgSend'); + late final __objc_msgSend_50 = __objc_msgSend_50Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer>)>(); + + late final _class_NSArray1 = _getClass1("NSArray"); + late final _sel_count1 = _registerName1("count"); + late final _sel_objectAtIndex_1 = _registerName1("objectAtIndex:"); + ffi.Pointer _objc_msgSend_51( + ffi.Pointer obj, + ffi.Pointer sel, + int index, + ) { + return __objc_msgSend_51( + obj, + sel, + index, + ); + } + + late final __objc_msgSend_51Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.UnsignedLong)>>('objc_msgSend'); + late final __objc_msgSend_51 = __objc_msgSend_51Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer, int)>(); + + late final _sel_initWithObjects_count_1 = + _registerName1("initWithObjects:count:"); + instancetype _objc_msgSend_52( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer> objects, + int cnt, + ) { + return __objc_msgSend_52( + obj, + sel, + objects, + cnt, + ); + } + + late final __objc_msgSend_52Ptr = _lookup< + ffi.NativeFunction< + instancetype Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer>, + ffi.UnsignedLong)>>('objc_msgSend'); + late final __objc_msgSend_52 = __objc_msgSend_52Ptr.asFunction< + instancetype Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer>, int)>(); + + late final _sel_initWithCoder_1 = _registerName1("initWithCoder:"); + instancetype _objc_msgSend_53( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer coder, + ) { + return __objc_msgSend_53( + obj, + sel, + coder, + ); + } + + late final __objc_msgSend_53Ptr = _lookup< + ffi.NativeFunction< + instancetype Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_53 = __objc_msgSend_53Ptr.asFunction< + instancetype Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); + + late final _sel_arrayByAddingObject_1 = + _registerName1("arrayByAddingObject:"); + ffi.Pointer _objc_msgSend_54( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer anObject, + ) { + return __objc_msgSend_54( + obj, + sel, + anObject, + ); + } + + late final __objc_msgSend_54Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_54 = __objc_msgSend_54Ptr.asFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>(); + + late final _sel_arrayByAddingObjectsFromArray_1 = + _registerName1("arrayByAddingObjectsFromArray:"); + ffi.Pointer _objc_msgSend_55( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer otherArray, + ) { + return __objc_msgSend_55( + obj, + sel, + otherArray, + ); + } + + late final __objc_msgSend_55Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_55 = __objc_msgSend_55Ptr.asFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>(); + + late final _sel_componentsJoinedByString_1 = + _registerName1("componentsJoinedByString:"); + ffi.Pointer _objc_msgSend_56( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer separator, + ) { + return __objc_msgSend_56( + obj, + sel, + separator, + ); + } + + late final __objc_msgSend_56Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_56 = __objc_msgSend_56Ptr.asFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>(); + + late final _sel_containsObject_1 = _registerName1("containsObject:"); + late final _sel_description1 = _registerName1("description"); + ffi.Pointer _objc_msgSend_57( + ffi.Pointer obj, + ffi.Pointer sel, + ) { + return __objc_msgSend_57( + obj, + sel, + ); + } + + late final __objc_msgSend_57Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_57 = __objc_msgSend_57Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); + + late final _sel_descriptionWithLocale_1 = + _registerName1("descriptionWithLocale:"); + ffi.Pointer _objc_msgSend_58( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer locale, + ) { + return __objc_msgSend_58( + obj, + sel, + locale, + ); + } + + late final __objc_msgSend_58Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_58 = __objc_msgSend_58Ptr.asFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>(); + + late final _sel_descriptionWithLocale_indent_1 = + _registerName1("descriptionWithLocale:indent:"); + ffi.Pointer _objc_msgSend_59( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer locale, + int level, + ) { + return __objc_msgSend_59( + obj, + sel, + locale, + level, + ); + } + + late final __objc_msgSend_59Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.UnsignedLong)>>('objc_msgSend'); + late final __objc_msgSend_59 = __objc_msgSend_59Ptr.asFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer, int)>(); + + late final _sel_firstObjectCommonWithArray_1 = + _registerName1("firstObjectCommonWithArray:"); + ffi.Pointer _objc_msgSend_60( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer otherArray, + ) { + return __objc_msgSend_60( + obj, + sel, + otherArray, + ); + } + + late final __objc_msgSend_60Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_60 = __objc_msgSend_60Ptr.asFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>(); + + late final _sel_getObjects_range_1 = _registerName1("getObjects:range:"); + void _objc_msgSend_61( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer> objects, + _NSRange range, + ) { + return __objc_msgSend_61( + obj, + sel, + objects, + range, + ); + } + + late final __objc_msgSend_61Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer>, _NSRange)>>('objc_msgSend'); + late final __objc_msgSend_61 = __objc_msgSend_61Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer>, _NSRange)>(); + + late final _sel_indexOfObject_1 = _registerName1("indexOfObject:"); + int _objc_msgSend_62( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer anObject, + ) { + return __objc_msgSend_62( + obj, + sel, + anObject, + ); + } + + late final __objc_msgSend_62Ptr = _lookup< + ffi.NativeFunction< + ffi.UnsignedLong Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_62 = __objc_msgSend_62Ptr.asFunction< + int Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); + + late final _sel_indexOfObject_inRange_1 = + _registerName1("indexOfObject:inRange:"); + int _objc_msgSend_63( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer anObject, + _NSRange range, + ) { + return __objc_msgSend_63( + obj, + sel, + anObject, + range, + ); + } + + late final __objc_msgSend_63Ptr = _lookup< + ffi.NativeFunction< + ffi.UnsignedLong Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + _NSRange)>>('objc_msgSend'); + late final __objc_msgSend_63 = __objc_msgSend_63Ptr.asFunction< + int Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, _NSRange)>(); + + late final _sel_indexOfObjectIdenticalTo_1 = + _registerName1("indexOfObjectIdenticalTo:"); + late final _sel_indexOfObjectIdenticalTo_inRange_1 = + _registerName1("indexOfObjectIdenticalTo:inRange:"); + late final _sel_isEqualToArray_1 = _registerName1("isEqualToArray:"); + bool _objc_msgSend_64( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer otherArray, + ) { + return __objc_msgSend_64( + obj, + sel, + otherArray, + ); + } + + late final __objc_msgSend_64Ptr = _lookup< + ffi.NativeFunction< + ffi.Bool Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_64 = __objc_msgSend_64Ptr.asFunction< + bool Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); + + late final _sel_firstObject1 = _registerName1("firstObject"); + late final _sel_lastObject1 = _registerName1("lastObject"); + late final _class_NSEnumerator1 = _getClass1("NSEnumerator"); + late final _sel_nextObject1 = _registerName1("nextObject"); + late final _sel_allObjects1 = _registerName1("allObjects"); + late final _sel_objectEnumerator1 = _registerName1("objectEnumerator"); + ffi.Pointer _objc_msgSend_65( + ffi.Pointer obj, + ffi.Pointer sel, + ) { + return __objc_msgSend_65( + obj, + sel, + ); + } + + late final __objc_msgSend_65Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_65 = __objc_msgSend_65Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); + + late final _sel_reverseObjectEnumerator1 = + _registerName1("reverseObjectEnumerator"); + late final _sel_sortedArrayHint1 = _registerName1("sortedArrayHint"); + ffi.Pointer _objc_msgSend_66( + ffi.Pointer obj, + ffi.Pointer sel, + ) { + return __objc_msgSend_66( + obj, + sel, + ); + } + + late final __objc_msgSend_66Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_66 = __objc_msgSend_66Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); + + late final _sel_sortedArrayUsingFunction_context_1 = + _registerName1("sortedArrayUsingFunction:context:"); + ffi.Pointer _objc_msgSend_67( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer< + ffi.NativeFunction< + ffi.Long Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>> + comparator, + ffi.Pointer context, + ) { + return __objc_msgSend_67( + obj, + sel, + comparator, + context, + ); + } + + late final __objc_msgSend_67Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer< + ffi.NativeFunction< + ffi.Long Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>>, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_67 = __objc_msgSend_67Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer< + ffi.NativeFunction< + ffi.Long Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>>, + ffi.Pointer)>(); + + late final _sel_sortedArrayUsingFunction_context_hint_1 = + _registerName1("sortedArrayUsingFunction:context:hint:"); + ffi.Pointer _objc_msgSend_68( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer< + ffi.NativeFunction< + ffi.Long Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>> + comparator, + ffi.Pointer context, + ffi.Pointer hint, + ) { + return __objc_msgSend_68( + obj, + sel, + comparator, + context, + hint, + ); + } + + late final __objc_msgSend_68Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer< + ffi.NativeFunction< + ffi.Long Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>>, + ffi.Pointer, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_68 = __objc_msgSend_68Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer< + ffi.NativeFunction< + ffi.Long Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>>, + ffi.Pointer, + ffi.Pointer)>(); + + late final _sel_sortedArrayUsingSelector_1 = + _registerName1("sortedArrayUsingSelector:"); + ffi.Pointer _objc_msgSend_69( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer comparator, + ) { + return __objc_msgSend_69( + obj, + sel, + comparator, + ); + } + + late final __objc_msgSend_69Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_69 = __objc_msgSend_69Ptr.asFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>(); + + late final _sel_subarrayWithRange_1 = _registerName1("subarrayWithRange:"); + ffi.Pointer _objc_msgSend_70( + ffi.Pointer obj, + ffi.Pointer sel, + _NSRange range, + ) { + return __objc_msgSend_70( + obj, + sel, + range, + ); + } + + late final __objc_msgSend_70Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, _NSRange)>>('objc_msgSend'); + late final __objc_msgSend_70 = __objc_msgSend_70Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer, _NSRange)>(); + + late final _class_NSURL1 = _getClass1("NSURL"); + late final _sel_writeToURL_error_1 = _registerName1("writeToURL:error:"); + bool _objc_msgSend_71( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer url, + ffi.Pointer> error, + ) { + return __objc_msgSend_71( + obj, + sel, + url, + error, + ); + } + + late final __objc_msgSend_71Ptr = _lookup< + ffi.NativeFunction< + ffi.Bool Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer>)>>('objc_msgSend'); + late final __objc_msgSend_71 = __objc_msgSend_71Ptr.asFunction< + bool Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, ffi.Pointer>)>(); + + late final _sel_makeObjectsPerformSelector_1 = + _registerName1("makeObjectsPerformSelector:"); + late final _sel_makeObjectsPerformSelector_withObject_1 = + _registerName1("makeObjectsPerformSelector:withObject:"); + void _objc_msgSend_72( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer aSelector, + ffi.Pointer argument, + ) { + return __objc_msgSend_72( + obj, + sel, + aSelector, + argument, + ); + } + + late final __objc_msgSend_72Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_72 = __objc_msgSend_72Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, ffi.Pointer)>(); + + late final _class_NSIndexSet1 = _getClass1("NSIndexSet"); + late final _sel_indexSet1 = _registerName1("indexSet"); + late final _sel_indexSetWithIndex_1 = _registerName1("indexSetWithIndex:"); + late final _sel_indexSetWithIndexesInRange_1 = + _registerName1("indexSetWithIndexesInRange:"); + instancetype _objc_msgSend_73( + ffi.Pointer obj, + ffi.Pointer sel, + _NSRange range, + ) { + return __objc_msgSend_73( + obj, + sel, + range, + ); + } + + late final __objc_msgSend_73Ptr = _lookup< + ffi.NativeFunction< + instancetype Function(ffi.Pointer, ffi.Pointer, + _NSRange)>>('objc_msgSend'); + late final __objc_msgSend_73 = __objc_msgSend_73Ptr.asFunction< + instancetype Function( + ffi.Pointer, ffi.Pointer, _NSRange)>(); + + late final _sel_initWithIndexesInRange_1 = + _registerName1("initWithIndexesInRange:"); + late final _sel_initWithIndexSet_1 = _registerName1("initWithIndexSet:"); + instancetype _objc_msgSend_74( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer indexSet, + ) { + return __objc_msgSend_74( + obj, + sel, + indexSet, + ); + } + + late final __objc_msgSend_74Ptr = _lookup< + ffi.NativeFunction< + instancetype Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_74 = __objc_msgSend_74Ptr.asFunction< + instancetype Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); + + late final _sel_initWithIndex_1 = _registerName1("initWithIndex:"); + late final _sel_isEqualToIndexSet_1 = _registerName1("isEqualToIndexSet:"); + bool _objc_msgSend_75( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer indexSet, + ) { + return __objc_msgSend_75( + obj, + sel, + indexSet, + ); + } + + late final __objc_msgSend_75Ptr = _lookup< + ffi.NativeFunction< + ffi.Bool Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_75 = __objc_msgSend_75Ptr.asFunction< + bool Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); + + late final _sel_firstIndex1 = _registerName1("firstIndex"); + late final _sel_lastIndex1 = _registerName1("lastIndex"); + late final _sel_indexGreaterThanIndex_1 = + _registerName1("indexGreaterThanIndex:"); + int _objc_msgSend_76( + ffi.Pointer obj, + ffi.Pointer sel, + int value, + ) { + return __objc_msgSend_76( + obj, + sel, + value, + ); + } + + late final __objc_msgSend_76Ptr = _lookup< + ffi.NativeFunction< + ffi.UnsignedLong Function(ffi.Pointer, + ffi.Pointer, ffi.UnsignedLong)>>('objc_msgSend'); + late final __objc_msgSend_76 = __objc_msgSend_76Ptr.asFunction< + int Function(ffi.Pointer, ffi.Pointer, int)>(); + + late final _sel_indexLessThanIndex_1 = _registerName1("indexLessThanIndex:"); + late final _sel_indexGreaterThanOrEqualToIndex_1 = + _registerName1("indexGreaterThanOrEqualToIndex:"); + late final _sel_indexLessThanOrEqualToIndex_1 = + _registerName1("indexLessThanOrEqualToIndex:"); + late final _sel_getIndexes_maxCount_inIndexRange_1 = + _registerName1("getIndexes:maxCount:inIndexRange:"); + int _objc_msgSend_77( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer indexBuffer, + int bufferSize, + ffi.Pointer<_NSRange> range, + ) { + return __objc_msgSend_77( + obj, + sel, + indexBuffer, + bufferSize, + range, + ); + } + + late final __objc_msgSend_77Ptr = _lookup< + ffi.NativeFunction< + ffi.UnsignedLong Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.UnsignedLong, + ffi.Pointer<_NSRange>)>>('objc_msgSend'); + late final __objc_msgSend_77 = __objc_msgSend_77Ptr.asFunction< + int Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, int, ffi.Pointer<_NSRange>)>(); + + late final _sel_countOfIndexesInRange_1 = + _registerName1("countOfIndexesInRange:"); + int _objc_msgSend_78( + ffi.Pointer obj, + ffi.Pointer sel, + _NSRange range, + ) { + return __objc_msgSend_78( + obj, + sel, + range, + ); + } + + late final __objc_msgSend_78Ptr = _lookup< + ffi.NativeFunction< + ffi.UnsignedLong Function(ffi.Pointer, + ffi.Pointer, _NSRange)>>('objc_msgSend'); + late final __objc_msgSend_78 = __objc_msgSend_78Ptr.asFunction< + int Function(ffi.Pointer, ffi.Pointer, _NSRange)>(); + + late final _sel_containsIndex_1 = _registerName1("containsIndex:"); + bool _objc_msgSend_79( + ffi.Pointer obj, + ffi.Pointer sel, + int value, + ) { + return __objc_msgSend_79( + obj, + sel, + value, + ); + } + + late final __objc_msgSend_79Ptr = _lookup< + ffi.NativeFunction< + ffi.Bool Function(ffi.Pointer, ffi.Pointer, + ffi.UnsignedLong)>>('objc_msgSend'); + late final __objc_msgSend_79 = __objc_msgSend_79Ptr.asFunction< + bool Function(ffi.Pointer, ffi.Pointer, int)>(); + + late final _sel_containsIndexesInRange_1 = + _registerName1("containsIndexesInRange:"); + bool _objc_msgSend_80( + ffi.Pointer obj, + ffi.Pointer sel, + _NSRange range, + ) { + return __objc_msgSend_80( + obj, + sel, + range, + ); + } + + late final __objc_msgSend_80Ptr = _lookup< + ffi.NativeFunction< + ffi.Bool Function(ffi.Pointer, ffi.Pointer, + _NSRange)>>('objc_msgSend'); + late final __objc_msgSend_80 = __objc_msgSend_80Ptr.asFunction< + bool Function(ffi.Pointer, ffi.Pointer, _NSRange)>(); + + late final _sel_containsIndexes_1 = _registerName1("containsIndexes:"); + late final _sel_intersectsIndexesInRange_1 = + _registerName1("intersectsIndexesInRange:"); + ffi.Pointer<_ObjCBlockDesc> _newBlockDesc1() { + final d = + pkg_ffi.calloc.allocate<_ObjCBlockDesc>(ffi.sizeOf<_ObjCBlockDesc>()); + d.ref.reserved = 0; + d.ref.size = ffi.sizeOf<_ObjCBlock>(); + d.ref.copy_helper = ffi.nullptr; + d.ref.dispose_helper = ffi.nullptr; + d.ref.signature = ffi.nullptr; + return d; + } + + late final _objc_block_desc1 = _newBlockDesc1(); + late final _objc_concrete_global_block1 = + _lookup('_NSConcreteGlobalBlock'); + ffi.Pointer<_ObjCBlock> _newBlock1( + ffi.Pointer invoke, ffi.Pointer target) { + final b = pkg_ffi.calloc.allocate<_ObjCBlock>(ffi.sizeOf<_ObjCBlock>()); + b.ref.isa = _objc_concrete_global_block1; + b.ref.flags = 0; + b.ref.reserved = 0; + b.ref.invoke = invoke; + b.ref.target = target; + b.ref.descriptor = _objc_block_desc1; + final copy = _Block_copy(b.cast()).cast<_ObjCBlock>(); + pkg_ffi.calloc.free(b); + return copy; + } + + ffi.Pointer _Block_copy( + ffi.Pointer value, + ) { + return __Block_copy( + value, + ); + } + + late final __Block_copyPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer)>>('_Block_copy'); + late final __Block_copy = __Block_copyPtr + .asFunction Function(ffi.Pointer)>(); + + void _Block_release( + ffi.Pointer value, + ) { + return __Block_release( + value, + ); + } + + late final __Block_releasePtr = + _lookup)>>( + '_Block_release'); + late final __Block_release = + __Block_releasePtr.asFunction)>(); + + late final _objc_releaseFinalizer11 = + ffi.NativeFinalizer(__Block_releasePtr.cast()); + late final _sel_enumerateIndexesUsingBlock_1 = + _registerName1("enumerateIndexesUsingBlock:"); + void _objc_msgSend_81( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer<_ObjCBlock> block, + ) { + return __objc_msgSend_81( + obj, + sel, + block, + ); + } + + late final __objc_msgSend_81Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer<_ObjCBlock>)>>('objc_msgSend'); + late final __objc_msgSend_81 = __objc_msgSend_81Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer<_ObjCBlock>)>(); + + late final _sel_enumerateIndexesWithOptions_usingBlock_1 = + _registerName1("enumerateIndexesWithOptions:usingBlock:"); + void _objc_msgSend_82( + ffi.Pointer obj, + ffi.Pointer sel, + int opts, + ffi.Pointer<_ObjCBlock> block, + ) { + return __objc_msgSend_82( + obj, + sel, + opts, + block, + ); + } + + late final __objc_msgSend_82Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Int32, ffi.Pointer<_ObjCBlock>)>>('objc_msgSend'); + late final __objc_msgSend_82 = __objc_msgSend_82Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, int, + ffi.Pointer<_ObjCBlock>)>(); + + late final _sel_enumerateIndexesInRange_options_usingBlock_1 = + _registerName1("enumerateIndexesInRange:options:usingBlock:"); + void _objc_msgSend_83( + ffi.Pointer obj, + ffi.Pointer sel, + _NSRange range, + int opts, + ffi.Pointer<_ObjCBlock> block, + ) { + return __objc_msgSend_83( + obj, + sel, + range, + opts, + block, + ); + } + + late final __objc_msgSend_83Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + _NSRange, ffi.Int32, ffi.Pointer<_ObjCBlock>)>>('objc_msgSend'); + late final __objc_msgSend_83 = __objc_msgSend_83Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, _NSRange, + int, ffi.Pointer<_ObjCBlock>)>(); + + late final _sel_indexPassingTest_1 = _registerName1("indexPassingTest:"); + int _objc_msgSend_84( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer<_ObjCBlock> predicate, + ) { + return __objc_msgSend_84( + obj, + sel, + predicate, + ); + } + + late final __objc_msgSend_84Ptr = _lookup< + ffi.NativeFunction< + ffi.UnsignedLong Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer<_ObjCBlock>)>>('objc_msgSend'); + late final __objc_msgSend_84 = __objc_msgSend_84Ptr.asFunction< + int Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer<_ObjCBlock>)>(); + + late final _sel_indexWithOptions_passingTest_1 = + _registerName1("indexWithOptions:passingTest:"); + int _objc_msgSend_85( + ffi.Pointer obj, + ffi.Pointer sel, + int opts, + ffi.Pointer<_ObjCBlock> predicate, + ) { + return __objc_msgSend_85( + obj, + sel, + opts, + predicate, + ); + } + + late final __objc_msgSend_85Ptr = _lookup< + ffi.NativeFunction< + ffi.UnsignedLong Function( + ffi.Pointer, + ffi.Pointer, + ffi.Int32, + ffi.Pointer<_ObjCBlock>)>>('objc_msgSend'); + late final __objc_msgSend_85 = __objc_msgSend_85Ptr.asFunction< + int Function(ffi.Pointer, ffi.Pointer, int, + ffi.Pointer<_ObjCBlock>)>(); + + late final _sel_indexInRange_options_passingTest_1 = + _registerName1("indexInRange:options:passingTest:"); + int _objc_msgSend_86( + ffi.Pointer obj, + ffi.Pointer sel, + _NSRange range, + int opts, + ffi.Pointer<_ObjCBlock> predicate, + ) { + return __objc_msgSend_86( + obj, + sel, + range, + opts, + predicate, + ); + } + + late final __objc_msgSend_86Ptr = _lookup< + ffi.NativeFunction< + ffi.UnsignedLong Function( + ffi.Pointer, + ffi.Pointer, + _NSRange, + ffi.Int32, + ffi.Pointer<_ObjCBlock>)>>('objc_msgSend'); + late final __objc_msgSend_86 = __objc_msgSend_86Ptr.asFunction< + int Function(ffi.Pointer, ffi.Pointer, _NSRange, int, + ffi.Pointer<_ObjCBlock>)>(); + + late final _sel_indexesPassingTest_1 = _registerName1("indexesPassingTest:"); + ffi.Pointer _objc_msgSend_87( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer<_ObjCBlock> predicate, + ) { + return __objc_msgSend_87( + obj, + sel, + predicate, + ); + } + + late final __objc_msgSend_87Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer<_ObjCBlock>)>>('objc_msgSend'); + late final __objc_msgSend_87 = __objc_msgSend_87Ptr.asFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer<_ObjCBlock>)>(); + + late final _sel_indexesWithOptions_passingTest_1 = + _registerName1("indexesWithOptions:passingTest:"); + ffi.Pointer _objc_msgSend_88( + ffi.Pointer obj, + ffi.Pointer sel, + int opts, + ffi.Pointer<_ObjCBlock> predicate, + ) { + return __objc_msgSend_88( + obj, + sel, + opts, + predicate, + ); + } + + late final __objc_msgSend_88Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Int32, + ffi.Pointer<_ObjCBlock>)>>('objc_msgSend'); + late final __objc_msgSend_88 = __objc_msgSend_88Ptr.asFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, int, ffi.Pointer<_ObjCBlock>)>(); + + late final _sel_indexesInRange_options_passingTest_1 = + _registerName1("indexesInRange:options:passingTest:"); + ffi.Pointer _objc_msgSend_89( + ffi.Pointer obj, + ffi.Pointer sel, + _NSRange range, + int opts, + ffi.Pointer<_ObjCBlock> predicate, + ) { + return __objc_msgSend_89( + obj, + sel, + range, + opts, + predicate, + ); + } + + late final __objc_msgSend_89Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + _NSRange, + ffi.Int32, + ffi.Pointer<_ObjCBlock>)>>('objc_msgSend'); + late final __objc_msgSend_89 = __objc_msgSend_89Ptr.asFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, _NSRange, int, ffi.Pointer<_ObjCBlock>)>(); + + late final _sel_enumerateRangesUsingBlock_1 = + _registerName1("enumerateRangesUsingBlock:"); + void _objc_msgSend_90( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer<_ObjCBlock> block, + ) { + return __objc_msgSend_90( + obj, + sel, + block, + ); + } + + late final __objc_msgSend_90Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer<_ObjCBlock>)>>('objc_msgSend'); + late final __objc_msgSend_90 = __objc_msgSend_90Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer<_ObjCBlock>)>(); + + late final _sel_enumerateRangesWithOptions_usingBlock_1 = + _registerName1("enumerateRangesWithOptions:usingBlock:"); + void _objc_msgSend_91( + ffi.Pointer obj, + ffi.Pointer sel, + int opts, + ffi.Pointer<_ObjCBlock> block, + ) { + return __objc_msgSend_91( + obj, + sel, + opts, + block, + ); + } + + late final __objc_msgSend_91Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Int32, ffi.Pointer<_ObjCBlock>)>>('objc_msgSend'); + late final __objc_msgSend_91 = __objc_msgSend_91Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, int, + ffi.Pointer<_ObjCBlock>)>(); + + late final _sel_enumerateRangesInRange_options_usingBlock_1 = + _registerName1("enumerateRangesInRange:options:usingBlock:"); + void _objc_msgSend_92( + ffi.Pointer obj, + ffi.Pointer sel, + _NSRange range, + int opts, + ffi.Pointer<_ObjCBlock> block, + ) { + return __objc_msgSend_92( + obj, + sel, + range, + opts, + block, + ); + } + + late final __objc_msgSend_92Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + _NSRange, ffi.Int32, ffi.Pointer<_ObjCBlock>)>>('objc_msgSend'); + late final __objc_msgSend_92 = __objc_msgSend_92Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, _NSRange, + int, ffi.Pointer<_ObjCBlock>)>(); + + late final _sel_objectsAtIndexes_1 = _registerName1("objectsAtIndexes:"); + ffi.Pointer _objc_msgSend_93( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer indexes, + ) { + return __objc_msgSend_93( + obj, + sel, + indexes, + ); + } + + late final __objc_msgSend_93Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_93 = __objc_msgSend_93Ptr.asFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>(); + + late final _sel_objectAtIndexedSubscript_1 = + _registerName1("objectAtIndexedSubscript:"); + late final _sel_enumerateObjectsUsingBlock_1 = + _registerName1("enumerateObjectsUsingBlock:"); + void _objc_msgSend_94( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer<_ObjCBlock> block, + ) { + return __objc_msgSend_94( + obj, + sel, + block, + ); + } + + late final __objc_msgSend_94Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer<_ObjCBlock>)>>('objc_msgSend'); + late final __objc_msgSend_94 = __objc_msgSend_94Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer<_ObjCBlock>)>(); + + late final _sel_enumerateObjectsWithOptions_usingBlock_1 = + _registerName1("enumerateObjectsWithOptions:usingBlock:"); + void _objc_msgSend_95( + ffi.Pointer obj, + ffi.Pointer sel, + int opts, + ffi.Pointer<_ObjCBlock> block, + ) { + return __objc_msgSend_95( + obj, + sel, + opts, + block, + ); + } + + late final __objc_msgSend_95Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Int32, ffi.Pointer<_ObjCBlock>)>>('objc_msgSend'); + late final __objc_msgSend_95 = __objc_msgSend_95Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, int, + ffi.Pointer<_ObjCBlock>)>(); + + late final _sel_enumerateObjectsAtIndexes_options_usingBlock_1 = + _registerName1("enumerateObjectsAtIndexes:options:usingBlock:"); + void _objc_msgSend_96( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer s, + int opts, + ffi.Pointer<_ObjCBlock> block, + ) { + return __objc_msgSend_96( + obj, + sel, + s, + opts, + block, + ); + } + + late final __objc_msgSend_96Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Int32, + ffi.Pointer<_ObjCBlock>)>>('objc_msgSend'); + late final __objc_msgSend_96 = __objc_msgSend_96Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, int, ffi.Pointer<_ObjCBlock>)>(); + + late final _sel_indexOfObjectPassingTest_1 = + _registerName1("indexOfObjectPassingTest:"); + int _objc_msgSend_97( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer<_ObjCBlock> predicate, + ) { + return __objc_msgSend_97( + obj, + sel, + predicate, + ); + } + + late final __objc_msgSend_97Ptr = _lookup< + ffi.NativeFunction< + ffi.UnsignedLong Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer<_ObjCBlock>)>>('objc_msgSend'); + late final __objc_msgSend_97 = __objc_msgSend_97Ptr.asFunction< + int Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer<_ObjCBlock>)>(); + + late final _sel_indexOfObjectWithOptions_passingTest_1 = + _registerName1("indexOfObjectWithOptions:passingTest:"); + int _objc_msgSend_98( + ffi.Pointer obj, + ffi.Pointer sel, + int opts, + ffi.Pointer<_ObjCBlock> predicate, + ) { + return __objc_msgSend_98( + obj, + sel, + opts, + predicate, + ); + } + + late final __objc_msgSend_98Ptr = _lookup< + ffi.NativeFunction< + ffi.UnsignedLong Function( + ffi.Pointer, + ffi.Pointer, + ffi.Int32, + ffi.Pointer<_ObjCBlock>)>>('objc_msgSend'); + late final __objc_msgSend_98 = __objc_msgSend_98Ptr.asFunction< + int Function(ffi.Pointer, ffi.Pointer, int, + ffi.Pointer<_ObjCBlock>)>(); + + late final _sel_indexOfObjectAtIndexes_options_passingTest_1 = + _registerName1("indexOfObjectAtIndexes:options:passingTest:"); + int _objc_msgSend_99( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer s, + int opts, + ffi.Pointer<_ObjCBlock> predicate, + ) { + return __objc_msgSend_99( + obj, + sel, + s, + opts, + predicate, + ); + } + + late final __objc_msgSend_99Ptr = _lookup< + ffi.NativeFunction< + ffi.UnsignedLong Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Int32, + ffi.Pointer<_ObjCBlock>)>>('objc_msgSend'); + late final __objc_msgSend_99 = __objc_msgSend_99Ptr.asFunction< + int Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, int, ffi.Pointer<_ObjCBlock>)>(); + + late final _sel_indexesOfObjectsPassingTest_1 = + _registerName1("indexesOfObjectsPassingTest:"); + ffi.Pointer _objc_msgSend_100( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer<_ObjCBlock> predicate, + ) { + return __objc_msgSend_100( + obj, + sel, + predicate, + ); + } + + late final __objc_msgSend_100Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer<_ObjCBlock>)>>('objc_msgSend'); + late final __objc_msgSend_100 = __objc_msgSend_100Ptr.asFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer<_ObjCBlock>)>(); + + late final _sel_indexesOfObjectsWithOptions_passingTest_1 = + _registerName1("indexesOfObjectsWithOptions:passingTest:"); + ffi.Pointer _objc_msgSend_101( + ffi.Pointer obj, + ffi.Pointer sel, + int opts, + ffi.Pointer<_ObjCBlock> predicate, + ) { + return __objc_msgSend_101( + obj, + sel, + opts, + predicate, + ); + } + + late final __objc_msgSend_101Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Int32, + ffi.Pointer<_ObjCBlock>)>>('objc_msgSend'); + late final __objc_msgSend_101 = __objc_msgSend_101Ptr.asFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, int, ffi.Pointer<_ObjCBlock>)>(); + + late final _sel_indexesOfObjectsAtIndexes_options_passingTest_1 = + _registerName1("indexesOfObjectsAtIndexes:options:passingTest:"); + ffi.Pointer _objc_msgSend_102( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer s, + int opts, + ffi.Pointer<_ObjCBlock> predicate, + ) { + return __objc_msgSend_102( + obj, + sel, + s, + opts, + predicate, + ); + } + + late final __objc_msgSend_102Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Int32, + ffi.Pointer<_ObjCBlock>)>>('objc_msgSend'); + late final __objc_msgSend_102 = __objc_msgSend_102Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + int, + ffi.Pointer<_ObjCBlock>)>(); + + late final _sel_sortedArrayUsingComparator_1 = + _registerName1("sortedArrayUsingComparator:"); + ffi.Pointer _objc_msgSend_103( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer<_ObjCBlock> cmptr, + ) { + return __objc_msgSend_103( + obj, + sel, + cmptr, + ); + } + + late final __objc_msgSend_103Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer<_ObjCBlock>)>>('objc_msgSend'); + late final __objc_msgSend_103 = __objc_msgSend_103Ptr.asFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer<_ObjCBlock>)>(); + + late final _sel_sortedArrayWithOptions_usingComparator_1 = + _registerName1("sortedArrayWithOptions:usingComparator:"); + ffi.Pointer _objc_msgSend_104( + ffi.Pointer obj, + ffi.Pointer sel, + int opts, + ffi.Pointer<_ObjCBlock> cmptr, + ) { + return __objc_msgSend_104( + obj, + sel, + opts, + cmptr, + ); + } + + late final __objc_msgSend_104Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Int32, + ffi.Pointer<_ObjCBlock>)>>('objc_msgSend'); + late final __objc_msgSend_104 = __objc_msgSend_104Ptr.asFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, int, ffi.Pointer<_ObjCBlock>)>(); + + late final _sel_indexOfObject_inSortedRange_options_usingComparator_1 = + _registerName1("indexOfObject:inSortedRange:options:usingComparator:"); + int _objc_msgSend_105( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer obj1, + _NSRange r, + int opts, + ffi.Pointer<_ObjCBlock> cmp, + ) { + return __objc_msgSend_105( + obj, + sel, + obj1, + r, + opts, + cmp, + ); + } + + late final __objc_msgSend_105Ptr = _lookup< + ffi.NativeFunction< + ffi.UnsignedLong Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + _NSRange, + ffi.Int32, + ffi.Pointer<_ObjCBlock>)>>('objc_msgSend'); + late final __objc_msgSend_105 = __objc_msgSend_105Ptr.asFunction< + int Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, _NSRange, int, ffi.Pointer<_ObjCBlock>)>(); + + late final _sel_array1 = _registerName1("array"); + late final _sel_arrayWithObject_1 = _registerName1("arrayWithObject:"); + instancetype _objc_msgSend_106( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer anObject, + ) { + return __objc_msgSend_106( + obj, + sel, + anObject, + ); + } + + late final __objc_msgSend_106Ptr = _lookup< + ffi.NativeFunction< + instancetype Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_106 = __objc_msgSend_106Ptr.asFunction< + instancetype Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); + + late final _sel_arrayWithObjects_count_1 = + _registerName1("arrayWithObjects:count:"); + late final _sel_arrayWithObjects_1 = _registerName1("arrayWithObjects:"); + late final _sel_arrayWithArray_1 = _registerName1("arrayWithArray:"); + instancetype _objc_msgSend_107( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer array, + ) { + return __objc_msgSend_107( + obj, + sel, + array, + ); + } + + late final __objc_msgSend_107Ptr = _lookup< + ffi.NativeFunction< + instancetype Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_107 = __objc_msgSend_107Ptr.asFunction< + instancetype Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); + + late final _sel_initWithObjects_1 = _registerName1("initWithObjects:"); + late final _sel_initWithArray_1 = _registerName1("initWithArray:"); + late final _sel_initWithArray_copyItems_1 = + _registerName1("initWithArray:copyItems:"); + instancetype _objc_msgSend_108( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer array, + bool flag, + ) { + return __objc_msgSend_108( + obj, + sel, + array, + flag, + ); + } + + late final __objc_msgSend_108Ptr = _lookup< + ffi.NativeFunction< + instancetype Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, ffi.Bool)>>('objc_msgSend'); + late final __objc_msgSend_108 = __objc_msgSend_108Ptr.asFunction< + instancetype Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, bool)>(); + + late final _sel_initWithContentsOfURL_error_1 = + _registerName1("initWithContentsOfURL:error:"); + ffi.Pointer _objc_msgSend_109( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer url, + ffi.Pointer> error, + ) { + return __objc_msgSend_109( + obj, + sel, + url, + error, + ); + } + + late final __objc_msgSend_109Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer>)>>('objc_msgSend'); + late final __objc_msgSend_109 = __objc_msgSend_109Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer>)>(); + + late final _sel_arrayWithContentsOfURL_error_1 = + _registerName1("arrayWithContentsOfURL:error:"); + late final _sel_differenceFromArray_withOptions_usingEquivalenceTest_1 = + _registerName1("differenceFromArray:withOptions:usingEquivalenceTest:"); + ffi.Pointer _objc_msgSend_110( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer other, + int options, + ffi.Pointer<_ObjCBlock> block, + ) { + return __objc_msgSend_110( + obj, + sel, + other, + options, + block, + ); + } + + late final __objc_msgSend_110Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Int32, + ffi.Pointer<_ObjCBlock>)>>('objc_msgSend'); + late final __objc_msgSend_110 = __objc_msgSend_110Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + int, + ffi.Pointer<_ObjCBlock>)>(); + + late final _sel_differenceFromArray_withOptions_1 = + _registerName1("differenceFromArray:withOptions:"); + ffi.Pointer _objc_msgSend_111( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer other, + int options, + ) { + return __objc_msgSend_111( + obj, + sel, + other, + options, + ); + } + + late final __objc_msgSend_111Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Int32)>>('objc_msgSend'); + late final __objc_msgSend_111 = __objc_msgSend_111Ptr.asFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer, int)>(); + + late final _sel_differenceFromArray_1 = + _registerName1("differenceFromArray:"); + late final _sel_arrayByApplyingDifference_1 = + _registerName1("arrayByApplyingDifference:"); + ffi.Pointer _objc_msgSend_112( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer difference, + ) { + return __objc_msgSend_112( + obj, + sel, + difference, + ); + } + + late final __objc_msgSend_112Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_112 = __objc_msgSend_112Ptr.asFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>(); + + late final _sel_getObjects_1 = _registerName1("getObjects:"); + void _objc_msgSend_113( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer> objects, + ) { + return __objc_msgSend_113( + obj, + sel, + objects, + ); + } + + late final __objc_msgSend_113Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer>)>>('objc_msgSend'); + late final __objc_msgSend_113 = __objc_msgSend_113Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer>)>(); + + late final _sel_arrayWithContentsOfFile_1 = + _registerName1("arrayWithContentsOfFile:"); + ffi.Pointer _objc_msgSend_114( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer path, + ) { + return __objc_msgSend_114( + obj, + sel, + path, + ); + } + + late final __objc_msgSend_114Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_114 = __objc_msgSend_114Ptr.asFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>(); + + late final _sel_arrayWithContentsOfURL_1 = + _registerName1("arrayWithContentsOfURL:"); + ffi.Pointer _objc_msgSend_115( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer url, + ) { + return __objc_msgSend_115( + obj, + sel, + url, + ); + } + + late final __objc_msgSend_115Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_115 = __objc_msgSend_115Ptr.asFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>(); + + late final _sel_initWithContentsOfFile_1 = + _registerName1("initWithContentsOfFile:"); + late final _sel_initWithContentsOfURL_1 = + _registerName1("initWithContentsOfURL:"); + late final _sel_writeToFile_atomically_1 = + _registerName1("writeToFile:atomically:"); + bool _objc_msgSend_116( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer path, + bool useAuxiliaryFile, + ) { + return __objc_msgSend_116( + obj, + sel, + path, + useAuxiliaryFile, + ); + } + + late final __objc_msgSend_116Ptr = _lookup< + ffi.NativeFunction< + ffi.Bool Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, ffi.Bool)>>('objc_msgSend'); + late final __objc_msgSend_116 = __objc_msgSend_116Ptr.asFunction< + bool Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, bool)>(); + + late final _sel_writeToURL_atomically_1 = + _registerName1("writeToURL:atomically:"); + bool _objc_msgSend_117( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer url, + bool atomically, + ) { + return __objc_msgSend_117( + obj, + sel, + url, + atomically, + ); + } + + late final __objc_msgSend_117Ptr = _lookup< + ffi.NativeFunction< + ffi.Bool Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, ffi.Bool)>>('objc_msgSend'); + late final __objc_msgSend_117 = __objc_msgSend_117Ptr.asFunction< + bool Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, bool)>(); + + late final _sel_decodeArrayOfObjectsOfClass_forKey_1 = + _registerName1("decodeArrayOfObjectsOfClass:forKey:"); + ffi.Pointer _objc_msgSend_118( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer cls, + ffi.Pointer key, + ) { + return __objc_msgSend_118( + obj, + sel, + cls, + key, + ); + } + + late final __objc_msgSend_118Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_118 = __objc_msgSend_118Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>(); + + late final _class_NSDictionary1 = _getClass1("NSDictionary"); + late final _sel_objectForKey_1 = _registerName1("objectForKey:"); + ffi.Pointer _objc_msgSend_119( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer aKey, + ) { + return __objc_msgSend_119( + obj, + sel, + aKey, + ); + } + + late final __objc_msgSend_119Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_119 = __objc_msgSend_119Ptr.asFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>(); + + late final _sel_keyEnumerator1 = _registerName1("keyEnumerator"); + late final _sel_initWithObjects_forKeys_count_1 = + _registerName1("initWithObjects:forKeys:count:"); + instancetype _objc_msgSend_120( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer> objects, + ffi.Pointer> keys, + int cnt, + ) { + return __objc_msgSend_120( + obj, + sel, + objects, + keys, + cnt, + ); + } + + late final __objc_msgSend_120Ptr = _lookup< + ffi.NativeFunction< + instancetype Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer>, + ffi.Pointer>, + ffi.UnsignedLong)>>('objc_msgSend'); + late final __objc_msgSend_120 = __objc_msgSend_120Ptr.asFunction< + instancetype Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer>, + ffi.Pointer>, + int)>(); + + late final _sel_allKeys1 = _registerName1("allKeys"); + ffi.Pointer _objc_msgSend_121( + ffi.Pointer obj, + ffi.Pointer sel, + ) { + return __objc_msgSend_121( + obj, + sel, + ); + } + + late final __objc_msgSend_121Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_121 = __objc_msgSend_121Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); + + late final _sel_allKeysForObject_1 = _registerName1("allKeysForObject:"); + late final _sel_allValues1 = _registerName1("allValues"); + late final _sel_descriptionInStringsFileFormat1 = + _registerName1("descriptionInStringsFileFormat"); + late final _sel_isEqualToDictionary_1 = + _registerName1("isEqualToDictionary:"); + bool _objc_msgSend_122( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer otherDictionary, + ) { + return __objc_msgSend_122( + obj, + sel, + otherDictionary, + ); + } + + late final __objc_msgSend_122Ptr = _lookup< + ffi.NativeFunction< + ffi.Bool Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_122 = __objc_msgSend_122Ptr.asFunction< + bool Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); + + late final _sel_objectsForKeys_notFoundMarker_1 = + _registerName1("objectsForKeys:notFoundMarker:"); + ffi.Pointer _objc_msgSend_123( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer keys, + ffi.Pointer marker, + ) { + return __objc_msgSend_123( + obj, + sel, + keys, + marker, + ); + } + + late final __objc_msgSend_123Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_123 = __objc_msgSend_123Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>(); + + late final _sel_keysSortedByValueUsingSelector_1 = + _registerName1("keysSortedByValueUsingSelector:"); + late final _sel_getObjects_andKeys_count_1 = + _registerName1("getObjects:andKeys:count:"); + void _objc_msgSend_124( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer> objects, + ffi.Pointer> keys, + int count, + ) { + return __objc_msgSend_124( + obj, + sel, + objects, + keys, + count, + ); + } + + late final __objc_msgSend_124Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer>, + ffi.Pointer>, + ffi.UnsignedLong)>>('objc_msgSend'); + late final __objc_msgSend_124 = __objc_msgSend_124Ptr.asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer>, + ffi.Pointer>, + int)>(); + + late final _sel_objectForKeyedSubscript_1 = + _registerName1("objectForKeyedSubscript:"); + late final _sel_enumerateKeysAndObjectsUsingBlock_1 = + _registerName1("enumerateKeysAndObjectsUsingBlock:"); + void _objc_msgSend_125( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer<_ObjCBlock> block, + ) { + return __objc_msgSend_125( + obj, + sel, + block, + ); + } + + late final __objc_msgSend_125Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer<_ObjCBlock>)>>('objc_msgSend'); + late final __objc_msgSend_125 = __objc_msgSend_125Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer<_ObjCBlock>)>(); + + late final _sel_enumerateKeysAndObjectsWithOptions_usingBlock_1 = + _registerName1("enumerateKeysAndObjectsWithOptions:usingBlock:"); + void _objc_msgSend_126( + ffi.Pointer obj, + ffi.Pointer sel, + int opts, + ffi.Pointer<_ObjCBlock> block, + ) { + return __objc_msgSend_126( + obj, + sel, + opts, + block, + ); + } + + late final __objc_msgSend_126Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Int32, ffi.Pointer<_ObjCBlock>)>>('objc_msgSend'); + late final __objc_msgSend_126 = __objc_msgSend_126Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, int, + ffi.Pointer<_ObjCBlock>)>(); + + late final _sel_keysSortedByValueUsingComparator_1 = + _registerName1("keysSortedByValueUsingComparator:"); + late final _sel_keysSortedByValueWithOptions_usingComparator_1 = + _registerName1("keysSortedByValueWithOptions:usingComparator:"); + late final _sel_keysOfEntriesPassingTest_1 = + _registerName1("keysOfEntriesPassingTest:"); + ffi.Pointer _objc_msgSend_127( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer<_ObjCBlock> predicate, + ) { + return __objc_msgSend_127( + obj, + sel, + predicate, + ); + } + + late final __objc_msgSend_127Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer<_ObjCBlock>)>>('objc_msgSend'); + late final __objc_msgSend_127 = __objc_msgSend_127Ptr.asFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer<_ObjCBlock>)>(); + + late final _sel_keysOfEntriesWithOptions_passingTest_1 = + _registerName1("keysOfEntriesWithOptions:passingTest:"); + ffi.Pointer _objc_msgSend_128( + ffi.Pointer obj, + ffi.Pointer sel, + int opts, + ffi.Pointer<_ObjCBlock> predicate, + ) { + return __objc_msgSend_128( + obj, + sel, + opts, + predicate, + ); + } + + late final __objc_msgSend_128Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Int32, + ffi.Pointer<_ObjCBlock>)>>('objc_msgSend'); + late final __objc_msgSend_128 = __objc_msgSend_128Ptr.asFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, int, ffi.Pointer<_ObjCBlock>)>(); + + late final _sel_getObjects_andKeys_1 = _registerName1("getObjects:andKeys:"); + void _objc_msgSend_129( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer> objects, + ffi.Pointer> keys, + ) { + return __objc_msgSend_129( + obj, + sel, + objects, + keys, + ); + } + + late final __objc_msgSend_129Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer>, + ffi.Pointer>)>>('objc_msgSend'); + late final __objc_msgSend_129 = __objc_msgSend_129Ptr.asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer>, + ffi.Pointer>)>(); + + late final _sel_dictionaryWithContentsOfFile_1 = + _registerName1("dictionaryWithContentsOfFile:"); + ffi.Pointer _objc_msgSend_130( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer path, + ) { + return __objc_msgSend_130( + obj, + sel, + path, + ); + } + + late final __objc_msgSend_130Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_130 = __objc_msgSend_130Ptr.asFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>(); + + late final _sel_dictionaryWithContentsOfURL_1 = + _registerName1("dictionaryWithContentsOfURL:"); + ffi.Pointer _objc_msgSend_131( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer url, + ) { + return __objc_msgSend_131( + obj, + sel, + url, + ); + } + + late final __objc_msgSend_131Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_131 = __objc_msgSend_131Ptr.asFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>(); + + late final _sel_dictionary1 = _registerName1("dictionary"); + late final _sel_dictionaryWithObject_forKey_1 = + _registerName1("dictionaryWithObject:forKey:"); + instancetype _objc_msgSend_132( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer object, + ffi.Pointer key, + ) { + return __objc_msgSend_132( + obj, + sel, + object, + key, + ); + } + + late final __objc_msgSend_132Ptr = _lookup< + ffi.NativeFunction< + instancetype Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_132 = __objc_msgSend_132Ptr.asFunction< + instancetype Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, ffi.Pointer)>(); + + late final _sel_dictionaryWithObjects_forKeys_count_1 = + _registerName1("dictionaryWithObjects:forKeys:count:"); + late final _sel_dictionaryWithObjectsAndKeys_1 = + _registerName1("dictionaryWithObjectsAndKeys:"); + late final _sel_dictionaryWithDictionary_1 = + _registerName1("dictionaryWithDictionary:"); + instancetype _objc_msgSend_133( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer dict, + ) { + return __objc_msgSend_133( + obj, + sel, + dict, + ); + } + + late final __objc_msgSend_133Ptr = _lookup< + ffi.NativeFunction< + instancetype Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_133 = __objc_msgSend_133Ptr.asFunction< + instancetype Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); + + late final _sel_dictionaryWithObjects_forKeys_1 = + _registerName1("dictionaryWithObjects:forKeys:"); + instancetype _objc_msgSend_134( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer objects, + ffi.Pointer keys, + ) { + return __objc_msgSend_134( + obj, + sel, + objects, + keys, + ); + } + + late final __objc_msgSend_134Ptr = _lookup< + ffi.NativeFunction< + instancetype Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_134 = __objc_msgSend_134Ptr.asFunction< + instancetype Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, ffi.Pointer)>(); + + late final _sel_initWithObjectsAndKeys_1 = + _registerName1("initWithObjectsAndKeys:"); + late final _sel_initWithDictionary_1 = _registerName1("initWithDictionary:"); + late final _sel_initWithDictionary_copyItems_1 = + _registerName1("initWithDictionary:copyItems:"); + instancetype _objc_msgSend_135( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer otherDictionary, + bool flag, + ) { + return __objc_msgSend_135( + obj, + sel, + otherDictionary, + flag, + ); + } + + late final __objc_msgSend_135Ptr = _lookup< + ffi.NativeFunction< + instancetype Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, ffi.Bool)>>('objc_msgSend'); + late final __objc_msgSend_135 = __objc_msgSend_135Ptr.asFunction< + instancetype Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, bool)>(); + + late final _sel_initWithObjects_forKeys_1 = + _registerName1("initWithObjects:forKeys:"); + ffi.Pointer _objc_msgSend_136( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer url, + ffi.Pointer> error, + ) { + return __objc_msgSend_136( + obj, + sel, + url, + error, + ); + } + + late final __objc_msgSend_136Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer>)>>('objc_msgSend'); + late final __objc_msgSend_136 = __objc_msgSend_136Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer>)>(); + + late final _sel_dictionaryWithContentsOfURL_error_1 = + _registerName1("dictionaryWithContentsOfURL:error:"); + late final _sel_sharedKeySetForKeys_1 = + _registerName1("sharedKeySetForKeys:"); + late final _sel_countByEnumeratingWithState_objects_count_1 = + _registerName1("countByEnumeratingWithState:objects:count:"); + int _objc_msgSend_137( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer state, + ffi.Pointer> buffer, + int len, + ) { + return __objc_msgSend_137( + obj, + sel, + state, + buffer, + len, + ); + } + + late final __objc_msgSend_137Ptr = _lookup< + ffi.NativeFunction< + ffi.UnsignedLong Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer>, + ffi.UnsignedLong)>>('objc_msgSend'); + late final __objc_msgSend_137 = __objc_msgSend_137Ptr.asFunction< + int Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer>, + int)>(); + + late final _sel_decodeDictionaryWithKeysOfClass_objectsOfClass_forKey_1 = + _registerName1("decodeDictionaryWithKeysOfClass:objectsOfClass:forKey:"); + ffi.Pointer _objc_msgSend_138( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer keyCls, + ffi.Pointer objectCls, + ffi.Pointer key, + ) { + return __objc_msgSend_138( + obj, + sel, + keyCls, + objectCls, + key, + ); + } + + late final __objc_msgSend_138Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_138 = __objc_msgSend_138Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>(); + + late final _class_NSSet1 = _getClass1("NSSet"); + late final _sel_member_1 = _registerName1("member:"); + late final _sel_anyObject1 = _registerName1("anyObject"); + late final _sel_intersectsSet_1 = _registerName1("intersectsSet:"); + bool _objc_msgSend_139( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer otherSet, + ) { + return __objc_msgSend_139( + obj, + sel, + otherSet, + ); + } + + late final __objc_msgSend_139Ptr = _lookup< + ffi.NativeFunction< + ffi.Bool Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_139 = __objc_msgSend_139Ptr.asFunction< + bool Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); + + late final _sel_isEqualToSet_1 = _registerName1("isEqualToSet:"); + late final _sel_isSubsetOfSet_1 = _registerName1("isSubsetOfSet:"); + late final _sel_setByAddingObject_1 = _registerName1("setByAddingObject:"); + ffi.Pointer _objc_msgSend_140( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer anObject, + ) { + return __objc_msgSend_140( + obj, + sel, + anObject, + ); + } + + late final __objc_msgSend_140Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_140 = __objc_msgSend_140Ptr.asFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>(); + + late final _sel_setByAddingObjectsFromSet_1 = + _registerName1("setByAddingObjectsFromSet:"); + ffi.Pointer _objc_msgSend_141( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer other, + ) { + return __objc_msgSend_141( + obj, + sel, + other, + ); + } + + late final __objc_msgSend_141Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_141 = __objc_msgSend_141Ptr.asFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>(); + + late final _sel_setByAddingObjectsFromArray_1 = + _registerName1("setByAddingObjectsFromArray:"); + ffi.Pointer _objc_msgSend_142( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer other, + ) { + return __objc_msgSend_142( + obj, + sel, + other, + ); + } + + late final __objc_msgSend_142Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_142 = __objc_msgSend_142Ptr.asFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>(); + + void _objc_msgSend_143( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer<_ObjCBlock> block, + ) { + return __objc_msgSend_143( + obj, + sel, + block, + ); + } + + late final __objc_msgSend_143Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer<_ObjCBlock>)>>('objc_msgSend'); + late final __objc_msgSend_143 = __objc_msgSend_143Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer<_ObjCBlock>)>(); + + void _objc_msgSend_144( + ffi.Pointer obj, + ffi.Pointer sel, + int opts, + ffi.Pointer<_ObjCBlock> block, + ) { + return __objc_msgSend_144( + obj, + sel, + opts, + block, + ); + } + + late final __objc_msgSend_144Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Int32, ffi.Pointer<_ObjCBlock>)>>('objc_msgSend'); + late final __objc_msgSend_144 = __objc_msgSend_144Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, int, + ffi.Pointer<_ObjCBlock>)>(); + + late final _sel_objectsPassingTest_1 = _registerName1("objectsPassingTest:"); + ffi.Pointer _objc_msgSend_145( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer<_ObjCBlock> predicate, + ) { + return __objc_msgSend_145( + obj, + sel, + predicate, + ); + } + + late final __objc_msgSend_145Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer<_ObjCBlock>)>>('objc_msgSend'); + late final __objc_msgSend_145 = __objc_msgSend_145Ptr.asFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer<_ObjCBlock>)>(); + + late final _sel_objectsWithOptions_passingTest_1 = + _registerName1("objectsWithOptions:passingTest:"); + ffi.Pointer _objc_msgSend_146( + ffi.Pointer obj, + ffi.Pointer sel, + int opts, + ffi.Pointer<_ObjCBlock> predicate, + ) { + return __objc_msgSend_146( + obj, + sel, + opts, + predicate, + ); + } + + late final __objc_msgSend_146Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Int32, + ffi.Pointer<_ObjCBlock>)>>('objc_msgSend'); + late final __objc_msgSend_146 = __objc_msgSend_146Ptr.asFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, int, ffi.Pointer<_ObjCBlock>)>(); + + late final _sel_set1 = _registerName1("set"); + late final _sel_setWithObject_1 = _registerName1("setWithObject:"); + late final _sel_setWithObjects_count_1 = + _registerName1("setWithObjects:count:"); + late final _sel_setWithObjects_1 = _registerName1("setWithObjects:"); + late final _sel_setWithSet_1 = _registerName1("setWithSet:"); + instancetype _objc_msgSend_147( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer set1, + ) { + return __objc_msgSend_147( + obj, + sel, + set1, + ); + } + + late final __objc_msgSend_147Ptr = _lookup< + ffi.NativeFunction< + instancetype Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_147 = __objc_msgSend_147Ptr.asFunction< + instancetype Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); + + late final _sel_setWithArray_1 = _registerName1("setWithArray:"); + late final _sel_initWithSet_1 = _registerName1("initWithSet:"); + late final _sel_initWithSet_copyItems_1 = + _registerName1("initWithSet:copyItems:"); + instancetype _objc_msgSend_148( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer set1, + bool flag, + ) { + return __objc_msgSend_148( + obj, + sel, + set1, + flag, + ); + } + + late final __objc_msgSend_148Ptr = _lookup< + ffi.NativeFunction< + instancetype Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, ffi.Bool)>>('objc_msgSend'); + late final __objc_msgSend_148 = __objc_msgSend_148Ptr.asFunction< + instancetype Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, bool)>(); + + late final _sel_decodeObjectOfClasses_forKey_1 = + _registerName1("decodeObjectOfClasses:forKey:"); + ffi.Pointer _objc_msgSend_149( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer classes, + ffi.Pointer key, + ) { + return __objc_msgSend_149( + obj, + sel, + classes, + key, + ); + } + + late final __objc_msgSend_149Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_149 = __objc_msgSend_149Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>(); + + late final _sel_decodeTopLevelObjectOfClasses_forKey_error_1 = + _registerName1("decodeTopLevelObjectOfClasses:forKey:error:"); + ffi.Pointer _objc_msgSend_150( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer classes, + ffi.Pointer key, + ffi.Pointer> error, + ) { + return __objc_msgSend_150( + obj, + sel, + classes, + key, + error, + ); + } + + late final __objc_msgSend_150Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer>)>>('objc_msgSend'); + late final __objc_msgSend_150 = __objc_msgSend_150Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer>)>(); + + late final _sel_decodeArrayOfObjectsOfClasses_forKey_1 = + _registerName1("decodeArrayOfObjectsOfClasses:forKey:"); + ffi.Pointer _objc_msgSend_151( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer classes, + ffi.Pointer key, + ) { + return __objc_msgSend_151( + obj, + sel, + classes, + key, + ); + } + + late final __objc_msgSend_151Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_151 = __objc_msgSend_151Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>(); + + late final _sel_decodeDictionaryWithKeysOfClasses_objectsOfClasses_forKey_1 = + _registerName1( + "decodeDictionaryWithKeysOfClasses:objectsOfClasses:forKey:"); + ffi.Pointer _objc_msgSend_152( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer keyClasses, + ffi.Pointer objectClasses, + ffi.Pointer key, + ) { + return __objc_msgSend_152( + obj, + sel, + keyClasses, + objectClasses, + key, + ); + } + + late final __objc_msgSend_152Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_152 = __objc_msgSend_152Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>(); + + late final _sel_decodePropertyListForKey_1 = + _registerName1("decodePropertyListForKey:"); + late final _sel_allowedClasses1 = _registerName1("allowedClasses"); + ffi.Pointer _objc_msgSend_153( + ffi.Pointer obj, + ffi.Pointer sel, + ) { + return __objc_msgSend_153( + obj, + sel, + ); + } + + late final __objc_msgSend_153Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_153 = __objc_msgSend_153Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); + + late final _sel_failWithError_1 = _registerName1("failWithError:"); + void _objc_msgSend_154( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer error, + ) { + return __objc_msgSend_154( + obj, + sel, + error, + ); + } + + late final __objc_msgSend_154Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_154 = __objc_msgSend_154Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); + + late final _sel_decodingFailurePolicy1 = + _registerName1("decodingFailurePolicy"); + int _objc_msgSend_155( + ffi.Pointer obj, + ffi.Pointer sel, + ) { + return __objc_msgSend_155( + obj, + sel, + ); + } + + late final __objc_msgSend_155Ptr = _lookup< + ffi.NativeFunction< + ffi.Int32 Function( + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_155 = __objc_msgSend_155Ptr.asFunction< + int Function(ffi.Pointer, ffi.Pointer)>(); + + late final _sel_error1 = _registerName1("error"); + ffi.Pointer _objc_msgSend_156( + ffi.Pointer obj, + ffi.Pointer sel, + ) { + return __objc_msgSend_156( + obj, + sel, + ); + } + + late final __objc_msgSend_156Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_156 = __objc_msgSend_156Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); + + late final _sel_encodeNXObject_1 = _registerName1("encodeNXObject:"); + late final _sel_decodeNXObject1 = _registerName1("decodeNXObject"); + late final _sel_decodeValueOfObjCType_at_1 = + _registerName1("decodeValueOfObjCType:at:"); + late final _sel_encodePoint_1 = _registerName1("encodePoint:"); + void _objc_msgSend_157( + ffi.Pointer obj, + ffi.Pointer sel, + CGPoint point, + ) { + return __objc_msgSend_157( + obj, + sel, + point, + ); + } + + late final __objc_msgSend_157Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + CGPoint)>>('objc_msgSend'); + late final __objc_msgSend_157 = __objc_msgSend_157Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, CGPoint)>(); + + late final _sel_decodePoint1 = _registerName1("decodePoint"); + void _objc_msgSend_158( + ffi.Pointer stret, + ffi.Pointer obj, + ffi.Pointer sel, + ) { + return __objc_msgSend_158( + stret, + obj, + sel, + ); + } + + late final __objc_msgSend_158Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>>('objc_msgSend_stret'); + late final __objc_msgSend_158 = __objc_msgSend_158Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); + + late final _sel_encodeSize_1 = _registerName1("encodeSize:"); + void _objc_msgSend_159( + ffi.Pointer obj, + ffi.Pointer sel, + CGSize size, + ) { + return __objc_msgSend_159( + obj, + sel, + size, + ); + } + + late final __objc_msgSend_159Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + CGSize)>>('objc_msgSend'); + late final __objc_msgSend_159 = __objc_msgSend_159Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, CGSize)>(); + + late final _sel_decodeSize1 = _registerName1("decodeSize"); + void _objc_msgSend_160( + ffi.Pointer stret, + ffi.Pointer obj, + ffi.Pointer sel, + ) { + return __objc_msgSend_160( + stret, + obj, + sel, + ); + } + + late final __objc_msgSend_160Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>>('objc_msgSend_stret'); + late final __objc_msgSend_160 = __objc_msgSend_160Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); + + late final _sel_encodeRect_1 = _registerName1("encodeRect:"); + void _objc_msgSend_161( + ffi.Pointer obj, + ffi.Pointer sel, + CGRect rect, + ) { + return __objc_msgSend_161( + obj, + sel, + rect, + ); + } + + late final __objc_msgSend_161Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + CGRect)>>('objc_msgSend'); + late final __objc_msgSend_161 = __objc_msgSend_161Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, CGRect)>(); + + late final _sel_decodeRect1 = _registerName1("decodeRect"); + void _objc_msgSend_162( + ffi.Pointer stret, + ffi.Pointer obj, + ffi.Pointer sel, + ) { + return __objc_msgSend_162( + stret, + obj, + sel, + ); + } + + late final __objc_msgSend_162Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>>('objc_msgSend_stret'); + late final __objc_msgSend_162 = __objc_msgSend_162Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); + + late final _sel_encodePoint_forKey_1 = _registerName1("encodePoint:forKey:"); + void _objc_msgSend_163( + ffi.Pointer obj, + ffi.Pointer sel, + CGPoint point, + ffi.Pointer key, + ) { + return __objc_msgSend_163( + obj, + sel, + point, + key, + ); + } + + late final __objc_msgSend_163Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + CGPoint, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_163 = __objc_msgSend_163Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, CGPoint, + ffi.Pointer)>(); + + late final _sel_encodeSize_forKey_1 = _registerName1("encodeSize:forKey:"); + void _objc_msgSend_164( + ffi.Pointer obj, + ffi.Pointer sel, + CGSize size, + ffi.Pointer key, + ) { + return __objc_msgSend_164( + obj, + sel, + size, + key, + ); + } + + late final __objc_msgSend_164Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + CGSize, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_164 = __objc_msgSend_164Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, CGSize, + ffi.Pointer)>(); + + late final _sel_encodeRect_forKey_1 = _registerName1("encodeRect:forKey:"); + void _objc_msgSend_165( + ffi.Pointer obj, + ffi.Pointer sel, + CGRect rect, + ffi.Pointer key, + ) { + return __objc_msgSend_165( + obj, + sel, + rect, + key, + ); + } + + late final __objc_msgSend_165Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + CGRect, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_165 = __objc_msgSend_165Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, CGRect, + ffi.Pointer)>(); + + late final _sel_decodePointForKey_1 = _registerName1("decodePointForKey:"); + void _objc_msgSend_166( + ffi.Pointer stret, + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer key, + ) { + return __objc_msgSend_166( + stret, + obj, + sel, + key, + ); + } + + late final __objc_msgSend_166Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>('objc_msgSend_stret'); + late final __objc_msgSend_166 = __objc_msgSend_166Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, ffi.Pointer)>(); + + late final _sel_decodeSizeForKey_1 = _registerName1("decodeSizeForKey:"); + void _objc_msgSend_167( + ffi.Pointer stret, + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer key, + ) { + return __objc_msgSend_167( + stret, + obj, + sel, + key, + ); + } + + late final __objc_msgSend_167Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>('objc_msgSend_stret'); + late final __objc_msgSend_167 = __objc_msgSend_167Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, ffi.Pointer)>(); + + late final _sel_decodeRectForKey_1 = _registerName1("decodeRectForKey:"); + void _objc_msgSend_168( + ffi.Pointer stret, + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer key, + ) { + return __objc_msgSend_168( + stret, + obj, + sel, + key, + ); + } + + late final __objc_msgSend_168Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>('objc_msgSend_stret'); + late final __objc_msgSend_168 = __objc_msgSend_168Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, ffi.Pointer)>(); + + late final _sel_substringFromIndex_1 = _registerName1("substringFromIndex:"); + ffi.Pointer _objc_msgSend_169( + ffi.Pointer obj, + ffi.Pointer sel, + int from, + ) { + return __objc_msgSend_169( + obj, + sel, + from, + ); + } + + late final __objc_msgSend_169Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.UnsignedLong)>>('objc_msgSend'); + late final __objc_msgSend_169 = __objc_msgSend_169Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer, int)>(); + + late final _sel_substringToIndex_1 = _registerName1("substringToIndex:"); + late final _sel_substringWithRange_1 = _registerName1("substringWithRange:"); + ffi.Pointer _objc_msgSend_170( + ffi.Pointer obj, + ffi.Pointer sel, + _NSRange range, + ) { + return __objc_msgSend_170( + obj, + sel, + range, + ); + } + + late final __objc_msgSend_170Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, _NSRange)>>('objc_msgSend'); + late final __objc_msgSend_170 = __objc_msgSend_170Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer, _NSRange)>(); + + late final _sel_getCharacters_range_1 = + _registerName1("getCharacters:range:"); + void _objc_msgSend_171( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer buffer, + _NSRange range, + ) { + return __objc_msgSend_171( + obj, + sel, + buffer, + range, + ); + } + + late final __objc_msgSend_171Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, _NSRange)>>('objc_msgSend'); + late final __objc_msgSend_171 = __objc_msgSend_171Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, _NSRange)>(); + + late final _sel_compare_1 = _registerName1("compare:"); + int _objc_msgSend_172( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer string, + ) { + return __objc_msgSend_172( + obj, + sel, + string, + ); + } + + late final __objc_msgSend_172Ptr = _lookup< + ffi.NativeFunction< + ffi.Int32 Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_172 = __objc_msgSend_172Ptr.asFunction< + int Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); + + late final _sel_compare_options_1 = _registerName1("compare:options:"); + int _objc_msgSend_173( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer string, + int mask, + ) { + return __objc_msgSend_173( + obj, + sel, + string, + mask, + ); + } + + late final __objc_msgSend_173Ptr = _lookup< + ffi.NativeFunction< + ffi.Int32 Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, ffi.Int32)>>('objc_msgSend'); + late final __objc_msgSend_173 = __objc_msgSend_173Ptr.asFunction< + int Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, int)>(); + + late final _sel_compare_options_range_1 = + _registerName1("compare:options:range:"); + int _objc_msgSend_174( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer string, + int mask, + _NSRange rangeOfReceiverToCompare, + ) { + return __objc_msgSend_174( + obj, + sel, + string, + mask, + rangeOfReceiverToCompare, + ); + } + + late final __objc_msgSend_174Ptr = _lookup< + ffi.NativeFunction< + ffi.Int32 Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, ffi.Int32, _NSRange)>>('objc_msgSend'); + late final __objc_msgSend_174 = __objc_msgSend_174Ptr.asFunction< + int Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, int, _NSRange)>(); + + late final _sel_compare_options_range_locale_1 = + _registerName1("compare:options:range:locale:"); + int _objc_msgSend_175( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer string, + int mask, + _NSRange rangeOfReceiverToCompare, + ffi.Pointer locale, + ) { + return __objc_msgSend_175( + obj, + sel, + string, + mask, + rangeOfReceiverToCompare, + locale, + ); + } + + late final __objc_msgSend_175Ptr = _lookup< + ffi.NativeFunction< + ffi.Int32 Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Int32, + _NSRange, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_175 = __objc_msgSend_175Ptr.asFunction< + int Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, int, _NSRange, ffi.Pointer)>(); + + late final _sel_caseInsensitiveCompare_1 = + _registerName1("caseInsensitiveCompare:"); + late final _sel_localizedCompare_1 = _registerName1("localizedCompare:"); + late final _sel_localizedCaseInsensitiveCompare_1 = + _registerName1("localizedCaseInsensitiveCompare:"); + late final _sel_localizedStandardCompare_1 = + _registerName1("localizedStandardCompare:"); + late final _sel_isEqualToString_1 = _registerName1("isEqualToString:"); + late final _sel_hasPrefix_1 = _registerName1("hasPrefix:"); + late final _sel_hasSuffix_1 = _registerName1("hasSuffix:"); + late final _sel_commonPrefixWithString_options_1 = + _registerName1("commonPrefixWithString:options:"); + ffi.Pointer _objc_msgSend_176( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer str, + int mask, + ) { + return __objc_msgSend_176( + obj, + sel, + str, + mask, + ); + } + + late final __objc_msgSend_176Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Int32)>>('objc_msgSend'); + late final __objc_msgSend_176 = __objc_msgSend_176Ptr.asFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer, int)>(); + + late final _sel_containsString_1 = _registerName1("containsString:"); + late final _sel_localizedCaseInsensitiveContainsString_1 = + _registerName1("localizedCaseInsensitiveContainsString:"); + late final _sel_localizedStandardContainsString_1 = + _registerName1("localizedStandardContainsString:"); + late final _sel_localizedStandardRangeOfString_1 = + _registerName1("localizedStandardRangeOfString:"); + void _objc_msgSend_177( + ffi.Pointer<_NSRange> stret, + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer str, + ) { + return __objc_msgSend_177( + stret, + obj, + sel, + str, + ); + } + + late final __objc_msgSend_177Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer<_NSRange>, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>('objc_msgSend_stret'); + late final __objc_msgSend_177 = __objc_msgSend_177Ptr.asFunction< + void Function(ffi.Pointer<_NSRange>, ffi.Pointer, + ffi.Pointer, ffi.Pointer)>(); + + late final _sel_rangeOfString_1 = _registerName1("rangeOfString:"); + late final _sel_rangeOfString_options_1 = + _registerName1("rangeOfString:options:"); + void _objc_msgSend_178( + ffi.Pointer<_NSRange> stret, + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer searchString, + int mask, + ) { + return __objc_msgSend_178( + stret, + obj, + sel, + searchString, + mask, + ); + } + + late final __objc_msgSend_178Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer<_NSRange>, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Int32)>>('objc_msgSend_stret'); + late final __objc_msgSend_178 = __objc_msgSend_178Ptr.asFunction< + void Function(ffi.Pointer<_NSRange>, ffi.Pointer, + ffi.Pointer, ffi.Pointer, int)>(); + + late final _sel_rangeOfString_options_range_1 = + _registerName1("rangeOfString:options:range:"); + void _objc_msgSend_179( + ffi.Pointer<_NSRange> stret, + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer searchString, + int mask, + _NSRange rangeOfReceiverToSearch, + ) { + return __objc_msgSend_179( + stret, + obj, + sel, + searchString, + mask, + rangeOfReceiverToSearch, + ); + } + + late final __objc_msgSend_179Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer<_NSRange>, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Int32, + _NSRange)>>('objc_msgSend_stret'); + late final __objc_msgSend_179 = __objc_msgSend_179Ptr.asFunction< + void Function(ffi.Pointer<_NSRange>, ffi.Pointer, + ffi.Pointer, ffi.Pointer, int, _NSRange)>(); + + late final _class_NSLocale1 = _getClass1("NSLocale"); + late final _sel_displayNameForKey_value_1 = + _registerName1("displayNameForKey:value:"); + ffi.Pointer _objc_msgSend_180( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer key, + ffi.Pointer value, + ) { + return __objc_msgSend_180( + obj, + sel, + key, + value, + ); + } + + late final __objc_msgSend_180Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_180 = __objc_msgSend_180Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>(); + + late final _sel_initWithLocaleIdentifier_1 = + _registerName1("initWithLocaleIdentifier:"); + instancetype _objc_msgSend_181( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer string, + ) { + return __objc_msgSend_181( + obj, + sel, + string, + ); + } + + late final __objc_msgSend_181Ptr = _lookup< + ffi.NativeFunction< + instancetype Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_181 = __objc_msgSend_181Ptr.asFunction< + instancetype Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); + + late final _sel_localeIdentifier1 = _registerName1("localeIdentifier"); + late final _sel_localizedStringForLocaleIdentifier_1 = + _registerName1("localizedStringForLocaleIdentifier:"); + late final _sel_languageCode1 = _registerName1("languageCode"); + late final _sel_localizedStringForLanguageCode_1 = + _registerName1("localizedStringForLanguageCode:"); + ffi.Pointer _objc_msgSend_182( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer languageCode, + ) { + return __objc_msgSend_182( + obj, + sel, + languageCode, + ); + } + + late final __objc_msgSend_182Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_182 = __objc_msgSend_182Ptr.asFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>(); + + late final _sel_languageIdentifier1 = _registerName1("languageIdentifier"); + late final _sel_countryCode1 = _registerName1("countryCode"); + ffi.Pointer _objc_msgSend_183( + ffi.Pointer obj, + ffi.Pointer sel, + ) { + return __objc_msgSend_183( + obj, + sel, + ); + } + + late final __objc_msgSend_183Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_183 = __objc_msgSend_183Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); + + late final _sel_localizedStringForCountryCode_1 = + _registerName1("localizedStringForCountryCode:"); + late final _sel_regionCode1 = _registerName1("regionCode"); + late final _sel_scriptCode1 = _registerName1("scriptCode"); + late final _sel_localizedStringForScriptCode_1 = + _registerName1("localizedStringForScriptCode:"); + late final _sel_variantCode1 = _registerName1("variantCode"); + late final _sel_localizedStringForVariantCode_1 = + _registerName1("localizedStringForVariantCode:"); + late final _class_NSCharacterSet1 = _getClass1("NSCharacterSet"); + late final _sel_exemplarCharacterSet1 = + _registerName1("exemplarCharacterSet"); + ffi.Pointer _objc_msgSend_184( + ffi.Pointer obj, + ffi.Pointer sel, + ) { + return __objc_msgSend_184( + obj, + sel, + ); + } + + late final __objc_msgSend_184Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_184 = __objc_msgSend_184Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); + + late final _sel_calendarIdentifier1 = _registerName1("calendarIdentifier"); + late final _sel_localizedStringForCalendarIdentifier_1 = + _registerName1("localizedStringForCalendarIdentifier:"); + late final _sel_collationIdentifier1 = _registerName1("collationIdentifier"); + late final _sel_localizedStringForCollationIdentifier_1 = + _registerName1("localizedStringForCollationIdentifier:"); + late final _sel_usesMetricSystem1 = _registerName1("usesMetricSystem"); + late final _sel_decimalSeparator1 = _registerName1("decimalSeparator"); + late final _sel_groupingSeparator1 = _registerName1("groupingSeparator"); + late final _sel_currencySymbol1 = _registerName1("currencySymbol"); + late final _sel_currencyCode1 = _registerName1("currencyCode"); + late final _sel_localizedStringForCurrencyCode_1 = + _registerName1("localizedStringForCurrencyCode:"); + late final _sel_collatorIdentifier1 = _registerName1("collatorIdentifier"); + late final _sel_localizedStringForCollatorIdentifier_1 = + _registerName1("localizedStringForCollatorIdentifier:"); + late final _sel_quotationBeginDelimiter1 = + _registerName1("quotationBeginDelimiter"); + late final _sel_quotationEndDelimiter1 = + _registerName1("quotationEndDelimiter"); + late final _sel_alternateQuotationBeginDelimiter1 = + _registerName1("alternateQuotationBeginDelimiter"); + late final _sel_alternateQuotationEndDelimiter1 = + _registerName1("alternateQuotationEndDelimiter"); + late final _sel_autoupdatingCurrentLocale1 = + _registerName1("autoupdatingCurrentLocale"); + ffi.Pointer _objc_msgSend_185( + ffi.Pointer obj, + ffi.Pointer sel, + ) { + return __objc_msgSend_185( + obj, + sel, + ); + } + + late final __objc_msgSend_185Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_185 = __objc_msgSend_185Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); + + late final _sel_currentLocale1 = _registerName1("currentLocale"); + late final _sel_systemLocale1 = _registerName1("systemLocale"); + late final _sel_localeWithLocaleIdentifier_1 = + _registerName1("localeWithLocaleIdentifier:"); + late final _sel_availableLocaleIdentifiers1 = + _registerName1("availableLocaleIdentifiers"); + late final _sel_ISOLanguageCodes1 = _registerName1("ISOLanguageCodes"); + late final _sel_ISOCountryCodes1 = _registerName1("ISOCountryCodes"); + late final _sel_ISOCurrencyCodes1 = _registerName1("ISOCurrencyCodes"); + late final _sel_commonISOCurrencyCodes1 = + _registerName1("commonISOCurrencyCodes"); + late final _sel_preferredLanguages1 = _registerName1("preferredLanguages"); + late final _sel_componentsFromLocaleIdentifier_1 = + _registerName1("componentsFromLocaleIdentifier:"); + ffi.Pointer _objc_msgSend_186( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer string, + ) { + return __objc_msgSend_186( + obj, + sel, + string, + ); + } + + late final __objc_msgSend_186Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_186 = __objc_msgSend_186Ptr.asFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>(); + + late final _sel_localeIdentifierFromComponents_1 = + _registerName1("localeIdentifierFromComponents:"); + ffi.Pointer _objc_msgSend_187( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer dict, + ) { + return __objc_msgSend_187( + obj, + sel, + dict, + ); + } + + late final __objc_msgSend_187Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_187 = __objc_msgSend_187Ptr.asFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>(); + + late final _sel_canonicalLocaleIdentifierFromString_1 = + _registerName1("canonicalLocaleIdentifierFromString:"); + late final _sel_canonicalLanguageIdentifierFromString_1 = + _registerName1("canonicalLanguageIdentifierFromString:"); + late final _sel_localeIdentifierFromWindowsLocaleCode_1 = + _registerName1("localeIdentifierFromWindowsLocaleCode:"); + ffi.Pointer _objc_msgSend_188( + ffi.Pointer obj, + ffi.Pointer sel, + int lcid, + ) { + return __objc_msgSend_188( + obj, + sel, + lcid, + ); + } + + late final __objc_msgSend_188Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Uint32)>>('objc_msgSend'); + late final __objc_msgSend_188 = __objc_msgSend_188Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer, int)>(); + + late final _sel_windowsLocaleCodeFromLocaleIdentifier_1 = + _registerName1("windowsLocaleCodeFromLocaleIdentifier:"); + int _objc_msgSend_189( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer localeIdentifier, + ) { + return __objc_msgSend_189( + obj, + sel, + localeIdentifier, + ); + } + + late final __objc_msgSend_189Ptr = _lookup< + ffi.NativeFunction< + ffi.Uint32 Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_189 = __objc_msgSend_189Ptr.asFunction< + int Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); + + late final _sel_characterDirectionForLanguage_1 = + _registerName1("characterDirectionForLanguage:"); + int _objc_msgSend_190( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer isoLangCode, + ) { + return __objc_msgSend_190( + obj, + sel, + isoLangCode, + ); + } + + late final __objc_msgSend_190Ptr = _lookup< + ffi.NativeFunction< + ffi.Int32 Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_190 = __objc_msgSend_190Ptr.asFunction< + int Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); + + late final _sel_lineDirectionForLanguage_1 = + _registerName1("lineDirectionForLanguage:"); + late final _sel_rangeOfString_options_range_locale_1 = + _registerName1("rangeOfString:options:range:locale:"); + void _objc_msgSend_191( + ffi.Pointer<_NSRange> stret, + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer searchString, + int mask, + _NSRange rangeOfReceiverToSearch, + ffi.Pointer locale, + ) { + return __objc_msgSend_191( + stret, + obj, + sel, + searchString, + mask, + rangeOfReceiverToSearch, + locale, + ); + } + + late final __objc_msgSend_191Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer<_NSRange>, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Int32, + _NSRange, + ffi.Pointer)>>('objc_msgSend_stret'); + late final __objc_msgSend_191 = __objc_msgSend_191Ptr.asFunction< + void Function( + ffi.Pointer<_NSRange>, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + int, + _NSRange, + ffi.Pointer)>(); + + late final _sel_rangeOfCharacterFromSet_1 = + _registerName1("rangeOfCharacterFromSet:"); + void _objc_msgSend_192( + ffi.Pointer<_NSRange> stret, + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer searchSet, + ) { + return __objc_msgSend_192( + stret, + obj, + sel, + searchSet, + ); + } + + late final __objc_msgSend_192Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer<_NSRange>, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>('objc_msgSend_stret'); + late final __objc_msgSend_192 = __objc_msgSend_192Ptr.asFunction< + void Function(ffi.Pointer<_NSRange>, ffi.Pointer, + ffi.Pointer, ffi.Pointer)>(); + + late final _sel_rangeOfCharacterFromSet_options_1 = + _registerName1("rangeOfCharacterFromSet:options:"); + void _objc_msgSend_193( + ffi.Pointer<_NSRange> stret, + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer searchSet, + int mask, + ) { + return __objc_msgSend_193( + stret, + obj, + sel, + searchSet, + mask, + ); + } + + late final __objc_msgSend_193Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer<_NSRange>, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Int32)>>('objc_msgSend_stret'); + late final __objc_msgSend_193 = __objc_msgSend_193Ptr.asFunction< + void Function(ffi.Pointer<_NSRange>, ffi.Pointer, + ffi.Pointer, ffi.Pointer, int)>(); + + late final _sel_rangeOfCharacterFromSet_options_range_1 = + _registerName1("rangeOfCharacterFromSet:options:range:"); + void _objc_msgSend_194( + ffi.Pointer<_NSRange> stret, + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer searchSet, + int mask, + _NSRange rangeOfReceiverToSearch, + ) { + return __objc_msgSend_194( + stret, + obj, + sel, + searchSet, + mask, + rangeOfReceiverToSearch, + ); + } + + late final __objc_msgSend_194Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer<_NSRange>, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Int32, + _NSRange)>>('objc_msgSend_stret'); + late final __objc_msgSend_194 = __objc_msgSend_194Ptr.asFunction< + void Function(ffi.Pointer<_NSRange>, ffi.Pointer, + ffi.Pointer, ffi.Pointer, int, _NSRange)>(); + + late final _sel_rangeOfComposedCharacterSequenceAtIndex_1 = + _registerName1("rangeOfComposedCharacterSequenceAtIndex:"); + void _objc_msgSend_195( + ffi.Pointer<_NSRange> stret, + ffi.Pointer obj, + ffi.Pointer sel, + int index, + ) { + return __objc_msgSend_195( + stret, + obj, + sel, + index, + ); + } + + late final __objc_msgSend_195Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer<_NSRange>, ffi.Pointer, + ffi.Pointer, ffi.UnsignedLong)>>('objc_msgSend_stret'); + late final __objc_msgSend_195 = __objc_msgSend_195Ptr.asFunction< + void Function(ffi.Pointer<_NSRange>, ffi.Pointer, + ffi.Pointer, int)>(); + + late final _sel_rangeOfComposedCharacterSequencesForRange_1 = + _registerName1("rangeOfComposedCharacterSequencesForRange:"); + void _objc_msgSend_196( + ffi.Pointer<_NSRange> stret, + ffi.Pointer obj, + ffi.Pointer sel, + _NSRange range, + ) { + return __objc_msgSend_196( + stret, + obj, + sel, + range, + ); + } + + late final __objc_msgSend_196Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer<_NSRange>, ffi.Pointer, + ffi.Pointer, _NSRange)>>('objc_msgSend_stret'); + late final __objc_msgSend_196 = __objc_msgSend_196Ptr.asFunction< + void Function(ffi.Pointer<_NSRange>, ffi.Pointer, + ffi.Pointer, _NSRange)>(); + + late final _sel_stringByAppendingString_1 = + _registerName1("stringByAppendingString:"); + late final _sel_stringByAppendingFormat_1 = + _registerName1("stringByAppendingFormat:"); + late final _sel_doubleValue1 = _registerName1("doubleValue"); + double _objc_msgSend_197( + ffi.Pointer obj, + ffi.Pointer sel, + ) { + return __objc_msgSend_197( + obj, + sel, + ); + } + + late final __objc_msgSend_197Ptr = _lookup< + ffi.NativeFunction< + ffi.Double Function(ffi.Pointer, + ffi.Pointer)>>('objc_msgSend_fpret'); + late final __objc_msgSend_197 = __objc_msgSend_197Ptr.asFunction< + double Function(ffi.Pointer, ffi.Pointer)>(); + + late final _sel_floatValue1 = _registerName1("floatValue"); + double _objc_msgSend_198( + ffi.Pointer obj, + ffi.Pointer sel, + ) { + return __objc_msgSend_198( + obj, + sel, + ); + } + + late final __objc_msgSend_198Ptr = _lookup< + ffi.NativeFunction< + ffi.Float Function(ffi.Pointer, + ffi.Pointer)>>('objc_msgSend_fpret'); + late final __objc_msgSend_198 = __objc_msgSend_198Ptr.asFunction< + double Function(ffi.Pointer, ffi.Pointer)>(); + + late final _sel_intValue1 = _registerName1("intValue"); + int _objc_msgSend_199( + ffi.Pointer obj, + ffi.Pointer sel, + ) { + return __objc_msgSend_199( + obj, + sel, + ); + } + + late final __objc_msgSend_199Ptr = _lookup< + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_199 = __objc_msgSend_199Ptr.asFunction< + int Function(ffi.Pointer, ffi.Pointer)>(); + + late final _sel_integerValue1 = _registerName1("integerValue"); + int _objc_msgSend_200( + ffi.Pointer obj, + ffi.Pointer sel, + ) { + return __objc_msgSend_200( + obj, + sel, + ); + } + + late final __objc_msgSend_200Ptr = _lookup< + ffi.NativeFunction< + ffi.Long Function( + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_200 = __objc_msgSend_200Ptr.asFunction< + int Function(ffi.Pointer, ffi.Pointer)>(); + + late final _sel_longLongValue1 = _registerName1("longLongValue"); + int _objc_msgSend_201( + ffi.Pointer obj, + ffi.Pointer sel, + ) { + return __objc_msgSend_201( + obj, + sel, + ); + } + + late final __objc_msgSend_201Ptr = _lookup< + ffi.NativeFunction< + ffi.LongLong Function( + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_201 = __objc_msgSend_201Ptr.asFunction< + int Function(ffi.Pointer, ffi.Pointer)>(); + + late final _sel_boolValue1 = _registerName1("boolValue"); + late final _sel_uppercaseString1 = _registerName1("uppercaseString"); + late final _sel_lowercaseString1 = _registerName1("lowercaseString"); + late final _sel_capitalizedString1 = _registerName1("capitalizedString"); + late final _sel_localizedUppercaseString1 = + _registerName1("localizedUppercaseString"); + late final _sel_localizedLowercaseString1 = + _registerName1("localizedLowercaseString"); + late final _sel_localizedCapitalizedString1 = + _registerName1("localizedCapitalizedString"); + late final _sel_uppercaseStringWithLocale_1 = + _registerName1("uppercaseStringWithLocale:"); + ffi.Pointer _objc_msgSend_202( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer locale, + ) { + return __objc_msgSend_202( + obj, + sel, + locale, + ); + } + + late final __objc_msgSend_202Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_202 = __objc_msgSend_202Ptr.asFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>(); + + late final _sel_lowercaseStringWithLocale_1 = + _registerName1("lowercaseStringWithLocale:"); + late final _sel_capitalizedStringWithLocale_1 = + _registerName1("capitalizedStringWithLocale:"); + late final _sel_getLineStart_end_contentsEnd_forRange_1 = + _registerName1("getLineStart:end:contentsEnd:forRange:"); + void _objc_msgSend_203( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer startPtr, + ffi.Pointer lineEndPtr, + ffi.Pointer contentsEndPtr, + _NSRange range, + ) { + return __objc_msgSend_203( + obj, + sel, + startPtr, + lineEndPtr, + contentsEndPtr, + range, + ); + } + + late final __objc_msgSend_203Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + _NSRange)>>('objc_msgSend'); + late final __objc_msgSend_203 = __objc_msgSend_203Ptr.asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + _NSRange)>(); + + late final _sel_lineRangeForRange_1 = _registerName1("lineRangeForRange:"); + late final _sel_getParagraphStart_end_contentsEnd_forRange_1 = + _registerName1("getParagraphStart:end:contentsEnd:forRange:"); + late final _sel_paragraphRangeForRange_1 = + _registerName1("paragraphRangeForRange:"); + late final _sel_enumerateSubstringsInRange_options_usingBlock_1 = + _registerName1("enumerateSubstringsInRange:options:usingBlock:"); + void _objc_msgSend_204( + ffi.Pointer obj, + ffi.Pointer sel, + _NSRange range, + int opts, + ffi.Pointer<_ObjCBlock> block, + ) { + return __objc_msgSend_204( + obj, + sel, + range, + opts, + block, + ); + } + + late final __objc_msgSend_204Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + _NSRange, ffi.Int32, ffi.Pointer<_ObjCBlock>)>>('objc_msgSend'); + late final __objc_msgSend_204 = __objc_msgSend_204Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, _NSRange, + int, ffi.Pointer<_ObjCBlock>)>(); + + late final _sel_enumerateLinesUsingBlock_1 = + _registerName1("enumerateLinesUsingBlock:"); + void _objc_msgSend_205( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer<_ObjCBlock> block, + ) { + return __objc_msgSend_205( + obj, + sel, + block, + ); + } + + late final __objc_msgSend_205Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer<_ObjCBlock>)>>('objc_msgSend'); + late final __objc_msgSend_205 = __objc_msgSend_205Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer<_ObjCBlock>)>(); + + late final _sel_UTF8String1 = _registerName1("UTF8String"); + ffi.Pointer _objc_msgSend_206( + ffi.Pointer obj, + ffi.Pointer sel, + ) { + return __objc_msgSend_206( + obj, + sel, + ); + } + + late final __objc_msgSend_206Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_206 = __objc_msgSend_206Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); + + late final _sel_fastestEncoding1 = _registerName1("fastestEncoding"); + late final _sel_smallestEncoding1 = _registerName1("smallestEncoding"); + late final _sel_dataUsingEncoding_allowLossyConversion_1 = + _registerName1("dataUsingEncoding:allowLossyConversion:"); + ffi.Pointer _objc_msgSend_207( + ffi.Pointer obj, + ffi.Pointer sel, + int encoding, + bool lossy, + ) { + return __objc_msgSend_207( + obj, + sel, + encoding, + lossy, + ); + } + + late final __objc_msgSend_207Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.UnsignedLong, + ffi.Bool)>>('objc_msgSend'); + late final __objc_msgSend_207 = __objc_msgSend_207Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer, int, bool)>(); + + late final _sel_dataUsingEncoding_1 = _registerName1("dataUsingEncoding:"); + ffi.Pointer _objc_msgSend_208( + ffi.Pointer obj, + ffi.Pointer sel, + int encoding, + ) { + return __objc_msgSend_208( + obj, + sel, + encoding, + ); + } + + late final __objc_msgSend_208Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.UnsignedLong)>>('objc_msgSend'); + late final __objc_msgSend_208 = __objc_msgSend_208Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer, int)>(); + + late final _sel_canBeConvertedToEncoding_1 = + _registerName1("canBeConvertedToEncoding:"); + late final _sel_cStringUsingEncoding_1 = + _registerName1("cStringUsingEncoding:"); + ffi.Pointer _objc_msgSend_209( + ffi.Pointer obj, + ffi.Pointer sel, + int encoding, + ) { + return __objc_msgSend_209( + obj, + sel, + encoding, + ); + } + + late final __objc_msgSend_209Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.UnsignedLong)>>('objc_msgSend'); + late final __objc_msgSend_209 = __objc_msgSend_209Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer, int)>(); + + late final _sel_getCString_maxLength_encoding_1 = + _registerName1("getCString:maxLength:encoding:"); + bool _objc_msgSend_210( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer buffer, + int maxBufferCount, + int encoding, + ) { + return __objc_msgSend_210( + obj, + sel, + buffer, + maxBufferCount, + encoding, + ); + } + + late final __objc_msgSend_210Ptr = _lookup< + ffi.NativeFunction< + ffi.Bool Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.UnsignedLong, + ffi.UnsignedLong)>>('objc_msgSend'); + late final __objc_msgSend_210 = __objc_msgSend_210Ptr.asFunction< + bool Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, int, int)>(); + + late final _sel_getBytes_maxLength_usedLength_encoding_options_range_remainingRange_1 = + _registerName1( + "getBytes:maxLength:usedLength:encoding:options:range:remainingRange:"); + bool _objc_msgSend_211( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer buffer, + int maxBufferCount, + ffi.Pointer usedBufferCount, + int encoding, + int options, + _NSRange range, + ffi.Pointer<_NSRange> leftover, + ) { + return __objc_msgSend_211( + obj, + sel, + buffer, + maxBufferCount, + usedBufferCount, + encoding, + options, + range, + leftover, + ); + } + + late final __objc_msgSend_211Ptr = _lookup< + ffi.NativeFunction< + ffi.Bool Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.UnsignedLong, + ffi.Pointer, + ffi.UnsignedLong, + ffi.Int32, + _NSRange, + ffi.Pointer<_NSRange>)>>('objc_msgSend'); + late final __objc_msgSend_211 = __objc_msgSend_211Ptr.asFunction< + bool Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + int, + ffi.Pointer, + int, + int, + _NSRange, + ffi.Pointer<_NSRange>)>(); + + late final _sel_maximumLengthOfBytesUsingEncoding_1 = + _registerName1("maximumLengthOfBytesUsingEncoding:"); + late final _sel_lengthOfBytesUsingEncoding_1 = + _registerName1("lengthOfBytesUsingEncoding:"); + late final _sel_availableStringEncodings1 = + _registerName1("availableStringEncodings"); + ffi.Pointer _objc_msgSend_212( + ffi.Pointer obj, + ffi.Pointer sel, + ) { + return __objc_msgSend_212( + obj, + sel, + ); + } + + late final __objc_msgSend_212Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_212 = __objc_msgSend_212Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); + + late final _sel_localizedNameOfStringEncoding_1 = + _registerName1("localizedNameOfStringEncoding:"); + late final _sel_defaultCStringEncoding1 = + _registerName1("defaultCStringEncoding"); + late final _sel_decomposedStringWithCanonicalMapping1 = + _registerName1("decomposedStringWithCanonicalMapping"); + late final _sel_precomposedStringWithCanonicalMapping1 = + _registerName1("precomposedStringWithCanonicalMapping"); + late final _sel_decomposedStringWithCompatibilityMapping1 = + _registerName1("decomposedStringWithCompatibilityMapping"); + late final _sel_precomposedStringWithCompatibilityMapping1 = + _registerName1("precomposedStringWithCompatibilityMapping"); + late final _sel_componentsSeparatedByString_1 = + _registerName1("componentsSeparatedByString:"); + ffi.Pointer _objc_msgSend_213( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer separator, + ) { + return __objc_msgSend_213( + obj, + sel, + separator, + ); + } + + late final __objc_msgSend_213Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_213 = __objc_msgSend_213Ptr.asFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>(); + + late final _sel_componentsSeparatedByCharactersInSet_1 = + _registerName1("componentsSeparatedByCharactersInSet:"); + ffi.Pointer _objc_msgSend_214( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer separator, + ) { + return __objc_msgSend_214( + obj, + sel, + separator, + ); + } + + late final __objc_msgSend_214Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_214 = __objc_msgSend_214Ptr.asFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>(); + + late final _sel_stringByTrimmingCharactersInSet_1 = + _registerName1("stringByTrimmingCharactersInSet:"); + ffi.Pointer _objc_msgSend_215( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer set1, + ) { + return __objc_msgSend_215( + obj, + sel, + set1, + ); + } + + late final __objc_msgSend_215Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_215 = __objc_msgSend_215Ptr.asFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>(); + + late final _sel_stringByPaddingToLength_withString_startingAtIndex_1 = + _registerName1("stringByPaddingToLength:withString:startingAtIndex:"); + ffi.Pointer _objc_msgSend_216( + ffi.Pointer obj, + ffi.Pointer sel, + int newLength, + ffi.Pointer padString, + int padIndex, + ) { + return __objc_msgSend_216( + obj, + sel, + newLength, + padString, + padIndex, + ); + } + + late final __objc_msgSend_216Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.UnsignedLong, + ffi.Pointer, + ffi.UnsignedLong)>>('objc_msgSend'); + late final __objc_msgSend_216 = __objc_msgSend_216Ptr.asFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, int, ffi.Pointer, int)>(); + + late final _sel_stringByFoldingWithOptions_locale_1 = + _registerName1("stringByFoldingWithOptions:locale:"); + ffi.Pointer _objc_msgSend_217( + ffi.Pointer obj, + ffi.Pointer sel, + int options, + ffi.Pointer locale, + ) { + return __objc_msgSend_217( + obj, + sel, + options, + locale, + ); + } + + late final __objc_msgSend_217Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Int32, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_217 = __objc_msgSend_217Ptr.asFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, int, ffi.Pointer)>(); + + late final _sel_stringByReplacingOccurrencesOfString_withString_options_range_1 = + _registerName1( + "stringByReplacingOccurrencesOfString:withString:options:range:"); + ffi.Pointer _objc_msgSend_218( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer target, + ffi.Pointer replacement, + int options, + _NSRange searchRange, + ) { + return __objc_msgSend_218( + obj, + sel, + target, + replacement, + options, + searchRange, + ); + } + + late final __objc_msgSend_218Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Int32, + _NSRange)>>('objc_msgSend'); + late final __objc_msgSend_218 = __objc_msgSend_218Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + int, + _NSRange)>(); + + late final _sel_stringByReplacingOccurrencesOfString_withString_1 = + _registerName1("stringByReplacingOccurrencesOfString:withString:"); + ffi.Pointer _objc_msgSend_219( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer target, + ffi.Pointer replacement, + ) { + return __objc_msgSend_219( + obj, + sel, + target, + replacement, + ); + } + + late final __objc_msgSend_219Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_219 = __objc_msgSend_219Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>(); + + late final _sel_stringByReplacingCharactersInRange_withString_1 = + _registerName1("stringByReplacingCharactersInRange:withString:"); + ffi.Pointer _objc_msgSend_220( + ffi.Pointer obj, + ffi.Pointer sel, + _NSRange range, + ffi.Pointer replacement, + ) { + return __objc_msgSend_220( + obj, + sel, + range, + replacement, + ); + } + + late final __objc_msgSend_220Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + _NSRange, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_220 = __objc_msgSend_220Ptr.asFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, _NSRange, ffi.Pointer)>(); + + late final _sel_stringByApplyingTransform_reverse_1 = + _registerName1("stringByApplyingTransform:reverse:"); + ffi.Pointer _objc_msgSend_221( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer transform, + bool reverse, + ) { + return __objc_msgSend_221( + obj, + sel, + transform, + reverse, + ); + } + + late final __objc_msgSend_221Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Bool)>>('objc_msgSend'); + late final __objc_msgSend_221 = __objc_msgSend_221Ptr.asFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer, bool)>(); + + late final _sel_writeToURL_atomically_encoding_error_1 = + _registerName1("writeToURL:atomically:encoding:error:"); + bool _objc_msgSend_222( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer url, + bool useAuxiliaryFile, + int enc, + ffi.Pointer> error, + ) { + return __objc_msgSend_222( + obj, + sel, + url, + useAuxiliaryFile, + enc, + error, + ); + } + + late final __objc_msgSend_222Ptr = _lookup< + ffi.NativeFunction< + ffi.Bool Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Bool, + ffi.UnsignedLong, + ffi.Pointer>)>>('objc_msgSend'); + late final __objc_msgSend_222 = __objc_msgSend_222Ptr.asFunction< + bool Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + bool, + int, + ffi.Pointer>)>(); + + late final _sel_writeToFile_atomically_encoding_error_1 = + _registerName1("writeToFile:atomically:encoding:error:"); + bool _objc_msgSend_223( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer path, + bool useAuxiliaryFile, + int enc, + ffi.Pointer> error, + ) { + return __objc_msgSend_223( + obj, + sel, + path, + useAuxiliaryFile, + enc, + error, + ); + } + + late final __objc_msgSend_223Ptr = _lookup< + ffi.NativeFunction< + ffi.Bool Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Bool, + ffi.UnsignedLong, + ffi.Pointer>)>>('objc_msgSend'); + late final __objc_msgSend_223 = __objc_msgSend_223Ptr.asFunction< + bool Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + bool, + int, + ffi.Pointer>)>(); + + late final _sel_initWithCharactersNoCopy_length_freeWhenDone_1 = + _registerName1("initWithCharactersNoCopy:length:freeWhenDone:"); + instancetype _objc_msgSend_224( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer characters, + int length, + bool freeBuffer, + ) { + return __objc_msgSend_224( + obj, + sel, + characters, + length, + freeBuffer, + ); + } + + late final __objc_msgSend_224Ptr = _lookup< + ffi.NativeFunction< + instancetype Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.UnsignedLong, + ffi.Bool)>>('objc_msgSend'); + late final __objc_msgSend_224 = __objc_msgSend_224Ptr.asFunction< + instancetype Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, int, bool)>(); + + late final _sel_initWithCharactersNoCopy_length_deallocator_1 = + _registerName1("initWithCharactersNoCopy:length:deallocator:"); + instancetype _objc_msgSend_225( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer chars, + int len, + ffi.Pointer<_ObjCBlock> deallocator, + ) { + return __objc_msgSend_225( + obj, + sel, + chars, + len, + deallocator, + ); + } + + late final __objc_msgSend_225Ptr = _lookup< + ffi.NativeFunction< + instancetype Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.UnsignedLong, + ffi.Pointer<_ObjCBlock>)>>('objc_msgSend'); + late final __objc_msgSend_225 = __objc_msgSend_225Ptr.asFunction< + instancetype Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, int, ffi.Pointer<_ObjCBlock>)>(); + + late final _sel_initWithCharacters_length_1 = + _registerName1("initWithCharacters:length:"); + instancetype _objc_msgSend_226( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer characters, + int length, + ) { + return __objc_msgSend_226( + obj, + sel, + characters, + length, + ); + } + + late final __objc_msgSend_226Ptr = _lookup< + ffi.NativeFunction< + instancetype Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.UnsignedLong)>>('objc_msgSend'); + late final __objc_msgSend_226 = __objc_msgSend_226Ptr.asFunction< + instancetype Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, int)>(); + + late final _sel_initWithUTF8String_1 = _registerName1("initWithUTF8String:"); + instancetype _objc_msgSend_227( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer nullTerminatedCString, + ) { + return __objc_msgSend_227( + obj, + sel, + nullTerminatedCString, + ); + } + + late final __objc_msgSend_227Ptr = _lookup< + ffi.NativeFunction< + instancetype Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_227 = __objc_msgSend_227Ptr.asFunction< + instancetype Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); + + late final _sel_initWithString_1 = _registerName1("initWithString:"); + late final _sel_initWithFormat_1 = _registerName1("initWithFormat:"); + late final _sel_initWithFormat_arguments_1 = + _registerName1("initWithFormat:arguments:"); + instancetype _objc_msgSend_228( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer format, + ffi.Pointer argList, + ) { + return __objc_msgSend_228( + obj, + sel, + format, + argList, + ); + } + + late final __objc_msgSend_228Ptr = _lookup< + ffi.NativeFunction< + instancetype Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_228 = __objc_msgSend_228Ptr.asFunction< + instancetype Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, ffi.Pointer)>(); + + late final _sel_initWithFormat_locale_1 = + _registerName1("initWithFormat:locale:"); + instancetype _objc_msgSend_229( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer format, + ffi.Pointer locale, + ) { + return __objc_msgSend_229( + obj, + sel, + format, + locale, + ); + } + + late final __objc_msgSend_229Ptr = _lookup< + ffi.NativeFunction< + instancetype Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_229 = __objc_msgSend_229Ptr.asFunction< + instancetype Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, ffi.Pointer)>(); + + late final _sel_initWithFormat_locale_arguments_1 = + _registerName1("initWithFormat:locale:arguments:"); + instancetype _objc_msgSend_230( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer format, + ffi.Pointer locale, + ffi.Pointer argList, + ) { + return __objc_msgSend_230( + obj, + sel, + format, + locale, + argList, + ); + } + + late final __objc_msgSend_230Ptr = _lookup< + ffi.NativeFunction< + instancetype Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_230 = __objc_msgSend_230Ptr.asFunction< + instancetype Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>(); + + late final _sel_initWithValidatedFormat_validFormatSpecifiers_error_1 = + _registerName1("initWithValidatedFormat:validFormatSpecifiers:error:"); + instancetype _objc_msgSend_231( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer format, + ffi.Pointer validFormatSpecifiers, + ffi.Pointer> error, + ) { + return __objc_msgSend_231( + obj, + sel, + format, + validFormatSpecifiers, + error, + ); + } + + late final __objc_msgSend_231Ptr = _lookup< + ffi.NativeFunction< + instancetype Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer>)>>('objc_msgSend'); + late final __objc_msgSend_231 = __objc_msgSend_231Ptr.asFunction< + instancetype Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer>)>(); + + late final _sel_initWithValidatedFormat_validFormatSpecifiers_locale_error_1 = + _registerName1( + "initWithValidatedFormat:validFormatSpecifiers:locale:error:"); + instancetype _objc_msgSend_232( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer format, + ffi.Pointer validFormatSpecifiers, + ffi.Pointer locale, + ffi.Pointer> error, + ) { + return __objc_msgSend_232( + obj, + sel, + format, + validFormatSpecifiers, + locale, + error, + ); + } + + late final __objc_msgSend_232Ptr = _lookup< + ffi.NativeFunction< + instancetype Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer>)>>('objc_msgSend'); + late final __objc_msgSend_232 = __objc_msgSend_232Ptr.asFunction< + instancetype Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer>)>(); + + late final _sel_initWithValidatedFormat_validFormatSpecifiers_arguments_error_1 = + _registerName1( + "initWithValidatedFormat:validFormatSpecifiers:arguments:error:"); + instancetype _objc_msgSend_233( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer format, + ffi.Pointer validFormatSpecifiers, + ffi.Pointer argList, + ffi.Pointer> error, + ) { + return __objc_msgSend_233( + obj, + sel, + format, + validFormatSpecifiers, + argList, + error, + ); + } + + late final __objc_msgSend_233Ptr = _lookup< + ffi.NativeFunction< + instancetype Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer>)>>('objc_msgSend'); + late final __objc_msgSend_233 = __objc_msgSend_233Ptr.asFunction< + instancetype Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer>)>(); + + late final _sel_initWithValidatedFormat_validFormatSpecifiers_locale_arguments_error_1 = + _registerName1( + "initWithValidatedFormat:validFormatSpecifiers:locale:arguments:error:"); + instancetype _objc_msgSend_234( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer format, + ffi.Pointer validFormatSpecifiers, + ffi.Pointer locale, + ffi.Pointer argList, + ffi.Pointer> error, + ) { + return __objc_msgSend_234( + obj, + sel, + format, + validFormatSpecifiers, + locale, + argList, + error, + ); + } + + late final __objc_msgSend_234Ptr = _lookup< + ffi.NativeFunction< + instancetype Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer>)>>('objc_msgSend'); + late final __objc_msgSend_234 = __objc_msgSend_234Ptr.asFunction< + instancetype Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer>)>(); + + late final _sel_initWithData_encoding_1 = + _registerName1("initWithData:encoding:"); + instancetype _objc_msgSend_235( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer data, + int encoding, + ) { + return __objc_msgSend_235( + obj, + sel, + data, + encoding, + ); + } + + late final __objc_msgSend_235Ptr = _lookup< + ffi.NativeFunction< + instancetype Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, ffi.UnsignedLong)>>('objc_msgSend'); + late final __objc_msgSend_235 = __objc_msgSend_235Ptr.asFunction< + instancetype Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, int)>(); + + late final _sel_initWithBytes_length_encoding_1 = + _registerName1("initWithBytes:length:encoding:"); + instancetype _objc_msgSend_236( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer bytes, + int len, + int encoding, + ) { + return __objc_msgSend_236( + obj, + sel, + bytes, + len, + encoding, + ); + } + + late final __objc_msgSend_236Ptr = _lookup< + ffi.NativeFunction< + instancetype Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.UnsignedLong, + ffi.UnsignedLong)>>('objc_msgSend'); + late final __objc_msgSend_236 = __objc_msgSend_236Ptr.asFunction< + instancetype Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, int, int)>(); + + late final _sel_initWithBytesNoCopy_length_encoding_freeWhenDone_1 = + _registerName1("initWithBytesNoCopy:length:encoding:freeWhenDone:"); + instancetype _objc_msgSend_237( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer bytes, + int len, + int encoding, + bool freeBuffer, + ) { + return __objc_msgSend_237( + obj, + sel, + bytes, + len, + encoding, + freeBuffer, + ); + } + + late final __objc_msgSend_237Ptr = _lookup< + ffi.NativeFunction< + instancetype Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.UnsignedLong, + ffi.UnsignedLong, + ffi.Bool)>>('objc_msgSend'); + late final __objc_msgSend_237 = __objc_msgSend_237Ptr.asFunction< + instancetype Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, int, int, bool)>(); + + late final _sel_initWithBytesNoCopy_length_encoding_deallocator_1 = + _registerName1("initWithBytesNoCopy:length:encoding:deallocator:"); + instancetype _objc_msgSend_238( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer bytes, + int len, + int encoding, + ffi.Pointer<_ObjCBlock> deallocator, + ) { + return __objc_msgSend_238( + obj, + sel, + bytes, + len, + encoding, + deallocator, + ); + } + + late final __objc_msgSend_238Ptr = _lookup< + ffi.NativeFunction< + instancetype Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.UnsignedLong, + ffi.UnsignedLong, + ffi.Pointer<_ObjCBlock>)>>('objc_msgSend'); + late final __objc_msgSend_238 = __objc_msgSend_238Ptr.asFunction< + instancetype Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, int, int, ffi.Pointer<_ObjCBlock>)>(); + + late final _sel_string1 = _registerName1("string"); + late final _sel_stringWithString_1 = _registerName1("stringWithString:"); + late final _sel_stringWithCharacters_length_1 = + _registerName1("stringWithCharacters:length:"); + late final _sel_stringWithUTF8String_1 = + _registerName1("stringWithUTF8String:"); + late final _sel_stringWithFormat_1 = _registerName1("stringWithFormat:"); + late final _sel_localizedStringWithFormat_1 = + _registerName1("localizedStringWithFormat:"); + late final _sel_stringWithValidatedFormat_validFormatSpecifiers_error_1 = + _registerName1("stringWithValidatedFormat:validFormatSpecifiers:error:"); + late final _sel_localizedStringWithValidatedFormat_validFormatSpecifiers_error_1 = + _registerName1( + "localizedStringWithValidatedFormat:validFormatSpecifiers:error:"); + late final _sel_initWithCString_encoding_1 = + _registerName1("initWithCString:encoding:"); + instancetype _objc_msgSend_239( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer nullTerminatedCString, + int encoding, + ) { + return __objc_msgSend_239( + obj, + sel, + nullTerminatedCString, + encoding, + ); + } + + late final __objc_msgSend_239Ptr = _lookup< + ffi.NativeFunction< + instancetype Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, ffi.UnsignedLong)>>('objc_msgSend'); + late final __objc_msgSend_239 = __objc_msgSend_239Ptr.asFunction< + instancetype Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, int)>(); + + late final _sel_stringWithCString_encoding_1 = + _registerName1("stringWithCString:encoding:"); + late final _sel_initWithContentsOfURL_encoding_error_1 = + _registerName1("initWithContentsOfURL:encoding:error:"); + instancetype _objc_msgSend_240( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer url, + int enc, + ffi.Pointer> error, + ) { + return __objc_msgSend_240( + obj, + sel, + url, + enc, + error, + ); + } + + late final __objc_msgSend_240Ptr = _lookup< + ffi.NativeFunction< + instancetype Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.UnsignedLong, + ffi.Pointer>)>>('objc_msgSend'); + late final __objc_msgSend_240 = __objc_msgSend_240Ptr.asFunction< + instancetype Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + int, + ffi.Pointer>)>(); + + late final _sel_initWithContentsOfFile_encoding_error_1 = + _registerName1("initWithContentsOfFile:encoding:error:"); + instancetype _objc_msgSend_241( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer path, + int enc, + ffi.Pointer> error, + ) { + return __objc_msgSend_241( + obj, + sel, + path, + enc, + error, + ); + } + + late final __objc_msgSend_241Ptr = _lookup< + ffi.NativeFunction< + instancetype Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.UnsignedLong, + ffi.Pointer>)>>('objc_msgSend'); + late final __objc_msgSend_241 = __objc_msgSend_241Ptr.asFunction< + instancetype Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + int, + ffi.Pointer>)>(); + + late final _sel_stringWithContentsOfURL_encoding_error_1 = + _registerName1("stringWithContentsOfURL:encoding:error:"); + late final _sel_stringWithContentsOfFile_encoding_error_1 = + _registerName1("stringWithContentsOfFile:encoding:error:"); + late final _sel_initWithContentsOfURL_usedEncoding_error_1 = + _registerName1("initWithContentsOfURL:usedEncoding:error:"); + instancetype _objc_msgSend_242( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer url, + ffi.Pointer enc, + ffi.Pointer> error, + ) { + return __objc_msgSend_242( + obj, + sel, + url, + enc, + error, + ); + } + + late final __objc_msgSend_242Ptr = _lookup< + ffi.NativeFunction< + instancetype Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer>)>>('objc_msgSend'); + late final __objc_msgSend_242 = __objc_msgSend_242Ptr.asFunction< + instancetype Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer>)>(); + + late final _sel_initWithContentsOfFile_usedEncoding_error_1 = + _registerName1("initWithContentsOfFile:usedEncoding:error:"); + instancetype _objc_msgSend_243( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer path, + ffi.Pointer enc, + ffi.Pointer> error, + ) { + return __objc_msgSend_243( + obj, + sel, + path, + enc, + error, + ); + } + + late final __objc_msgSend_243Ptr = _lookup< + ffi.NativeFunction< + instancetype Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer>)>>('objc_msgSend'); + late final __objc_msgSend_243 = __objc_msgSend_243Ptr.asFunction< + instancetype Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer>)>(); + + late final _sel_stringWithContentsOfURL_usedEncoding_error_1 = + _registerName1("stringWithContentsOfURL:usedEncoding:error:"); + late final _sel_stringWithContentsOfFile_usedEncoding_error_1 = + _registerName1("stringWithContentsOfFile:usedEncoding:error:"); + late final _sel_stringEncodingForData_encodingOptions_convertedString_usedLossyConversion_1 = + _registerName1( + "stringEncodingForData:encodingOptions:convertedString:usedLossyConversion:"); + int _objc_msgSend_244( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer data, + ffi.Pointer opts, + ffi.Pointer> string, + ffi.Pointer usedLossyConversion, + ) { + return __objc_msgSend_244( + obj, + sel, + data, + opts, + string, + usedLossyConversion, + ); + } + + late final __objc_msgSend_244Ptr = _lookup< + ffi.NativeFunction< + ffi.UnsignedLong Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer>, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_244 = __objc_msgSend_244Ptr.asFunction< + int Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer>, + ffi.Pointer)>(); + + late final _sel_propertyList1 = _registerName1("propertyList"); + late final _sel_propertyListFromStringsFileFormat1 = + _registerName1("propertyListFromStringsFileFormat"); + ffi.Pointer _objc_msgSend_245( + ffi.Pointer obj, + ffi.Pointer sel, + ) { + return __objc_msgSend_245( + obj, + sel, + ); + } + + late final __objc_msgSend_245Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_245 = __objc_msgSend_245Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); + + late final _sel_cString1 = _registerName1("cString"); + late final _sel_lossyCString1 = _registerName1("lossyCString"); + late final _sel_cStringLength1 = _registerName1("cStringLength"); + late final _sel_getCString_1 = _registerName1("getCString:"); + late final _sel_getCString_maxLength_1 = + _registerName1("getCString:maxLength:"); + void _objc_msgSend_246( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer bytes, + int maxLength, + ) { + return __objc_msgSend_246( + obj, + sel, + bytes, + maxLength, + ); + } + + late final __objc_msgSend_246Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, ffi.UnsignedLong)>>('objc_msgSend'); + late final __objc_msgSend_246 = __objc_msgSend_246Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, int)>(); + + late final _sel_getCString_maxLength_range_remainingRange_1 = + _registerName1("getCString:maxLength:range:remainingRange:"); + void _objc_msgSend_247( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer bytes, + int maxLength, + _NSRange aRange, + ffi.Pointer<_NSRange> leftoverRange, + ) { + return __objc_msgSend_247( + obj, + sel, + bytes, + maxLength, + aRange, + leftoverRange, + ); + } + + late final __objc_msgSend_247Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.UnsignedLong, + _NSRange, + ffi.Pointer<_NSRange>)>>('objc_msgSend'); + late final __objc_msgSend_247 = __objc_msgSend_247Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, int, _NSRange, ffi.Pointer<_NSRange>)>(); + + ffi.Pointer _objc_msgSend_248( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer url, + ) { + return __objc_msgSend_248( + obj, + sel, + url, + ); + } + + late final __objc_msgSend_248Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_248 = __objc_msgSend_248Ptr.asFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>(); + + late final _sel_stringWithContentsOfFile_1 = + _registerName1("stringWithContentsOfFile:"); + late final _sel_stringWithContentsOfURL_1 = + _registerName1("stringWithContentsOfURL:"); + late final _sel_initWithCStringNoCopy_length_freeWhenDone_1 = + _registerName1("initWithCStringNoCopy:length:freeWhenDone:"); + ffi.Pointer _objc_msgSend_249( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer bytes, + int length, + bool freeBuffer, + ) { + return __objc_msgSend_249( + obj, + sel, + bytes, + length, + freeBuffer, + ); + } + + late final __objc_msgSend_249Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.UnsignedLong, + ffi.Bool)>>('objc_msgSend'); + late final __objc_msgSend_249 = __objc_msgSend_249Ptr.asFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer, int, bool)>(); + + late final _sel_initWithCString_length_1 = + _registerName1("initWithCString:length:"); + late final _sel_initWithCString_1 = _registerName1("initWithCString:"); + late final _sel_stringWithCString_length_1 = + _registerName1("stringWithCString:length:"); + late final _sel_stringWithCString_1 = _registerName1("stringWithCString:"); + late final _sel_getCharacters_1 = _registerName1("getCharacters:"); + void _objc_msgSend_250( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer buffer, + ) { + return __objc_msgSend_250( + obj, + sel, + buffer, + ); + } + + late final __objc_msgSend_250Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_250 = __objc_msgSend_250Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); + + late final _sel_variantFittingPresentationWidth_1 = + _registerName1("variantFittingPresentationWidth:"); + ffi.Pointer _objc_msgSend_251( + ffi.Pointer obj, + ffi.Pointer sel, + int width, + ) { + return __objc_msgSend_251( + obj, + sel, + width, + ); + } + + late final __objc_msgSend_251Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Long)>>('objc_msgSend'); + late final __objc_msgSend_251 = __objc_msgSend_251Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer, int)>(); + + late final _sel_debugDescription1 = _registerName1("debugDescription"); + late final _sel_version1 = _registerName1("version"); + late final _sel_setVersion_1 = _registerName1("setVersion:"); + void _objc_msgSend_252( + ffi.Pointer obj, + ffi.Pointer sel, + int aVersion, + ) { + return __objc_msgSend_252( + obj, + sel, + aVersion, + ); + } + + late final __objc_msgSend_252Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Long)>>('objc_msgSend'); + late final __objc_msgSend_252 = __objc_msgSend_252Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, int)>(); + + late final _sel_classForCoder1 = _registerName1("classForCoder"); + late final _sel_replacementObjectForCoder_1 = + _registerName1("replacementObjectForCoder:"); + late final _sel_awakeAfterUsingCoder_1 = + _registerName1("awakeAfterUsingCoder:"); + late final _sel_poseAsClass_1 = _registerName1("poseAsClass:"); + late final _sel_autoContentAccessingProxy1 = + _registerName1("autoContentAccessingProxy"); + late final _class_NSValue1 = _getClass1("NSValue"); + late final _sel_getValue_size_1 = _registerName1("getValue:size:"); + late final _sel_objCType1 = _registerName1("objCType"); + late final _sel_initWithBytes_objCType_1 = + _registerName1("initWithBytes:objCType:"); + instancetype _objc_msgSend_253( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer value, + ffi.Pointer type, + ) { + return __objc_msgSend_253( + obj, + sel, + value, + type, + ); + } + + late final __objc_msgSend_253Ptr = _lookup< + ffi.NativeFunction< + instancetype Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_253 = __objc_msgSend_253Ptr.asFunction< + instancetype Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, ffi.Pointer)>(); + + late final _sel_valueWithBytes_objCType_1 = + _registerName1("valueWithBytes:objCType:"); + ffi.Pointer _objc_msgSend_254( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer value, + ffi.Pointer type, + ) { + return __objc_msgSend_254( + obj, + sel, + value, + type, + ); + } + + late final __objc_msgSend_254Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_254 = __objc_msgSend_254Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>(); + + late final _sel_value_withObjCType_1 = _registerName1("value:withObjCType:"); + late final _sel_valueWithNonretainedObject_1 = + _registerName1("valueWithNonretainedObject:"); + ffi.Pointer _objc_msgSend_255( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer anObject, + ) { + return __objc_msgSend_255( + obj, + sel, + anObject, + ); + } + + late final __objc_msgSend_255Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_255 = __objc_msgSend_255Ptr.asFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>(); + + late final _sel_nonretainedObjectValue1 = + _registerName1("nonretainedObjectValue"); + late final _sel_valueWithPointer_1 = _registerName1("valueWithPointer:"); + ffi.Pointer _objc_msgSend_256( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer pointer, + ) { + return __objc_msgSend_256( + obj, + sel, + pointer, + ); + } + + late final __objc_msgSend_256Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_256 = __objc_msgSend_256Ptr.asFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>(); + + late final _sel_pointerValue1 = _registerName1("pointerValue"); + late final _sel_isEqualToValue_1 = _registerName1("isEqualToValue:"); + bool _objc_msgSend_257( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer value, + ) { + return __objc_msgSend_257( + obj, + sel, + value, + ); + } + + late final __objc_msgSend_257Ptr = _lookup< + ffi.NativeFunction< + ffi.Bool Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_257 = __objc_msgSend_257Ptr.asFunction< + bool Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); + + late final _sel_getValue_1 = _registerName1("getValue:"); + void _objc_msgSend_258( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer value, + ) { + return __objc_msgSend_258( + obj, + sel, + value, + ); + } + + late final __objc_msgSend_258Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_258 = __objc_msgSend_258Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); + + late final _sel_valueWithRange_1 = _registerName1("valueWithRange:"); + ffi.Pointer _objc_msgSend_259( + ffi.Pointer obj, + ffi.Pointer sel, + _NSRange range, + ) { + return __objc_msgSend_259( + obj, + sel, + range, + ); + } + + late final __objc_msgSend_259Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, _NSRange)>>('objc_msgSend'); + late final __objc_msgSend_259 = __objc_msgSend_259Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer, _NSRange)>(); + + late final _sel_rangeValue1 = _registerName1("rangeValue"); + void _objc_msgSend_260( + ffi.Pointer<_NSRange> stret, + ffi.Pointer obj, + ffi.Pointer sel, + ) { + return __objc_msgSend_260( + stret, + obj, + sel, + ); + } + + late final __objc_msgSend_260Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer<_NSRange>, ffi.Pointer, + ffi.Pointer)>>('objc_msgSend_stret'); + late final __objc_msgSend_260 = __objc_msgSend_260Ptr.asFunction< + void Function(ffi.Pointer<_NSRange>, ffi.Pointer, + ffi.Pointer)>(); + + late final _sel_valueWithPoint_1 = _registerName1("valueWithPoint:"); + ffi.Pointer _objc_msgSend_261( + ffi.Pointer obj, + ffi.Pointer sel, + CGPoint point, + ) { + return __objc_msgSend_261( + obj, + sel, + point, + ); + } + + late final __objc_msgSend_261Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, CGPoint)>>('objc_msgSend'); + late final __objc_msgSend_261 = __objc_msgSend_261Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer, CGPoint)>(); + + late final _sel_valueWithSize_1 = _registerName1("valueWithSize:"); + ffi.Pointer _objc_msgSend_262( + ffi.Pointer obj, + ffi.Pointer sel, + CGSize size, + ) { + return __objc_msgSend_262( + obj, + sel, + size, + ); + } + + late final __objc_msgSend_262Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, CGSize)>>('objc_msgSend'); + late final __objc_msgSend_262 = __objc_msgSend_262Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer, CGSize)>(); + + late final _sel_valueWithRect_1 = _registerName1("valueWithRect:"); + ffi.Pointer _objc_msgSend_263( + ffi.Pointer obj, + ffi.Pointer sel, + CGRect rect, + ) { + return __objc_msgSend_263( + obj, + sel, + rect, + ); + } + + late final __objc_msgSend_263Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, CGRect)>>('objc_msgSend'); + late final __objc_msgSend_263 = __objc_msgSend_263Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer, CGRect)>(); + + late final _sel_valueWithEdgeInsets_1 = + _registerName1("valueWithEdgeInsets:"); + ffi.Pointer _objc_msgSend_264( + ffi.Pointer obj, + ffi.Pointer sel, + NSEdgeInsets insets, + ) { + return __objc_msgSend_264( + obj, + sel, + insets, + ); + } + + late final __objc_msgSend_264Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, NSEdgeInsets)>>('objc_msgSend'); + late final __objc_msgSend_264 = __objc_msgSend_264Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer, NSEdgeInsets)>(); + + late final _sel_pointValue1 = _registerName1("pointValue"); + late final _sel_sizeValue1 = _registerName1("sizeValue"); + late final _sel_rectValue1 = _registerName1("rectValue"); + late final _sel_edgeInsetsValue1 = _registerName1("edgeInsetsValue"); + void _objc_msgSend_265( + ffi.Pointer stret, + ffi.Pointer obj, + ffi.Pointer sel, + ) { + return __objc_msgSend_265( + stret, + obj, + sel, + ); + } + + late final __objc_msgSend_265Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>>('objc_msgSend_stret'); + late final __objc_msgSend_265 = __objc_msgSend_265Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); + + late final _class_NSNumber1 = _getClass1("NSNumber"); + late final _sel_initWithChar_1 = _registerName1("initWithChar:"); + ffi.Pointer _objc_msgSend_266( + ffi.Pointer obj, + ffi.Pointer sel, + int value, + ) { + return __objc_msgSend_266( + obj, + sel, + value, + ); + } + + late final __objc_msgSend_266Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Char)>>('objc_msgSend'); + late final __objc_msgSend_266 = __objc_msgSend_266Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer, int)>(); + + late final _sel_initWithUnsignedChar_1 = + _registerName1("initWithUnsignedChar:"); + ffi.Pointer _objc_msgSend_267( + ffi.Pointer obj, + ffi.Pointer sel, + int value, + ) { + return __objc_msgSend_267( + obj, + sel, + value, + ); + } + + late final __objc_msgSend_267Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.UnsignedChar)>>('objc_msgSend'); + late final __objc_msgSend_267 = __objc_msgSend_267Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer, int)>(); + + late final _sel_initWithShort_1 = _registerName1("initWithShort:"); + ffi.Pointer _objc_msgSend_268( + ffi.Pointer obj, + ffi.Pointer sel, + int value, + ) { + return __objc_msgSend_268( + obj, + sel, + value, + ); + } + + late final __objc_msgSend_268Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Short)>>('objc_msgSend'); + late final __objc_msgSend_268 = __objc_msgSend_268Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer, int)>(); + + late final _sel_initWithUnsignedShort_1 = + _registerName1("initWithUnsignedShort:"); + ffi.Pointer _objc_msgSend_269( + ffi.Pointer obj, + ffi.Pointer sel, + int value, + ) { + return __objc_msgSend_269( + obj, + sel, + value, + ); + } + + late final __objc_msgSend_269Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.UnsignedShort)>>('objc_msgSend'); + late final __objc_msgSend_269 = __objc_msgSend_269Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer, int)>(); + + late final _sel_initWithInt_1 = _registerName1("initWithInt:"); + ffi.Pointer _objc_msgSend_270( + ffi.Pointer obj, + ffi.Pointer sel, + int value, + ) { + return __objc_msgSend_270( + obj, + sel, + value, + ); + } + + late final __objc_msgSend_270Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Int)>>('objc_msgSend'); + late final __objc_msgSend_270 = __objc_msgSend_270Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer, int)>(); + + late final _sel_initWithUnsignedInt_1 = + _registerName1("initWithUnsignedInt:"); + ffi.Pointer _objc_msgSend_271( + ffi.Pointer obj, + ffi.Pointer sel, + int value, + ) { + return __objc_msgSend_271( + obj, + sel, + value, + ); + } + + late final __objc_msgSend_271Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.UnsignedInt)>>('objc_msgSend'); + late final __objc_msgSend_271 = __objc_msgSend_271Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer, int)>(); + + late final _sel_initWithLong_1 = _registerName1("initWithLong:"); + ffi.Pointer _objc_msgSend_272( + ffi.Pointer obj, + ffi.Pointer sel, + int value, + ) { + return __objc_msgSend_272( + obj, + sel, + value, + ); + } + + late final __objc_msgSend_272Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Long)>>('objc_msgSend'); + late final __objc_msgSend_272 = __objc_msgSend_272Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer, int)>(); + + late final _sel_initWithUnsignedLong_1 = + _registerName1("initWithUnsignedLong:"); + ffi.Pointer _objc_msgSend_273( + ffi.Pointer obj, + ffi.Pointer sel, + int value, + ) { + return __objc_msgSend_273( + obj, + sel, + value, + ); + } + + late final __objc_msgSend_273Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.UnsignedLong)>>('objc_msgSend'); + late final __objc_msgSend_273 = __objc_msgSend_273Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer, int)>(); + + late final _sel_initWithLongLong_1 = _registerName1("initWithLongLong:"); + ffi.Pointer _objc_msgSend_274( + ffi.Pointer obj, + ffi.Pointer sel, + int value, + ) { + return __objc_msgSend_274( + obj, + sel, + value, + ); + } + + late final __objc_msgSend_274Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.LongLong)>>('objc_msgSend'); + late final __objc_msgSend_274 = __objc_msgSend_274Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer, int)>(); + + late final _sel_initWithUnsignedLongLong_1 = + _registerName1("initWithUnsignedLongLong:"); + ffi.Pointer _objc_msgSend_275( + ffi.Pointer obj, + ffi.Pointer sel, + int value, + ) { + return __objc_msgSend_275( + obj, + sel, + value, + ); + } + + late final __objc_msgSend_275Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.UnsignedLongLong)>>('objc_msgSend'); + late final __objc_msgSend_275 = __objc_msgSend_275Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer, int)>(); + + late final _sel_initWithFloat_1 = _registerName1("initWithFloat:"); + ffi.Pointer _objc_msgSend_276( + ffi.Pointer obj, + ffi.Pointer sel, + double value, + ) { + return __objc_msgSend_276( + obj, + sel, + value, + ); + } + + late final __objc_msgSend_276Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Float)>>('objc_msgSend'); + late final __objc_msgSend_276 = __objc_msgSend_276Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer, double)>(); + + late final _sel_initWithDouble_1 = _registerName1("initWithDouble:"); + ffi.Pointer _objc_msgSend_277( + ffi.Pointer obj, + ffi.Pointer sel, + double value, + ) { + return __objc_msgSend_277( + obj, + sel, + value, + ); + } + + late final __objc_msgSend_277Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Double)>>('objc_msgSend'); + late final __objc_msgSend_277 = __objc_msgSend_277Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer, double)>(); + + late final _sel_initWithBool_1 = _registerName1("initWithBool:"); + ffi.Pointer _objc_msgSend_278( + ffi.Pointer obj, + ffi.Pointer sel, + bool value, + ) { + return __objc_msgSend_278( + obj, + sel, + value, + ); + } + + late final __objc_msgSend_278Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Bool)>>('objc_msgSend'); + late final __objc_msgSend_278 = __objc_msgSend_278Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer, bool)>(); + + late final _sel_initWithInteger_1 = _registerName1("initWithInteger:"); + late final _sel_initWithUnsignedInteger_1 = + _registerName1("initWithUnsignedInteger:"); + late final _sel_charValue1 = _registerName1("charValue"); + int _objc_msgSend_279( + ffi.Pointer obj, + ffi.Pointer sel, + ) { + return __objc_msgSend_279( + obj, + sel, + ); + } + + late final __objc_msgSend_279Ptr = _lookup< + ffi.NativeFunction< + ffi.Char Function( + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_279 = __objc_msgSend_279Ptr.asFunction< + int Function(ffi.Pointer, ffi.Pointer)>(); + + late final _sel_unsignedCharValue1 = _registerName1("unsignedCharValue"); + int _objc_msgSend_280( + ffi.Pointer obj, + ffi.Pointer sel, + ) { + return __objc_msgSend_280( + obj, + sel, + ); + } + + late final __objc_msgSend_280Ptr = _lookup< + ffi.NativeFunction< + ffi.UnsignedChar Function( + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_280 = __objc_msgSend_280Ptr.asFunction< + int Function(ffi.Pointer, ffi.Pointer)>(); + + late final _sel_shortValue1 = _registerName1("shortValue"); + int _objc_msgSend_281( + ffi.Pointer obj, + ffi.Pointer sel, + ) { + return __objc_msgSend_281( + obj, + sel, + ); + } + + late final __objc_msgSend_281Ptr = _lookup< + ffi.NativeFunction< + ffi.Short Function( + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_281 = __objc_msgSend_281Ptr.asFunction< + int Function(ffi.Pointer, ffi.Pointer)>(); + + late final _sel_unsignedShortValue1 = _registerName1("unsignedShortValue"); + int _objc_msgSend_282( + ffi.Pointer obj, + ffi.Pointer sel, + ) { + return __objc_msgSend_282( + obj, + sel, + ); + } + + late final __objc_msgSend_282Ptr = _lookup< + ffi.NativeFunction< + ffi.UnsignedShort Function( + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_282 = __objc_msgSend_282Ptr.asFunction< + int Function(ffi.Pointer, ffi.Pointer)>(); + + late final _sel_unsignedIntValue1 = _registerName1("unsignedIntValue"); + late final _sel_longValue1 = _registerName1("longValue"); + late final _sel_unsignedLongValue1 = _registerName1("unsignedLongValue"); + late final _sel_unsignedLongLongValue1 = + _registerName1("unsignedLongLongValue"); + int _objc_msgSend_283( + ffi.Pointer obj, + ffi.Pointer sel, + ) { + return __objc_msgSend_283( + obj, + sel, + ); + } + + late final __objc_msgSend_283Ptr = _lookup< + ffi.NativeFunction< + ffi.UnsignedLongLong Function( + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_283 = __objc_msgSend_283Ptr.asFunction< + int Function(ffi.Pointer, ffi.Pointer)>(); + + late final _sel_unsignedIntegerValue1 = + _registerName1("unsignedIntegerValue"); + late final _sel_stringValue1 = _registerName1("stringValue"); + int _objc_msgSend_284( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer otherNumber, + ) { + return __objc_msgSend_284( + obj, + sel, + otherNumber, + ); + } + + late final __objc_msgSend_284Ptr = _lookup< + ffi.NativeFunction< + ffi.Int32 Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_284 = __objc_msgSend_284Ptr.asFunction< + int Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); + + late final _sel_isEqualToNumber_1 = _registerName1("isEqualToNumber:"); + bool _objc_msgSend_285( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer number, + ) { + return __objc_msgSend_285( + obj, + sel, + number, + ); + } + + late final __objc_msgSend_285Ptr = _lookup< + ffi.NativeFunction< + ffi.Bool Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_285 = __objc_msgSend_285Ptr.asFunction< + bool Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); + + late final _sel_numberWithChar_1 = _registerName1("numberWithChar:"); + late final _sel_numberWithUnsignedChar_1 = + _registerName1("numberWithUnsignedChar:"); + late final _sel_numberWithShort_1 = _registerName1("numberWithShort:"); + late final _sel_numberWithUnsignedShort_1 = + _registerName1("numberWithUnsignedShort:"); + late final _sel_numberWithInt_1 = _registerName1("numberWithInt:"); + late final _sel_numberWithUnsignedInt_1 = + _registerName1("numberWithUnsignedInt:"); + late final _sel_numberWithLong_1 = _registerName1("numberWithLong:"); + late final _sel_numberWithUnsignedLong_1 = + _registerName1("numberWithUnsignedLong:"); + late final _sel_numberWithLongLong_1 = _registerName1("numberWithLongLong:"); + late final _sel_numberWithUnsignedLongLong_1 = + _registerName1("numberWithUnsignedLongLong:"); + late final _sel_numberWithFloat_1 = _registerName1("numberWithFloat:"); + late final _sel_numberWithDouble_1 = _registerName1("numberWithDouble:"); + late final _sel_numberWithBool_1 = _registerName1("numberWithBool:"); + late final _sel_numberWithInteger_1 = _registerName1("numberWithInteger:"); + late final _sel_numberWithUnsignedInteger_1 = + _registerName1("numberWithUnsignedInteger:"); + late final _class_NSMutableArray1 = _getClass1("NSMutableArray"); + late final _sel_addObject_1 = _registerName1("addObject:"); + late final _sel_insertObject_atIndex_1 = + _registerName1("insertObject:atIndex:"); + void _objc_msgSend_286( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer anObject, + int index, + ) { + return __objc_msgSend_286( + obj, + sel, + anObject, + index, + ); + } + + late final __objc_msgSend_286Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, ffi.UnsignedLong)>>('objc_msgSend'); + late final __objc_msgSend_286 = __objc_msgSend_286Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, int)>(); + + late final _sel_removeLastObject1 = _registerName1("removeLastObject"); + late final _sel_removeObjectAtIndex_1 = + _registerName1("removeObjectAtIndex:"); + void _objc_msgSend_287( + ffi.Pointer obj, + ffi.Pointer sel, + int index, + ) { + return __objc_msgSend_287( + obj, + sel, + index, + ); + } + + late final __objc_msgSend_287Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.UnsignedLong)>>('objc_msgSend'); + late final __objc_msgSend_287 = __objc_msgSend_287Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, int)>(); + + late final _sel_replaceObjectAtIndex_withObject_1 = + _registerName1("replaceObjectAtIndex:withObject:"); + void _objc_msgSend_288( + ffi.Pointer obj, + ffi.Pointer sel, + int index, + ffi.Pointer anObject, + ) { + return __objc_msgSend_288( + obj, + sel, + index, + anObject, + ); + } + + late final __objc_msgSend_288Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.UnsignedLong, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_288 = __objc_msgSend_288Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, int, + ffi.Pointer)>(); + + late final _sel_initWithCapacity_1 = _registerName1("initWithCapacity:"); + late final _sel_addObjectsFromArray_1 = + _registerName1("addObjectsFromArray:"); + void _objc_msgSend_289( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer otherArray, + ) { + return __objc_msgSend_289( + obj, + sel, + otherArray, + ); + } + + late final __objc_msgSend_289Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_289 = __objc_msgSend_289Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); + + late final _sel_exchangeObjectAtIndex_withObjectAtIndex_1 = + _registerName1("exchangeObjectAtIndex:withObjectAtIndex:"); + void _objc_msgSend_290( + ffi.Pointer obj, + ffi.Pointer sel, + int idx1, + int idx2, + ) { + return __objc_msgSend_290( + obj, + sel, + idx1, + idx2, + ); + } + + late final __objc_msgSend_290Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.UnsignedLong, ffi.UnsignedLong)>>('objc_msgSend'); + late final __objc_msgSend_290 = __objc_msgSend_290Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, int, int)>(); + + late final _sel_removeAllObjects1 = _registerName1("removeAllObjects"); + late final _sel_removeObject_inRange_1 = + _registerName1("removeObject:inRange:"); + void _objc_msgSend_291( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer anObject, + _NSRange range, + ) { + return __objc_msgSend_291( + obj, + sel, + anObject, + range, + ); + } + + late final __objc_msgSend_291Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, _NSRange)>>('objc_msgSend'); + late final __objc_msgSend_291 = __objc_msgSend_291Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, _NSRange)>(); + + late final _sel_removeObject_1 = _registerName1("removeObject:"); + late final _sel_removeObjectIdenticalTo_inRange_1 = + _registerName1("removeObjectIdenticalTo:inRange:"); + late final _sel_removeObjectIdenticalTo_1 = + _registerName1("removeObjectIdenticalTo:"); + late final _sel_removeObjectsFromIndices_numIndices_1 = + _registerName1("removeObjectsFromIndices:numIndices:"); + void _objc_msgSend_292( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer indices, + int cnt, + ) { + return __objc_msgSend_292( + obj, + sel, + indices, + cnt, + ); + } + + late final __objc_msgSend_292Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.UnsignedLong)>>('objc_msgSend'); + late final __objc_msgSend_292 = __objc_msgSend_292Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, int)>(); + + late final _sel_removeObjectsInArray_1 = + _registerName1("removeObjectsInArray:"); + late final _sel_removeObjectsInRange_1 = + _registerName1("removeObjectsInRange:"); + void _objc_msgSend_293( + ffi.Pointer obj, + ffi.Pointer sel, + _NSRange range, + ) { + return __objc_msgSend_293( + obj, + sel, + range, + ); + } + + late final __objc_msgSend_293Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + _NSRange)>>('objc_msgSend'); + late final __objc_msgSend_293 = __objc_msgSend_293Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, _NSRange)>(); + + late final _sel_replaceObjectsInRange_withObjectsFromArray_range_1 = + _registerName1("replaceObjectsInRange:withObjectsFromArray:range:"); + void _objc_msgSend_294( + ffi.Pointer obj, + ffi.Pointer sel, + _NSRange range, + ffi.Pointer otherArray, + _NSRange otherRange, + ) { + return __objc_msgSend_294( + obj, + sel, + range, + otherArray, + otherRange, + ); + } + + late final __objc_msgSend_294Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + _NSRange, ffi.Pointer, _NSRange)>>('objc_msgSend'); + late final __objc_msgSend_294 = __objc_msgSend_294Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, _NSRange, + ffi.Pointer, _NSRange)>(); + + late final _sel_replaceObjectsInRange_withObjectsFromArray_1 = + _registerName1("replaceObjectsInRange:withObjectsFromArray:"); + void _objc_msgSend_295( + ffi.Pointer obj, + ffi.Pointer sel, + _NSRange range, + ffi.Pointer otherArray, + ) { + return __objc_msgSend_295( + obj, + sel, + range, + otherArray, + ); + } + + late final __objc_msgSend_295Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + _NSRange, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_295 = __objc_msgSend_295Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, _NSRange, + ffi.Pointer)>(); + + late final _sel_setArray_1 = _registerName1("setArray:"); + late final _sel_sortUsingFunction_context_1 = + _registerName1("sortUsingFunction:context:"); + void _objc_msgSend_296( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer< + ffi.NativeFunction< + ffi.Long Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>> + compare, + ffi.Pointer context, + ) { + return __objc_msgSend_296( + obj, + sel, + compare, + context, + ); + } + + late final __objc_msgSend_296Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer< + ffi.NativeFunction< + ffi.Long Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>>, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_296 = __objc_msgSend_296Ptr.asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer< + ffi.NativeFunction< + ffi.Long Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>>, + ffi.Pointer)>(); + + late final _sel_sortUsingSelector_1 = _registerName1("sortUsingSelector:"); + late final _sel_insertObjects_atIndexes_1 = + _registerName1("insertObjects:atIndexes:"); + void _objc_msgSend_297( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer objects, + ffi.Pointer indexes, + ) { + return __objc_msgSend_297( + obj, + sel, + objects, + indexes, + ); + } + + late final __objc_msgSend_297Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_297 = __objc_msgSend_297Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, ffi.Pointer)>(); + + late final _sel_removeObjectsAtIndexes_1 = + _registerName1("removeObjectsAtIndexes:"); + void _objc_msgSend_298( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer indexes, + ) { + return __objc_msgSend_298( + obj, + sel, + indexes, + ); + } + + late final __objc_msgSend_298Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_298 = __objc_msgSend_298Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); + + late final _sel_replaceObjectsAtIndexes_withObjects_1 = + _registerName1("replaceObjectsAtIndexes:withObjects:"); + void _objc_msgSend_299( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer indexes, + ffi.Pointer objects, + ) { + return __objc_msgSend_299( + obj, + sel, + indexes, + objects, + ); + } + + late final __objc_msgSend_299Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_299 = __objc_msgSend_299Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, ffi.Pointer)>(); + + late final _sel_setObject_atIndexedSubscript_1 = + _registerName1("setObject:atIndexedSubscript:"); + late final _sel_sortUsingComparator_1 = + _registerName1("sortUsingComparator:"); + void _objc_msgSend_300( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer<_ObjCBlock> cmptr, + ) { + return __objc_msgSend_300( + obj, + sel, + cmptr, + ); + } + + late final __objc_msgSend_300Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer<_ObjCBlock>)>>('objc_msgSend'); + late final __objc_msgSend_300 = __objc_msgSend_300Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer<_ObjCBlock>)>(); + + late final _sel_sortWithOptions_usingComparator_1 = + _registerName1("sortWithOptions:usingComparator:"); + void _objc_msgSend_301( + ffi.Pointer obj, + ffi.Pointer sel, + int opts, + ffi.Pointer<_ObjCBlock> cmptr, + ) { + return __objc_msgSend_301( + obj, + sel, + opts, + cmptr, + ); + } + + late final __objc_msgSend_301Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Int32, ffi.Pointer<_ObjCBlock>)>>('objc_msgSend'); + late final __objc_msgSend_301 = __objc_msgSend_301Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, int, + ffi.Pointer<_ObjCBlock>)>(); + + late final _sel_arrayWithCapacity_1 = _registerName1("arrayWithCapacity:"); + ffi.Pointer _objc_msgSend_302( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer path, + ) { + return __objc_msgSend_302( + obj, + sel, + path, + ); + } + + late final __objc_msgSend_302Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_302 = __objc_msgSend_302Ptr.asFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>(); + + ffi.Pointer _objc_msgSend_303( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer url, + ) { + return __objc_msgSend_303( + obj, + sel, + url, + ); + } + + late final __objc_msgSend_303Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_303 = __objc_msgSend_303Ptr.asFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>(); + + late final _sel_applyDifference_1 = _registerName1("applyDifference:"); + late final _class_NSItemProvider1 = _getClass1("NSItemProvider"); + late final _class_NSProgress1 = _getClass1("NSProgress"); + late final _sel_currentProgress1 = _registerName1("currentProgress"); + ffi.Pointer _objc_msgSend_304( + ffi.Pointer obj, + ffi.Pointer sel, + ) { + return __objc_msgSend_304( + obj, + sel, + ); + } + + late final __objc_msgSend_304Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_304 = __objc_msgSend_304Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); + + late final _sel_progressWithTotalUnitCount_1 = + _registerName1("progressWithTotalUnitCount:"); + ffi.Pointer _objc_msgSend_305( + ffi.Pointer obj, + ffi.Pointer sel, + int unitCount, + ) { + return __objc_msgSend_305( + obj, + sel, + unitCount, + ); + } + + late final __objc_msgSend_305Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Int64)>>('objc_msgSend'); + late final __objc_msgSend_305 = __objc_msgSend_305Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer, int)>(); + + late final _sel_discreteProgressWithTotalUnitCount_1 = + _registerName1("discreteProgressWithTotalUnitCount:"); + late final _sel_progressWithTotalUnitCount_parent_pendingUnitCount_1 = + _registerName1("progressWithTotalUnitCount:parent:pendingUnitCount:"); + ffi.Pointer _objc_msgSend_306( + ffi.Pointer obj, + ffi.Pointer sel, + int unitCount, + ffi.Pointer parent, + int portionOfParentTotalUnitCount, + ) { + return __objc_msgSend_306( + obj, + sel, + unitCount, + parent, + portionOfParentTotalUnitCount, + ); + } + + late final __objc_msgSend_306Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Int64, + ffi.Pointer, + ffi.Int64)>>('objc_msgSend'); + late final __objc_msgSend_306 = __objc_msgSend_306Ptr.asFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, int, ffi.Pointer, int)>(); + + late final _sel_initWithParent_userInfo_1 = + _registerName1("initWithParent:userInfo:"); + instancetype _objc_msgSend_307( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer parentProgressOrNil, + ffi.Pointer userInfoOrNil, + ) { + return __objc_msgSend_307( + obj, + sel, + parentProgressOrNil, + userInfoOrNil, + ); + } + + late final __objc_msgSend_307Ptr = _lookup< + ffi.NativeFunction< + instancetype Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_307 = __objc_msgSend_307Ptr.asFunction< + instancetype Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, ffi.Pointer)>(); + + late final _sel_becomeCurrentWithPendingUnitCount_1 = + _registerName1("becomeCurrentWithPendingUnitCount:"); + void _objc_msgSend_308( + ffi.Pointer obj, + ffi.Pointer sel, + int unitCount, + ) { + return __objc_msgSend_308( + obj, + sel, + unitCount, + ); + } + + late final __objc_msgSend_308Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Int64)>>('objc_msgSend'); + late final __objc_msgSend_308 = __objc_msgSend_308Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, int)>(); + + late final _sel_performAsCurrentWithPendingUnitCount_usingBlock_1 = + _registerName1("performAsCurrentWithPendingUnitCount:usingBlock:"); + void _objc_msgSend_309( + ffi.Pointer obj, + ffi.Pointer sel, + int unitCount, + ffi.Pointer<_ObjCBlock> work, + ) { + return __objc_msgSend_309( + obj, + sel, + unitCount, + work, + ); + } + + late final __objc_msgSend_309Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Int64, ffi.Pointer<_ObjCBlock>)>>('objc_msgSend'); + late final __objc_msgSend_309 = __objc_msgSend_309Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, int, + ffi.Pointer<_ObjCBlock>)>(); + + late final _sel_resignCurrent1 = _registerName1("resignCurrent"); + late final _sel_addChild_withPendingUnitCount_1 = + _registerName1("addChild:withPendingUnitCount:"); + void _objc_msgSend_310( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer child, + int inUnitCount, + ) { + return __objc_msgSend_310( + obj, + sel, + child, + inUnitCount, + ); + } + + late final __objc_msgSend_310Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, ffi.Int64)>>('objc_msgSend'); + late final __objc_msgSend_310 = __objc_msgSend_310Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, int)>(); + + late final _sel_totalUnitCount1 = _registerName1("totalUnitCount"); + int _objc_msgSend_311( + ffi.Pointer obj, + ffi.Pointer sel, + ) { + return __objc_msgSend_311( + obj, + sel, + ); + } + + late final __objc_msgSend_311Ptr = _lookup< + ffi.NativeFunction< + ffi.Int64 Function( + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_311 = __objc_msgSend_311Ptr.asFunction< + int Function(ffi.Pointer, ffi.Pointer)>(); + + late final _sel_setTotalUnitCount_1 = _registerName1("setTotalUnitCount:"); + void _objc_msgSend_312( + ffi.Pointer obj, + ffi.Pointer sel, + int value, + ) { + return __objc_msgSend_312( + obj, + sel, + value, + ); + } + + late final __objc_msgSend_312Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Int64)>>('objc_msgSend'); + late final __objc_msgSend_312 = __objc_msgSend_312Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, int)>(); + + late final _sel_completedUnitCount1 = _registerName1("completedUnitCount"); + late final _sel_setCompletedUnitCount_1 = + _registerName1("setCompletedUnitCount:"); + late final _sel_localizedDescription1 = + _registerName1("localizedDescription"); + late final _sel_setLocalizedDescription_1 = + _registerName1("setLocalizedDescription:"); + void _objc_msgSend_313( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer value, + ) { + return __objc_msgSend_313( + obj, + sel, + value, + ); + } + + late final __objc_msgSend_313Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_313 = __objc_msgSend_313Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); + + late final _sel_localizedAdditionalDescription1 = + _registerName1("localizedAdditionalDescription"); + late final _sel_setLocalizedAdditionalDescription_1 = + _registerName1("setLocalizedAdditionalDescription:"); + late final _sel_isCancellable1 = _registerName1("isCancellable"); + late final _sel_setCancellable_1 = _registerName1("setCancellable:"); + void _objc_msgSend_314( + ffi.Pointer obj, + ffi.Pointer sel, + bool value, + ) { + return __objc_msgSend_314( + obj, + sel, + value, + ); + } + + late final __objc_msgSend_314Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Bool)>>('objc_msgSend'); + late final __objc_msgSend_314 = __objc_msgSend_314Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, bool)>(); + + late final _sel_isPausable1 = _registerName1("isPausable"); + late final _sel_setPausable_1 = _registerName1("setPausable:"); + late final _sel_isCancelled1 = _registerName1("isCancelled"); + late final _sel_isPaused1 = _registerName1("isPaused"); + late final _sel_cancellationHandler1 = _registerName1("cancellationHandler"); + ffi.Pointer<_ObjCBlock> _objc_msgSend_315( + ffi.Pointer obj, + ffi.Pointer sel, + ) { + return __objc_msgSend_315( + obj, + sel, + ); + } + + late final __objc_msgSend_315Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer<_ObjCBlock> Function( + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_315 = __objc_msgSend_315Ptr.asFunction< + ffi.Pointer<_ObjCBlock> Function( + ffi.Pointer, ffi.Pointer)>(); + + late final _sel_setCancellationHandler_1 = + _registerName1("setCancellationHandler:"); + void _objc_msgSend_316( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer<_ObjCBlock> value, + ) { + return __objc_msgSend_316( + obj, + sel, + value, + ); + } + + late final __objc_msgSend_316Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer<_ObjCBlock>)>>('objc_msgSend'); + late final __objc_msgSend_316 = __objc_msgSend_316Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer<_ObjCBlock>)>(); + + late final _sel_pausingHandler1 = _registerName1("pausingHandler"); + late final _sel_setPausingHandler_1 = _registerName1("setPausingHandler:"); + late final _sel_resumingHandler1 = _registerName1("resumingHandler"); + late final _sel_setResumingHandler_1 = _registerName1("setResumingHandler:"); + late final _sel_setUserInfoObject_forKey_1 = + _registerName1("setUserInfoObject:forKey:"); + late final _sel_isIndeterminate1 = _registerName1("isIndeterminate"); + late final _sel_fractionCompleted1 = _registerName1("fractionCompleted"); + late final _sel_isFinished1 = _registerName1("isFinished"); + late final _sel_cancel1 = _registerName1("cancel"); + late final _sel_pause1 = _registerName1("pause"); + late final _sel_resume1 = _registerName1("resume"); + late final _sel_userInfo1 = _registerName1("userInfo"); + late final _sel_kind1 = _registerName1("kind"); + late final _sel_setKind_1 = _registerName1("setKind:"); + void _objc_msgSend_317( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer value, + ) { + return __objc_msgSend_317( + obj, + sel, + value, + ); + } + + late final __objc_msgSend_317Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_317 = __objc_msgSend_317Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); + + late final _sel_estimatedTimeRemaining1 = + _registerName1("estimatedTimeRemaining"); + ffi.Pointer _objc_msgSend_318( + ffi.Pointer obj, + ffi.Pointer sel, + ) { + return __objc_msgSend_318( + obj, + sel, + ); + } + + late final __objc_msgSend_318Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_318 = __objc_msgSend_318Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); + + late final _sel_setEstimatedTimeRemaining_1 = + _registerName1("setEstimatedTimeRemaining:"); + void _objc_msgSend_319( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer value, + ) { + return __objc_msgSend_319( + obj, + sel, + value, + ); + } + + late final __objc_msgSend_319Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_319 = __objc_msgSend_319Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); + + late final _sel_throughput1 = _registerName1("throughput"); + late final _sel_setThroughput_1 = _registerName1("setThroughput:"); + late final _sel_fileOperationKind1 = _registerName1("fileOperationKind"); + late final _sel_setFileOperationKind_1 = + _registerName1("setFileOperationKind:"); + late final _sel_fileURL1 = _registerName1("fileURL"); + ffi.Pointer _objc_msgSend_320( + ffi.Pointer obj, + ffi.Pointer sel, + ) { + return __objc_msgSend_320( + obj, + sel, + ); + } + + late final __objc_msgSend_320Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_320 = __objc_msgSend_320Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); + + late final _sel_setFileURL_1 = _registerName1("setFileURL:"); + void _objc_msgSend_321( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer value, + ) { + return __objc_msgSend_321( + obj, + sel, + value, + ); + } + + late final __objc_msgSend_321Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_321 = __objc_msgSend_321Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); + + late final _sel_fileTotalCount1 = _registerName1("fileTotalCount"); + late final _sel_setFileTotalCount_1 = _registerName1("setFileTotalCount:"); + late final _sel_fileCompletedCount1 = _registerName1("fileCompletedCount"); + late final _sel_setFileCompletedCount_1 = + _registerName1("setFileCompletedCount:"); + late final _sel_publish1 = _registerName1("publish"); + late final _sel_unpublish1 = _registerName1("unpublish"); + late final _sel_addSubscriberForFileURL_withPublishingHandler_1 = + _registerName1("addSubscriberForFileURL:withPublishingHandler:"); + ffi.Pointer _objc_msgSend_322( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer url, + ffi.Pointer<_ObjCBlock> publishingHandler, + ) { + return __objc_msgSend_322( + obj, + sel, + url, + publishingHandler, + ); + } + + late final __objc_msgSend_322Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer<_ObjCBlock>)>>('objc_msgSend'); + late final __objc_msgSend_322 = __objc_msgSend_322Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer<_ObjCBlock>)>(); + + late final _sel_removeSubscriber_1 = _registerName1("removeSubscriber:"); + late final _sel_isOld1 = _registerName1("isOld"); + late final _sel_registerDataRepresentationForTypeIdentifier_visibility_loadHandler_1 = + _registerName1( + "registerDataRepresentationForTypeIdentifier:visibility:loadHandler:"); + void _objc_msgSend_323( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer typeIdentifier, + int visibility, + ffi.Pointer<_ObjCBlock> loadHandler, + ) { + return __objc_msgSend_323( + obj, + sel, + typeIdentifier, + visibility, + loadHandler, + ); + } + + late final __objc_msgSend_323Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Int32, + ffi.Pointer<_ObjCBlock>)>>('objc_msgSend'); + late final __objc_msgSend_323 = __objc_msgSend_323Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, int, ffi.Pointer<_ObjCBlock>)>(); + + late final _sel_registerFileRepresentationForTypeIdentifier_fileOptions_visibility_loadHandler_1 = + _registerName1( + "registerFileRepresentationForTypeIdentifier:fileOptions:visibility:loadHandler:"); + void _objc_msgSend_324( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer typeIdentifier, + int fileOptions, + int visibility, + ffi.Pointer<_ObjCBlock> loadHandler, + ) { + return __objc_msgSend_324( + obj, + sel, + typeIdentifier, + fileOptions, + visibility, + loadHandler, + ); + } + + late final __objc_msgSend_324Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Int32, + ffi.Int32, + ffi.Pointer<_ObjCBlock>)>>('objc_msgSend'); + late final __objc_msgSend_324 = __objc_msgSend_324Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, int, int, ffi.Pointer<_ObjCBlock>)>(); + + late final _sel_registeredTypeIdentifiers1 = + _registerName1("registeredTypeIdentifiers"); + late final _sel_registeredTypeIdentifiersWithFileOptions_1 = + _registerName1("registeredTypeIdentifiersWithFileOptions:"); + ffi.Pointer _objc_msgSend_325( + ffi.Pointer obj, + ffi.Pointer sel, + int fileOptions, + ) { + return __objc_msgSend_325( + obj, + sel, + fileOptions, + ); + } + + late final __objc_msgSend_325Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Int32)>>('objc_msgSend'); + late final __objc_msgSend_325 = __objc_msgSend_325Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer, int)>(); + + late final _sel_hasItemConformingToTypeIdentifier_1 = + _registerName1("hasItemConformingToTypeIdentifier:"); + late final _sel_hasRepresentationConformingToTypeIdentifier_fileOptions_1 = + _registerName1( + "hasRepresentationConformingToTypeIdentifier:fileOptions:"); + bool _objc_msgSend_326( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer typeIdentifier, + int fileOptions, + ) { + return __objc_msgSend_326( + obj, + sel, + typeIdentifier, + fileOptions, + ); + } + + late final __objc_msgSend_326Ptr = _lookup< + ffi.NativeFunction< + ffi.Bool Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, ffi.Int32)>>('objc_msgSend'); + late final __objc_msgSend_326 = __objc_msgSend_326Ptr.asFunction< + bool Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, int)>(); + + late final _sel_loadDataRepresentationForTypeIdentifier_completionHandler_1 = + _registerName1( + "loadDataRepresentationForTypeIdentifier:completionHandler:"); + ffi.Pointer _objc_msgSend_327( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer typeIdentifier, + ffi.Pointer<_ObjCBlock> completionHandler, + ) { + return __objc_msgSend_327( + obj, + sel, + typeIdentifier, + completionHandler, + ); + } + + late final __objc_msgSend_327Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer<_ObjCBlock>)>>('objc_msgSend'); + late final __objc_msgSend_327 = __objc_msgSend_327Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer<_ObjCBlock>)>(); + + late final _sel_loadFileRepresentationForTypeIdentifier_completionHandler_1 = + _registerName1( + "loadFileRepresentationForTypeIdentifier:completionHandler:"); + ffi.Pointer _objc_msgSend_328( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer typeIdentifier, + ffi.Pointer<_ObjCBlock> completionHandler, + ) { + return __objc_msgSend_328( + obj, + sel, + typeIdentifier, + completionHandler, + ); + } + + late final __objc_msgSend_328Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer<_ObjCBlock>)>>('objc_msgSend'); + late final __objc_msgSend_328 = __objc_msgSend_328Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer<_ObjCBlock>)>(); + + late final _sel_loadInPlaceFileRepresentationForTypeIdentifier_completionHandler_1 = + _registerName1( + "loadInPlaceFileRepresentationForTypeIdentifier:completionHandler:"); + ffi.Pointer _objc_msgSend_329( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer typeIdentifier, + ffi.Pointer<_ObjCBlock> completionHandler, + ) { + return __objc_msgSend_329( + obj, + sel, + typeIdentifier, + completionHandler, + ); + } + + late final __objc_msgSend_329Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer<_ObjCBlock>)>>('objc_msgSend'); + late final __objc_msgSend_329 = __objc_msgSend_329Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer<_ObjCBlock>)>(); + + late final _sel_suggestedName1 = _registerName1("suggestedName"); + late final _sel_setSuggestedName_1 = _registerName1("setSuggestedName:"); + late final _sel_initWithObject_1 = _registerName1("initWithObject:"); + late final _sel_registerObject_visibility_1 = + _registerName1("registerObject:visibility:"); + void _objc_msgSend_330( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer object, + int visibility, + ) { + return __objc_msgSend_330( + obj, + sel, + object, + visibility, + ); + } + + late final __objc_msgSend_330Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, ffi.Int32)>>('objc_msgSend'); + late final __objc_msgSend_330 = __objc_msgSend_330Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, int)>(); + + late final _sel_registerObjectOfClass_visibility_loadHandler_1 = + _registerName1("registerObjectOfClass:visibility:loadHandler:"); + void _objc_msgSend_331( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer aClass, + int visibility, + ffi.Pointer<_ObjCBlock> loadHandler, + ) { + return __objc_msgSend_331( + obj, + sel, + aClass, + visibility, + loadHandler, + ); + } + + late final __objc_msgSend_331Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Int32, + ffi.Pointer<_ObjCBlock>)>>('objc_msgSend'); + late final __objc_msgSend_331 = __objc_msgSend_331Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, int, ffi.Pointer<_ObjCBlock>)>(); + + late final _sel_canLoadObjectOfClass_1 = + _registerName1("canLoadObjectOfClass:"); + late final _sel_loadObjectOfClass_completionHandler_1 = + _registerName1("loadObjectOfClass:completionHandler:"); + ffi.Pointer _objc_msgSend_332( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer aClass, + ffi.Pointer<_ObjCBlock> completionHandler, + ) { + return __objc_msgSend_332( + obj, + sel, + aClass, + completionHandler, + ); + } + + late final __objc_msgSend_332Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer<_ObjCBlock>)>>('objc_msgSend'); + late final __objc_msgSend_332 = __objc_msgSend_332Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer<_ObjCBlock>)>(); + + late final _sel_initWithItem_typeIdentifier_1 = + _registerName1("initWithItem:typeIdentifier:"); + instancetype _objc_msgSend_333( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer item, + ffi.Pointer typeIdentifier, + ) { + return __objc_msgSend_333( + obj, + sel, + item, + typeIdentifier, + ); + } + + late final __objc_msgSend_333Ptr = _lookup< + ffi.NativeFunction< + instancetype Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_333 = __objc_msgSend_333Ptr.asFunction< + instancetype Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, ffi.Pointer)>(); + + late final _sel_registerItemForTypeIdentifier_loadHandler_1 = + _registerName1("registerItemForTypeIdentifier:loadHandler:"); + void _objc_msgSend_334( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer typeIdentifier, + ffi.Pointer<_ObjCBlock> loadHandler, + ) { + return __objc_msgSend_334( + obj, + sel, + typeIdentifier, + loadHandler, + ); + } + + late final __objc_msgSend_334Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer<_ObjCBlock>)>>('objc_msgSend'); + late final __objc_msgSend_334 = __objc_msgSend_334Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, ffi.Pointer<_ObjCBlock>)>(); + + late final _sel_loadItemForTypeIdentifier_options_completionHandler_1 = + _registerName1("loadItemForTypeIdentifier:options:completionHandler:"); + void _objc_msgSend_335( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer typeIdentifier, + ffi.Pointer options, + ffi.Pointer<_ObjCBlock> completionHandler, + ) { + return __objc_msgSend_335( + obj, + sel, + typeIdentifier, + options, + completionHandler, + ); + } + + late final __objc_msgSend_335Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer<_ObjCBlock>)>>('objc_msgSend'); + late final __objc_msgSend_335 = __objc_msgSend_335Ptr.asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer<_ObjCBlock>)>(); + + late final _sel_previewImageHandler1 = _registerName1("previewImageHandler"); + ffi.Pointer<_ObjCBlock> _objc_msgSend_336( + ffi.Pointer obj, + ffi.Pointer sel, + ) { + return __objc_msgSend_336( + obj, + sel, + ); + } + + late final __objc_msgSend_336Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer<_ObjCBlock> Function( + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_336 = __objc_msgSend_336Ptr.asFunction< + ffi.Pointer<_ObjCBlock> Function( + ffi.Pointer, ffi.Pointer)>(); + + late final _sel_setPreviewImageHandler_1 = + _registerName1("setPreviewImageHandler:"); + void _objc_msgSend_337( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer<_ObjCBlock> value, + ) { + return __objc_msgSend_337( + obj, + sel, + value, + ); + } + + late final __objc_msgSend_337Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer<_ObjCBlock>)>>('objc_msgSend'); + late final __objc_msgSend_337 = __objc_msgSend_337Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer<_ObjCBlock>)>(); + + late final _sel_loadPreviewImageWithOptions_completionHandler_1 = + _registerName1("loadPreviewImageWithOptions:completionHandler:"); + void _objc_msgSend_338( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer options, + ffi.Pointer<_ObjCBlock> completionHandler, + ) { + return __objc_msgSend_338( + obj, + sel, + options, + completionHandler, + ); + } + + late final __objc_msgSend_338Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer<_ObjCBlock>)>>('objc_msgSend'); + late final __objc_msgSend_338 = __objc_msgSend_338Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, ffi.Pointer<_ObjCBlock>)>(); + + late final _class_NSMutableString1 = _getClass1("NSMutableString"); + late final _sel_replaceCharactersInRange_withString_1 = + _registerName1("replaceCharactersInRange:withString:"); + void _objc_msgSend_339( + ffi.Pointer obj, + ffi.Pointer sel, + _NSRange range, + ffi.Pointer aString, + ) { + return __objc_msgSend_339( + obj, + sel, + range, + aString, + ); + } + + late final __objc_msgSend_339Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + _NSRange, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_339 = __objc_msgSend_339Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, _NSRange, + ffi.Pointer)>(); + + late final _sel_insertString_atIndex_1 = + _registerName1("insertString:atIndex:"); + void _objc_msgSend_340( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer aString, + int loc, + ) { + return __objc_msgSend_340( + obj, + sel, + aString, + loc, + ); + } + + late final __objc_msgSend_340Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, ffi.UnsignedLong)>>('objc_msgSend'); + late final __objc_msgSend_340 = __objc_msgSend_340Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, int)>(); + + late final _sel_deleteCharactersInRange_1 = + _registerName1("deleteCharactersInRange:"); + late final _sel_appendString_1 = _registerName1("appendString:"); + void _objc_msgSend_341( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer aString, + ) { + return __objc_msgSend_341( + obj, + sel, + aString, + ); + } + + late final __objc_msgSend_341Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_341 = __objc_msgSend_341Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); + + late final _sel_appendFormat_1 = _registerName1("appendFormat:"); + late final _sel_setString_1 = _registerName1("setString:"); + late final _sel_replaceOccurrencesOfString_withString_options_range_1 = + _registerName1("replaceOccurrencesOfString:withString:options:range:"); + int _objc_msgSend_342( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer target, + ffi.Pointer replacement, + int options, + _NSRange searchRange, + ) { + return __objc_msgSend_342( + obj, + sel, + target, + replacement, + options, + searchRange, + ); + } + + late final __objc_msgSend_342Ptr = _lookup< + ffi.NativeFunction< + ffi.UnsignedLong Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Int32, + _NSRange)>>('objc_msgSend'); + late final __objc_msgSend_342 = __objc_msgSend_342Ptr.asFunction< + int Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, ffi.Pointer, int, _NSRange)>(); + + late final _sel_applyTransform_reverse_range_updatedRange_1 = + _registerName1("applyTransform:reverse:range:updatedRange:"); + bool _objc_msgSend_343( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer transform, + bool reverse, + _NSRange range, + ffi.Pointer<_NSRange> resultingRange, + ) { + return __objc_msgSend_343( + obj, + sel, + transform, + reverse, + range, + resultingRange, + ); + } + + late final __objc_msgSend_343Ptr = _lookup< + ffi.NativeFunction< + ffi.Bool Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Bool, + _NSRange, + ffi.Pointer<_NSRange>)>>('objc_msgSend'); + late final __objc_msgSend_343 = __objc_msgSend_343Ptr.asFunction< + bool Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, bool, _NSRange, ffi.Pointer<_NSRange>)>(); + + ffi.Pointer _objc_msgSend_344( + ffi.Pointer obj, + ffi.Pointer sel, + int capacity, + ) { + return __objc_msgSend_344( + obj, + sel, + capacity, + ); + } + + late final __objc_msgSend_344Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.UnsignedLong)>>('objc_msgSend'); + late final __objc_msgSend_344 = __objc_msgSend_344Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer, int)>(); + + late final _sel_stringWithCapacity_1 = _registerName1("stringWithCapacity:"); + late final _class_NSMutableDictionary1 = _getClass1("NSMutableDictionary"); + late final _sel_removeObjectForKey_1 = _registerName1("removeObjectForKey:"); + late final _sel_setObject_forKey_1 = _registerName1("setObject:forKey:"); + void _objc_msgSend_345( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer anObject, + ffi.Pointer aKey, + ) { + return __objc_msgSend_345( + obj, + sel, + anObject, + aKey, + ); + } + + late final __objc_msgSend_345Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_345 = __objc_msgSend_345Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, ffi.Pointer)>(); + + late final _sel_addEntriesFromDictionary_1 = + _registerName1("addEntriesFromDictionary:"); + void _objc_msgSend_346( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer otherDictionary, + ) { + return __objc_msgSend_346( + obj, + sel, + otherDictionary, + ); + } + + late final __objc_msgSend_346Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_346 = __objc_msgSend_346Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); + + late final _sel_removeObjectsForKeys_1 = + _registerName1("removeObjectsForKeys:"); + late final _sel_setDictionary_1 = _registerName1("setDictionary:"); + late final _sel_setObject_forKeyedSubscript_1 = + _registerName1("setObject:forKeyedSubscript:"); + void _objc_msgSend_347( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer obj1, + ffi.Pointer key, + ) { + return __objc_msgSend_347( + obj, + sel, + obj1, + key, + ); + } + + late final __objc_msgSend_347Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_347 = __objc_msgSend_347Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, ffi.Pointer)>(); + + late final _sel_dictionaryWithCapacity_1 = + _registerName1("dictionaryWithCapacity:"); + ffi.Pointer _objc_msgSend_348( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer path, + ) { + return __objc_msgSend_348( + obj, + sel, + path, + ); + } + + late final __objc_msgSend_348Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_348 = __objc_msgSend_348Ptr.asFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>(); + + ffi.Pointer _objc_msgSend_349( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer url, + ) { + return __objc_msgSend_349( + obj, + sel, + url, + ); + } + + late final __objc_msgSend_349Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_349 = __objc_msgSend_349Ptr.asFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>(); + + late final _sel_dictionaryWithSharedKeySet_1 = + _registerName1("dictionaryWithSharedKeySet:"); + ffi.Pointer _objc_msgSend_350( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer keyset, + ) { + return __objc_msgSend_350( + obj, + sel, + keyset, + ); + } + + late final __objc_msgSend_350Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_350 = __objc_msgSend_350Ptr.asFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>(); + + late final _class_NSMutableSet1 = _getClass1("NSMutableSet"); + late final _sel_intersectSet_1 = _registerName1("intersectSet:"); + void _objc_msgSend_351( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer otherSet, + ) { + return __objc_msgSend_351( + obj, + sel, + otherSet, + ); + } + + late final __objc_msgSend_351Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_351 = __objc_msgSend_351Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); + + late final _sel_minusSet_1 = _registerName1("minusSet:"); + late final _sel_unionSet_1 = _registerName1("unionSet:"); + late final _sel_setSet_1 = _registerName1("setSet:"); + late final _sel_setWithCapacity_1 = _registerName1("setWithCapacity:"); + late final _class_NSNotification1 = _getClass1("NSNotification"); + late final _sel_name1 = _registerName1("name"); + late final _sel_object1 = _registerName1("object"); + late final _sel_initWithName_object_userInfo_1 = + _registerName1("initWithName:object:userInfo:"); + instancetype _objc_msgSend_352( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer name, + ffi.Pointer object, + ffi.Pointer userInfo, + ) { + return __objc_msgSend_352( + obj, + sel, + name, + object, + userInfo, + ); + } + + late final __objc_msgSend_352Ptr = _lookup< + ffi.NativeFunction< + instancetype Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_352 = __objc_msgSend_352Ptr.asFunction< + instancetype Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>(); + + late final _sel_notificationWithName_object_1 = + _registerName1("notificationWithName:object:"); + late final _sel_notificationWithName_object_userInfo_1 = + _registerName1("notificationWithName:object:userInfo:"); + late final _class_NSBundle1 = _getClass1("NSBundle"); + late final _sel_mainBundle1 = _registerName1("mainBundle"); + ffi.Pointer _objc_msgSend_353( + ffi.Pointer obj, + ffi.Pointer sel, + ) { + return __objc_msgSend_353( + obj, + sel, + ); + } + + late final __objc_msgSend_353Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_353 = __objc_msgSend_353Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); + + late final _sel_bundleWithPath_1 = _registerName1("bundleWithPath:"); + late final _sel_initWithPath_1 = _registerName1("initWithPath:"); + late final _sel_bundleWithURL_1 = _registerName1("bundleWithURL:"); + late final _sel_initWithURL_1 = _registerName1("initWithURL:"); + late final _sel_bundleForClass_1 = _registerName1("bundleForClass:"); + ffi.Pointer _objc_msgSend_354( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer aClass, + ) { + return __objc_msgSend_354( + obj, + sel, + aClass, + ); + } + + late final __objc_msgSend_354Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_354 = __objc_msgSend_354Ptr.asFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>(); + + late final _sel_bundleWithIdentifier_1 = + _registerName1("bundleWithIdentifier:"); + ffi.Pointer _objc_msgSend_355( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer identifier, + ) { + return __objc_msgSend_355( + obj, + sel, + identifier, + ); + } + + late final __objc_msgSend_355Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_355 = __objc_msgSend_355Ptr.asFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>(); + + late final _sel_allBundles1 = _registerName1("allBundles"); + late final _sel_allFrameworks1 = _registerName1("allFrameworks"); + late final _sel_isLoaded1 = _registerName1("isLoaded"); + late final _sel_unload1 = _registerName1("unload"); + late final _sel_preflightAndReturnError_1 = + _registerName1("preflightAndReturnError:"); + bool _objc_msgSend_356( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer> error, + ) { + return __objc_msgSend_356( + obj, + sel, + error, + ); + } + + late final __objc_msgSend_356Ptr = _lookup< + ffi.NativeFunction< + ffi.Bool Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer>)>>('objc_msgSend'); + late final __objc_msgSend_356 = __objc_msgSend_356Ptr.asFunction< + bool Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer>)>(); + + late final _sel_loadAndReturnError_1 = _registerName1("loadAndReturnError:"); + late final _sel_bundleURL1 = _registerName1("bundleURL"); + ffi.Pointer _objc_msgSend_357( + ffi.Pointer obj, + ffi.Pointer sel, + ) { + return __objc_msgSend_357( + obj, + sel, + ); + } + + late final __objc_msgSend_357Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_357 = __objc_msgSend_357Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); + + late final _sel_resourceURL1 = _registerName1("resourceURL"); + late final _sel_executableURL1 = _registerName1("executableURL"); + late final _sel_URLForAuxiliaryExecutable_1 = + _registerName1("URLForAuxiliaryExecutable:"); + ffi.Pointer _objc_msgSend_358( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer executableName, + ) { + return __objc_msgSend_358( + obj, + sel, + executableName, + ); + } + + late final __objc_msgSend_358Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_358 = __objc_msgSend_358Ptr.asFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>(); + + late final _sel_privateFrameworksURL1 = + _registerName1("privateFrameworksURL"); + late final _sel_sharedFrameworksURL1 = _registerName1("sharedFrameworksURL"); + late final _sel_sharedSupportURL1 = _registerName1("sharedSupportURL"); + late final _sel_builtInPlugInsURL1 = _registerName1("builtInPlugInsURL"); + late final _sel_appStoreReceiptURL1 = _registerName1("appStoreReceiptURL"); + late final _sel_bundlePath1 = _registerName1("bundlePath"); + late final _sel_resourcePath1 = _registerName1("resourcePath"); + late final _sel_executablePath1 = _registerName1("executablePath"); + late final _sel_pathForAuxiliaryExecutable_1 = + _registerName1("pathForAuxiliaryExecutable:"); + late final _sel_privateFrameworksPath1 = + _registerName1("privateFrameworksPath"); + late final _sel_sharedFrameworksPath1 = + _registerName1("sharedFrameworksPath"); + late final _sel_sharedSupportPath1 = _registerName1("sharedSupportPath"); + late final _sel_builtInPlugInsPath1 = _registerName1("builtInPlugInsPath"); + late final _sel_URLForResource_withExtension_subdirectory_inBundleWithURL_1 = + _registerName1( + "URLForResource:withExtension:subdirectory:inBundleWithURL:"); + ffi.Pointer _objc_msgSend_359( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer name, + ffi.Pointer ext, + ffi.Pointer subpath, + ffi.Pointer bundleURL, + ) { + return __objc_msgSend_359( + obj, + sel, + name, + ext, + subpath, + bundleURL, + ); + } + + late final __objc_msgSend_359Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_359 = __objc_msgSend_359Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>(); + + late final _sel_URLsForResourcesWithExtension_subdirectory_inBundleWithURL_1 = + _registerName1( + "URLsForResourcesWithExtension:subdirectory:inBundleWithURL:"); + ffi.Pointer _objc_msgSend_360( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer ext, + ffi.Pointer subpath, + ffi.Pointer bundleURL, + ) { + return __objc_msgSend_360( + obj, + sel, + ext, + subpath, + bundleURL, + ); + } + + late final __objc_msgSend_360Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_360 = __objc_msgSend_360Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>(); + + late final _sel_URLForResource_withExtension_1 = + _registerName1("URLForResource:withExtension:"); + ffi.Pointer _objc_msgSend_361( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer name, + ffi.Pointer ext, + ) { + return __objc_msgSend_361( + obj, + sel, + name, + ext, + ); + } + + late final __objc_msgSend_361Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_361 = __objc_msgSend_361Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>(); + + late final _sel_URLForResource_withExtension_subdirectory_1 = + _registerName1("URLForResource:withExtension:subdirectory:"); + ffi.Pointer _objc_msgSend_362( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer name, + ffi.Pointer ext, + ffi.Pointer subpath, + ) { + return __objc_msgSend_362( + obj, + sel, + name, + ext, + subpath, + ); + } + + late final __objc_msgSend_362Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_362 = __objc_msgSend_362Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>(); + + late final _sel_URLForResource_withExtension_subdirectory_localization_1 = + _registerName1("URLForResource:withExtension:subdirectory:localization:"); + ffi.Pointer _objc_msgSend_363( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer name, + ffi.Pointer ext, + ffi.Pointer subpath, + ffi.Pointer localizationName, + ) { + return __objc_msgSend_363( + obj, + sel, + name, + ext, + subpath, + localizationName, + ); + } + + late final __objc_msgSend_363Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_363 = __objc_msgSend_363Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>(); + + late final _sel_URLsForResourcesWithExtension_subdirectory_1 = + _registerName1("URLsForResourcesWithExtension:subdirectory:"); + ffi.Pointer _objc_msgSend_364( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer ext, + ffi.Pointer subpath, + ) { + return __objc_msgSend_364( + obj, + sel, + ext, + subpath, + ); + } + + late final __objc_msgSend_364Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_364 = __objc_msgSend_364Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>(); + + late final _sel_URLsForResourcesWithExtension_subdirectory_localization_1 = + _registerName1( + "URLsForResourcesWithExtension:subdirectory:localization:"); + ffi.Pointer _objc_msgSend_365( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer ext, + ffi.Pointer subpath, + ffi.Pointer localizationName, + ) { + return __objc_msgSend_365( + obj, + sel, + ext, + subpath, + localizationName, + ); + } + + late final __objc_msgSend_365Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_365 = __objc_msgSend_365Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>(); + + late final _sel_pathForResource_ofType_inDirectory_1 = + _registerName1("pathForResource:ofType:inDirectory:"); + ffi.Pointer _objc_msgSend_366( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer name, + ffi.Pointer ext, + ffi.Pointer bundlePath, + ) { + return __objc_msgSend_366( + obj, + sel, + name, + ext, + bundlePath, + ); + } + + late final __objc_msgSend_366Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_366 = __objc_msgSend_366Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>(); + + late final _sel_pathsForResourcesOfType_inDirectory_1 = + _registerName1("pathsForResourcesOfType:inDirectory:"); + ffi.Pointer _objc_msgSend_367( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer ext, + ffi.Pointer bundlePath, + ) { + return __objc_msgSend_367( + obj, + sel, + ext, + bundlePath, + ); + } + + late final __objc_msgSend_367Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_367 = __objc_msgSend_367Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>(); + + late final _sel_pathForResource_ofType_1 = + _registerName1("pathForResource:ofType:"); + ffi.Pointer _objc_msgSend_368( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer name, + ffi.Pointer ext, + ) { + return __objc_msgSend_368( + obj, + sel, + name, + ext, + ); + } + + late final __objc_msgSend_368Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_368 = __objc_msgSend_368Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>(); + + late final _sel_pathForResource_ofType_inDirectory_forLocalization_1 = + _registerName1("pathForResource:ofType:inDirectory:forLocalization:"); + ffi.Pointer _objc_msgSend_369( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer name, + ffi.Pointer ext, + ffi.Pointer subpath, + ffi.Pointer localizationName, + ) { + return __objc_msgSend_369( + obj, + sel, + name, + ext, + subpath, + localizationName, + ); + } + + late final __objc_msgSend_369Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_369 = __objc_msgSend_369Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>(); + + late final _sel_pathsForResourcesOfType_inDirectory_forLocalization_1 = + _registerName1("pathsForResourcesOfType:inDirectory:forLocalization:"); + ffi.Pointer _objc_msgSend_370( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer ext, + ffi.Pointer subpath, + ffi.Pointer localizationName, + ) { + return __objc_msgSend_370( + obj, + sel, + ext, + subpath, + localizationName, + ); + } + + late final __objc_msgSend_370Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_370 = __objc_msgSend_370Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>(); + + late final _sel_localizedStringForKey_value_table_1 = + _registerName1("localizedStringForKey:value:table:"); + ffi.Pointer _objc_msgSend_371( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer key, + ffi.Pointer value, + ffi.Pointer tableName, + ) { + return __objc_msgSend_371( + obj, + sel, + key, + value, + tableName, + ); + } + + late final __objc_msgSend_371Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_371 = __objc_msgSend_371Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>(); + + late final _class_NSAttributedString1 = _getClass1("NSAttributedString"); + late final _sel_localizedAttributedStringForKey_value_table_1 = + _registerName1("localizedAttributedStringForKey:value:table:"); + ffi.Pointer _objc_msgSend_372( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer key, + ffi.Pointer value, + ffi.Pointer tableName, + ) { + return __objc_msgSend_372( + obj, + sel, + key, + value, + tableName, + ); + } + + late final __objc_msgSend_372Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_372 = __objc_msgSend_372Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>(); + + late final _sel_bundleIdentifier1 = _registerName1("bundleIdentifier"); + late final _sel_infoDictionary1 = _registerName1("infoDictionary"); + late final _sel_localizedInfoDictionary1 = + _registerName1("localizedInfoDictionary"); + late final _sel_objectForInfoDictionaryKey_1 = + _registerName1("objectForInfoDictionaryKey:"); + late final _sel_classNamed_1 = _registerName1("classNamed:"); + late final _sel_principalClass1 = _registerName1("principalClass"); + late final _sel_preferredLocalizations1 = + _registerName1("preferredLocalizations"); + late final _sel_localizations1 = _registerName1("localizations"); + late final _sel_developmentLocalization1 = + _registerName1("developmentLocalization"); + late final _sel_preferredLocalizationsFromArray_1 = + _registerName1("preferredLocalizationsFromArray:"); + late final _sel_preferredLocalizationsFromArray_forPreferences_1 = + _registerName1("preferredLocalizationsFromArray:forPreferences:"); + ffi.Pointer _objc_msgSend_373( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer localizationsArray, + ffi.Pointer preferencesArray, + ) { + return __objc_msgSend_373( + obj, + sel, + localizationsArray, + preferencesArray, + ); + } + + late final __objc_msgSend_373Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_373 = __objc_msgSend_373Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>(); + + late final _sel_executableArchitectures1 = + _registerName1("executableArchitectures"); + ffi.Pointer _objc_msgSend_374( + ffi.Pointer obj, + ffi.Pointer sel, + ) { + return __objc_msgSend_374( + obj, + sel, + ); + } + + late final __objc_msgSend_374Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_374 = __objc_msgSend_374Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); + + late final _sel_setPreservationPriority_forTags_1 = + _registerName1("setPreservationPriority:forTags:"); + void _objc_msgSend_375( + ffi.Pointer obj, + ffi.Pointer sel, + double priority, + ffi.Pointer tags, + ) { + return __objc_msgSend_375( + obj, + sel, + priority, + tags, + ); + } + + late final __objc_msgSend_375Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Double, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_375 = __objc_msgSend_375Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, double, + ffi.Pointer)>(); + + late final _sel_preservationPriorityForTag_1 = + _registerName1("preservationPriorityForTag:"); + late final _class_NSDate1 = _getClass1("NSDate"); + late final _sel_timeIntervalSinceReferenceDate1 = + _registerName1("timeIntervalSinceReferenceDate"); + late final _sel_initWithTimeIntervalSinceReferenceDate_1 = + _registerName1("initWithTimeIntervalSinceReferenceDate:"); + instancetype _objc_msgSend_376( + ffi.Pointer obj, + ffi.Pointer sel, + double ti, + ) { + return __objc_msgSend_376( + obj, + sel, + ti, + ); + } + + late final __objc_msgSend_376Ptr = _lookup< + ffi.NativeFunction< + instancetype Function(ffi.Pointer, ffi.Pointer, + ffi.Double)>>('objc_msgSend'); + late final __objc_msgSend_376 = __objc_msgSend_376Ptr.asFunction< + instancetype Function( + ffi.Pointer, ffi.Pointer, double)>(); + + late final _sel_timeIntervalSinceDate_1 = + _registerName1("timeIntervalSinceDate:"); + double _objc_msgSend_377( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer anotherDate, + ) { + return __objc_msgSend_377( + obj, + sel, + anotherDate, + ); + } + + late final __objc_msgSend_377Ptr = _lookup< + ffi.NativeFunction< + ffi.Double Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>>('objc_msgSend_fpret'); + late final __objc_msgSend_377 = __objc_msgSend_377Ptr.asFunction< + double Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); + + late final _sel_timeIntervalSinceNow1 = + _registerName1("timeIntervalSinceNow"); + late final _sel_timeIntervalSince19701 = + _registerName1("timeIntervalSince1970"); + late final _sel_addTimeInterval_1 = _registerName1("addTimeInterval:"); + late final _sel_dateByAddingTimeInterval_1 = + _registerName1("dateByAddingTimeInterval:"); + late final _sel_earlierDate_1 = _registerName1("earlierDate:"); + ffi.Pointer _objc_msgSend_378( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer anotherDate, + ) { + return __objc_msgSend_378( + obj, + sel, + anotherDate, + ); + } + + late final __objc_msgSend_378Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_378 = __objc_msgSend_378Ptr.asFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>(); + + late final _sel_laterDate_1 = _registerName1("laterDate:"); + int _objc_msgSend_379( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer other, + ) { + return __objc_msgSend_379( + obj, + sel, + other, + ); + } + + late final __objc_msgSend_379Ptr = _lookup< + ffi.NativeFunction< + ffi.Int32 Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_379 = __objc_msgSend_379Ptr.asFunction< + int Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); + + late final _sel_isEqualToDate_1 = _registerName1("isEqualToDate:"); + bool _objc_msgSend_380( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer otherDate, + ) { + return __objc_msgSend_380( + obj, + sel, + otherDate, + ); + } + + late final __objc_msgSend_380Ptr = _lookup< + ffi.NativeFunction< + ffi.Bool Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_380 = __objc_msgSend_380Ptr.asFunction< + bool Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); + + late final _sel_date1 = _registerName1("date"); + late final _sel_dateWithTimeIntervalSinceNow_1 = + _registerName1("dateWithTimeIntervalSinceNow:"); + late final _sel_dateWithTimeIntervalSinceReferenceDate_1 = + _registerName1("dateWithTimeIntervalSinceReferenceDate:"); + late final _sel_dateWithTimeIntervalSince1970_1 = + _registerName1("dateWithTimeIntervalSince1970:"); + late final _sel_dateWithTimeInterval_sinceDate_1 = + _registerName1("dateWithTimeInterval:sinceDate:"); + instancetype _objc_msgSend_381( + ffi.Pointer obj, + ffi.Pointer sel, + double secsToBeAdded, + ffi.Pointer date, + ) { + return __objc_msgSend_381( + obj, + sel, + secsToBeAdded, + date, + ); + } + + late final __objc_msgSend_381Ptr = _lookup< + ffi.NativeFunction< + instancetype Function(ffi.Pointer, ffi.Pointer, + ffi.Double, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_381 = __objc_msgSend_381Ptr.asFunction< + instancetype Function(ffi.Pointer, ffi.Pointer, + double, ffi.Pointer)>(); + + late final _sel_distantFuture1 = _registerName1("distantFuture"); + ffi.Pointer _objc_msgSend_382( + ffi.Pointer obj, + ffi.Pointer sel, + ) { + return __objc_msgSend_382( + obj, + sel, + ); + } + + late final __objc_msgSend_382Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_382 = __objc_msgSend_382Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); + + late final _sel_distantPast1 = _registerName1("distantPast"); + late final _sel_now1 = _registerName1("now"); + late final _sel_initWithTimeIntervalSinceNow_1 = + _registerName1("initWithTimeIntervalSinceNow:"); + late final _sel_initWithTimeIntervalSince1970_1 = + _registerName1("initWithTimeIntervalSince1970:"); + late final _sel_initWithTimeInterval_sinceDate_1 = + _registerName1("initWithTimeInterval:sinceDate:"); + late final _class_NSProcessInfo1 = _getClass1("NSProcessInfo"); + late final _sel_processInfo1 = _registerName1("processInfo"); + ffi.Pointer _objc_msgSend_383( + ffi.Pointer obj, + ffi.Pointer sel, + ) { + return __objc_msgSend_383( + obj, + sel, + ); + } + + late final __objc_msgSend_383Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_383 = __objc_msgSend_383Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); + + late final _sel_environment1 = _registerName1("environment"); + ffi.Pointer _objc_msgSend_384( + ffi.Pointer obj, + ffi.Pointer sel, + ) { + return __objc_msgSend_384( + obj, + sel, + ); + } + + late final __objc_msgSend_384Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_384 = __objc_msgSend_384Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); + + late final _sel_arguments1 = _registerName1("arguments"); + late final _sel_hostName1 = _registerName1("hostName"); + late final _sel_processName1 = _registerName1("processName"); + late final _sel_setProcessName_1 = _registerName1("setProcessName:"); + late final _sel_processIdentifier1 = _registerName1("processIdentifier"); + late final _sel_globallyUniqueString1 = + _registerName1("globallyUniqueString"); + late final _sel_operatingSystem1 = _registerName1("operatingSystem"); + late final _sel_operatingSystemName1 = _registerName1("operatingSystemName"); + late final _sel_operatingSystemVersionString1 = + _registerName1("operatingSystemVersionString"); + late final _sel_operatingSystemVersion1 = + _registerName1("operatingSystemVersion"); + void _objc_msgSend_385( + ffi.Pointer stret, + ffi.Pointer obj, + ffi.Pointer sel, + ) { + return __objc_msgSend_385( + stret, + obj, + sel, + ); + } + + late final __objc_msgSend_385Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>('objc_msgSend_stret'); + late final __objc_msgSend_385 = __objc_msgSend_385Ptr.asFunction< + void Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>(); + + late final _sel_processorCount1 = _registerName1("processorCount"); + late final _sel_activeProcessorCount1 = + _registerName1("activeProcessorCount"); + late final _sel_physicalMemory1 = _registerName1("physicalMemory"); + late final _sel_isOperatingSystemAtLeastVersion_1 = + _registerName1("isOperatingSystemAtLeastVersion:"); + bool _objc_msgSend_386( + ffi.Pointer obj, + ffi.Pointer sel, + NSOperatingSystemVersion version, + ) { + return __objc_msgSend_386( + obj, + sel, + version, + ); + } + + late final __objc_msgSend_386Ptr = _lookup< + ffi.NativeFunction< + ffi.Bool Function(ffi.Pointer, ffi.Pointer, + NSOperatingSystemVersion)>>('objc_msgSend'); + late final __objc_msgSend_386 = __objc_msgSend_386Ptr.asFunction< + bool Function(ffi.Pointer, ffi.Pointer, + NSOperatingSystemVersion)>(); + + late final _sel_systemUptime1 = _registerName1("systemUptime"); + late final _sel_disableSuddenTermination1 = + _registerName1("disableSuddenTermination"); + late final _sel_enableSuddenTermination1 = + _registerName1("enableSuddenTermination"); + late final _sel_disableAutomaticTermination_1 = + _registerName1("disableAutomaticTermination:"); + late final _sel_enableAutomaticTermination_1 = + _registerName1("enableAutomaticTermination:"); + late final _sel_automaticTerminationSupportEnabled1 = + _registerName1("automaticTerminationSupportEnabled"); + late final _sel_setAutomaticTerminationSupportEnabled_1 = + _registerName1("setAutomaticTerminationSupportEnabled:"); + late final _sel_beginActivityWithOptions_reason_1 = + _registerName1("beginActivityWithOptions:reason:"); + ffi.Pointer _objc_msgSend_387( + ffi.Pointer obj, + ffi.Pointer sel, + int options, + ffi.Pointer reason, + ) { + return __objc_msgSend_387( + obj, + sel, + options, + reason, + ); + } + + late final __objc_msgSend_387Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Int32, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_387 = __objc_msgSend_387Ptr.asFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, int, ffi.Pointer)>(); + + late final _sel_endActivity_1 = _registerName1("endActivity:"); + late final _sel_performActivityWithOptions_reason_usingBlock_1 = + _registerName1("performActivityWithOptions:reason:usingBlock:"); + void _objc_msgSend_388( + ffi.Pointer obj, + ffi.Pointer sel, + int options, + ffi.Pointer reason, + ffi.Pointer<_ObjCBlock> block, + ) { + return __objc_msgSend_388( + obj, + sel, + options, + reason, + block, + ); + } + + late final __objc_msgSend_388Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Int32, + ffi.Pointer, + ffi.Pointer<_ObjCBlock>)>>('objc_msgSend'); + late final __objc_msgSend_388 = __objc_msgSend_388Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, int, + ffi.Pointer, ffi.Pointer<_ObjCBlock>)>(); + + late final _sel_performExpiringActivityWithReason_usingBlock_1 = + _registerName1("performExpiringActivityWithReason:usingBlock:"); + void _objc_msgSend_389( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer reason, + ffi.Pointer<_ObjCBlock> block, + ) { + return __objc_msgSend_389( + obj, + sel, + reason, + block, + ); + } + + late final __objc_msgSend_389Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer<_ObjCBlock>)>>('objc_msgSend'); + late final __objc_msgSend_389 = __objc_msgSend_389Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, ffi.Pointer<_ObjCBlock>)>(); + + late final _sel_userName1 = _registerName1("userName"); + late final _sel_fullUserName1 = _registerName1("fullUserName"); + late final _sel_thermalState1 = _registerName1("thermalState"); + int _objc_msgSend_390( + ffi.Pointer obj, + ffi.Pointer sel, + ) { + return __objc_msgSend_390( + obj, + sel, + ); + } + + late final __objc_msgSend_390Ptr = _lookup< + ffi.NativeFunction< + ffi.Int32 Function( + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_390 = __objc_msgSend_390Ptr.asFunction< + int Function(ffi.Pointer, ffi.Pointer)>(); + + late final _sel_isLowPowerModeEnabled1 = + _registerName1("isLowPowerModeEnabled"); + late final _sel_isMacCatalystApp1 = _registerName1("isMacCatalystApp"); + late final _sel_isiOSAppOnMac1 = _registerName1("isiOSAppOnMac"); + late final _class_NSScreen1 = _getClass1("NSScreen"); + late final _sel_screens1 = _registerName1("screens"); + late final _sel_mainScreen1 = _registerName1("mainScreen"); + ffi.Pointer _objc_msgSend_391( + ffi.Pointer obj, + ffi.Pointer sel, + ) { + return __objc_msgSend_391( + obj, + sel, + ); + } + + late final __objc_msgSend_391Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_391 = __objc_msgSend_391Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); + + late final _sel_deepestScreen1 = _registerName1("deepestScreen"); + late final _sel_screensHaveSeparateSpaces1 = + _registerName1("screensHaveSeparateSpaces"); + late final _sel_depth1 = _registerName1("depth"); + int _objc_msgSend_392( + ffi.Pointer obj, + ffi.Pointer sel, + ) { + return __objc_msgSend_392( + obj, + sel, + ); + } + + late final __objc_msgSend_392Ptr = _lookup< + ffi.NativeFunction< + ffi.Int32 Function( + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_392 = __objc_msgSend_392Ptr.asFunction< + int Function(ffi.Pointer, ffi.Pointer)>(); + + late final _sel_frame1 = _registerName1("frame"); + late final _sel_visibleFrame1 = _registerName1("visibleFrame"); + late final _sel_deviceDescription1 = _registerName1("deviceDescription"); + late final _class_NSColorSpace1 = _getClass1("NSColorSpace"); + late final _sel_colorSpace1 = _registerName1("colorSpace"); + ffi.Pointer _objc_msgSend_393( + ffi.Pointer obj, + ffi.Pointer sel, + ) { + return __objc_msgSend_393( + obj, + sel, + ); + } + + late final __objc_msgSend_393Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_393 = __objc_msgSend_393Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); + + late final _sel_supportedWindowDepths1 = + _registerName1("supportedWindowDepths"); + ffi.Pointer _objc_msgSend_394( + ffi.Pointer obj, + ffi.Pointer sel, + ) { + return __objc_msgSend_394( + obj, + sel, + ); + } + + late final __objc_msgSend_394Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_394 = __objc_msgSend_394Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); + + late final _sel_canRepresentDisplayGamut_1 = + _registerName1("canRepresentDisplayGamut:"); + bool _objc_msgSend_395( + ffi.Pointer obj, + ffi.Pointer sel, + int displayGamut, + ) { + return __objc_msgSend_395( + obj, + sel, + displayGamut, + ); + } + + late final __objc_msgSend_395Ptr = _lookup< + ffi.NativeFunction< + ffi.Bool Function(ffi.Pointer, ffi.Pointer, + ffi.Int32)>>('objc_msgSend'); + late final __objc_msgSend_395 = __objc_msgSend_395Ptr.asFunction< + bool Function(ffi.Pointer, ffi.Pointer, int)>(); + + late final _sel_convertRectToBacking_1 = + _registerName1("convertRectToBacking:"); + void _objc_msgSend_396( + ffi.Pointer stret, + ffi.Pointer obj, + ffi.Pointer sel, + CGRect rect, + ) { + return __objc_msgSend_396( + stret, + obj, + sel, + rect, + ); + } + + late final __objc_msgSend_396Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, CGRect)>>('objc_msgSend_stret'); + late final __objc_msgSend_396 = __objc_msgSend_396Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, CGRect)>(); + + late final _sel_convertRectFromBacking_1 = + _registerName1("convertRectFromBacking:"); + late final _sel_backingAlignedRect_options_1 = + _registerName1("backingAlignedRect:options:"); + void _objc_msgSend_397( + ffi.Pointer stret, + ffi.Pointer obj, + ffi.Pointer sel, + CGRect rect, + int options, + ) { + return __objc_msgSend_397( + stret, + obj, + sel, + rect, + options, + ); + } + + late final __objc_msgSend_397Ptr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, CGRect, ffi.Int32)>>('objc_msgSend_stret'); + late final __objc_msgSend_397 = __objc_msgSend_397Ptr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, CGRect, int)>(); + + late final _sel_backingScaleFactor1 = _registerName1("backingScaleFactor"); + late final _sel_localizedName1 = _registerName1("localizedName"); + late final _sel_safeAreaInsets1 = _registerName1("safeAreaInsets"); + late final _sel_auxiliaryTopLeftArea1 = + _registerName1("auxiliaryTopLeftArea"); + late final _sel_auxiliaryTopRightArea1 = + _registerName1("auxiliaryTopRightArea"); + late final _sel_maximumExtendedDynamicRangeColorComponentValue1 = + _registerName1("maximumExtendedDynamicRangeColorComponentValue"); + late final _sel_maximumPotentialExtendedDynamicRangeColorComponentValue1 = + _registerName1("maximumPotentialExtendedDynamicRangeColorComponentValue"); + late final _sel_maximumReferenceExtendedDynamicRangeColorComponentValue1 = + _registerName1("maximumReferenceExtendedDynamicRangeColorComponentValue"); + late final _sel_maximumFramesPerSecond1 = + _registerName1("maximumFramesPerSecond"); + late final _sel_minimumRefreshInterval1 = + _registerName1("minimumRefreshInterval"); + late final _sel_maximumRefreshInterval1 = + _registerName1("maximumRefreshInterval"); + late final _sel_displayUpdateGranularity1 = + _registerName1("displayUpdateGranularity"); + late final _sel_lastDisplayUpdateTimestamp1 = + _registerName1("lastDisplayUpdateTimestamp"); + late final _class_CADisplayLink1 = _getClass1("CADisplayLink"); + late final _sel_displayLinkWithTarget_selector_1 = + _registerName1("displayLinkWithTarget:selector:"); + ffi.Pointer _objc_msgSend_398( + ffi.Pointer obj, + ffi.Pointer sel, + ffi.Pointer target, + ffi.Pointer selector, + ) { + return __objc_msgSend_398( + obj, + sel, + target, + selector, + ); + } + + late final __objc_msgSend_398Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>('objc_msgSend'); + late final __objc_msgSend_398 = __objc_msgSend_398Ptr.asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>(); + + late final _sel_userSpaceScaleFactor1 = + _registerName1("userSpaceScaleFactor"); + + /// ! @const kIOMasterPortDefault + /// @abstract Deprecated name for kIOMainPortDefault. + late final ffi.Pointer _kIOMasterPortDefault = + _lookup('kIOMasterPortDefault'); + + int get kIOMasterPortDefault => _kIOMasterPortDefault.value; + + set kIOMasterPortDefault(int value) => _kIOMasterPortDefault.value = value; + + /// ! @function IOObjectRelease + /// @abstract Releases an object handle previously returned by IOKitLib. + /// @discussion All objects returned by IOKitLib should be released with this function when access to them is no longer needed. Using the object after it has been released may or may not return an error, depending on how many references the task has to the same object in the kernel. + /// @param object The IOKit object to release. + /// @result A kern_return_t error code. + int IOObjectRelease( + int object, + ) { + return _IOObjectRelease( + object, + ); + } + + late final _IOObjectReleasePtr = + _lookup>( + 'IOObjectRelease'); + late final _IOObjectRelease = + _IOObjectReleasePtr.asFunction(); + + /// ! + /// @function IOServiceGetMatchingService + /// @abstract Look up a registered IOService object that matches a matching dictionary. + /// @discussion This is the preferred method of finding IOService objects currently registered by IOKit (that is, objects that have had their registerService() methods invoked). To find IOService objects that aren't yet registered, use an iterator as created by IORegistryEntryCreateIterator(). IOServiceAddMatchingNotification can also supply this information and install a notification of new IOServices. The matching information used in the matching dictionary may vary depending on the class of service being looked up. + /// @param mainPort The main port obtained from IOMainPort(). Pass kIOMainPortDefault to look up the default main port. + /// @param matching A CF dictionary containing matching information, of which one reference is always consumed by this function (Note prior to the Tiger release there was a small chance that the dictionary might not be released if there was an error attempting to serialize the dictionary). IOKitLib can construct matching dictionaries for common criteria with helper functions such as IOServiceMatching, IOServiceNameMatching, IOBSDNameMatching. + /// @result The first service matched is returned on success. The service must be released by the caller. + int IOServiceGetMatchingService( + int mainPort, + ffi.Pointer matching, + ) { + return _IOServiceGetMatchingService( + mainPort, + matching, + ); + } + + late final _IOServiceGetMatchingServicePtr = _lookup< + ffi.NativeFunction< + ffi.UnsignedInt Function(ffi.UnsignedInt, + ffi.Pointer)>>('IOServiceGetMatchingService'); + late final _IOServiceGetMatchingService = _IOServiceGetMatchingServicePtr + .asFunction)>(); + + /// ! @function IORegistryEntryCreateCFProperty + /// @abstract Create a CF representation of a registry entry's property. + /// @discussion This function creates an instantaneous snapshot of a registry entry property, creating a CF container analogue in the caller's task. Not every object available in the kernel is represented as a CF container; currently OSDictionary, OSArray, OSSet, OSSymbol, OSString, OSData, OSNumber, OSBoolean are created as their CF counterparts. + /// @param entry The registry entry handle whose property to copy. + /// @param key A CFString specifying the property name. + /// @param allocator The CF allocator to use when creating the CF container. + /// @param options No options are currently defined. + /// @result A CF container is created and returned the caller on success. The caller should release with CFRelease. + CFTypeRef1 IORegistryEntryCreateCFProperty( + int entry, + ffi.Pointer key, + ffi.Pointer<__CFAllocator> allocator, + int options, + ) { + return _IORegistryEntryCreateCFProperty( + entry, + key, + allocator, + options, + ); + } + + late final _IORegistryEntryCreateCFPropertyPtr = _lookup< + ffi.NativeFunction< + CFTypeRef1 Function( + ffi.UnsignedInt, + ffi.Pointer, + ffi.Pointer<__CFAllocator>, + ffi.UnsignedInt)>>('IORegistryEntryCreateCFProperty'); + late final _IORegistryEntryCreateCFProperty = + _IORegistryEntryCreateCFPropertyPtr.asFunction< + CFTypeRef1 Function( + int, ffi.Pointer, ffi.Pointer<__CFAllocator>, int)>(); + + /// ! @function IOServiceMatching + /// @abstract Create a matching dictionary that specifies an IOService class match. + /// @discussion A very common matching criteria for IOService is based on its class. IOServiceMatching will create a matching dictionary that specifies any IOService of a class, or its subclasses. The class is specified by C-string name. + /// @param name The class name, as a const C-string. Class matching is successful on IOService's of this class or any subclass. + /// @result The matching dictionary created, is returned on success, or zero on failure. The dictionary is commonly passed to IOServiceGetMatchingServices or IOServiceAddNotification which will consume a reference, otherwise it should be released with CFRelease by the caller. + ffi.Pointer IOServiceMatching( + ffi.Pointer name, + ) { + return _IOServiceMatching( + name, + ); + } + + late final _IOServiceMatchingPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer)>>('IOServiceMatching'); + late final _IOServiceMatching = _IOServiceMatchingPtr.asFunction< + ffi.Pointer Function(ffi.Pointer)>(); +} + +final class utsname extends ffi.Struct { + /// [XSI] Name of OS + @ffi.Array.multi([256]) + external ffi.Array sysname; + + /// [XSI] Name of this network node + @ffi.Array.multi([256]) + external ffi.Array nodename; + + /// [XSI] Release level + @ffi.Array.multi([256]) + external ffi.Array release; + + /// [XSI] Version level + @ffi.Array.multi([256]) + external ffi.Array version; + + /// [XSI] Hardware type + @ffi.Array.multi([256]) + external ffi.Array machine; +} + +final class __CFAllocator extends ffi.Opaque {} + +/// Base "type" of all "CF objects", and polymorphic functions on them +typedef CFTypeRef = ffi.Pointer; + +final class CFDictionary extends ffi.Opaque {} + +final class CFDictionaryKeyCallBacks extends ffi.Struct { + @ffi.Long() + external int version; + + external ffi.Pointer< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer<__CFAllocator>, ffi.Pointer)>> retain; + + external ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer<__CFAllocator>, ffi.Pointer)>> release; + + external ffi.Pointer< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>> + copyDescription; + + external ffi.Pointer< + ffi.NativeFunction< + ffi.UnsignedChar Function( + ffi.Pointer, ffi.Pointer)>> equal; + + external ffi.Pointer< + ffi.NativeFunction)>> + hash; +} + +final class CFString extends ffi.Opaque {} + +final class CFDictionaryValueCallBacks extends ffi.Struct { + @ffi.Long() + external int version; + + external ffi.Pointer< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer<__CFAllocator>, ffi.Pointer)>> retain; + + external ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer<__CFAllocator>, ffi.Pointer)>> release; + + external ffi.Pointer< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>> + copyDescription; + + external ffi.Pointer< + ffi.NativeFunction< + ffi.UnsignedChar Function( + ffi.Pointer, ffi.Pointer)>> equal; +} + +final class CFData extends ffi.Opaque {} + +abstract class CFStringBuiltInEncodings { + static const int kCFStringEncodingMacRoman = 0; + static const int kCFStringEncodingWindowsLatin1 = 1280; + static const int kCFStringEncodingISOLatin1 = 513; + static const int kCFStringEncodingNextStepLatin = 2817; + static const int kCFStringEncodingASCII = 1536; + static const int kCFStringEncodingUnicode = 256; + static const int kCFStringEncodingUTF8 = 134217984; + static const int kCFStringEncodingNonLossyASCII = 3071; + static const int kCFStringEncodingUTF16 = 256; + static const int kCFStringEncodingUTF16BE = 268435712; + static const int kCFStringEncodingUTF16LE = 335544576; + static const int kCFStringEncodingUTF32 = 201326848; + static const int kCFStringEncodingUTF32BE = 402653440; + static const int kCFStringEncodingUTF32LE = 469762304; +} + +class _ObjCWrapper implements ffi.Finalizable { + final ffi.Pointer _id; + final NativeMacOsFramework _lib; + bool _pendingRelease; + + _ObjCWrapper._(this._id, this._lib, + {bool retain = false, bool release = false}) + : _pendingRelease = release { + if (retain) { + _lib._objc_retain(_id.cast()); + } + if (release) { + _lib._objc_releaseFinalizer2.attach(this, _id.cast(), detach: this); + } + } + + /// Releases the reference to the underlying ObjC object held by this wrapper. + /// Throws a StateError if this wrapper doesn't currently hold a reference. + void release() { + if (_pendingRelease) { + _pendingRelease = false; + _lib._objc_release(_id.cast()); + _lib._objc_releaseFinalizer2.detach(this); + } else { + throw StateError( + 'Released an ObjC object that was unowned or already released.'); + } + } + + @override + bool operator ==(Object other) { + return other is _ObjCWrapper && _id == other._id; + } + + @override + int get hashCode => _id.hashCode; + + /// Return a pointer to this object. + ffi.Pointer get pointer => _id; + + ffi.Pointer _retainAndReturnId() { + _lib._objc_retain(_id.cast()); + return _id; + } +} + +class NSObject extends _ObjCWrapper { + NSObject._(ffi.Pointer id, NativeMacOsFramework lib, + {bool retain = false, bool release = false}) + : super._(id, lib, retain: retain, release: release); + + /// Returns a [NSObject] that points to the same underlying object as [other]. + static NSObject castFrom(T other) { + return NSObject._(other._id, other._lib, retain: true, release: true); + } + + /// Returns a [NSObject] that wraps the given raw object pointer. + static NSObject castFromPointer( + NativeMacOsFramework lib, ffi.Pointer other, + {bool retain = false, bool release = false}) { + return NSObject._(other, lib, retain: retain, release: release); + } + + /// Returns whether [obj] is an instance of [NSObject]. + static bool isInstance(_ObjCWrapper obj) { + return obj._lib._objc_msgSend_0( + obj._id, obj._lib._sel_isKindOfClass_1, obj._lib._class_NSObject1); + } + + static void load(NativeMacOsFramework _lib) { + _lib._objc_msgSend_1(_lib._class_NSObject1, _lib._sel_load1); + } + + static void initialize(NativeMacOsFramework _lib) { + _lib._objc_msgSend_1(_lib._class_NSObject1, _lib._sel_initialize1); + } + + NSObject init() { + final _ret = _lib._objc_msgSend_2(_id, _lib._sel_init1); + return NSObject._(_ret, _lib, retain: true, release: true); + } + + static NSObject new1(NativeMacOsFramework _lib) { + final _ret = _lib._objc_msgSend_2(_lib._class_NSObject1, _lib._sel_new1); + return NSObject._(_ret, _lib, retain: false, release: true); + } + + static NSObject allocWithZone_( + NativeMacOsFramework _lib, ffi.Pointer<_NSZone> zone) { + final _ret = _lib._objc_msgSend_3( + _lib._class_NSObject1, _lib._sel_allocWithZone_1, zone); + return NSObject._(_ret, _lib, retain: false, release: true); + } + + static NSObject alloc(NativeMacOsFramework _lib) { + final _ret = _lib._objc_msgSend_2(_lib._class_NSObject1, _lib._sel_alloc1); + return NSObject._(_ret, _lib, retain: false, release: true); + } + + void dealloc() { + _lib._objc_msgSend_1(_id, _lib._sel_dealloc1); + } + + void finalize() { + _lib._objc_msgSend_1(_id, _lib._sel_finalize1); + } + + NSObject copy() { + final _ret = _lib._objc_msgSend_2(_id, _lib._sel_copy1); + return NSObject._(_ret, _lib, retain: false, release: true); + } + + NSObject mutableCopy() { + final _ret = _lib._objc_msgSend_2(_id, _lib._sel_mutableCopy1); + return NSObject._(_ret, _lib, retain: false, release: true); + } + + static NSObject copyWithZone_( + NativeMacOsFramework _lib, ffi.Pointer<_NSZone> zone) { + final _ret = _lib._objc_msgSend_3( + _lib._class_NSObject1, _lib._sel_copyWithZone_1, zone); + return NSObject._(_ret, _lib, retain: false, release: true); + } + + static NSObject mutableCopyWithZone_( + NativeMacOsFramework _lib, ffi.Pointer<_NSZone> zone) { + final _ret = _lib._objc_msgSend_3( + _lib._class_NSObject1, _lib._sel_mutableCopyWithZone_1, zone); + return NSObject._(_ret, _lib, retain: false, release: true); + } + + static bool instancesRespondToSelector_( + NativeMacOsFramework _lib, ffi.Pointer aSelector) { + return _lib._objc_msgSend_4(_lib._class_NSObject1, + _lib._sel_instancesRespondToSelector_1, aSelector); + } + + static bool conformsToProtocol_( + NativeMacOsFramework _lib, Protocol protocol) { + return _lib._objc_msgSend_5( + _lib._class_NSObject1, _lib._sel_conformsToProtocol_1, protocol._id); + } + + ffi.Pointer> methodForSelector_( + ffi.Pointer aSelector) { + return _lib._objc_msgSend_6(_id, _lib._sel_methodForSelector_1, aSelector); + } + + static ffi.Pointer> + instanceMethodForSelector_( + NativeMacOsFramework _lib, ffi.Pointer aSelector) { + return _lib._objc_msgSend_6(_lib._class_NSObject1, + _lib._sel_instanceMethodForSelector_1, aSelector); + } + + void doesNotRecognizeSelector_(ffi.Pointer aSelector) { + _lib._objc_msgSend_7(_id, _lib._sel_doesNotRecognizeSelector_1, aSelector); + } + + NSObject forwardingTargetForSelector_(ffi.Pointer aSelector) { + final _ret = _lib._objc_msgSend_8( + _id, _lib._sel_forwardingTargetForSelector_1, aSelector); + return NSObject._(_ret, _lib, retain: true, release: true); + } + + void forwardInvocation_(NSInvocation anInvocation) { + _lib._objc_msgSend_9(_id, _lib._sel_forwardInvocation_1, anInvocation._id); + } + + NSMethodSignature methodSignatureForSelector_( + ffi.Pointer aSelector) { + final _ret = _lib._objc_msgSend_10( + _id, _lib._sel_methodSignatureForSelector_1, aSelector); + return NSMethodSignature._(_ret, _lib, retain: true, release: true); + } + + static NSMethodSignature instanceMethodSignatureForSelector_( + NativeMacOsFramework _lib, ffi.Pointer aSelector) { + final _ret = _lib._objc_msgSend_10(_lib._class_NSObject1, + _lib._sel_instanceMethodSignatureForSelector_1, aSelector); + return NSMethodSignature._(_ret, _lib, retain: true, release: true); + } + + bool allowsWeakReference() { + return _lib._objc_msgSend_11(_id, _lib._sel_allowsWeakReference1); + } + + bool retainWeakReference() { + return _lib._objc_msgSend_11(_id, _lib._sel_retainWeakReference1); + } + + static bool isSubclassOfClass_(NativeMacOsFramework _lib, NSObject aClass) { + return _lib._objc_msgSend_0( + _lib._class_NSObject1, _lib._sel_isSubclassOfClass_1, aClass._id); + } + + static bool resolveClassMethod_( + NativeMacOsFramework _lib, ffi.Pointer sel) { + return _lib._objc_msgSend_4( + _lib._class_NSObject1, _lib._sel_resolveClassMethod_1, sel); + } + + static bool resolveInstanceMethod_( + NativeMacOsFramework _lib, ffi.Pointer sel) { + return _lib._objc_msgSend_4( + _lib._class_NSObject1, _lib._sel_resolveInstanceMethod_1, sel); + } + + static int hash(NativeMacOsFramework _lib) { + return _lib._objc_msgSend_12(_lib._class_NSObject1, _lib._sel_hash1); + } + + static NSObject superclass(NativeMacOsFramework _lib) { + final _ret = + _lib._objc_msgSend_2(_lib._class_NSObject1, _lib._sel_superclass1); + return NSObject._(_ret, _lib, retain: true, release: true); + } + + static NSObject class1(NativeMacOsFramework _lib) { + final _ret = _lib._objc_msgSend_2(_lib._class_NSObject1, _lib._sel_class1); + return NSObject._(_ret, _lib, retain: true, release: true); + } + + static NSString description(NativeMacOsFramework _lib) { + final _ret = + _lib._objc_msgSend_57(_lib._class_NSObject1, _lib._sel_description1); + return NSString._(_ret, _lib, retain: true, release: true); + } + + static NSString debugDescription(NativeMacOsFramework _lib) { + final _ret = _lib._objc_msgSend_57( + _lib._class_NSObject1, _lib._sel_debugDescription1); + return NSString._(_ret, _lib, retain: true, release: true); + } + + static int version(NativeMacOsFramework _lib) { + return _lib._objc_msgSend_200(_lib._class_NSObject1, _lib._sel_version1); + } + + static void setVersion_(NativeMacOsFramework _lib, int aVersion) { + _lib._objc_msgSend_252( + _lib._class_NSObject1, _lib._sel_setVersion_1, aVersion); + } + + NSObject get classForCoder { + final _ret = _lib._objc_msgSend_2(_id, _lib._sel_classForCoder1); + return NSObject._(_ret, _lib, retain: true, release: true); + } + + NSObject? replacementObjectForCoder_(NSCoder coder) { + final _ret = _lib._objc_msgSend_53( + _id, _lib._sel_replacementObjectForCoder_1, coder._id); + return _ret.address == 0 + ? null + : NSObject._(_ret, _lib, retain: true, release: true); + } + + NSObject? awakeAfterUsingCoder_(NSCoder coder) { + final _ret = + _lib._objc_msgSend_53(_id, _lib._sel_awakeAfterUsingCoder_1, coder._id); + return _ret.address == 0 + ? null + : NSObject._(_ret, _lib, retain: false, release: true); + } + + static void poseAsClass_(NativeMacOsFramework _lib, NSObject aClass) { + _lib._objc_msgSend_21( + _lib._class_NSObject1, _lib._sel_poseAsClass_1, aClass._id); + } + + NSObject get autoContentAccessingProxy { + final _ret = + _lib._objc_msgSend_2(_id, _lib._sel_autoContentAccessingProxy1); + return NSObject._(_ret, _lib, retain: true, release: true); + } +} + +final class ObjCSel extends ffi.Opaque {} + +final class ObjCObject extends ffi.Opaque {} + +typedef instancetype = ffi.Pointer; +typedef Dartinstancetype = NSObject; + +final class _NSZone extends ffi.Opaque {} + +class Protocol extends _ObjCWrapper { + Protocol._(ffi.Pointer id, NativeMacOsFramework lib, + {bool retain = false, bool release = false}) + : super._(id, lib, retain: retain, release: release); + + /// Returns a [Protocol] that points to the same underlying object as [other]. + static Protocol castFrom(T other) { + return Protocol._(other._id, other._lib, retain: true, release: true); + } + + /// Returns a [Protocol] that wraps the given raw object pointer. + static Protocol castFromPointer( + NativeMacOsFramework lib, ffi.Pointer other, + {bool retain = false, bool release = false}) { + return Protocol._(other, lib, retain: retain, release: release); + } + + /// Returns whether [obj] is an instance of [Protocol]. + static bool isInstance(_ObjCWrapper obj) { + return obj._lib._objc_msgSend_0( + obj._id, obj._lib._sel_isKindOfClass_1, obj._lib._class_Protocol1); + } +} + +class NSInvocation extends _ObjCWrapper { + NSInvocation._(ffi.Pointer id, NativeMacOsFramework lib, + {bool retain = false, bool release = false}) + : super._(id, lib, retain: retain, release: release); + + /// Returns a [NSInvocation] that points to the same underlying object as [other]. + static NSInvocation castFrom(T other) { + return NSInvocation._(other._id, other._lib, retain: true, release: true); + } + + /// Returns a [NSInvocation] that wraps the given raw object pointer. + static NSInvocation castFromPointer( + NativeMacOsFramework lib, ffi.Pointer other, + {bool retain = false, bool release = false}) { + return NSInvocation._(other, lib, retain: retain, release: release); + } + + /// Returns whether [obj] is an instance of [NSInvocation]. + static bool isInstance(_ObjCWrapper obj) { + return obj._lib._objc_msgSend_0( + obj._id, obj._lib._sel_isKindOfClass_1, obj._lib._class_NSInvocation1); + } +} + +class NSMethodSignature extends _ObjCWrapper { + NSMethodSignature._(ffi.Pointer id, NativeMacOsFramework lib, + {bool retain = false, bool release = false}) + : super._(id, lib, retain: retain, release: release); + + /// Returns a [NSMethodSignature] that points to the same underlying object as [other]. + static NSMethodSignature castFrom(T other) { + return NSMethodSignature._(other._id, other._lib, + retain: true, release: true); + } + + /// Returns a [NSMethodSignature] that wraps the given raw object pointer. + static NSMethodSignature castFromPointer( + NativeMacOsFramework lib, ffi.Pointer other, + {bool retain = false, bool release = false}) { + return NSMethodSignature._(other, lib, retain: retain, release: release); + } + + /// Returns whether [obj] is an instance of [NSMethodSignature]. + static bool isInstance(_ObjCWrapper obj) { + return obj._lib._objc_msgSend_0(obj._id, obj._lib._sel_isKindOfClass_1, + obj._lib._class_NSMethodSignature1); + } +} + +class NSString extends NSObject { + NSString._(ffi.Pointer id, NativeMacOsFramework lib, + {bool retain = false, bool release = false}) + : super._(id, lib, retain: retain, release: release); + + /// Returns a [NSString] that points to the same underlying object as [other]. + static NSString castFrom(T other) { + return NSString._(other._id, other._lib, retain: true, release: true); + } + + /// Returns a [NSString] that wraps the given raw object pointer. + static NSString castFromPointer( + NativeMacOsFramework lib, ffi.Pointer other, + {bool retain = false, bool release = false}) { + return NSString._(other, lib, retain: retain, release: release); + } + + /// Returns whether [obj] is an instance of [NSString]. + static bool isInstance(_ObjCWrapper obj) { + return obj._lib._objc_msgSend_0( + obj._id, obj._lib._sel_isKindOfClass_1, obj._lib._class_NSString1); + } + + factory NSString(NativeMacOsFramework _lib, String str) { + final cstr = str.toNativeUtf16(); + final nsstr = stringWithCharacters_length_(_lib, cstr.cast(), str.length); + pkg_ffi.calloc.free(cstr); + return nsstr; + } + + @override + String toString() { + final data = + dataUsingEncoding_(0x94000100 /* NSUTF16LittleEndianStringEncoding */); + return data!.bytes.cast().toDartString(length: length); + } + + int get length { + return _lib._objc_msgSend_12(_id, _lib._sel_length1); + } + + int characterAtIndex_(int index) { + return _lib._objc_msgSend_13(_id, _lib._sel_characterAtIndex_1, index); + } + + @override + NSString init() { + final _ret = _lib._objc_msgSend_2(_id, _lib._sel_init1); + return NSString._(_ret, _lib, retain: true, release: true); + } + + NSString? initWithCoder_(NSCoder coder) { + final _ret = + _lib._objc_msgSend_53(_id, _lib._sel_initWithCoder_1, coder._id); + return _ret.address == 0 + ? null + : NSString._(_ret, _lib, retain: true, release: true); + } + + NSString substringFromIndex_(int from) { + final _ret = + _lib._objc_msgSend_169(_id, _lib._sel_substringFromIndex_1, from); + return NSString._(_ret, _lib, retain: true, release: true); + } + + NSString substringToIndex_(int to) { + final _ret = _lib._objc_msgSend_169(_id, _lib._sel_substringToIndex_1, to); + return NSString._(_ret, _lib, retain: true, release: true); + } + + NSString substringWithRange_(_NSRange range) { + final _ret = + _lib._objc_msgSend_170(_id, _lib._sel_substringWithRange_1, range); + return NSString._(_ret, _lib, retain: true, release: true); + } + + void getCharacters_range_( + ffi.Pointer buffer, _NSRange range) { + _lib._objc_msgSend_171(_id, _lib._sel_getCharacters_range_1, buffer, range); + } + + int compare_(NSString string) { + return _lib._objc_msgSend_172(_id, _lib._sel_compare_1, string._id); + } + + int compare_options_(NSString string, int mask) { + return _lib._objc_msgSend_173( + _id, _lib._sel_compare_options_1, string._id, mask); + } + + int compare_options_range_( + NSString string, int mask, _NSRange rangeOfReceiverToCompare) { + return _lib._objc_msgSend_174(_id, _lib._sel_compare_options_range_1, + string._id, mask, rangeOfReceiverToCompare); + } + + int compare_options_range_locale_(NSString string, int mask, + _NSRange rangeOfReceiverToCompare, NSObject? locale) { + return _lib._objc_msgSend_175(_id, _lib._sel_compare_options_range_locale_1, + string._id, mask, rangeOfReceiverToCompare, locale?._id ?? ffi.nullptr); + } + + int caseInsensitiveCompare_(NSString string) { + return _lib._objc_msgSend_172( + _id, _lib._sel_caseInsensitiveCompare_1, string._id); + } + + int localizedCompare_(NSString string) { + return _lib._objc_msgSend_172( + _id, _lib._sel_localizedCompare_1, string._id); + } + + int localizedCaseInsensitiveCompare_(NSString string) { + return _lib._objc_msgSend_172( + _id, _lib._sel_localizedCaseInsensitiveCompare_1, string._id); + } + + int localizedStandardCompare_(NSString string) { + return _lib._objc_msgSend_172( + _id, _lib._sel_localizedStandardCompare_1, string._id); + } + + bool isEqualToString_(NSString aString) { + return _lib._objc_msgSend_39(_id, _lib._sel_isEqualToString_1, aString._id); + } + + bool hasPrefix_(NSString str) { + return _lib._objc_msgSend_39(_id, _lib._sel_hasPrefix_1, str._id); + } + + bool hasSuffix_(NSString str) { + return _lib._objc_msgSend_39(_id, _lib._sel_hasSuffix_1, str._id); + } + + NSString commonPrefixWithString_options_(NSString str, int mask) { + final _ret = _lib._objc_msgSend_176( + _id, _lib._sel_commonPrefixWithString_options_1, str._id, mask); + return NSString._(_ret, _lib, retain: true, release: true); + } + + bool containsString_(NSString str) { + return _lib._objc_msgSend_39(_id, _lib._sel_containsString_1, str._id); + } + + bool localizedCaseInsensitiveContainsString_(NSString str) { + return _lib._objc_msgSend_39( + _id, _lib._sel_localizedCaseInsensitiveContainsString_1, str._id); + } + + bool localizedStandardContainsString_(NSString str) { + return _lib._objc_msgSend_39( + _id, _lib._sel_localizedStandardContainsString_1, str._id); + } + + void localizedStandardRangeOfString_( + ffi.Pointer<_NSRange> stret, NSString str) { + _lib._objc_msgSend_177( + stret, _id, _lib._sel_localizedStandardRangeOfString_1, str._id); + } + + void rangeOfString_(ffi.Pointer<_NSRange> stret, NSString searchString) { + _lib._objc_msgSend_177( + stret, _id, _lib._sel_rangeOfString_1, searchString._id); + } + + void rangeOfString_options_( + ffi.Pointer<_NSRange> stret, NSString searchString, int mask) { + _lib._objc_msgSend_178( + stret, _id, _lib._sel_rangeOfString_options_1, searchString._id, mask); + } + + void rangeOfString_options_range_(ffi.Pointer<_NSRange> stret, + NSString searchString, int mask, _NSRange rangeOfReceiverToSearch) { + _lib._objc_msgSend_179(stret, _id, _lib._sel_rangeOfString_options_range_1, + searchString._id, mask, rangeOfReceiverToSearch); + } + + void rangeOfString_options_range_locale_( + ffi.Pointer<_NSRange> stret, + NSString searchString, + int mask, + _NSRange rangeOfReceiverToSearch, + NSLocale? locale) { + _lib._objc_msgSend_191( + stret, + _id, + _lib._sel_rangeOfString_options_range_locale_1, + searchString._id, + mask, + rangeOfReceiverToSearch, + locale?._id ?? ffi.nullptr); + } + + void rangeOfCharacterFromSet_( + ffi.Pointer<_NSRange> stret, NSCharacterSet searchSet) { + _lib._objc_msgSend_192( + stret, _id, _lib._sel_rangeOfCharacterFromSet_1, searchSet._id); + } + + void rangeOfCharacterFromSet_options_( + ffi.Pointer<_NSRange> stret, NSCharacterSet searchSet, int mask) { + _lib._objc_msgSend_193(stret, _id, + _lib._sel_rangeOfCharacterFromSet_options_1, searchSet._id, mask); + } + + void rangeOfCharacterFromSet_options_range_(ffi.Pointer<_NSRange> stret, + NSCharacterSet searchSet, int mask, _NSRange rangeOfReceiverToSearch) { + _lib._objc_msgSend_194( + stret, + _id, + _lib._sel_rangeOfCharacterFromSet_options_range_1, + searchSet._id, + mask, + rangeOfReceiverToSearch); + } + + void rangeOfComposedCharacterSequenceAtIndex_( + ffi.Pointer<_NSRange> stret, int index) { + _lib._objc_msgSend_195( + stret, _id, _lib._sel_rangeOfComposedCharacterSequenceAtIndex_1, index); + } + + void rangeOfComposedCharacterSequencesForRange_( + ffi.Pointer<_NSRange> stret, _NSRange range) { + _lib._objc_msgSend_196(stret, _id, + _lib._sel_rangeOfComposedCharacterSequencesForRange_1, range); + } + + NSString stringByAppendingString_(NSString aString) { + final _ret = _lib._objc_msgSend_56( + _id, _lib._sel_stringByAppendingString_1, aString._id); + return NSString._(_ret, _lib, retain: true, release: true); + } + + NSString stringByAppendingFormat_(NSString format) { + final _ret = _lib._objc_msgSend_56( + _id, _lib._sel_stringByAppendingFormat_1, format._id); + return NSString._(_ret, _lib, retain: true, release: true); + } + + double get doubleValue { + return _lib._objc_msgSend_197(_id, _lib._sel_doubleValue1); + } + + double get floatValue { + return _lib._objc_msgSend_198(_id, _lib._sel_floatValue1); + } + + int get intValue { + return _lib._objc_msgSend_199(_id, _lib._sel_intValue1); + } + + int get integerValue { + return _lib._objc_msgSend_200(_id, _lib._sel_integerValue1); + } + + int get longLongValue { + return _lib._objc_msgSend_201(_id, _lib._sel_longLongValue1); + } + + bool get boolValue { + return _lib._objc_msgSend_11(_id, _lib._sel_boolValue1); + } + + NSString get uppercaseString { + final _ret = _lib._objc_msgSend_57(_id, _lib._sel_uppercaseString1); + return NSString._(_ret, _lib, retain: true, release: true); + } + + NSString get lowercaseString { + final _ret = _lib._objc_msgSend_57(_id, _lib._sel_lowercaseString1); + return NSString._(_ret, _lib, retain: true, release: true); + } + + NSString get capitalizedString { + final _ret = _lib._objc_msgSend_57(_id, _lib._sel_capitalizedString1); + return NSString._(_ret, _lib, retain: true, release: true); + } + + NSString get localizedUppercaseString { + final _ret = + _lib._objc_msgSend_57(_id, _lib._sel_localizedUppercaseString1); + return NSString._(_ret, _lib, retain: true, release: true); + } + + NSString get localizedLowercaseString { + final _ret = + _lib._objc_msgSend_57(_id, _lib._sel_localizedLowercaseString1); + return NSString._(_ret, _lib, retain: true, release: true); + } + + NSString get localizedCapitalizedString { + final _ret = + _lib._objc_msgSend_57(_id, _lib._sel_localizedCapitalizedString1); + return NSString._(_ret, _lib, retain: true, release: true); + } + + NSString uppercaseStringWithLocale_(NSLocale? locale) { + final _ret = _lib._objc_msgSend_202( + _id, _lib._sel_uppercaseStringWithLocale_1, locale?._id ?? ffi.nullptr); + return NSString._(_ret, _lib, retain: true, release: true); + } + + NSString lowercaseStringWithLocale_(NSLocale? locale) { + final _ret = _lib._objc_msgSend_202( + _id, _lib._sel_lowercaseStringWithLocale_1, locale?._id ?? ffi.nullptr); + return NSString._(_ret, _lib, retain: true, release: true); + } + + NSString capitalizedStringWithLocale_(NSLocale? locale) { + final _ret = _lib._objc_msgSend_202(_id, + _lib._sel_capitalizedStringWithLocale_1, locale?._id ?? ffi.nullptr); + return NSString._(_ret, _lib, retain: true, release: true); + } + + void getLineStart_end_contentsEnd_forRange_( + ffi.Pointer startPtr, + ffi.Pointer lineEndPtr, + ffi.Pointer contentsEndPtr, + _NSRange range) { + _lib._objc_msgSend_203( + _id, + _lib._sel_getLineStart_end_contentsEnd_forRange_1, + startPtr, + lineEndPtr, + contentsEndPtr, + range); + } + + void lineRangeForRange_(ffi.Pointer<_NSRange> stret, _NSRange range) { + _lib._objc_msgSend_196(stret, _id, _lib._sel_lineRangeForRange_1, range); + } + + void getParagraphStart_end_contentsEnd_forRange_( + ffi.Pointer startPtr, + ffi.Pointer parEndPtr, + ffi.Pointer contentsEndPtr, + _NSRange range) { + _lib._objc_msgSend_203( + _id, + _lib._sel_getParagraphStart_end_contentsEnd_forRange_1, + startPtr, + parEndPtr, + contentsEndPtr, + range); + } + + void paragraphRangeForRange_(ffi.Pointer<_NSRange> stret, _NSRange range) { + _lib._objc_msgSend_196( + stret, _id, _lib._sel_paragraphRangeForRange_1, range); + } + + void enumerateSubstringsInRange_options_usingBlock_(_NSRange range, int opts, + ObjCBlock_ffiVoid_NSString_NSRange_NSRange_bool block) { + _lib._objc_msgSend_204( + _id, + _lib._sel_enumerateSubstringsInRange_options_usingBlock_1, + range, + opts, + block._id); + } + + void enumerateLinesUsingBlock_(ObjCBlock_ffiVoid_NSString_bool block) { + _lib._objc_msgSend_205( + _id, _lib._sel_enumerateLinesUsingBlock_1, block._id); + } + + ffi.Pointer get UTF8String { + return _lib._objc_msgSend_206(_id, _lib._sel_UTF8String1); + } + + int get fastestEncoding { + return _lib._objc_msgSend_12(_id, _lib._sel_fastestEncoding1); + } + + int get smallestEncoding { + return _lib._objc_msgSend_12(_id, _lib._sel_smallestEncoding1); + } + + NSData? dataUsingEncoding_allowLossyConversion_(int encoding, bool lossy) { + final _ret = _lib._objc_msgSend_207(_id, + _lib._sel_dataUsingEncoding_allowLossyConversion_1, encoding, lossy); + return _ret.address == 0 + ? null + : NSData._(_ret, _lib, retain: true, release: true); + } + + NSData? dataUsingEncoding_(int encoding) { + final _ret = + _lib._objc_msgSend_208(_id, _lib._sel_dataUsingEncoding_1, encoding); + return _ret.address == 0 + ? null + : NSData._(_ret, _lib, retain: true, release: true); + } + + bool canBeConvertedToEncoding_(int encoding) { + return _lib._objc_msgSend_79( + _id, _lib._sel_canBeConvertedToEncoding_1, encoding); + } + + ffi.Pointer cStringUsingEncoding_(int encoding) { + return _lib._objc_msgSend_209( + _id, _lib._sel_cStringUsingEncoding_1, encoding); + } + + bool getCString_maxLength_encoding_( + ffi.Pointer buffer, int maxBufferCount, int encoding) { + return _lib._objc_msgSend_210( + _id, + _lib._sel_getCString_maxLength_encoding_1, + buffer, + maxBufferCount, + encoding); + } + + bool getBytes_maxLength_usedLength_encoding_options_range_remainingRange_( + ffi.Pointer buffer, + int maxBufferCount, + ffi.Pointer usedBufferCount, + int encoding, + int options, + _NSRange range, + ffi.Pointer<_NSRange> leftover) { + return _lib._objc_msgSend_211( + _id, + _lib._sel_getBytes_maxLength_usedLength_encoding_options_range_remainingRange_1, + buffer, + maxBufferCount, + usedBufferCount, + encoding, + options, + range, + leftover); + } + + int maximumLengthOfBytesUsingEncoding_(int enc) { + return _lib._objc_msgSend_76( + _id, _lib._sel_maximumLengthOfBytesUsingEncoding_1, enc); + } + + int lengthOfBytesUsingEncoding_(int enc) { + return _lib._objc_msgSend_76( + _id, _lib._sel_lengthOfBytesUsingEncoding_1, enc); + } + + static ffi.Pointer getAvailableStringEncodings( + NativeMacOsFramework _lib) { + return _lib._objc_msgSend_212( + _lib._class_NSString1, _lib._sel_availableStringEncodings1); + } + + static NSString localizedNameOfStringEncoding_( + NativeMacOsFramework _lib, int encoding) { + final _ret = _lib._objc_msgSend_169(_lib._class_NSString1, + _lib._sel_localizedNameOfStringEncoding_1, encoding); + return NSString._(_ret, _lib, retain: true, release: true); + } + + static int getDefaultCStringEncoding(NativeMacOsFramework _lib) { + return _lib._objc_msgSend_12( + _lib._class_NSString1, _lib._sel_defaultCStringEncoding1); + } + + NSString get decomposedStringWithCanonicalMapping { + final _ret = _lib._objc_msgSend_57( + _id, _lib._sel_decomposedStringWithCanonicalMapping1); + return NSString._(_ret, _lib, retain: true, release: true); + } + + NSString get precomposedStringWithCanonicalMapping { + final _ret = _lib._objc_msgSend_57( + _id, _lib._sel_precomposedStringWithCanonicalMapping1); + return NSString._(_ret, _lib, retain: true, release: true); + } + + NSString get decomposedStringWithCompatibilityMapping { + final _ret = _lib._objc_msgSend_57( + _id, _lib._sel_decomposedStringWithCompatibilityMapping1); + return NSString._(_ret, _lib, retain: true, release: true); + } + + NSString get precomposedStringWithCompatibilityMapping { + final _ret = _lib._objc_msgSend_57( + _id, _lib._sel_precomposedStringWithCompatibilityMapping1); + return NSString._(_ret, _lib, retain: true, release: true); + } + + NSArray componentsSeparatedByString_(NSString separator) { + final _ret = _lib._objc_msgSend_213( + _id, _lib._sel_componentsSeparatedByString_1, separator._id); + return NSArray._(_ret, _lib, retain: true, release: true); + } + + NSArray componentsSeparatedByCharactersInSet_(NSCharacterSet separator) { + final _ret = _lib._objc_msgSend_214( + _id, _lib._sel_componentsSeparatedByCharactersInSet_1, separator._id); + return NSArray._(_ret, _lib, retain: true, release: true); + } + + NSString stringByTrimmingCharactersInSet_(NSCharacterSet set) { + final _ret = _lib._objc_msgSend_215( + _id, _lib._sel_stringByTrimmingCharactersInSet_1, set._id); + return NSString._(_ret, _lib, retain: true, release: true); + } + + NSString stringByPaddingToLength_withString_startingAtIndex_( + int newLength, NSString padString, int padIndex) { + final _ret = _lib._objc_msgSend_216( + _id, + _lib._sel_stringByPaddingToLength_withString_startingAtIndex_1, + newLength, + padString._id, + padIndex); + return NSString._(_ret, _lib, retain: true, release: true); + } + + NSString stringByFoldingWithOptions_locale_(int options, NSLocale? locale) { + final _ret = _lib._objc_msgSend_217( + _id, + _lib._sel_stringByFoldingWithOptions_locale_1, + options, + locale?._id ?? ffi.nullptr); + return NSString._(_ret, _lib, retain: true, release: true); + } + + NSString stringByReplacingOccurrencesOfString_withString_options_range_( + NSString target, + NSString replacement, + int options, + _NSRange searchRange) { + final _ret = _lib._objc_msgSend_218( + _id, + _lib._sel_stringByReplacingOccurrencesOfString_withString_options_range_1, + target._id, + replacement._id, + options, + searchRange); + return NSString._(_ret, _lib, retain: true, release: true); + } + + NSString stringByReplacingOccurrencesOfString_withString_( + NSString target, NSString replacement) { + final _ret = _lib._objc_msgSend_219( + _id, + _lib._sel_stringByReplacingOccurrencesOfString_withString_1, + target._id, + replacement._id); + return NSString._(_ret, _lib, retain: true, release: true); + } + + NSString stringByReplacingCharactersInRange_withString_( + _NSRange range, NSString replacement) { + final _ret = _lib._objc_msgSend_220( + _id, + _lib._sel_stringByReplacingCharactersInRange_withString_1, + range, + replacement._id); + return NSString._(_ret, _lib, retain: true, release: true); + } + + NSString? stringByApplyingTransform_reverse_( + NSString transform, bool reverse) { + final _ret = _lib._objc_msgSend_221(_id, + _lib._sel_stringByApplyingTransform_reverse_1, transform._id, reverse); + return _ret.address == 0 + ? null + : NSString._(_ret, _lib, retain: true, release: true); + } + + bool writeToURL_atomically_encoding_error_(NSURL url, bool useAuxiliaryFile, + int enc, ffi.Pointer> error) { + return _lib._objc_msgSend_222( + _id, + _lib._sel_writeToURL_atomically_encoding_error_1, + url._id, + useAuxiliaryFile, + enc, + error); + } + + bool writeToFile_atomically_encoding_error_( + NSString path, + bool useAuxiliaryFile, + int enc, + ffi.Pointer> error) { + return _lib._objc_msgSend_223( + _id, + _lib._sel_writeToFile_atomically_encoding_error_1, + path._id, + useAuxiliaryFile, + enc, + error); + } + + NSString get description { + final _ret = _lib._objc_msgSend_57(_id, _lib._sel_description1); + return NSString._(_ret, _lib, retain: true, release: true); + } + + int get hash { + return _lib._objc_msgSend_12(_id, _lib._sel_hash1); + } + + NSString initWithCharactersNoCopy_length_freeWhenDone_( + ffi.Pointer characters, int length, bool freeBuffer) { + final _ret = _lib._objc_msgSend_224( + _id, + _lib._sel_initWithCharactersNoCopy_length_freeWhenDone_1, + characters, + length, + freeBuffer); + return NSString._(_ret, _lib, retain: false, release: true); + } + + NSString initWithCharactersNoCopy_length_deallocator_( + ffi.Pointer chars, + int len, + ObjCBlock_ffiVoid_ffiUnsignedShort_ffiUnsignedLong? deallocator) { + final _ret = _lib._objc_msgSend_225( + _id, + _lib._sel_initWithCharactersNoCopy_length_deallocator_1, + chars, + len, + deallocator?._id ?? ffi.nullptr); + return NSString._(_ret, _lib, retain: false, release: true); + } + + NSString initWithCharacters_length_( + ffi.Pointer characters, int length) { + final _ret = _lib._objc_msgSend_226( + _id, _lib._sel_initWithCharacters_length_1, characters, length); + return NSString._(_ret, _lib, retain: true, release: true); + } + + NSString? initWithUTF8String_(ffi.Pointer nullTerminatedCString) { + final _ret = _lib._objc_msgSend_227( + _id, _lib._sel_initWithUTF8String_1, nullTerminatedCString); + return _ret.address == 0 + ? null + : NSString._(_ret, _lib, retain: true, release: true); + } + + NSString initWithString_(NSString aString) { + final _ret = + _lib._objc_msgSend_181(_id, _lib._sel_initWithString_1, aString._id); + return NSString._(_ret, _lib, retain: true, release: true); + } + + NSString initWithFormat_(NSString format) { + final _ret = + _lib._objc_msgSend_181(_id, _lib._sel_initWithFormat_1, format._id); + return NSString._(_ret, _lib, retain: true, release: true); + } + + NSString initWithFormat_arguments_( + NSString format, ffi.Pointer argList) { + final _ret = _lib._objc_msgSend_228( + _id, _lib._sel_initWithFormat_arguments_1, format._id, argList); + return NSString._(_ret, _lib, retain: true, release: true); + } + + NSString initWithFormat_locale_(NSString format, NSObject? locale) { + final _ret = _lib._objc_msgSend_229(_id, _lib._sel_initWithFormat_locale_1, + format._id, locale?._id ?? ffi.nullptr); + return NSString._(_ret, _lib, retain: true, release: true); + } + + NSString initWithFormat_locale_arguments_( + NSString format, NSObject? locale, ffi.Pointer argList) { + final _ret = _lib._objc_msgSend_230( + _id, + _lib._sel_initWithFormat_locale_arguments_1, + format._id, + locale?._id ?? ffi.nullptr, + argList); + return NSString._(_ret, _lib, retain: true, release: true); + } + + NSString? initWithValidatedFormat_validFormatSpecifiers_error_( + NSString format, + NSString validFormatSpecifiers, + ffi.Pointer> error) { + final _ret = _lib._objc_msgSend_231( + _id, + _lib._sel_initWithValidatedFormat_validFormatSpecifiers_error_1, + format._id, + validFormatSpecifiers._id, + error); + return _ret.address == 0 + ? null + : NSString._(_ret, _lib, retain: true, release: true); + } + + NSString? initWithValidatedFormat_validFormatSpecifiers_locale_error_( + NSString format, + NSString validFormatSpecifiers, + NSObject? locale, + ffi.Pointer> error) { + final _ret = _lib._objc_msgSend_232( + _id, + _lib._sel_initWithValidatedFormat_validFormatSpecifiers_locale_error_1, + format._id, + validFormatSpecifiers._id, + locale?._id ?? ffi.nullptr, + error); + return _ret.address == 0 + ? null + : NSString._(_ret, _lib, retain: true, release: true); + } + + NSString? initWithValidatedFormat_validFormatSpecifiers_arguments_error_( + NSString format, + NSString validFormatSpecifiers, + ffi.Pointer argList, + ffi.Pointer> error) { + final _ret = _lib._objc_msgSend_233( + _id, + _lib._sel_initWithValidatedFormat_validFormatSpecifiers_arguments_error_1, + format._id, + validFormatSpecifiers._id, + argList, + error); + return _ret.address == 0 + ? null + : NSString._(_ret, _lib, retain: true, release: true); + } + + NSString? + initWithValidatedFormat_validFormatSpecifiers_locale_arguments_error_( + NSString format, + NSString validFormatSpecifiers, + NSObject? locale, + ffi.Pointer argList, + ffi.Pointer> error) { + final _ret = _lib._objc_msgSend_234( + _id, + _lib._sel_initWithValidatedFormat_validFormatSpecifiers_locale_arguments_error_1, + format._id, + validFormatSpecifiers._id, + locale?._id ?? ffi.nullptr, + argList, + error); + return _ret.address == 0 + ? null + : NSString._(_ret, _lib, retain: true, release: true); + } + + NSString? initWithData_encoding_(NSData data, int encoding) { + final _ret = _lib._objc_msgSend_235( + _id, _lib._sel_initWithData_encoding_1, data._id, encoding); + return _ret.address == 0 + ? null + : NSString._(_ret, _lib, retain: true, release: true); + } + + NSString? initWithBytes_length_encoding_( + ffi.Pointer bytes, int len, int encoding) { + final _ret = _lib._objc_msgSend_236( + _id, _lib._sel_initWithBytes_length_encoding_1, bytes, len, encoding); + return _ret.address == 0 + ? null + : NSString._(_ret, _lib, retain: true, release: true); + } + + NSString? initWithBytesNoCopy_length_encoding_freeWhenDone_( + ffi.Pointer bytes, int len, int encoding, bool freeBuffer) { + final _ret = _lib._objc_msgSend_237( + _id, + _lib._sel_initWithBytesNoCopy_length_encoding_freeWhenDone_1, + bytes, + len, + encoding, + freeBuffer); + return _ret.address == 0 + ? null + : NSString._(_ret, _lib, retain: false, release: true); + } + + NSString? initWithBytesNoCopy_length_encoding_deallocator_( + ffi.Pointer bytes, + int len, + int encoding, + ObjCBlock_ffiVoid_ffiVoid_ffiUnsignedLong? deallocator) { + final _ret = _lib._objc_msgSend_238( + _id, + _lib._sel_initWithBytesNoCopy_length_encoding_deallocator_1, + bytes, + len, + encoding, + deallocator?._id ?? ffi.nullptr); + return _ret.address == 0 + ? null + : NSString._(_ret, _lib, retain: false, release: true); + } + + static NSString string(NativeMacOsFramework _lib) { + final _ret = _lib._objc_msgSend_2(_lib._class_NSString1, _lib._sel_string1); + return NSString._(_ret, _lib, retain: true, release: true); + } + + static NSString stringWithString_( + NativeMacOsFramework _lib, NSString string) { + final _ret = _lib._objc_msgSend_181( + _lib._class_NSString1, _lib._sel_stringWithString_1, string._id); + return NSString._(_ret, _lib, retain: true, release: true); + } + + static NSString stringWithCharacters_length_(NativeMacOsFramework _lib, + ffi.Pointer characters, int length) { + final _ret = _lib._objc_msgSend_226(_lib._class_NSString1, + _lib._sel_stringWithCharacters_length_1, characters, length); + return NSString._(_ret, _lib, retain: true, release: true); + } + + static NSString? stringWithUTF8String_( + NativeMacOsFramework _lib, ffi.Pointer nullTerminatedCString) { + final _ret = _lib._objc_msgSend_227(_lib._class_NSString1, + _lib._sel_stringWithUTF8String_1, nullTerminatedCString); + return _ret.address == 0 + ? null + : NSString._(_ret, _lib, retain: true, release: true); + } + + static NSString stringWithFormat_( + NativeMacOsFramework _lib, NSString format) { + final _ret = _lib._objc_msgSend_181( + _lib._class_NSString1, _lib._sel_stringWithFormat_1, format._id); + return NSString._(_ret, _lib, retain: true, release: true); + } + + static NSString localizedStringWithFormat_( + NativeMacOsFramework _lib, NSString format) { + final _ret = _lib._objc_msgSend_181(_lib._class_NSString1, + _lib._sel_localizedStringWithFormat_1, format._id); + return NSString._(_ret, _lib, retain: true, release: true); + } + + static NSString? stringWithValidatedFormat_validFormatSpecifiers_error_( + NativeMacOsFramework _lib, + NSString format, + NSString validFormatSpecifiers, + ffi.Pointer> error) { + final _ret = _lib._objc_msgSend_231( + _lib._class_NSString1, + _lib._sel_stringWithValidatedFormat_validFormatSpecifiers_error_1, + format._id, + validFormatSpecifiers._id, + error); + return _ret.address == 0 + ? null + : NSString._(_ret, _lib, retain: true, release: true); + } + + static NSString? + localizedStringWithValidatedFormat_validFormatSpecifiers_error_( + NativeMacOsFramework _lib, + NSString format, + NSString validFormatSpecifiers, + ffi.Pointer> error) { + final _ret = _lib._objc_msgSend_231( + _lib._class_NSString1, + _lib._sel_localizedStringWithValidatedFormat_validFormatSpecifiers_error_1, + format._id, + validFormatSpecifiers._id, + error); + return _ret.address == 0 + ? null + : NSString._(_ret, _lib, retain: true, release: true); + } + + NSString? initWithCString_encoding_( + ffi.Pointer nullTerminatedCString, int encoding) { + final _ret = _lib._objc_msgSend_239(_id, + _lib._sel_initWithCString_encoding_1, nullTerminatedCString, encoding); + return _ret.address == 0 + ? null + : NSString._(_ret, _lib, retain: true, release: true); + } + + static NSString? stringWithCString_encoding_( + NativeMacOsFramework _lib, ffi.Pointer cString, int enc) { + final _ret = _lib._objc_msgSend_239(_lib._class_NSString1, + _lib._sel_stringWithCString_encoding_1, cString, enc); + return _ret.address == 0 + ? null + : NSString._(_ret, _lib, retain: true, release: true); + } + + NSString? initWithContentsOfURL_encoding_error_( + NSURL url, int enc, ffi.Pointer> error) { + final _ret = _lib._objc_msgSend_240(_id, + _lib._sel_initWithContentsOfURL_encoding_error_1, url._id, enc, error); + return _ret.address == 0 + ? null + : NSString._(_ret, _lib, retain: true, release: true); + } + + NSString? initWithContentsOfFile_encoding_error_( + NSString path, int enc, ffi.Pointer> error) { + final _ret = _lib._objc_msgSend_241( + _id, + _lib._sel_initWithContentsOfFile_encoding_error_1, + path._id, + enc, + error); + return _ret.address == 0 + ? null + : NSString._(_ret, _lib, retain: true, release: true); + } + + static NSString? stringWithContentsOfURL_encoding_error_( + NativeMacOsFramework _lib, + NSURL url, + int enc, + ffi.Pointer> error) { + final _ret = _lib._objc_msgSend_240( + _lib._class_NSString1, + _lib._sel_stringWithContentsOfURL_encoding_error_1, + url._id, + enc, + error); + return _ret.address == 0 + ? null + : NSString._(_ret, _lib, retain: true, release: true); + } + + static NSString? stringWithContentsOfFile_encoding_error_( + NativeMacOsFramework _lib, + NSString path, + int enc, + ffi.Pointer> error) { + final _ret = _lib._objc_msgSend_241( + _lib._class_NSString1, + _lib._sel_stringWithContentsOfFile_encoding_error_1, + path._id, + enc, + error); + return _ret.address == 0 + ? null + : NSString._(_ret, _lib, retain: true, release: true); + } + + NSString? initWithContentsOfURL_usedEncoding_error_( + NSURL url, + ffi.Pointer enc, + ffi.Pointer> error) { + final _ret = _lib._objc_msgSend_242( + _id, + _lib._sel_initWithContentsOfURL_usedEncoding_error_1, + url._id, + enc, + error); + return _ret.address == 0 + ? null + : NSString._(_ret, _lib, retain: true, release: true); + } + + NSString? initWithContentsOfFile_usedEncoding_error_( + NSString path, + ffi.Pointer enc, + ffi.Pointer> error) { + final _ret = _lib._objc_msgSend_243( + _id, + _lib._sel_initWithContentsOfFile_usedEncoding_error_1, + path._id, + enc, + error); + return _ret.address == 0 + ? null + : NSString._(_ret, _lib, retain: true, release: true); + } + + static NSString? stringWithContentsOfURL_usedEncoding_error_( + NativeMacOsFramework _lib, + NSURL url, + ffi.Pointer enc, + ffi.Pointer> error) { + final _ret = _lib._objc_msgSend_242( + _lib._class_NSString1, + _lib._sel_stringWithContentsOfURL_usedEncoding_error_1, + url._id, + enc, + error); + return _ret.address == 0 + ? null + : NSString._(_ret, _lib, retain: true, release: true); + } + + static NSString? stringWithContentsOfFile_usedEncoding_error_( + NativeMacOsFramework _lib, + NSString path, + ffi.Pointer enc, + ffi.Pointer> error) { + final _ret = _lib._objc_msgSend_243( + _lib._class_NSString1, + _lib._sel_stringWithContentsOfFile_usedEncoding_error_1, + path._id, + enc, + error); + return _ret.address == 0 + ? null + : NSString._(_ret, _lib, retain: true, release: true); + } + + static int + stringEncodingForData_encodingOptions_convertedString_usedLossyConversion_( + NativeMacOsFramework _lib, + NSData data, + NSDictionary? opts, + ffi.Pointer> string, + ffi.Pointer usedLossyConversion) { + return _lib._objc_msgSend_244( + _lib._class_NSString1, + _lib._sel_stringEncodingForData_encodingOptions_convertedString_usedLossyConversion_1, + data._id, + opts?._id ?? ffi.nullptr, + string, + usedLossyConversion); + } + + NSObject propertyList() { + final _ret = _lib._objc_msgSend_2(_id, _lib._sel_propertyList1); + return NSObject._(_ret, _lib, retain: true, release: true); + } + + NSDictionary? propertyListFromStringsFileFormat() { + final _ret = _lib._objc_msgSend_245( + _id, _lib._sel_propertyListFromStringsFileFormat1); + return _ret.address == 0 + ? null + : NSDictionary._(_ret, _lib, retain: true, release: true); + } + + ffi.Pointer cString() { + return _lib._objc_msgSend_206(_id, _lib._sel_cString1); + } + + ffi.Pointer lossyCString() { + return _lib._objc_msgSend_206(_id, _lib._sel_lossyCString1); + } + + int cStringLength() { + return _lib._objc_msgSend_12(_id, _lib._sel_cStringLength1); + } + + void getCString_(ffi.Pointer bytes) { + _lib._objc_msgSend_22(_id, _lib._sel_getCString_1, bytes); + } + + void getCString_maxLength_(ffi.Pointer bytes, int maxLength) { + _lib._objc_msgSend_246( + _id, _lib._sel_getCString_maxLength_1, bytes, maxLength); + } + + void getCString_maxLength_range_remainingRange_(ffi.Pointer bytes, + int maxLength, _NSRange aRange, ffi.Pointer<_NSRange> leftoverRange) { + _lib._objc_msgSend_247( + _id, + _lib._sel_getCString_maxLength_range_remainingRange_1, + bytes, + maxLength, + aRange, + leftoverRange); + } + + bool writeToFile_atomically_(NSString path, bool useAuxiliaryFile) { + return _lib._objc_msgSend_116( + _id, _lib._sel_writeToFile_atomically_1, path._id, useAuxiliaryFile); + } + + bool writeToURL_atomically_(NSURL url, bool atomically) { + return _lib._objc_msgSend_117( + _id, _lib._sel_writeToURL_atomically_1, url._id, atomically); + } + + NSObject? initWithContentsOfFile_(NSString path) { + final _ret = _lib._objc_msgSend_40( + _id, _lib._sel_initWithContentsOfFile_1, path._id); + return _ret.address == 0 + ? null + : NSObject._(_ret, _lib, retain: true, release: true); + } + + NSObject? initWithContentsOfURL_(NSURL url) { + final _ret = + _lib._objc_msgSend_248(_id, _lib._sel_initWithContentsOfURL_1, url._id); + return _ret.address == 0 + ? null + : NSObject._(_ret, _lib, retain: true, release: true); + } + + static NSObject? stringWithContentsOfFile_( + NativeMacOsFramework _lib, NSString path) { + final _ret = _lib._objc_msgSend_40( + _lib._class_NSString1, _lib._sel_stringWithContentsOfFile_1, path._id); + return _ret.address == 0 + ? null + : NSObject._(_ret, _lib, retain: true, release: true); + } + + static NSObject? stringWithContentsOfURL_( + NativeMacOsFramework _lib, NSURL url) { + final _ret = _lib._objc_msgSend_248( + _lib._class_NSString1, _lib._sel_stringWithContentsOfURL_1, url._id); + return _ret.address == 0 + ? null + : NSObject._(_ret, _lib, retain: true, release: true); + } + + NSObject? initWithCStringNoCopy_length_freeWhenDone_( + ffi.Pointer bytes, int length, bool freeBuffer) { + final _ret = _lib._objc_msgSend_249( + _id, + _lib._sel_initWithCStringNoCopy_length_freeWhenDone_1, + bytes, + length, + freeBuffer); + return _ret.address == 0 + ? null + : NSObject._(_ret, _lib, retain: false, release: true); + } + + NSObject? initWithCString_length_(ffi.Pointer bytes, int length) { + final _ret = _lib._objc_msgSend_239( + _id, _lib._sel_initWithCString_length_1, bytes, length); + return _ret.address == 0 + ? null + : NSObject._(_ret, _lib, retain: true, release: true); + } + + NSObject? initWithCString_(ffi.Pointer bytes) { + final _ret = + _lib._objc_msgSend_227(_id, _lib._sel_initWithCString_1, bytes); + return _ret.address == 0 + ? null + : NSObject._(_ret, _lib, retain: true, release: true); + } + + static NSObject? stringWithCString_length_( + NativeMacOsFramework _lib, ffi.Pointer bytes, int length) { + final _ret = _lib._objc_msgSend_239(_lib._class_NSString1, + _lib._sel_stringWithCString_length_1, bytes, length); + return _ret.address == 0 + ? null + : NSObject._(_ret, _lib, retain: true, release: true); + } + + static NSObject? stringWithCString_( + NativeMacOsFramework _lib, ffi.Pointer bytes) { + final _ret = _lib._objc_msgSend_227( + _lib._class_NSString1, _lib._sel_stringWithCString_1, bytes); + return _ret.address == 0 + ? null + : NSObject._(_ret, _lib, retain: true, release: true); + } + + void getCharacters_(ffi.Pointer buffer) { + _lib._objc_msgSend_250(_id, _lib._sel_getCharacters_1, buffer); + } + + /// For strings with length variations, such as from a stringsdict file, this method returns the variant at the given width. If there is no variant at the given width, the one for the next smaller width is returned. And if there are none smaller, the smallest available is returned. For strings without variations, this method returns self. The unit that width is expressed in is decided by the application or framework. But it is intended to be some measurement indicative of the context a string would fit best to avoid truncation and wasted space. + NSString variantFittingPresentationWidth_(int width) { + final _ret = _lib._objc_msgSend_251( + _id, _lib._sel_variantFittingPresentationWidth_1, width); + return NSString._(_ret, _lib, retain: true, release: true); + } + + static NSString new1(NativeMacOsFramework _lib) { + final _ret = _lib._objc_msgSend_2(_lib._class_NSString1, _lib._sel_new1); + return NSString._(_ret, _lib, retain: false, release: true); + } + + static NSString allocWithZone_( + NativeMacOsFramework _lib, ffi.Pointer<_NSZone> zone) { + final _ret = _lib._objc_msgSend_3( + _lib._class_NSString1, _lib._sel_allocWithZone_1, zone); + return NSString._(_ret, _lib, retain: false, release: true); + } + + static NSString alloc(NativeMacOsFramework _lib) { + final _ret = _lib._objc_msgSend_2(_lib._class_NSString1, _lib._sel_alloc1); + return NSString._(_ret, _lib, retain: false, release: true); + } +} + +extension StringToNSString on String { + NSString toNSString(NativeMacOsFramework lib) => NSString(lib, this); +} + +class NSCoder extends NSObject { + NSCoder._(ffi.Pointer id, NativeMacOsFramework lib, + {bool retain = false, bool release = false}) + : super._(id, lib, retain: retain, release: release); + + /// Returns a [NSCoder] that points to the same underlying object as [other]. + static NSCoder castFrom(T other) { + return NSCoder._(other._id, other._lib, retain: true, release: true); + } + + /// Returns a [NSCoder] that wraps the given raw object pointer. + static NSCoder castFromPointer( + NativeMacOsFramework lib, ffi.Pointer other, + {bool retain = false, bool release = false}) { + return NSCoder._(other, lib, retain: retain, release: release); + } + + /// Returns whether [obj] is an instance of [NSCoder]. + static bool isInstance(_ObjCWrapper obj) { + return obj._lib._objc_msgSend_0( + obj._id, obj._lib._sel_isKindOfClass_1, obj._lib._class_NSCoder1); + } + + void encodeValueOfObjCType_at_( + ffi.Pointer type, ffi.Pointer addr) { + _lib._objc_msgSend_14( + _id, _lib._sel_encodeValueOfObjCType_at_1, type, addr); + } + + void encodeDataObject_(NSData data) { + _lib._objc_msgSend_16(_id, _lib._sel_encodeDataObject_1, data._id); + } + + NSData? decodeDataObject() { + final _ret = _lib._objc_msgSend_17(_id, _lib._sel_decodeDataObject1); + return _ret.address == 0 + ? null + : NSData._(_ret, _lib, retain: true, release: true); + } + + void decodeValueOfObjCType_at_size_( + ffi.Pointer type, ffi.Pointer data, int size) { + _lib._objc_msgSend_18( + _id, _lib._sel_decodeValueOfObjCType_at_size_1, type, data, size); + } + + int versionForClassName_(NSString className) { + return _lib._objc_msgSend_19( + _id, _lib._sel_versionForClassName_1, className._id); + } + + void encodeObject_(NSObject? object) { + _lib._objc_msgSend_20( + _id, _lib._sel_encodeObject_1, object?._id ?? ffi.nullptr); + } + + void encodeRootObject_(NSObject rootObject) { + _lib._objc_msgSend_21(_id, _lib._sel_encodeRootObject_1, rootObject._id); + } + + void encodeBycopyObject_(NSObject? anObject) { + _lib._objc_msgSend_20( + _id, _lib._sel_encodeBycopyObject_1, anObject?._id ?? ffi.nullptr); + } + + void encodeByrefObject_(NSObject? anObject) { + _lib._objc_msgSend_20( + _id, _lib._sel_encodeByrefObject_1, anObject?._id ?? ffi.nullptr); + } + + void encodeConditionalObject_(NSObject? object) { + _lib._objc_msgSend_20( + _id, _lib._sel_encodeConditionalObject_1, object?._id ?? ffi.nullptr); + } + + void encodeValuesOfObjCTypes_(ffi.Pointer types) { + _lib._objc_msgSend_22(_id, _lib._sel_encodeValuesOfObjCTypes_1, types); + } + + void encodeArrayOfObjCType_count_at_( + ffi.Pointer type, int count, ffi.Pointer array) { + _lib._objc_msgSend_23( + _id, _lib._sel_encodeArrayOfObjCType_count_at_1, type, count, array); + } + + void encodeBytes_length_(ffi.Pointer byteaddr, int length) { + _lib._objc_msgSend_24( + _id, _lib._sel_encodeBytes_length_1, byteaddr, length); + } + + NSObject? decodeObject() { + final _ret = _lib._objc_msgSend_25(_id, _lib._sel_decodeObject1); + return _ret.address == 0 + ? null + : NSObject._(_ret, _lib, retain: true, release: true); + } + + NSObject? decodeTopLevelObjectAndReturnError_( + ffi.Pointer> error) { + final _ret = _lib._objc_msgSend_26( + _id, _lib._sel_decodeTopLevelObjectAndReturnError_1, error); + return _ret.address == 0 + ? null + : NSObject._(_ret, _lib, retain: true, release: true); + } + + void decodeValuesOfObjCTypes_(ffi.Pointer types) { + _lib._objc_msgSend_22(_id, _lib._sel_decodeValuesOfObjCTypes_1, types); + } + + void decodeArrayOfObjCType_count_at_( + ffi.Pointer itemType, int count, ffi.Pointer array) { + _lib._objc_msgSend_23(_id, _lib._sel_decodeArrayOfObjCType_count_at_1, + itemType, count, array); + } + + ffi.Pointer decodeBytesWithReturnedLength_( + ffi.Pointer lengthp) { + return _lib._objc_msgSend_27( + _id, _lib._sel_decodeBytesWithReturnedLength_1, lengthp); + } + + void encodePropertyList_(NSObject aPropertyList) { + _lib._objc_msgSend_21( + _id, _lib._sel_encodePropertyList_1, aPropertyList._id); + } + + NSObject? decodePropertyList() { + final _ret = _lib._objc_msgSend_25(_id, _lib._sel_decodePropertyList1); + return _ret.address == 0 + ? null + : NSObject._(_ret, _lib, retain: true, release: true); + } + + void setObjectZone_(ffi.Pointer<_NSZone> zone) { + _lib._objc_msgSend_28(_id, _lib._sel_setObjectZone_1, zone); + } + + ffi.Pointer<_NSZone> objectZone() { + return _lib._objc_msgSend_29(_id, _lib._sel_objectZone1); + } + + int get systemVersion { + return _lib._objc_msgSend_30(_id, _lib._sel_systemVersion1); + } + + bool get allowsKeyedCoding { + return _lib._objc_msgSend_11(_id, _lib._sel_allowsKeyedCoding1); + } + + void encodeObject_forKey_(NSObject? object, NSString key) { + _lib._objc_msgSend_31(_id, _lib._sel_encodeObject_forKey_1, + object?._id ?? ffi.nullptr, key._id); + } + + void encodeConditionalObject_forKey_(NSObject? object, NSString key) { + _lib._objc_msgSend_31(_id, _lib._sel_encodeConditionalObject_forKey_1, + object?._id ?? ffi.nullptr, key._id); + } + + void encodeBool_forKey_(bool value, NSString key) { + _lib._objc_msgSend_32(_id, _lib._sel_encodeBool_forKey_1, value, key._id); + } + + void encodeInt_forKey_(int value, NSString key) { + _lib._objc_msgSend_33(_id, _lib._sel_encodeInt_forKey_1, value, key._id); + } + + void encodeInt32_forKey_(int value, NSString key) { + _lib._objc_msgSend_34(_id, _lib._sel_encodeInt32_forKey_1, value, key._id); + } + + void encodeInt64_forKey_(int value, NSString key) { + _lib._objc_msgSend_35(_id, _lib._sel_encodeInt64_forKey_1, value, key._id); + } + + void encodeFloat_forKey_(double value, NSString key) { + _lib._objc_msgSend_36(_id, _lib._sel_encodeFloat_forKey_1, value, key._id); + } + + void encodeDouble_forKey_(double value, NSString key) { + _lib._objc_msgSend_37(_id, _lib._sel_encodeDouble_forKey_1, value, key._id); + } + + void encodeBytes_length_forKey_( + ffi.Pointer bytes, int length, NSString key) { + _lib._objc_msgSend_38( + _id, _lib._sel_encodeBytes_length_forKey_1, bytes, length, key._id); + } + + bool containsValueForKey_(NSString key) { + return _lib._objc_msgSend_39(_id, _lib._sel_containsValueForKey_1, key._id); + } + + NSObject? decodeObjectForKey_(NSString key) { + final _ret = + _lib._objc_msgSend_40(_id, _lib._sel_decodeObjectForKey_1, key._id); + return _ret.address == 0 + ? null + : NSObject._(_ret, _lib, retain: true, release: true); + } + + NSObject? decodeTopLevelObjectForKey_error_( + NSString key, ffi.Pointer> error) { + final _ret = _lib._objc_msgSend_41( + _id, _lib._sel_decodeTopLevelObjectForKey_error_1, key._id, error); + return _ret.address == 0 + ? null + : NSObject._(_ret, _lib, retain: true, release: true); + } + + bool decodeBoolForKey_(NSString key) { + return _lib._objc_msgSend_39(_id, _lib._sel_decodeBoolForKey_1, key._id); + } + + int decodeIntForKey_(NSString key) { + return _lib._objc_msgSend_42(_id, _lib._sel_decodeIntForKey_1, key._id); + } + + int decodeInt32ForKey_(NSString key) { + return _lib._objc_msgSend_43(_id, _lib._sel_decodeInt32ForKey_1, key._id); + } + + int decodeInt64ForKey_(NSString key) { + return _lib._objc_msgSend_44(_id, _lib._sel_decodeInt64ForKey_1, key._id); + } + + double decodeFloatForKey_(NSString key) { + return _lib._objc_msgSend_45(_id, _lib._sel_decodeFloatForKey_1, key._id); + } + + double decodeDoubleForKey_(NSString key) { + return _lib._objc_msgSend_46(_id, _lib._sel_decodeDoubleForKey_1, key._id); + } + + ffi.Pointer decodeBytesForKey_returnedLength_( + NSString key, ffi.Pointer lengthp) { + return _lib._objc_msgSend_47( + _id, _lib._sel_decodeBytesForKey_returnedLength_1, key._id, lengthp); + } + + void encodeInteger_forKey_(int value, NSString key) { + _lib._objc_msgSend_48( + _id, _lib._sel_encodeInteger_forKey_1, value, key._id); + } + + int decodeIntegerForKey_(NSString key) { + return _lib._objc_msgSend_19(_id, _lib._sel_decodeIntegerForKey_1, key._id); + } + + bool get requiresSecureCoding { + return _lib._objc_msgSend_11(_id, _lib._sel_requiresSecureCoding1); + } + + NSObject? decodeObjectOfClass_forKey_(NSObject aClass, NSString key) { + final _ret = _lib._objc_msgSend_49( + _id, _lib._sel_decodeObjectOfClass_forKey_1, aClass._id, key._id); + return _ret.address == 0 + ? null + : NSObject._(_ret, _lib, retain: true, release: true); + } + + NSObject? decodeTopLevelObjectOfClass_forKey_error_(NSObject aClass, + NSString key, ffi.Pointer> error) { + final _ret = _lib._objc_msgSend_50( + _id, + _lib._sel_decodeTopLevelObjectOfClass_forKey_error_1, + aClass._id, + key._id, + error); + return _ret.address == 0 + ? null + : NSObject._(_ret, _lib, retain: true, release: true); + } + + NSArray? decodeArrayOfObjectsOfClass_forKey_(NSObject cls, NSString key) { + final _ret = _lib._objc_msgSend_118( + _id, _lib._sel_decodeArrayOfObjectsOfClass_forKey_1, cls._id, key._id); + return _ret.address == 0 + ? null + : NSArray._(_ret, _lib, retain: true, release: true); + } + + NSDictionary? decodeDictionaryWithKeysOfClass_objectsOfClass_forKey_( + NSObject keyCls, NSObject objectCls, NSString key) { + final _ret = _lib._objc_msgSend_138( + _id, + _lib._sel_decodeDictionaryWithKeysOfClass_objectsOfClass_forKey_1, + keyCls._id, + objectCls._id, + key._id); + return _ret.address == 0 + ? null + : NSDictionary._(_ret, _lib, retain: true, release: true); + } + + NSObject? decodeObjectOfClasses_forKey_(NSSet? classes, NSString key) { + final _ret = _lib._objc_msgSend_149( + _id, + _lib._sel_decodeObjectOfClasses_forKey_1, + classes?._id ?? ffi.nullptr, + key._id); + return _ret.address == 0 + ? null + : NSObject._(_ret, _lib, retain: true, release: true); + } + + NSObject? decodeTopLevelObjectOfClasses_forKey_error_(NSSet? classes, + NSString key, ffi.Pointer> error) { + final _ret = _lib._objc_msgSend_150( + _id, + _lib._sel_decodeTopLevelObjectOfClasses_forKey_error_1, + classes?._id ?? ffi.nullptr, + key._id, + error); + return _ret.address == 0 + ? null + : NSObject._(_ret, _lib, retain: true, release: true); + } + + NSArray? decodeArrayOfObjectsOfClasses_forKey_(NSSet classes, NSString key) { + final _ret = _lib._objc_msgSend_151(_id, + _lib._sel_decodeArrayOfObjectsOfClasses_forKey_1, classes._id, key._id); + return _ret.address == 0 + ? null + : NSArray._(_ret, _lib, retain: true, release: true); + } + + NSDictionary? decodeDictionaryWithKeysOfClasses_objectsOfClasses_forKey_( + NSSet keyClasses, NSSet objectClasses, NSString key) { + final _ret = _lib._objc_msgSend_152( + _id, + _lib._sel_decodeDictionaryWithKeysOfClasses_objectsOfClasses_forKey_1, + keyClasses._id, + objectClasses._id, + key._id); + return _ret.address == 0 + ? null + : NSDictionary._(_ret, _lib, retain: true, release: true); + } + + NSObject? decodePropertyListForKey_(NSString key) { + final _ret = _lib._objc_msgSend_40( + _id, _lib._sel_decodePropertyListForKey_1, key._id); + return _ret.address == 0 + ? null + : NSObject._(_ret, _lib, retain: true, release: true); + } + + NSSet? get allowedClasses { + final _ret = _lib._objc_msgSend_153(_id, _lib._sel_allowedClasses1); + return _ret.address == 0 + ? null + : NSSet._(_ret, _lib, retain: true, release: true); + } + + void failWithError_(NSError error) { + _lib._objc_msgSend_154(_id, _lib._sel_failWithError_1, error._id); + } + + int get decodingFailurePolicy { + return _lib._objc_msgSend_155(_id, _lib._sel_decodingFailurePolicy1); + } + + NSError? get error { + final _ret = _lib._objc_msgSend_156(_id, _lib._sel_error1); + return _ret.address == 0 + ? null + : NSError._(_ret, _lib, retain: true, release: true); + } + + void encodeNXObject_(NSObject object) { + _lib._objc_msgSend_21(_id, _lib._sel_encodeNXObject_1, object._id); + } + + NSObject? decodeNXObject() { + final _ret = _lib._objc_msgSend_25(_id, _lib._sel_decodeNXObject1); + return _ret.address == 0 + ? null + : NSObject._(_ret, _lib, retain: true, release: true); + } + + void decodeValueOfObjCType_at_( + ffi.Pointer type, ffi.Pointer data) { + _lib._objc_msgSend_14( + _id, _lib._sel_decodeValueOfObjCType_at_1, type, data); + } + + void encodePoint_(CGPoint point) { + _lib._objc_msgSend_157(_id, _lib._sel_encodePoint_1, point); + } + + void decodePoint(ffi.Pointer stret) { + _lib._objc_msgSend_158(stret, _id, _lib._sel_decodePoint1); + } + + void encodeSize_(CGSize size) { + _lib._objc_msgSend_159(_id, _lib._sel_encodeSize_1, size); + } + + void decodeSize(ffi.Pointer stret) { + _lib._objc_msgSend_160(stret, _id, _lib._sel_decodeSize1); + } + + void encodeRect_(CGRect rect) { + _lib._objc_msgSend_161(_id, _lib._sel_encodeRect_1, rect); + } + + void decodeRect(ffi.Pointer stret) { + _lib._objc_msgSend_162(stret, _id, _lib._sel_decodeRect1); + } + + void encodePoint_forKey_(CGPoint point, NSString key) { + _lib._objc_msgSend_163(_id, _lib._sel_encodePoint_forKey_1, point, key._id); + } + + void encodeSize_forKey_(CGSize size, NSString key) { + _lib._objc_msgSend_164(_id, _lib._sel_encodeSize_forKey_1, size, key._id); + } + + void encodeRect_forKey_(CGRect rect, NSString key) { + _lib._objc_msgSend_165(_id, _lib._sel_encodeRect_forKey_1, rect, key._id); + } + + void decodePointForKey_(ffi.Pointer stret, NSString key) { + _lib._objc_msgSend_166(stret, _id, _lib._sel_decodePointForKey_1, key._id); + } + + void decodeSizeForKey_(ffi.Pointer stret, NSString key) { + _lib._objc_msgSend_167(stret, _id, _lib._sel_decodeSizeForKey_1, key._id); + } + + void decodeRectForKey_(ffi.Pointer stret, NSString key) { + _lib._objc_msgSend_168(stret, _id, _lib._sel_decodeRectForKey_1, key._id); + } + + @override + NSCoder init() { + final _ret = _lib._objc_msgSend_2(_id, _lib._sel_init1); + return NSCoder._(_ret, _lib, retain: true, release: true); + } + + static NSCoder new1(NativeMacOsFramework _lib) { + final _ret = _lib._objc_msgSend_2(_lib._class_NSCoder1, _lib._sel_new1); + return NSCoder._(_ret, _lib, retain: false, release: true); + } + + static NSCoder allocWithZone_( + NativeMacOsFramework _lib, ffi.Pointer<_NSZone> zone) { + final _ret = _lib._objc_msgSend_3( + _lib._class_NSCoder1, _lib._sel_allocWithZone_1, zone); + return NSCoder._(_ret, _lib, retain: false, release: true); + } + + static NSCoder alloc(NativeMacOsFramework _lib) { + final _ret = _lib._objc_msgSend_2(_lib._class_NSCoder1, _lib._sel_alloc1); + return NSCoder._(_ret, _lib, retain: false, release: true); + } +} + +class NSData extends _ObjCWrapper { + NSData._(ffi.Pointer id, NativeMacOsFramework lib, + {bool retain = false, bool release = false}) + : super._(id, lib, retain: retain, release: release); + + /// Returns a [NSData] that points to the same underlying object as [other]. + static NSData castFrom(T other) { + return NSData._(other._id, other._lib, retain: true, release: true); + } + + /// Returns a [NSData] that wraps the given raw object pointer. + static NSData castFromPointer( + NativeMacOsFramework lib, ffi.Pointer other, + {bool retain = false, bool release = false}) { + return NSData._(other, lib, retain: retain, release: release); + } + + /// Returns whether [obj] is an instance of [NSData]. + static bool isInstance(_ObjCWrapper obj) { + return obj._lib._objc_msgSend_0( + obj._id, obj._lib._sel_isKindOfClass_1, obj._lib._class_NSData1); + } + + ffi.Pointer get bytes { + return _lib._objc_msgSend_15(_id, _lib._sel_bytes1); + } +} + +class NSError extends _ObjCWrapper { + NSError._(ffi.Pointer id, NativeMacOsFramework lib, + {bool retain = false, bool release = false}) + : super._(id, lib, retain: retain, release: release); + + /// Returns a [NSError] that points to the same underlying object as [other]. + static NSError castFrom(T other) { + return NSError._(other._id, other._lib, retain: true, release: true); + } + + /// Returns a [NSError] that wraps the given raw object pointer. + static NSError castFromPointer( + NativeMacOsFramework lib, ffi.Pointer other, + {bool retain = false, bool release = false}) { + return NSError._(other, lib, retain: retain, release: release); + } + + /// Returns whether [obj] is an instance of [NSError]. + static bool isInstance(_ObjCWrapper obj) { + return obj._lib._objc_msgSend_0( + obj._id, obj._lib._sel_isKindOfClass_1, obj._lib._class_NSError1); + } +} + +class NSArray extends NSObject { + NSArray._(ffi.Pointer id, NativeMacOsFramework lib, + {bool retain = false, bool release = false}) + : super._(id, lib, retain: retain, release: release); + + /// Returns a [NSArray] that points to the same underlying object as [other]. + static NSArray castFrom(T other) { + return NSArray._(other._id, other._lib, retain: true, release: true); + } + + /// Returns a [NSArray] that wraps the given raw object pointer. + static NSArray castFromPointer( + NativeMacOsFramework lib, ffi.Pointer other, + {bool retain = false, bool release = false}) { + return NSArray._(other, lib, retain: retain, release: release); + } + + /// Returns whether [obj] is an instance of [NSArray]. + static bool isInstance(_ObjCWrapper obj) { + return obj._lib._objc_msgSend_0( + obj._id, obj._lib._sel_isKindOfClass_1, obj._lib._class_NSArray1); + } + + int get count { + return _lib._objc_msgSend_12(_id, _lib._sel_count1); + } + + NSObject objectAtIndex_(int index) { + final _ret = _lib._objc_msgSend_51(_id, _lib._sel_objectAtIndex_1, index); + return NSObject._(_ret, _lib, retain: true, release: true); + } + + @override + NSArray init() { + final _ret = _lib._objc_msgSend_2(_id, _lib._sel_init1); + return NSArray._(_ret, _lib, retain: true, release: true); + } + + NSArray initWithObjects_count_( + ffi.Pointer> objects, int cnt) { + final _ret = _lib._objc_msgSend_52( + _id, _lib._sel_initWithObjects_count_1, objects, cnt); + return NSArray._(_ret, _lib, retain: true, release: true); + } + + NSArray? initWithCoder_(NSCoder coder) { + final _ret = + _lib._objc_msgSend_53(_id, _lib._sel_initWithCoder_1, coder._id); + return _ret.address == 0 + ? null + : NSArray._(_ret, _lib, retain: true, release: true); + } + + NSArray arrayByAddingObject_(NSObject anObject) { + final _ret = _lib._objc_msgSend_54( + _id, _lib._sel_arrayByAddingObject_1, anObject._id); + return NSArray._(_ret, _lib, retain: true, release: true); + } + + NSArray arrayByAddingObjectsFromArray_(NSArray otherArray) { + final _ret = _lib._objc_msgSend_55( + _id, _lib._sel_arrayByAddingObjectsFromArray_1, otherArray._id); + return NSArray._(_ret, _lib, retain: true, release: true); + } + + NSString componentsJoinedByString_(NSString separator) { + final _ret = _lib._objc_msgSend_56( + _id, _lib._sel_componentsJoinedByString_1, separator._id); + return NSString._(_ret, _lib, retain: true, release: true); + } + + bool containsObject_(NSObject anObject) { + return _lib._objc_msgSend_0(_id, _lib._sel_containsObject_1, anObject._id); + } + + NSString get description { + final _ret = _lib._objc_msgSend_57(_id, _lib._sel_description1); + return NSString._(_ret, _lib, retain: true, release: true); + } + + NSString descriptionWithLocale_(NSObject? locale) { + final _ret = _lib._objc_msgSend_58( + _id, _lib._sel_descriptionWithLocale_1, locale?._id ?? ffi.nullptr); + return NSString._(_ret, _lib, retain: true, release: true); + } + + NSString descriptionWithLocale_indent_(NSObject? locale, int level) { + final _ret = _lib._objc_msgSend_59( + _id, + _lib._sel_descriptionWithLocale_indent_1, + locale?._id ?? ffi.nullptr, + level); + return NSString._(_ret, _lib, retain: true, release: true); + } + + NSObject? firstObjectCommonWithArray_(NSArray otherArray) { + final _ret = _lib._objc_msgSend_60( + _id, _lib._sel_firstObjectCommonWithArray_1, otherArray._id); + return _ret.address == 0 + ? null + : NSObject._(_ret, _lib, retain: true, release: true); + } + + void getObjects_range_( + ffi.Pointer> objects, _NSRange range) { + _lib._objc_msgSend_61(_id, _lib._sel_getObjects_range_1, objects, range); + } + + int indexOfObject_(NSObject anObject) { + return _lib._objc_msgSend_62(_id, _lib._sel_indexOfObject_1, anObject._id); + } + + int indexOfObject_inRange_(NSObject anObject, _NSRange range) { + return _lib._objc_msgSend_63( + _id, _lib._sel_indexOfObject_inRange_1, anObject._id, range); + } + + int indexOfObjectIdenticalTo_(NSObject anObject) { + return _lib._objc_msgSend_62( + _id, _lib._sel_indexOfObjectIdenticalTo_1, anObject._id); + } + + int indexOfObjectIdenticalTo_inRange_(NSObject anObject, _NSRange range) { + return _lib._objc_msgSend_63( + _id, _lib._sel_indexOfObjectIdenticalTo_inRange_1, anObject._id, range); + } + + bool isEqualToArray_(NSArray otherArray) { + return _lib._objc_msgSend_64( + _id, _lib._sel_isEqualToArray_1, otherArray._id); + } + + NSObject? get firstObject { + final _ret = _lib._objc_msgSend_25(_id, _lib._sel_firstObject1); + return _ret.address == 0 + ? null + : NSObject._(_ret, _lib, retain: true, release: true); + } + + NSObject? get lastObject { + final _ret = _lib._objc_msgSend_25(_id, _lib._sel_lastObject1); + return _ret.address == 0 + ? null + : NSObject._(_ret, _lib, retain: true, release: true); + } + + NSEnumerator objectEnumerator() { + final _ret = _lib._objc_msgSend_65(_id, _lib._sel_objectEnumerator1); + return NSEnumerator._(_ret, _lib, retain: true, release: true); + } + + NSEnumerator reverseObjectEnumerator() { + final _ret = _lib._objc_msgSend_65(_id, _lib._sel_reverseObjectEnumerator1); + return NSEnumerator._(_ret, _lib, retain: true, release: true); + } + + NSData get sortedArrayHint { + final _ret = _lib._objc_msgSend_66(_id, _lib._sel_sortedArrayHint1); + return NSData._(_ret, _lib, retain: true, release: true); + } + + NSArray sortedArrayUsingFunction_context_( + ffi.Pointer< + ffi.NativeFunction< + ffi.Long Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>> + comparator, + ffi.Pointer context) { + final _ret = _lib._objc_msgSend_67( + _id, _lib._sel_sortedArrayUsingFunction_context_1, comparator, context); + return NSArray._(_ret, _lib, retain: true, release: true); + } + + NSArray sortedArrayUsingFunction_context_hint_( + ffi.Pointer< + ffi.NativeFunction< + ffi.Long Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>> + comparator, + ffi.Pointer context, + NSData? hint) { + final _ret = _lib._objc_msgSend_68( + _id, + _lib._sel_sortedArrayUsingFunction_context_hint_1, + comparator, + context, + hint?._id ?? ffi.nullptr); + return NSArray._(_ret, _lib, retain: true, release: true); + } + + NSArray sortedArrayUsingSelector_(ffi.Pointer comparator) { + final _ret = _lib._objc_msgSend_69( + _id, _lib._sel_sortedArrayUsingSelector_1, comparator); + return NSArray._(_ret, _lib, retain: true, release: true); + } + + NSArray subarrayWithRange_(_NSRange range) { + final _ret = + _lib._objc_msgSend_70(_id, _lib._sel_subarrayWithRange_1, range); + return NSArray._(_ret, _lib, retain: true, release: true); + } + + bool writeToURL_error_( + NSURL url, ffi.Pointer> error) { + return _lib._objc_msgSend_71( + _id, _lib._sel_writeToURL_error_1, url._id, error); + } + + void makeObjectsPerformSelector_(ffi.Pointer aSelector) { + _lib._objc_msgSend_7( + _id, _lib._sel_makeObjectsPerformSelector_1, aSelector); + } + + void makeObjectsPerformSelector_withObject_( + ffi.Pointer aSelector, NSObject? argument) { + _lib._objc_msgSend_72( + _id, + _lib._sel_makeObjectsPerformSelector_withObject_1, + aSelector, + argument?._id ?? ffi.nullptr); + } + + NSArray objectsAtIndexes_(NSIndexSet indexes) { + final _ret = + _lib._objc_msgSend_93(_id, _lib._sel_objectsAtIndexes_1, indexes._id); + return NSArray._(_ret, _lib, retain: true, release: true); + } + + NSObject objectAtIndexedSubscript_(int idx) { + final _ret = + _lib._objc_msgSend_51(_id, _lib._sel_objectAtIndexedSubscript_1, idx); + return NSObject._(_ret, _lib, retain: true, release: true); + } + + void enumerateObjectsUsingBlock_( + ObjCBlock_ffiVoid_ObjCObject_ffiUnsignedLong_bool block) { + _lib._objc_msgSend_94( + _id, _lib._sel_enumerateObjectsUsingBlock_1, block._id); + } + + void enumerateObjectsWithOptions_usingBlock_( + int opts, ObjCBlock_ffiVoid_ObjCObject_ffiUnsignedLong_bool block) { + _lib._objc_msgSend_95(_id, + _lib._sel_enumerateObjectsWithOptions_usingBlock_1, opts, block._id); + } + + void enumerateObjectsAtIndexes_options_usingBlock_(NSIndexSet s, int opts, + ObjCBlock_ffiVoid_ObjCObject_ffiUnsignedLong_bool block) { + _lib._objc_msgSend_96( + _id, + _lib._sel_enumerateObjectsAtIndexes_options_usingBlock_1, + s._id, + opts, + block._id); + } + + int indexOfObjectPassingTest_( + ObjCBlock_bool_ObjCObject_ffiUnsignedLong_bool predicate) { + return _lib._objc_msgSend_97( + _id, _lib._sel_indexOfObjectPassingTest_1, predicate._id); + } + + int indexOfObjectWithOptions_passingTest_( + int opts, ObjCBlock_bool_ObjCObject_ffiUnsignedLong_bool predicate) { + return _lib._objc_msgSend_98(_id, + _lib._sel_indexOfObjectWithOptions_passingTest_1, opts, predicate._id); + } + + int indexOfObjectAtIndexes_options_passingTest_(NSIndexSet s, int opts, + ObjCBlock_bool_ObjCObject_ffiUnsignedLong_bool predicate) { + return _lib._objc_msgSend_99( + _id, + _lib._sel_indexOfObjectAtIndexes_options_passingTest_1, + s._id, + opts, + predicate._id); + } + + NSIndexSet indexesOfObjectsPassingTest_( + ObjCBlock_bool_ObjCObject_ffiUnsignedLong_bool predicate) { + final _ret = _lib._objc_msgSend_100( + _id, _lib._sel_indexesOfObjectsPassingTest_1, predicate._id); + return NSIndexSet._(_ret, _lib, retain: true, release: true); + } + + NSIndexSet indexesOfObjectsWithOptions_passingTest_( + int opts, ObjCBlock_bool_ObjCObject_ffiUnsignedLong_bool predicate) { + final _ret = _lib._objc_msgSend_101( + _id, + _lib._sel_indexesOfObjectsWithOptions_passingTest_1, + opts, + predicate._id); + return NSIndexSet._(_ret, _lib, retain: true, release: true); + } + + NSIndexSet indexesOfObjectsAtIndexes_options_passingTest_(NSIndexSet s, + int opts, ObjCBlock_bool_ObjCObject_ffiUnsignedLong_bool predicate) { + final _ret = _lib._objc_msgSend_102( + _id, + _lib._sel_indexesOfObjectsAtIndexes_options_passingTest_1, + s._id, + opts, + predicate._id); + return NSIndexSet._(_ret, _lib, retain: true, release: true); + } + + NSArray sortedArrayUsingComparator_( + ObjCBlock_NSComparisonResult_ObjCObject_ObjCObject cmptr) { + final _ret = _lib._objc_msgSend_103( + _id, _lib._sel_sortedArrayUsingComparator_1, cmptr._id); + return NSArray._(_ret, _lib, retain: true, release: true); + } + + NSArray sortedArrayWithOptions_usingComparator_( + int opts, ObjCBlock_NSComparisonResult_ObjCObject_ObjCObject cmptr) { + final _ret = _lib._objc_msgSend_104(_id, + _lib._sel_sortedArrayWithOptions_usingComparator_1, opts, cmptr._id); + return NSArray._(_ret, _lib, retain: true, release: true); + } + + int indexOfObject_inSortedRange_options_usingComparator_( + NSObject obj, + _NSRange r, + int opts, + ObjCBlock_NSComparisonResult_ObjCObject_ObjCObject cmp) { + return _lib._objc_msgSend_105( + _id, + _lib._sel_indexOfObject_inSortedRange_options_usingComparator_1, + obj._id, + r, + opts, + cmp._id); + } + + static NSArray array(NativeMacOsFramework _lib) { + final _ret = _lib._objc_msgSend_2(_lib._class_NSArray1, _lib._sel_array1); + return NSArray._(_ret, _lib, retain: true, release: true); + } + + static NSArray arrayWithObject_( + NativeMacOsFramework _lib, NSObject anObject) { + final _ret = _lib._objc_msgSend_106( + _lib._class_NSArray1, _lib._sel_arrayWithObject_1, anObject._id); + return NSArray._(_ret, _lib, retain: true, release: true); + } + + static NSArray arrayWithObjects_count_(NativeMacOsFramework _lib, + ffi.Pointer> objects, int cnt) { + final _ret = _lib._objc_msgSend_52( + _lib._class_NSArray1, _lib._sel_arrayWithObjects_count_1, objects, cnt); + return NSArray._(_ret, _lib, retain: true, release: true); + } + + static NSArray arrayWithObjects_( + NativeMacOsFramework _lib, NSObject firstObj) { + final _ret = _lib._objc_msgSend_106( + _lib._class_NSArray1, _lib._sel_arrayWithObjects_1, firstObj._id); + return NSArray._(_ret, _lib, retain: true, release: true); + } + + static NSArray arrayWithArray_(NativeMacOsFramework _lib, NSArray array) { + final _ret = _lib._objc_msgSend_107( + _lib._class_NSArray1, _lib._sel_arrayWithArray_1, array._id); + return NSArray._(_ret, _lib, retain: true, release: true); + } + + NSArray initWithObjects_(NSObject firstObj) { + final _ret = + _lib._objc_msgSend_106(_id, _lib._sel_initWithObjects_1, firstObj._id); + return NSArray._(_ret, _lib, retain: true, release: true); + } + + NSArray initWithArray_(NSArray array) { + final _ret = + _lib._objc_msgSend_107(_id, _lib._sel_initWithArray_1, array._id); + return NSArray._(_ret, _lib, retain: true, release: true); + } + + NSArray initWithArray_copyItems_(NSArray array, bool flag) { + final _ret = _lib._objc_msgSend_108( + _id, _lib._sel_initWithArray_copyItems_1, array._id, flag); + return NSArray._(_ret, _lib, retain: false, release: true); + } + + NSArray? initWithContentsOfURL_error_( + NSURL url, ffi.Pointer> error) { + final _ret = _lib._objc_msgSend_109( + _id, _lib._sel_initWithContentsOfURL_error_1, url._id, error); + return _ret.address == 0 + ? null + : NSArray._(_ret, _lib, retain: true, release: true); + } + + static NSArray? arrayWithContentsOfURL_error_(NativeMacOsFramework _lib, + NSURL url, ffi.Pointer> error) { + final _ret = _lib._objc_msgSend_109(_lib._class_NSArray1, + _lib._sel_arrayWithContentsOfURL_error_1, url._id, error); + return _ret.address == 0 + ? null + : NSArray._(_ret, _lib, retain: true, release: true); + } + + NSObject differenceFromArray_withOptions_usingEquivalenceTest_( + NSArray other, int options, ObjCBlock_bool_ObjCObject_ObjCObject block) { + final _ret = _lib._objc_msgSend_110( + _id, + _lib._sel_differenceFromArray_withOptions_usingEquivalenceTest_1, + other._id, + options, + block._id); + return NSObject._(_ret, _lib, retain: true, release: true); + } + + NSObject differenceFromArray_withOptions_(NSArray other, int options) { + final _ret = _lib._objc_msgSend_111( + _id, _lib._sel_differenceFromArray_withOptions_1, other._id, options); + return NSObject._(_ret, _lib, retain: true, release: true); + } + + NSObject differenceFromArray_(NSArray other) { + final _ret = + _lib._objc_msgSend_107(_id, _lib._sel_differenceFromArray_1, other._id); + return NSObject._(_ret, _lib, retain: true, release: true); + } + + NSArray? arrayByApplyingDifference_(NSObject difference) { + final _ret = _lib._objc_msgSend_112( + _id, _lib._sel_arrayByApplyingDifference_1, difference._id); + return _ret.address == 0 + ? null + : NSArray._(_ret, _lib, retain: true, release: true); + } + + void getObjects_(ffi.Pointer> objects) { + _lib._objc_msgSend_113(_id, _lib._sel_getObjects_1, objects); + } + + static NSArray? arrayWithContentsOfFile_( + NativeMacOsFramework _lib, NSString path) { + final _ret = _lib._objc_msgSend_114( + _lib._class_NSArray1, _lib._sel_arrayWithContentsOfFile_1, path._id); + return _ret.address == 0 + ? null + : NSArray._(_ret, _lib, retain: true, release: true); + } + + static NSArray? arrayWithContentsOfURL_( + NativeMacOsFramework _lib, NSURL url) { + final _ret = _lib._objc_msgSend_115( + _lib._class_NSArray1, _lib._sel_arrayWithContentsOfURL_1, url._id); + return _ret.address == 0 + ? null + : NSArray._(_ret, _lib, retain: true, release: true); + } + + NSArray? initWithContentsOfFile_(NSString path) { + final _ret = _lib._objc_msgSend_114( + _id, _lib._sel_initWithContentsOfFile_1, path._id); + return _ret.address == 0 + ? null + : NSArray._(_ret, _lib, retain: true, release: true); + } + + NSArray? initWithContentsOfURL_(NSURL url) { + final _ret = + _lib._objc_msgSend_115(_id, _lib._sel_initWithContentsOfURL_1, url._id); + return _ret.address == 0 + ? null + : NSArray._(_ret, _lib, retain: true, release: true); + } + + bool writeToFile_atomically_(NSString path, bool useAuxiliaryFile) { + return _lib._objc_msgSend_116( + _id, _lib._sel_writeToFile_atomically_1, path._id, useAuxiliaryFile); + } + + bool writeToURL_atomically_(NSURL url, bool atomically) { + return _lib._objc_msgSend_117( + _id, _lib._sel_writeToURL_atomically_1, url._id, atomically); + } + + static NSArray new1(NativeMacOsFramework _lib) { + final _ret = _lib._objc_msgSend_2(_lib._class_NSArray1, _lib._sel_new1); + return NSArray._(_ret, _lib, retain: false, release: true); + } + + static NSArray allocWithZone_( + NativeMacOsFramework _lib, ffi.Pointer<_NSZone> zone) { + final _ret = _lib._objc_msgSend_3( + _lib._class_NSArray1, _lib._sel_allocWithZone_1, zone); + return NSArray._(_ret, _lib, retain: false, release: true); + } + + static NSArray alloc(NativeMacOsFramework _lib) { + final _ret = _lib._objc_msgSend_2(_lib._class_NSArray1, _lib._sel_alloc1); + return NSArray._(_ret, _lib, retain: false, release: true); + } +} + +final class _NSRange extends ffi.Struct { + @ffi.UnsignedLong() + external int location; + + @ffi.UnsignedLong() + external int length; +} + +class NSEnumerator extends NSObject { + NSEnumerator._(ffi.Pointer id, NativeMacOsFramework lib, + {bool retain = false, bool release = false}) + : super._(id, lib, retain: retain, release: release); + + /// Returns a [NSEnumerator] that points to the same underlying object as [other]. + static NSEnumerator castFrom(T other) { + return NSEnumerator._(other._id, other._lib, retain: true, release: true); + } + + /// Returns a [NSEnumerator] that wraps the given raw object pointer. + static NSEnumerator castFromPointer( + NativeMacOsFramework lib, ffi.Pointer other, + {bool retain = false, bool release = false}) { + return NSEnumerator._(other, lib, retain: retain, release: release); + } + + /// Returns whether [obj] is an instance of [NSEnumerator]. + static bool isInstance(_ObjCWrapper obj) { + return obj._lib._objc_msgSend_0( + obj._id, obj._lib._sel_isKindOfClass_1, obj._lib._class_NSEnumerator1); + } + + NSObject? nextObject() { + final _ret = _lib._objc_msgSend_25(_id, _lib._sel_nextObject1); + return _ret.address == 0 + ? null + : NSObject._(_ret, _lib, retain: true, release: true); + } + + NSObject get allObjects { + final _ret = _lib._objc_msgSend_2(_id, _lib._sel_allObjects1); + return NSObject._(_ret, _lib, retain: true, release: true); + } + + @override + NSEnumerator init() { + final _ret = _lib._objc_msgSend_2(_id, _lib._sel_init1); + return NSEnumerator._(_ret, _lib, retain: true, release: true); + } + + static NSEnumerator new1(NativeMacOsFramework _lib) { + final _ret = + _lib._objc_msgSend_2(_lib._class_NSEnumerator1, _lib._sel_new1); + return NSEnumerator._(_ret, _lib, retain: false, release: true); + } + + static NSEnumerator allocWithZone_( + NativeMacOsFramework _lib, ffi.Pointer<_NSZone> zone) { + final _ret = _lib._objc_msgSend_3( + _lib._class_NSEnumerator1, _lib._sel_allocWithZone_1, zone); + return NSEnumerator._(_ret, _lib, retain: false, release: true); + } + + static NSEnumerator alloc(NativeMacOsFramework _lib) { + final _ret = + _lib._objc_msgSend_2(_lib._class_NSEnumerator1, _lib._sel_alloc1); + return NSEnumerator._(_ret, _lib, retain: false, release: true); + } +} + +class NSURL extends _ObjCWrapper { + NSURL._(ffi.Pointer id, NativeMacOsFramework lib, + {bool retain = false, bool release = false}) + : super._(id, lib, retain: retain, release: release); + + /// Returns a [NSURL] that points to the same underlying object as [other]. + static NSURL castFrom(T other) { + return NSURL._(other._id, other._lib, retain: true, release: true); + } + + /// Returns a [NSURL] that wraps the given raw object pointer. + static NSURL castFromPointer( + NativeMacOsFramework lib, ffi.Pointer other, + {bool retain = false, bool release = false}) { + return NSURL._(other, lib, retain: retain, release: release); + } + + /// Returns whether [obj] is an instance of [NSURL]. + static bool isInstance(_ObjCWrapper obj) { + return obj._lib._objc_msgSend_0( + obj._id, obj._lib._sel_isKindOfClass_1, obj._lib._class_NSURL1); + } +} + +class NSIndexSet extends NSObject { + NSIndexSet._(ffi.Pointer id, NativeMacOsFramework lib, + {bool retain = false, bool release = false}) + : super._(id, lib, retain: retain, release: release); + + /// Returns a [NSIndexSet] that points to the same underlying object as [other]. + static NSIndexSet castFrom(T other) { + return NSIndexSet._(other._id, other._lib, retain: true, release: true); + } + + /// Returns a [NSIndexSet] that wraps the given raw object pointer. + static NSIndexSet castFromPointer( + NativeMacOsFramework lib, ffi.Pointer other, + {bool retain = false, bool release = false}) { + return NSIndexSet._(other, lib, retain: retain, release: release); + } + + /// Returns whether [obj] is an instance of [NSIndexSet]. + static bool isInstance(_ObjCWrapper obj) { + return obj._lib._objc_msgSend_0( + obj._id, obj._lib._sel_isKindOfClass_1, obj._lib._class_NSIndexSet1); + } + + static NSIndexSet indexSet(NativeMacOsFramework _lib) { + final _ret = + _lib._objc_msgSend_2(_lib._class_NSIndexSet1, _lib._sel_indexSet1); + return NSIndexSet._(_ret, _lib, retain: true, release: true); + } + + static NSIndexSet indexSetWithIndex_(NativeMacOsFramework _lib, int value) { + final _ret = _lib._objc_msgSend_51( + _lib._class_NSIndexSet1, _lib._sel_indexSetWithIndex_1, value); + return NSIndexSet._(_ret, _lib, retain: true, release: true); + } + + static NSIndexSet indexSetWithIndexesInRange_( + NativeMacOsFramework _lib, _NSRange range) { + final _ret = _lib._objc_msgSend_73( + _lib._class_NSIndexSet1, _lib._sel_indexSetWithIndexesInRange_1, range); + return NSIndexSet._(_ret, _lib, retain: true, release: true); + } + + NSIndexSet initWithIndexesInRange_(_NSRange range) { + final _ret = + _lib._objc_msgSend_73(_id, _lib._sel_initWithIndexesInRange_1, range); + return NSIndexSet._(_ret, _lib, retain: true, release: true); + } + + NSIndexSet initWithIndexSet_(NSIndexSet indexSet) { + final _ret = + _lib._objc_msgSend_74(_id, _lib._sel_initWithIndexSet_1, indexSet._id); + return NSIndexSet._(_ret, _lib, retain: true, release: true); + } + + NSIndexSet initWithIndex_(int value) { + final _ret = _lib._objc_msgSend_51(_id, _lib._sel_initWithIndex_1, value); + return NSIndexSet._(_ret, _lib, retain: true, release: true); + } + + bool isEqualToIndexSet_(NSIndexSet indexSet) { + return _lib._objc_msgSend_75( + _id, _lib._sel_isEqualToIndexSet_1, indexSet._id); + } + + int get count { + return _lib._objc_msgSend_12(_id, _lib._sel_count1); + } + + int get firstIndex { + return _lib._objc_msgSend_12(_id, _lib._sel_firstIndex1); + } + + int get lastIndex { + return _lib._objc_msgSend_12(_id, _lib._sel_lastIndex1); + } + + int indexGreaterThanIndex_(int value) { + return _lib._objc_msgSend_76(_id, _lib._sel_indexGreaterThanIndex_1, value); + } + + int indexLessThanIndex_(int value) { + return _lib._objc_msgSend_76(_id, _lib._sel_indexLessThanIndex_1, value); + } + + int indexGreaterThanOrEqualToIndex_(int value) { + return _lib._objc_msgSend_76( + _id, _lib._sel_indexGreaterThanOrEqualToIndex_1, value); + } + + int indexLessThanOrEqualToIndex_(int value) { + return _lib._objc_msgSend_76( + _id, _lib._sel_indexLessThanOrEqualToIndex_1, value); + } + + int getIndexes_maxCount_inIndexRange_( + ffi.Pointer indexBuffer, + int bufferSize, + ffi.Pointer<_NSRange> range) { + return _lib._objc_msgSend_77( + _id, + _lib._sel_getIndexes_maxCount_inIndexRange_1, + indexBuffer, + bufferSize, + range); + } + + int countOfIndexesInRange_(_NSRange range) { + return _lib._objc_msgSend_78(_id, _lib._sel_countOfIndexesInRange_1, range); + } + + bool containsIndex_(int value) { + return _lib._objc_msgSend_79(_id, _lib._sel_containsIndex_1, value); + } + + bool containsIndexesInRange_(_NSRange range) { + return _lib._objc_msgSend_80( + _id, _lib._sel_containsIndexesInRange_1, range); + } + + bool containsIndexes_(NSIndexSet indexSet) { + return _lib._objc_msgSend_75( + _id, _lib._sel_containsIndexes_1, indexSet._id); + } + + bool intersectsIndexesInRange_(_NSRange range) { + return _lib._objc_msgSend_80( + _id, _lib._sel_intersectsIndexesInRange_1, range); + } + + void enumerateIndexesUsingBlock_( + ObjCBlock_ffiVoid_ffiUnsignedLong_bool block) { + _lib._objc_msgSend_81( + _id, _lib._sel_enumerateIndexesUsingBlock_1, block._id); + } + + void enumerateIndexesWithOptions_usingBlock_( + int opts, ObjCBlock_ffiVoid_ffiUnsignedLong_bool block) { + _lib._objc_msgSend_82(_id, + _lib._sel_enumerateIndexesWithOptions_usingBlock_1, opts, block._id); + } + + void enumerateIndexesInRange_options_usingBlock_( + _NSRange range, int opts, ObjCBlock_ffiVoid_ffiUnsignedLong_bool block) { + _lib._objc_msgSend_83( + _id, + _lib._sel_enumerateIndexesInRange_options_usingBlock_1, + range, + opts, + block._id); + } + + int indexPassingTest_(ObjCBlock_bool_ffiUnsignedLong_bool predicate) { + return _lib._objc_msgSend_84( + _id, _lib._sel_indexPassingTest_1, predicate._id); + } + + int indexWithOptions_passingTest_( + int opts, ObjCBlock_bool_ffiUnsignedLong_bool predicate) { + return _lib._objc_msgSend_85( + _id, _lib._sel_indexWithOptions_passingTest_1, opts, predicate._id); + } + + int indexInRange_options_passingTest_( + _NSRange range, int opts, ObjCBlock_bool_ffiUnsignedLong_bool predicate) { + return _lib._objc_msgSend_86( + _id, + _lib._sel_indexInRange_options_passingTest_1, + range, + opts, + predicate._id); + } + + NSIndexSet indexesPassingTest_( + ObjCBlock_bool_ffiUnsignedLong_bool predicate) { + final _ret = _lib._objc_msgSend_87( + _id, _lib._sel_indexesPassingTest_1, predicate._id); + return NSIndexSet._(_ret, _lib, retain: true, release: true); + } + + NSIndexSet indexesWithOptions_passingTest_( + int opts, ObjCBlock_bool_ffiUnsignedLong_bool predicate) { + final _ret = _lib._objc_msgSend_88( + _id, _lib._sel_indexesWithOptions_passingTest_1, opts, predicate._id); + return NSIndexSet._(_ret, _lib, retain: true, release: true); + } + + NSIndexSet indexesInRange_options_passingTest_( + _NSRange range, int opts, ObjCBlock_bool_ffiUnsignedLong_bool predicate) { + final _ret = _lib._objc_msgSend_89( + _id, + _lib._sel_indexesInRange_options_passingTest_1, + range, + opts, + predicate._id); + return NSIndexSet._(_ret, _lib, retain: true, release: true); + } + + void enumerateRangesUsingBlock_(ObjCBlock_ffiVoid_NSRange_bool block) { + _lib._objc_msgSend_90( + _id, _lib._sel_enumerateRangesUsingBlock_1, block._id); + } + + void enumerateRangesWithOptions_usingBlock_( + int opts, ObjCBlock_ffiVoid_NSRange_bool block) { + _lib._objc_msgSend_91(_id, + _lib._sel_enumerateRangesWithOptions_usingBlock_1, opts, block._id); + } + + void enumerateRangesInRange_options_usingBlock_( + _NSRange range, int opts, ObjCBlock_ffiVoid_NSRange_bool block) { + _lib._objc_msgSend_92( + _id, + _lib._sel_enumerateRangesInRange_options_usingBlock_1, + range, + opts, + block._id); + } + + @override + NSIndexSet init() { + final _ret = _lib._objc_msgSend_2(_id, _lib._sel_init1); + return NSIndexSet._(_ret, _lib, retain: true, release: true); + } + + static NSIndexSet new1(NativeMacOsFramework _lib) { + final _ret = _lib._objc_msgSend_2(_lib._class_NSIndexSet1, _lib._sel_new1); + return NSIndexSet._(_ret, _lib, retain: false, release: true); + } + + static NSIndexSet allocWithZone_( + NativeMacOsFramework _lib, ffi.Pointer<_NSZone> zone) { + final _ret = _lib._objc_msgSend_3( + _lib._class_NSIndexSet1, _lib._sel_allocWithZone_1, zone); + return NSIndexSet._(_ret, _lib, retain: false, release: true); + } + + static NSIndexSet alloc(NativeMacOsFramework _lib) { + final _ret = + _lib._objc_msgSend_2(_lib._class_NSIndexSet1, _lib._sel_alloc1); + return NSIndexSet._(_ret, _lib, retain: false, release: true); + } +} + +class _ObjCBlockBase implements ffi.Finalizable { + final ffi.Pointer<_ObjCBlock> _id; + final NativeMacOsFramework _lib; + bool _pendingRelease; + + _ObjCBlockBase._(this._id, this._lib, + {bool retain = false, bool release = false}) + : _pendingRelease = release { + if (retain) { + _lib._Block_copy(_id.cast()); + } + if (release) { + _lib._objc_releaseFinalizer11.attach(this, _id.cast(), detach: this); + } + } + + /// Releases the reference to the underlying ObjC block held by this wrapper. + /// Throws a StateError if this wrapper doesn't currently hold a reference. + void release() { + if (_pendingRelease) { + _pendingRelease = false; + _lib._Block_release(_id.cast()); + _lib._objc_releaseFinalizer11.detach(this); + } else { + throw StateError( + 'Released an ObjC block that was unowned or already released.'); + } + } + + @override + bool operator ==(Object other) { + return other is _ObjCBlockBase && _id == other._id; + } + + @override + int get hashCode => _id.hashCode; + + /// Return a pointer to this object. + ffi.Pointer<_ObjCBlock> get pointer => _id; + + ffi.Pointer<_ObjCBlock> _retainAndReturnId() { + _lib._Block_copy(_id.cast()); + return _id; + } +} + +void _ObjCBlock_ffiVoid_ffiUnsignedLong_bool_fnPtrTrampoline( + ffi.Pointer<_ObjCBlock> block, int arg0, ffi.Pointer arg1) => + block.ref.target + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.UnsignedLong arg0, ffi.Pointer arg1)>>() + .asFunction)>()(arg0, arg1); +final _ObjCBlock_ffiVoid_ffiUnsignedLong_bool_closureRegistry = + )>{}; +int _ObjCBlock_ffiVoid_ffiUnsignedLong_bool_closureRegistryIndex = 0; +ffi.Pointer _ObjCBlock_ffiVoid_ffiUnsignedLong_bool_registerClosure( + void Function(int, ffi.Pointer) fn) { + final id = ++_ObjCBlock_ffiVoid_ffiUnsignedLong_bool_closureRegistryIndex; + _ObjCBlock_ffiVoid_ffiUnsignedLong_bool_closureRegistry[id] = fn; + return ffi.Pointer.fromAddress(id); +} + +void _ObjCBlock_ffiVoid_ffiUnsignedLong_bool_closureTrampoline( + ffi.Pointer<_ObjCBlock> block, int arg0, ffi.Pointer arg1) => + _ObjCBlock_ffiVoid_ffiUnsignedLong_bool_closureRegistry[ + block.ref.target.address]!(arg0, arg1); + +class ObjCBlock_ffiVoid_ffiUnsignedLong_bool extends _ObjCBlockBase { + ObjCBlock_ffiVoid_ffiUnsignedLong_bool._( + ffi.Pointer<_ObjCBlock> id, NativeMacOsFramework lib, + {bool retain = false, bool release = true}) + : super._(id, lib, retain: retain, release: release); + + /// Creates a block from a C function pointer. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + ObjCBlock_ffiVoid_ffiUnsignedLong_bool.fromFunctionPointer( + NativeMacOsFramework lib, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.UnsignedLong arg0, ffi.Pointer arg1)>> + ptr) + : this._( + lib._newBlock1( + _cFuncTrampoline ??= ffi.Pointer.fromFunction< + ffi.Void Function(ffi.Pointer<_ObjCBlock>, + ffi.UnsignedLong, ffi.Pointer)>( + _ObjCBlock_ffiVoid_ffiUnsignedLong_bool_fnPtrTrampoline) + .cast(), + ptr.cast()), + lib); + static ffi.Pointer? _cFuncTrampoline; + + /// Creates a block from a Dart function. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + ObjCBlock_ffiVoid_ffiUnsignedLong_bool.fromFunction( + NativeMacOsFramework lib, void Function(int, ffi.Pointer) fn) + : this._( + lib._newBlock1( + _dartFuncTrampoline ??= ffi.Pointer.fromFunction< + ffi.Void Function(ffi.Pointer<_ObjCBlock>, + ffi.UnsignedLong, ffi.Pointer)>( + _ObjCBlock_ffiVoid_ffiUnsignedLong_bool_closureTrampoline) + .cast(), + _ObjCBlock_ffiVoid_ffiUnsignedLong_bool_registerClosure( + (int arg0, ffi.Pointer arg1) => fn(arg0, arg1))), + lib); + static ffi.Pointer? _dartFuncTrampoline; + + /// Creates a listener block from a Dart function. + /// + /// This is based on FFI's NativeCallable.listener, and has the same + /// capabilities and limitations. This block can be invoked from any thread, + /// but only supports void functions, and is not run synchronously. See + /// NativeCallable.listener for more details. + /// + /// Note that unlike the default behavior of NativeCallable.listener, listener + /// blocks do not keep the isolate alive. + ObjCBlock_ffiVoid_ffiUnsignedLong_bool.listener( + NativeMacOsFramework lib, void Function(int, ffi.Pointer) fn) + : this._( + lib._newBlock1( + (_dartFuncListenerTrampoline ??= ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer<_ObjCBlock>, + ffi.UnsignedLong, + ffi.Pointer)>.listener( + _ObjCBlock_ffiVoid_ffiUnsignedLong_bool_closureTrampoline) + ..keepIsolateAlive = false) + .nativeFunction + .cast(), + _ObjCBlock_ffiVoid_ffiUnsignedLong_bool_registerClosure( + (int arg0, ffi.Pointer arg1) => fn(arg0, arg1))), + lib); + static ffi.NativeCallable< + ffi.Void Function(ffi.Pointer<_ObjCBlock>, ffi.UnsignedLong, + ffi.Pointer)>? _dartFuncListenerTrampoline; + + void call(int arg0, ffi.Pointer arg1) => _id.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer<_ObjCBlock> block, + ffi.UnsignedLong arg0, ffi.Pointer arg1)>>() + .asFunction< + void Function(ffi.Pointer<_ObjCBlock>, int, + ffi.Pointer)>()(_id, arg0, arg1); +} + +final class _ObjCBlockDesc extends ffi.Struct { + @ffi.UnsignedLong() + external int reserved; + + @ffi.UnsignedLong() + external int size; + + external ffi.Pointer copy_helper; + + external ffi.Pointer dispose_helper; + + external ffi.Pointer signature; +} + +final class _ObjCBlock extends ffi.Struct { + external ffi.Pointer isa; + + @ffi.Int() + external int flags; + + @ffi.Int() + external int reserved; + + external ffi.Pointer invoke; + + external ffi.Pointer<_ObjCBlockDesc> descriptor; + + external ffi.Pointer target; +} + +abstract class NSEnumerationOptions { + static const int NSEnumerationConcurrent = 1; + static const int NSEnumerationReverse = 2; +} + +bool _ObjCBlock_bool_ffiUnsignedLong_bool_fnPtrTrampoline( + ffi.Pointer<_ObjCBlock> block, int arg0, ffi.Pointer arg1) => + block.ref.target + .cast< + ffi.NativeFunction< + ffi.Bool Function( + ffi.UnsignedLong arg0, ffi.Pointer arg1)>>() + .asFunction)>()(arg0, arg1); +final _ObjCBlock_bool_ffiUnsignedLong_bool_closureRegistry = + )>{}; +int _ObjCBlock_bool_ffiUnsignedLong_bool_closureRegistryIndex = 0; +ffi.Pointer _ObjCBlock_bool_ffiUnsignedLong_bool_registerClosure( + bool Function(int, ffi.Pointer) fn) { + final id = ++_ObjCBlock_bool_ffiUnsignedLong_bool_closureRegistryIndex; + _ObjCBlock_bool_ffiUnsignedLong_bool_closureRegistry[id] = fn; + return ffi.Pointer.fromAddress(id); +} + +bool _ObjCBlock_bool_ffiUnsignedLong_bool_closureTrampoline( + ffi.Pointer<_ObjCBlock> block, int arg0, ffi.Pointer arg1) => + _ObjCBlock_bool_ffiUnsignedLong_bool_closureRegistry[ + block.ref.target.address]!(arg0, arg1); + +class ObjCBlock_bool_ffiUnsignedLong_bool extends _ObjCBlockBase { + ObjCBlock_bool_ffiUnsignedLong_bool._( + ffi.Pointer<_ObjCBlock> id, NativeMacOsFramework lib, + {bool retain = false, bool release = true}) + : super._(id, lib, retain: retain, release: release); + + /// Creates a block from a C function pointer. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + ObjCBlock_bool_ffiUnsignedLong_bool.fromFunctionPointer( + NativeMacOsFramework lib, + ffi.Pointer< + ffi.NativeFunction< + ffi.Bool Function( + ffi.UnsignedLong arg0, ffi.Pointer arg1)>> + ptr) + : this._( + lib._newBlock1( + _cFuncTrampoline ??= ffi.Pointer.fromFunction< + ffi.Bool Function(ffi.Pointer<_ObjCBlock>, + ffi.UnsignedLong, ffi.Pointer)>( + _ObjCBlock_bool_ffiUnsignedLong_bool_fnPtrTrampoline, + false) + .cast(), + ptr.cast()), + lib); + static ffi.Pointer? _cFuncTrampoline; + + /// Creates a block from a Dart function. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + ObjCBlock_bool_ffiUnsignedLong_bool.fromFunction( + NativeMacOsFramework lib, bool Function(int, ffi.Pointer) fn) + : this._( + lib._newBlock1( + _dartFuncTrampoline ??= ffi.Pointer.fromFunction< + ffi.Bool Function(ffi.Pointer<_ObjCBlock>, + ffi.UnsignedLong, ffi.Pointer)>( + _ObjCBlock_bool_ffiUnsignedLong_bool_closureTrampoline, + false) + .cast(), + _ObjCBlock_bool_ffiUnsignedLong_bool_registerClosure( + (int arg0, ffi.Pointer arg1) => fn(arg0, arg1))), + lib); + static ffi.Pointer? _dartFuncTrampoline; + + bool call(int arg0, ffi.Pointer arg1) => _id.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Bool Function(ffi.Pointer<_ObjCBlock> block, + ffi.UnsignedLong arg0, ffi.Pointer arg1)>>() + .asFunction< + bool Function(ffi.Pointer<_ObjCBlock>, int, + ffi.Pointer)>()(_id, arg0, arg1); +} + +void _ObjCBlock_ffiVoid_NSRange_bool_fnPtrTrampoline( + ffi.Pointer<_ObjCBlock> block, + _NSRange arg0, + ffi.Pointer arg1) => + block.ref.target + .cast< + ffi.NativeFunction< + ffi.Void Function(_NSRange arg0, ffi.Pointer arg1)>>() + .asFunction< + void Function(_NSRange, ffi.Pointer)>()(arg0, arg1); +final _ObjCBlock_ffiVoid_NSRange_bool_closureRegistry = + )>{}; +int _ObjCBlock_ffiVoid_NSRange_bool_closureRegistryIndex = 0; +ffi.Pointer _ObjCBlock_ffiVoid_NSRange_bool_registerClosure( + void Function(_NSRange, ffi.Pointer) fn) { + final id = ++_ObjCBlock_ffiVoid_NSRange_bool_closureRegistryIndex; + _ObjCBlock_ffiVoid_NSRange_bool_closureRegistry[id] = fn; + return ffi.Pointer.fromAddress(id); +} + +void _ObjCBlock_ffiVoid_NSRange_bool_closureTrampoline( + ffi.Pointer<_ObjCBlock> block, + _NSRange arg0, + ffi.Pointer arg1) => + _ObjCBlock_ffiVoid_NSRange_bool_closureRegistry[block.ref.target.address]!( + arg0, arg1); + +class ObjCBlock_ffiVoid_NSRange_bool extends _ObjCBlockBase { + ObjCBlock_ffiVoid_NSRange_bool._( + ffi.Pointer<_ObjCBlock> id, NativeMacOsFramework lib, + {bool retain = false, bool release = true}) + : super._(id, lib, retain: retain, release: release); + + /// Creates a block from a C function pointer. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + ObjCBlock_ffiVoid_NSRange_bool.fromFunctionPointer( + NativeMacOsFramework lib, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(_NSRange arg0, ffi.Pointer arg1)>> + ptr) + : this._( + lib._newBlock1( + _cFuncTrampoline ??= ffi.Pointer.fromFunction< + ffi.Void Function(ffi.Pointer<_ObjCBlock>, _NSRange, + ffi.Pointer)>( + _ObjCBlock_ffiVoid_NSRange_bool_fnPtrTrampoline) + .cast(), + ptr.cast()), + lib); + static ffi.Pointer? _cFuncTrampoline; + + /// Creates a block from a Dart function. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + ObjCBlock_ffiVoid_NSRange_bool.fromFunction(NativeMacOsFramework lib, + void Function(_NSRange, ffi.Pointer) fn) + : this._( + lib._newBlock1( + _dartFuncTrampoline ??= ffi.Pointer.fromFunction< + ffi.Void Function(ffi.Pointer<_ObjCBlock>, _NSRange, + ffi.Pointer)>( + _ObjCBlock_ffiVoid_NSRange_bool_closureTrampoline) + .cast(), + _ObjCBlock_ffiVoid_NSRange_bool_registerClosure( + (_NSRange arg0, ffi.Pointer arg1) => + fn(arg0, arg1))), + lib); + static ffi.Pointer? _dartFuncTrampoline; + + /// Creates a listener block from a Dart function. + /// + /// This is based on FFI's NativeCallable.listener, and has the same + /// capabilities and limitations. This block can be invoked from any thread, + /// but only supports void functions, and is not run synchronously. See + /// NativeCallable.listener for more details. + /// + /// Note that unlike the default behavior of NativeCallable.listener, listener + /// blocks do not keep the isolate alive. + ObjCBlock_ffiVoid_NSRange_bool.listener(NativeMacOsFramework lib, + void Function(_NSRange, ffi.Pointer) fn) + : this._( + lib._newBlock1( + (_dartFuncListenerTrampoline ??= ffi.NativeCallable< + ffi.Void Function(ffi.Pointer<_ObjCBlock>, _NSRange, + ffi.Pointer)>.listener( + _ObjCBlock_ffiVoid_NSRange_bool_closureTrampoline) + ..keepIsolateAlive = false) + .nativeFunction + .cast(), + _ObjCBlock_ffiVoid_NSRange_bool_registerClosure( + (_NSRange arg0, ffi.Pointer arg1) => + fn(arg0, arg1))), + lib); + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer<_ObjCBlock>, _NSRange, ffi.Pointer)>? + _dartFuncListenerTrampoline; + + void call(_NSRange arg0, ffi.Pointer arg1) => _id.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer<_ObjCBlock> block, _NSRange arg0, + ffi.Pointer arg1)>>() + .asFunction< + void Function(ffi.Pointer<_ObjCBlock>, _NSRange, + ffi.Pointer)>()(_id, arg0, arg1); +} + +void _ObjCBlock_ffiVoid_ObjCObject_ffiUnsignedLong_bool_fnPtrTrampoline( + ffi.Pointer<_ObjCBlock> block, + ffi.Pointer arg0, + int arg1, + ffi.Pointer arg2) => + block.ref.target + .cast< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer arg0, + ffi.UnsignedLong arg1, ffi.Pointer arg2)>>() + .asFunction< + void Function(ffi.Pointer, int, + ffi.Pointer)>()(arg0, arg1, arg2); +final _ObjCBlock_ffiVoid_ObjCObject_ffiUnsignedLong_bool_closureRegistry = + , int, ffi.Pointer)>{}; +int _ObjCBlock_ffiVoid_ObjCObject_ffiUnsignedLong_bool_closureRegistryIndex = 0; +ffi.Pointer + _ObjCBlock_ffiVoid_ObjCObject_ffiUnsignedLong_bool_registerClosure( + void Function(ffi.Pointer, int, ffi.Pointer) fn) { + final id = + ++_ObjCBlock_ffiVoid_ObjCObject_ffiUnsignedLong_bool_closureRegistryIndex; + _ObjCBlock_ffiVoid_ObjCObject_ffiUnsignedLong_bool_closureRegistry[id] = fn; + return ffi.Pointer.fromAddress(id); +} + +void _ObjCBlock_ffiVoid_ObjCObject_ffiUnsignedLong_bool_closureTrampoline( + ffi.Pointer<_ObjCBlock> block, + ffi.Pointer arg0, + int arg1, + ffi.Pointer arg2) => + _ObjCBlock_ffiVoid_ObjCObject_ffiUnsignedLong_bool_closureRegistry[ + block.ref.target.address]!(arg0, arg1, arg2); + +class ObjCBlock_ffiVoid_ObjCObject_ffiUnsignedLong_bool extends _ObjCBlockBase { + ObjCBlock_ffiVoid_ObjCObject_ffiUnsignedLong_bool._( + ffi.Pointer<_ObjCBlock> id, NativeMacOsFramework lib, + {bool retain = false, bool release = true}) + : super._(id, lib, retain: retain, release: release); + + /// Creates a block from a C function pointer. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + ObjCBlock_ffiVoid_ObjCObject_ffiUnsignedLong_bool.fromFunctionPointer( + NativeMacOsFramework lib, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer arg0, + ffi.UnsignedLong arg1, ffi.Pointer arg2)>> + ptr) + : this._( + lib._newBlock1( + _cFuncTrampoline ??= ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer<_ObjCBlock>, + ffi.Pointer, + ffi.UnsignedLong, + ffi.Pointer)>( + _ObjCBlock_ffiVoid_ObjCObject_ffiUnsignedLong_bool_fnPtrTrampoline) + .cast(), + ptr.cast()), + lib); + static ffi.Pointer? _cFuncTrampoline; + + /// Creates a block from a Dart function. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + ObjCBlock_ffiVoid_ObjCObject_ffiUnsignedLong_bool.fromFunction( + NativeMacOsFramework lib, + void Function(NSObject, int, ffi.Pointer) fn) + : this._( + lib._newBlock1( + _dartFuncTrampoline ??= ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer<_ObjCBlock>, + ffi.Pointer, + ffi.UnsignedLong, + ffi.Pointer)>( + _ObjCBlock_ffiVoid_ObjCObject_ffiUnsignedLong_bool_closureTrampoline) + .cast(), + _ObjCBlock_ffiVoid_ObjCObject_ffiUnsignedLong_bool_registerClosure( + (ffi.Pointer arg0, int arg1, + ffi.Pointer arg2) => + fn(NSObject._(arg0, lib, retain: true, release: true), arg1, arg2))), + lib); + static ffi.Pointer? _dartFuncTrampoline; + + /// Creates a listener block from a Dart function. + /// + /// This is based on FFI's NativeCallable.listener, and has the same + /// capabilities and limitations. This block can be invoked from any thread, + /// but only supports void functions, and is not run synchronously. See + /// NativeCallable.listener for more details. + /// + /// Note that unlike the default behavior of NativeCallable.listener, listener + /// blocks do not keep the isolate alive. + ObjCBlock_ffiVoid_ObjCObject_ffiUnsignedLong_bool.listener( + NativeMacOsFramework lib, + void Function(NSObject, int, ffi.Pointer) fn) + : this._( + lib._newBlock1( + (_dartFuncListenerTrampoline ??= ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer<_ObjCBlock>, + ffi.Pointer, + ffi.UnsignedLong, + ffi.Pointer)>.listener( + _ObjCBlock_ffiVoid_ObjCObject_ffiUnsignedLong_bool_closureTrampoline) + ..keepIsolateAlive = false) + .nativeFunction + .cast(), + _ObjCBlock_ffiVoid_ObjCObject_ffiUnsignedLong_bool_registerClosure( + (ffi.Pointer arg0, int arg1, ffi.Pointer arg2) => + fn(NSObject._(arg0, lib, retain: true, release: true), + arg1, arg2))), + lib); + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer<_ObjCBlock>, + ffi.Pointer, + ffi.UnsignedLong, + ffi.Pointer)>? _dartFuncListenerTrampoline; + + void call(NSObject arg0, int arg1, ffi.Pointer arg2) => + _id.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer<_ObjCBlock> block, + ffi.Pointer arg0, + ffi.UnsignedLong arg1, + ffi.Pointer arg2)>>() + .asFunction< + void Function(ffi.Pointer<_ObjCBlock>, ffi.Pointer, + int, ffi.Pointer)>()(_id, arg0._id, arg1, arg2); +} + +bool _ObjCBlock_bool_ObjCObject_ffiUnsignedLong_bool_fnPtrTrampoline( + ffi.Pointer<_ObjCBlock> block, + ffi.Pointer arg0, + int arg1, + ffi.Pointer arg2) => + block.ref.target + .cast< + ffi.NativeFunction< + ffi.Bool Function(ffi.Pointer arg0, + ffi.UnsignedLong arg1, ffi.Pointer arg2)>>() + .asFunction< + bool Function(ffi.Pointer, int, + ffi.Pointer)>()(arg0, arg1, arg2); +final _ObjCBlock_bool_ObjCObject_ffiUnsignedLong_bool_closureRegistry = + , int, ffi.Pointer)>{}; +int _ObjCBlock_bool_ObjCObject_ffiUnsignedLong_bool_closureRegistryIndex = 0; +ffi.Pointer + _ObjCBlock_bool_ObjCObject_ffiUnsignedLong_bool_registerClosure( + bool Function(ffi.Pointer, int, ffi.Pointer) fn) { + final id = + ++_ObjCBlock_bool_ObjCObject_ffiUnsignedLong_bool_closureRegistryIndex; + _ObjCBlock_bool_ObjCObject_ffiUnsignedLong_bool_closureRegistry[id] = fn; + return ffi.Pointer.fromAddress(id); +} + +bool _ObjCBlock_bool_ObjCObject_ffiUnsignedLong_bool_closureTrampoline( + ffi.Pointer<_ObjCBlock> block, + ffi.Pointer arg0, + int arg1, + ffi.Pointer arg2) => + _ObjCBlock_bool_ObjCObject_ffiUnsignedLong_bool_closureRegistry[ + block.ref.target.address]!(arg0, arg1, arg2); + +class ObjCBlock_bool_ObjCObject_ffiUnsignedLong_bool extends _ObjCBlockBase { + ObjCBlock_bool_ObjCObject_ffiUnsignedLong_bool._( + ffi.Pointer<_ObjCBlock> id, NativeMacOsFramework lib, + {bool retain = false, bool release = true}) + : super._(id, lib, retain: retain, release: release); + + /// Creates a block from a C function pointer. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + ObjCBlock_bool_ObjCObject_ffiUnsignedLong_bool.fromFunctionPointer( + NativeMacOsFramework lib, + ffi.Pointer< + ffi.NativeFunction< + ffi.Bool Function(ffi.Pointer arg0, + ffi.UnsignedLong arg1, ffi.Pointer arg2)>> + ptr) + : this._( + lib._newBlock1( + _cFuncTrampoline ??= ffi.Pointer.fromFunction< + ffi.Bool Function( + ffi.Pointer<_ObjCBlock>, + ffi.Pointer, + ffi.UnsignedLong, + ffi.Pointer)>( + _ObjCBlock_bool_ObjCObject_ffiUnsignedLong_bool_fnPtrTrampoline, + false) + .cast(), + ptr.cast()), + lib); + static ffi.Pointer? _cFuncTrampoline; + + /// Creates a block from a Dart function. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + ObjCBlock_bool_ObjCObject_ffiUnsignedLong_bool.fromFunction( + NativeMacOsFramework lib, + bool Function(NSObject, int, ffi.Pointer) fn) + : this._( + lib._newBlock1( + _dartFuncTrampoline ??= ffi.Pointer.fromFunction< + ffi.Bool Function( + ffi.Pointer<_ObjCBlock>, + ffi.Pointer, + ffi.UnsignedLong, + ffi.Pointer)>( + _ObjCBlock_bool_ObjCObject_ffiUnsignedLong_bool_closureTrampoline, false) + .cast(), + _ObjCBlock_bool_ObjCObject_ffiUnsignedLong_bool_registerClosure( + (ffi.Pointer arg0, int arg1, + ffi.Pointer arg2) => + fn(NSObject._(arg0, lib, retain: true, release: true), arg1, arg2))), + lib); + static ffi.Pointer? _dartFuncTrampoline; + + bool call(NSObject arg0, int arg1, ffi.Pointer arg2) => + _id.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Bool Function( + ffi.Pointer<_ObjCBlock> block, + ffi.Pointer arg0, + ffi.UnsignedLong arg1, + ffi.Pointer arg2)>>() + .asFunction< + bool Function(ffi.Pointer<_ObjCBlock>, ffi.Pointer, + int, ffi.Pointer)>()(_id, arg0._id, arg1, arg2); +} + +int _ObjCBlock_NSComparisonResult_ObjCObject_ObjCObject_fnPtrTrampoline( + ffi.Pointer<_ObjCBlock> block, + ffi.Pointer arg0, + ffi.Pointer arg1) => + block.ref.target + .cast< + ffi.NativeFunction< + ffi.Int32 Function(ffi.Pointer arg0, + ffi.Pointer arg1)>>() + .asFunction< + int Function(ffi.Pointer, + ffi.Pointer)>()(arg0, arg1); +final _ObjCBlock_NSComparisonResult_ObjCObject_ObjCObject_closureRegistry = + , ffi.Pointer)>{}; +int _ObjCBlock_NSComparisonResult_ObjCObject_ObjCObject_closureRegistryIndex = + 0; +ffi.Pointer + _ObjCBlock_NSComparisonResult_ObjCObject_ObjCObject_registerClosure( + int Function(ffi.Pointer, ffi.Pointer) fn) { + final id = + ++_ObjCBlock_NSComparisonResult_ObjCObject_ObjCObject_closureRegistryIndex; + _ObjCBlock_NSComparisonResult_ObjCObject_ObjCObject_closureRegistry[id] = fn; + return ffi.Pointer.fromAddress(id); +} + +int _ObjCBlock_NSComparisonResult_ObjCObject_ObjCObject_closureTrampoline( + ffi.Pointer<_ObjCBlock> block, + ffi.Pointer arg0, + ffi.Pointer arg1) => + _ObjCBlock_NSComparisonResult_ObjCObject_ObjCObject_closureRegistry[ + block.ref.target.address]!(arg0, arg1); + +class ObjCBlock_NSComparisonResult_ObjCObject_ObjCObject + extends _ObjCBlockBase { + ObjCBlock_NSComparisonResult_ObjCObject_ObjCObject._( + ffi.Pointer<_ObjCBlock> id, NativeMacOsFramework lib, + {bool retain = false, bool release = true}) + : super._(id, lib, retain: retain, release: release); + + /// Creates a block from a C function pointer. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + ObjCBlock_NSComparisonResult_ObjCObject_ObjCObject.fromFunctionPointer( + NativeMacOsFramework lib, + ffi.Pointer< + ffi.NativeFunction< + ffi.Int32 Function(ffi.Pointer arg0, + ffi.Pointer arg1)>> + ptr) + : this._( + lib._newBlock1( + _cFuncTrampoline ??= ffi.Pointer.fromFunction< + ffi.Int32 Function( + ffi.Pointer<_ObjCBlock>, + ffi.Pointer, + ffi.Pointer)>( + _ObjCBlock_NSComparisonResult_ObjCObject_ObjCObject_fnPtrTrampoline, + 0) + .cast(), + ptr.cast()), + lib); + static ffi.Pointer? _cFuncTrampoline; + + /// Creates a block from a Dart function. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + ObjCBlock_NSComparisonResult_ObjCObject_ObjCObject.fromFunction( + NativeMacOsFramework lib, int Function(NSObject, NSObject) fn) + : this._( + lib._newBlock1( + _dartFuncTrampoline ??= ffi.Pointer.fromFunction< + ffi.Int32 Function(ffi.Pointer<_ObjCBlock>, ffi.Pointer, ffi.Pointer)>( + _ObjCBlock_NSComparisonResult_ObjCObject_ObjCObject_closureTrampoline, 0) + .cast(), + _ObjCBlock_NSComparisonResult_ObjCObject_ObjCObject_registerClosure( + (ffi.Pointer arg0, ffi.Pointer arg1) => fn( + NSObject._(arg0, lib, retain: true, release: true), + NSObject._(arg1, lib, retain: true, release: true)))), + lib); + static ffi.Pointer? _dartFuncTrampoline; + + int call(NSObject arg0, NSObject arg1) => _id.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Int32 Function( + ffi.Pointer<_ObjCBlock> block, + ffi.Pointer arg0, + ffi.Pointer arg1)>>() + .asFunction< + int Function(ffi.Pointer<_ObjCBlock>, ffi.Pointer, + ffi.Pointer)>()(_id, arg0._id, arg1._id); +} + +abstract class NSComparisonResult { + static const int NSOrderedAscending = -1; + static const int NSOrderedSame = 0; + static const int NSOrderedDescending = 1; +} + +abstract class NSSortOptions { + static const int NSSortConcurrent = 1; + static const int NSSortStable = 16; +} + +abstract class NSBinarySearchingOptions { + static const int NSBinarySearchingFirstEqual = 256; + static const int NSBinarySearchingLastEqual = 512; + static const int NSBinarySearchingInsertionIndex = 1024; +} + +abstract class NSOrderedCollectionDifferenceCalculationOptions { + static const int NSOrderedCollectionDifferenceCalculationOmitInsertedObjects = + 1; + static const int NSOrderedCollectionDifferenceCalculationOmitRemovedObjects = + 2; + static const int NSOrderedCollectionDifferenceCalculationInferMoves = 4; +} + +bool _ObjCBlock_bool_ObjCObject_ObjCObject_fnPtrTrampoline( + ffi.Pointer<_ObjCBlock> block, + ffi.Pointer arg0, + ffi.Pointer arg1) => + block.ref.target + .cast< + ffi.NativeFunction< + ffi.Bool Function(ffi.Pointer arg0, + ffi.Pointer arg1)>>() + .asFunction< + bool Function(ffi.Pointer, + ffi.Pointer)>()(arg0, arg1); +final _ObjCBlock_bool_ObjCObject_ObjCObject_closureRegistry = + , ffi.Pointer)>{}; +int _ObjCBlock_bool_ObjCObject_ObjCObject_closureRegistryIndex = 0; +ffi.Pointer _ObjCBlock_bool_ObjCObject_ObjCObject_registerClosure( + bool Function(ffi.Pointer, ffi.Pointer) fn) { + final id = ++_ObjCBlock_bool_ObjCObject_ObjCObject_closureRegistryIndex; + _ObjCBlock_bool_ObjCObject_ObjCObject_closureRegistry[id] = fn; + return ffi.Pointer.fromAddress(id); +} + +bool _ObjCBlock_bool_ObjCObject_ObjCObject_closureTrampoline( + ffi.Pointer<_ObjCBlock> block, + ffi.Pointer arg0, + ffi.Pointer arg1) => + _ObjCBlock_bool_ObjCObject_ObjCObject_closureRegistry[ + block.ref.target.address]!(arg0, arg1); + +class ObjCBlock_bool_ObjCObject_ObjCObject extends _ObjCBlockBase { + ObjCBlock_bool_ObjCObject_ObjCObject._( + ffi.Pointer<_ObjCBlock> id, NativeMacOsFramework lib, + {bool retain = false, bool release = true}) + : super._(id, lib, retain: retain, release: release); + + /// Creates a block from a C function pointer. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + ObjCBlock_bool_ObjCObject_ObjCObject.fromFunctionPointer( + NativeMacOsFramework lib, + ffi.Pointer< + ffi.NativeFunction< + ffi.Bool Function(ffi.Pointer arg0, + ffi.Pointer arg1)>> + ptr) + : this._( + lib._newBlock1( + _cFuncTrampoline ??= ffi.Pointer.fromFunction< + ffi.Bool Function( + ffi.Pointer<_ObjCBlock>, + ffi.Pointer, + ffi.Pointer)>( + _ObjCBlock_bool_ObjCObject_ObjCObject_fnPtrTrampoline, + false) + .cast(), + ptr.cast()), + lib); + static ffi.Pointer? _cFuncTrampoline; + + /// Creates a block from a Dart function. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + ObjCBlock_bool_ObjCObject_ObjCObject.fromFunction( + NativeMacOsFramework lib, bool Function(NSObject, NSObject) fn) + : this._( + lib._newBlock1( + _dartFuncTrampoline ??= ffi.Pointer.fromFunction< + ffi.Bool Function( + ffi.Pointer<_ObjCBlock>, + ffi.Pointer, + ffi.Pointer)>( + _ObjCBlock_bool_ObjCObject_ObjCObject_closureTrampoline, + false) + .cast(), + _ObjCBlock_bool_ObjCObject_ObjCObject_registerClosure( + (ffi.Pointer arg0, ffi.Pointer arg1) => + fn(NSObject._(arg0, lib, retain: true, release: true), NSObject._(arg1, lib, retain: true, release: true)))), + lib); + static ffi.Pointer? _dartFuncTrampoline; + + bool call(NSObject arg0, NSObject arg1) => _id.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Bool Function( + ffi.Pointer<_ObjCBlock> block, + ffi.Pointer arg0, + ffi.Pointer arg1)>>() + .asFunction< + bool Function(ffi.Pointer<_ObjCBlock>, ffi.Pointer, + ffi.Pointer)>()(_id, arg0._id, arg1._id); +} + +class NSDictionary extends NSObject { + NSDictionary._(ffi.Pointer id, NativeMacOsFramework lib, + {bool retain = false, bool release = false}) + : super._(id, lib, retain: retain, release: release); + + /// Returns a [NSDictionary] that points to the same underlying object as [other]. + static NSDictionary castFrom(T other) { + return NSDictionary._(other._id, other._lib, retain: true, release: true); + } + + /// Returns a [NSDictionary] that wraps the given raw object pointer. + static NSDictionary castFromPointer( + NativeMacOsFramework lib, ffi.Pointer other, + {bool retain = false, bool release = false}) { + return NSDictionary._(other, lib, retain: retain, release: release); + } + + /// Returns whether [obj] is an instance of [NSDictionary]. + static bool isInstance(_ObjCWrapper obj) { + return obj._lib._objc_msgSend_0( + obj._id, obj._lib._sel_isKindOfClass_1, obj._lib._class_NSDictionary1); + } + + int get count { + return _lib._objc_msgSend_12(_id, _lib._sel_count1); + } + + NSObject? objectForKey_(NSObject aKey) { + final _ret = + _lib._objc_msgSend_119(_id, _lib._sel_objectForKey_1, aKey._id); + return _ret.address == 0 + ? null + : NSObject._(_ret, _lib, retain: true, release: true); + } + + NSEnumerator keyEnumerator() { + final _ret = _lib._objc_msgSend_65(_id, _lib._sel_keyEnumerator1); + return NSEnumerator._(_ret, _lib, retain: true, release: true); + } + + @override + NSDictionary init() { + final _ret = _lib._objc_msgSend_2(_id, _lib._sel_init1); + return NSDictionary._(_ret, _lib, retain: true, release: true); + } + + NSDictionary initWithObjects_forKeys_count_( + ffi.Pointer> objects, + ffi.Pointer> keys, + int cnt) { + final _ret = _lib._objc_msgSend_120( + _id, _lib._sel_initWithObjects_forKeys_count_1, objects, keys, cnt); + return NSDictionary._(_ret, _lib, retain: true, release: true); + } + + NSDictionary? initWithCoder_(NSCoder coder) { + final _ret = + _lib._objc_msgSend_53(_id, _lib._sel_initWithCoder_1, coder._id); + return _ret.address == 0 + ? null + : NSDictionary._(_ret, _lib, retain: true, release: true); + } + + NSArray get allKeys { + final _ret = _lib._objc_msgSend_121(_id, _lib._sel_allKeys1); + return NSArray._(_ret, _lib, retain: true, release: true); + } + + NSArray allKeysForObject_(NSObject anObject) { + final _ret = + _lib._objc_msgSend_54(_id, _lib._sel_allKeysForObject_1, anObject._id); + return NSArray._(_ret, _lib, retain: true, release: true); + } + + NSArray get allValues { + final _ret = _lib._objc_msgSend_121(_id, _lib._sel_allValues1); + return NSArray._(_ret, _lib, retain: true, release: true); + } + + NSString get description { + final _ret = _lib._objc_msgSend_57(_id, _lib._sel_description1); + return NSString._(_ret, _lib, retain: true, release: true); + } + + NSString get descriptionInStringsFileFormat { + final _ret = + _lib._objc_msgSend_57(_id, _lib._sel_descriptionInStringsFileFormat1); + return NSString._(_ret, _lib, retain: true, release: true); + } + + NSString descriptionWithLocale_(NSObject? locale) { + final _ret = _lib._objc_msgSend_58( + _id, _lib._sel_descriptionWithLocale_1, locale?._id ?? ffi.nullptr); + return NSString._(_ret, _lib, retain: true, release: true); + } + + NSString descriptionWithLocale_indent_(NSObject? locale, int level) { + final _ret = _lib._objc_msgSend_59( + _id, + _lib._sel_descriptionWithLocale_indent_1, + locale?._id ?? ffi.nullptr, + level); + return NSString._(_ret, _lib, retain: true, release: true); + } + + bool isEqualToDictionary_(NSDictionary otherDictionary) { + return _lib._objc_msgSend_122( + _id, _lib._sel_isEqualToDictionary_1, otherDictionary._id); + } + + NSEnumerator objectEnumerator() { + final _ret = _lib._objc_msgSend_65(_id, _lib._sel_objectEnumerator1); + return NSEnumerator._(_ret, _lib, retain: true, release: true); + } + + NSArray objectsForKeys_notFoundMarker_(NSArray keys, NSObject marker) { + final _ret = _lib._objc_msgSend_123( + _id, _lib._sel_objectsForKeys_notFoundMarker_1, keys._id, marker._id); + return NSArray._(_ret, _lib, retain: true, release: true); + } + + bool writeToURL_error_( + NSURL url, ffi.Pointer> error) { + return _lib._objc_msgSend_71( + _id, _lib._sel_writeToURL_error_1, url._id, error); + } + + NSArray keysSortedByValueUsingSelector_(ffi.Pointer comparator) { + final _ret = _lib._objc_msgSend_69( + _id, _lib._sel_keysSortedByValueUsingSelector_1, comparator); + return NSArray._(_ret, _lib, retain: true, release: true); + } + + void getObjects_andKeys_count_(ffi.Pointer> objects, + ffi.Pointer> keys, int count) { + _lib._objc_msgSend_124( + _id, _lib._sel_getObjects_andKeys_count_1, objects, keys, count); + } + + NSObject? objectForKeyedSubscript_(NSObject key) { + final _ret = _lib._objc_msgSend_119( + _id, _lib._sel_objectForKeyedSubscript_1, key._id); + return _ret.address == 0 + ? null + : NSObject._(_ret, _lib, retain: true, release: true); + } + + void enumerateKeysAndObjectsUsingBlock_( + ObjCBlock_ffiVoid_ObjCObject_ObjCObject_bool block) { + _lib._objc_msgSend_125( + _id, _lib._sel_enumerateKeysAndObjectsUsingBlock_1, block._id); + } + + void enumerateKeysAndObjectsWithOptions_usingBlock_( + int opts, ObjCBlock_ffiVoid_ObjCObject_ObjCObject_bool block) { + _lib._objc_msgSend_126( + _id, + _lib._sel_enumerateKeysAndObjectsWithOptions_usingBlock_1, + opts, + block._id); + } + + NSArray keysSortedByValueUsingComparator_( + ObjCBlock_NSComparisonResult_ObjCObject_ObjCObject cmptr) { + final _ret = _lib._objc_msgSend_103( + _id, _lib._sel_keysSortedByValueUsingComparator_1, cmptr._id); + return NSArray._(_ret, _lib, retain: true, release: true); + } + + NSArray keysSortedByValueWithOptions_usingComparator_( + int opts, ObjCBlock_NSComparisonResult_ObjCObject_ObjCObject cmptr) { + final _ret = _lib._objc_msgSend_104( + _id, + _lib._sel_keysSortedByValueWithOptions_usingComparator_1, + opts, + cmptr._id); + return NSArray._(_ret, _lib, retain: true, release: true); + } + + NSObject keysOfEntriesPassingTest_( + ObjCBlock_bool_ObjCObject_ObjCObject_bool predicate) { + final _ret = _lib._objc_msgSend_127( + _id, _lib._sel_keysOfEntriesPassingTest_1, predicate._id); + return NSObject._(_ret, _lib, retain: true, release: true); + } + + NSObject keysOfEntriesWithOptions_passingTest_( + int opts, ObjCBlock_bool_ObjCObject_ObjCObject_bool predicate) { + final _ret = _lib._objc_msgSend_128(_id, + _lib._sel_keysOfEntriesWithOptions_passingTest_1, opts, predicate._id); + return NSObject._(_ret, _lib, retain: true, release: true); + } + + void getObjects_andKeys_(ffi.Pointer> objects, + ffi.Pointer> keys) { + _lib._objc_msgSend_129(_id, _lib._sel_getObjects_andKeys_1, objects, keys); + } + + static NSDictionary? dictionaryWithContentsOfFile_( + NativeMacOsFramework _lib, NSString path) { + final _ret = _lib._objc_msgSend_130(_lib._class_NSDictionary1, + _lib._sel_dictionaryWithContentsOfFile_1, path._id); + return _ret.address == 0 + ? null + : NSDictionary._(_ret, _lib, retain: true, release: true); + } + + static NSDictionary? dictionaryWithContentsOfURL_( + NativeMacOsFramework _lib, NSURL url) { + final _ret = _lib._objc_msgSend_131(_lib._class_NSDictionary1, + _lib._sel_dictionaryWithContentsOfURL_1, url._id); + return _ret.address == 0 + ? null + : NSDictionary._(_ret, _lib, retain: true, release: true); + } + + NSDictionary? initWithContentsOfFile_(NSString path) { + final _ret = _lib._objc_msgSend_130( + _id, _lib._sel_initWithContentsOfFile_1, path._id); + return _ret.address == 0 + ? null + : NSDictionary._(_ret, _lib, retain: true, release: true); + } + + NSDictionary? initWithContentsOfURL_(NSURL url) { + final _ret = + _lib._objc_msgSend_131(_id, _lib._sel_initWithContentsOfURL_1, url._id); + return _ret.address == 0 + ? null + : NSDictionary._(_ret, _lib, retain: true, release: true); + } + + bool writeToFile_atomically_(NSString path, bool useAuxiliaryFile) { + return _lib._objc_msgSend_116( + _id, _lib._sel_writeToFile_atomically_1, path._id, useAuxiliaryFile); + } + + bool writeToURL_atomically_(NSURL url, bool atomically) { + return _lib._objc_msgSend_117( + _id, _lib._sel_writeToURL_atomically_1, url._id, atomically); + } + + static NSDictionary dictionary(NativeMacOsFramework _lib) { + final _ret = + _lib._objc_msgSend_2(_lib._class_NSDictionary1, _lib._sel_dictionary1); + return NSDictionary._(_ret, _lib, retain: true, release: true); + } + + static NSDictionary dictionaryWithObject_forKey_( + NativeMacOsFramework _lib, NSObject object, NSObject key) { + final _ret = _lib._objc_msgSend_132(_lib._class_NSDictionary1, + _lib._sel_dictionaryWithObject_forKey_1, object._id, key._id); + return NSDictionary._(_ret, _lib, retain: true, release: true); + } + + static NSDictionary dictionaryWithObjects_forKeys_count_( + NativeMacOsFramework _lib, + ffi.Pointer> objects, + ffi.Pointer> keys, + int cnt) { + final _ret = _lib._objc_msgSend_120(_lib._class_NSDictionary1, + _lib._sel_dictionaryWithObjects_forKeys_count_1, objects, keys, cnt); + return NSDictionary._(_ret, _lib, retain: true, release: true); + } + + static NSDictionary dictionaryWithObjectsAndKeys_( + NativeMacOsFramework _lib, NSObject firstObject) { + final _ret = _lib._objc_msgSend_106(_lib._class_NSDictionary1, + _lib._sel_dictionaryWithObjectsAndKeys_1, firstObject._id); + return NSDictionary._(_ret, _lib, retain: true, release: true); + } + + static NSDictionary dictionaryWithDictionary_( + NativeMacOsFramework _lib, NSDictionary dict) { + final _ret = _lib._objc_msgSend_133(_lib._class_NSDictionary1, + _lib._sel_dictionaryWithDictionary_1, dict._id); + return NSDictionary._(_ret, _lib, retain: true, release: true); + } + + static NSDictionary dictionaryWithObjects_forKeys_( + NativeMacOsFramework _lib, NSArray objects, NSArray keys) { + final _ret = _lib._objc_msgSend_134(_lib._class_NSDictionary1, + _lib._sel_dictionaryWithObjects_forKeys_1, objects._id, keys._id); + return NSDictionary._(_ret, _lib, retain: true, release: true); + } + + NSDictionary initWithObjectsAndKeys_(NSObject firstObject) { + final _ret = _lib._objc_msgSend_106( + _id, _lib._sel_initWithObjectsAndKeys_1, firstObject._id); + return NSDictionary._(_ret, _lib, retain: true, release: true); + } + + NSDictionary initWithDictionary_(NSDictionary otherDictionary) { + final _ret = _lib._objc_msgSend_133( + _id, _lib._sel_initWithDictionary_1, otherDictionary._id); + return NSDictionary._(_ret, _lib, retain: true, release: true); + } + + NSDictionary initWithDictionary_copyItems_( + NSDictionary otherDictionary, bool flag) { + final _ret = _lib._objc_msgSend_135(_id, + _lib._sel_initWithDictionary_copyItems_1, otherDictionary._id, flag); + return NSDictionary._(_ret, _lib, retain: false, release: true); + } + + NSDictionary initWithObjects_forKeys_(NSArray objects, NSArray keys) { + final _ret = _lib._objc_msgSend_134( + _id, _lib._sel_initWithObjects_forKeys_1, objects._id, keys._id); + return NSDictionary._(_ret, _lib, retain: true, release: true); + } + + NSDictionary? initWithContentsOfURL_error_( + NSURL url, ffi.Pointer> error) { + final _ret = _lib._objc_msgSend_136( + _id, _lib._sel_initWithContentsOfURL_error_1, url._id, error); + return _ret.address == 0 + ? null + : NSDictionary._(_ret, _lib, retain: true, release: true); + } + + static NSDictionary? dictionaryWithContentsOfURL_error_( + NativeMacOsFramework _lib, + NSURL url, + ffi.Pointer> error) { + final _ret = _lib._objc_msgSend_136(_lib._class_NSDictionary1, + _lib._sel_dictionaryWithContentsOfURL_error_1, url._id, error); + return _ret.address == 0 + ? null + : NSDictionary._(_ret, _lib, retain: true, release: true); + } + + static NSObject sharedKeySetForKeys_( + NativeMacOsFramework _lib, NSArray keys) { + final _ret = _lib._objc_msgSend_107( + _lib._class_NSDictionary1, _lib._sel_sharedKeySetForKeys_1, keys._id); + return NSObject._(_ret, _lib, retain: true, release: true); + } + + int countByEnumeratingWithState_objects_count_( + ffi.Pointer state, + ffi.Pointer> buffer, + int len) { + return _lib._objc_msgSend_137( + _id, + _lib._sel_countByEnumeratingWithState_objects_count_1, + state, + buffer, + len); + } + + static NSDictionary new1(NativeMacOsFramework _lib) { + final _ret = + _lib._objc_msgSend_2(_lib._class_NSDictionary1, _lib._sel_new1); + return NSDictionary._(_ret, _lib, retain: false, release: true); + } + + static NSDictionary allocWithZone_( + NativeMacOsFramework _lib, ffi.Pointer<_NSZone> zone) { + final _ret = _lib._objc_msgSend_3( + _lib._class_NSDictionary1, _lib._sel_allocWithZone_1, zone); + return NSDictionary._(_ret, _lib, retain: false, release: true); + } + + static NSDictionary alloc(NativeMacOsFramework _lib) { + final _ret = + _lib._objc_msgSend_2(_lib._class_NSDictionary1, _lib._sel_alloc1); + return NSDictionary._(_ret, _lib, retain: false, release: true); + } +} + +void _ObjCBlock_ffiVoid_ObjCObject_ObjCObject_bool_fnPtrTrampoline( + ffi.Pointer<_ObjCBlock> block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2) => + block.ref.target + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2)>>() + .asFunction< + void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>()(arg0, arg1, arg2); +final _ObjCBlock_ffiVoid_ObjCObject_ObjCObject_bool_closureRegistry = , ffi.Pointer, + ffi.Pointer)>{}; +int _ObjCBlock_ffiVoid_ObjCObject_ObjCObject_bool_closureRegistryIndex = 0; +ffi.Pointer + _ObjCBlock_ffiVoid_ObjCObject_ObjCObject_bool_registerClosure( + void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer) + fn) { + final id = + ++_ObjCBlock_ffiVoid_ObjCObject_ObjCObject_bool_closureRegistryIndex; + _ObjCBlock_ffiVoid_ObjCObject_ObjCObject_bool_closureRegistry[id] = fn; + return ffi.Pointer.fromAddress(id); +} + +void _ObjCBlock_ffiVoid_ObjCObject_ObjCObject_bool_closureTrampoline( + ffi.Pointer<_ObjCBlock> block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2) => + _ObjCBlock_ffiVoid_ObjCObject_ObjCObject_bool_closureRegistry[ + block.ref.target.address]!(arg0, arg1, arg2); + +class ObjCBlock_ffiVoid_ObjCObject_ObjCObject_bool extends _ObjCBlockBase { + ObjCBlock_ffiVoid_ObjCObject_ObjCObject_bool._( + ffi.Pointer<_ObjCBlock> id, NativeMacOsFramework lib, + {bool retain = false, bool release = true}) + : super._(id, lib, retain: retain, release: release); + + /// Creates a block from a C function pointer. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + ObjCBlock_ffiVoid_ObjCObject_ObjCObject_bool.fromFunctionPointer( + NativeMacOsFramework lib, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2)>> + ptr) + : this._( + lib._newBlock1( + _cFuncTrampoline ??= ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer<_ObjCBlock>, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>( + _ObjCBlock_ffiVoid_ObjCObject_ObjCObject_bool_fnPtrTrampoline) + .cast(), + ptr.cast()), + lib); + static ffi.Pointer? _cFuncTrampoline; + + /// Creates a block from a Dart function. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + ObjCBlock_ffiVoid_ObjCObject_ObjCObject_bool.fromFunction( + NativeMacOsFramework lib, + void Function(NSObject, NSObject, ffi.Pointer) fn) + : this._( + lib._newBlock1( + _dartFuncTrampoline ??= ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer<_ObjCBlock>, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>( + _ObjCBlock_ffiVoid_ObjCObject_ObjCObject_bool_closureTrampoline) + .cast(), + _ObjCBlock_ffiVoid_ObjCObject_ObjCObject_bool_registerClosure( + (ffi.Pointer arg0, ffi.Pointer arg1, ffi.Pointer arg2) => fn( + NSObject._(arg0, lib, retain: true, release: true), + NSObject._(arg1, lib, retain: true, release: true), + arg2))), + lib); + static ffi.Pointer? _dartFuncTrampoline; + + /// Creates a listener block from a Dart function. + /// + /// This is based on FFI's NativeCallable.listener, and has the same + /// capabilities and limitations. This block can be invoked from any thread, + /// but only supports void functions, and is not run synchronously. See + /// NativeCallable.listener for more details. + /// + /// Note that unlike the default behavior of NativeCallable.listener, listener + /// blocks do not keep the isolate alive. + ObjCBlock_ffiVoid_ObjCObject_ObjCObject_bool.listener( + NativeMacOsFramework lib, + void Function(NSObject, NSObject, ffi.Pointer) fn) + : this._( + lib._newBlock1( + (_dartFuncListenerTrampoline ??= ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer<_ObjCBlock>, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>.listener( + _ObjCBlock_ffiVoid_ObjCObject_ObjCObject_bool_closureTrampoline) + ..keepIsolateAlive = false) + .nativeFunction + .cast(), + _ObjCBlock_ffiVoid_ObjCObject_ObjCObject_bool_registerClosure((ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2) => + fn( + NSObject._(arg0, lib, retain: true, release: true), + NSObject._(arg1, lib, retain: true, release: true), + arg2))), + lib); + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer<_ObjCBlock>, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>? _dartFuncListenerTrampoline; + + void call(NSObject arg0, NSObject arg1, ffi.Pointer arg2) => + _id.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer<_ObjCBlock> block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2)>>() + .asFunction< + void Function( + ffi.Pointer<_ObjCBlock>, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>()(_id, arg0._id, arg1._id, arg2); +} + +bool _ObjCBlock_bool_ObjCObject_ObjCObject_bool_fnPtrTrampoline( + ffi.Pointer<_ObjCBlock> block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2) => + block.ref.target + .cast< + ffi.NativeFunction< + ffi.Bool Function( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2)>>() + .asFunction< + bool Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>()(arg0, arg1, arg2); +final _ObjCBlock_bool_ObjCObject_ObjCObject_bool_closureRegistry = , ffi.Pointer, + ffi.Pointer)>{}; +int _ObjCBlock_bool_ObjCObject_ObjCObject_bool_closureRegistryIndex = 0; +ffi.Pointer + _ObjCBlock_bool_ObjCObject_ObjCObject_bool_registerClosure( + bool Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer) + fn) { + final id = ++_ObjCBlock_bool_ObjCObject_ObjCObject_bool_closureRegistryIndex; + _ObjCBlock_bool_ObjCObject_ObjCObject_bool_closureRegistry[id] = fn; + return ffi.Pointer.fromAddress(id); +} + +bool _ObjCBlock_bool_ObjCObject_ObjCObject_bool_closureTrampoline( + ffi.Pointer<_ObjCBlock> block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2) => + _ObjCBlock_bool_ObjCObject_ObjCObject_bool_closureRegistry[ + block.ref.target.address]!(arg0, arg1, arg2); + +class ObjCBlock_bool_ObjCObject_ObjCObject_bool extends _ObjCBlockBase { + ObjCBlock_bool_ObjCObject_ObjCObject_bool._( + ffi.Pointer<_ObjCBlock> id, NativeMacOsFramework lib, + {bool retain = false, bool release = true}) + : super._(id, lib, retain: retain, release: release); + + /// Creates a block from a C function pointer. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + ObjCBlock_bool_ObjCObject_ObjCObject_bool.fromFunctionPointer( + NativeMacOsFramework lib, + ffi.Pointer< + ffi.NativeFunction< + ffi.Bool Function( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2)>> + ptr) + : this._( + lib._newBlock1( + _cFuncTrampoline ??= ffi.Pointer.fromFunction< + ffi.Bool Function( + ffi.Pointer<_ObjCBlock>, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>( + _ObjCBlock_bool_ObjCObject_ObjCObject_bool_fnPtrTrampoline, + false) + .cast(), + ptr.cast()), + lib); + static ffi.Pointer? _cFuncTrampoline; + + /// Creates a block from a Dart function. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + ObjCBlock_bool_ObjCObject_ObjCObject_bool.fromFunction( + NativeMacOsFramework lib, + bool Function(NSObject, NSObject, ffi.Pointer) fn) + : this._( + lib._newBlock1( + _dartFuncTrampoline ??= ffi.Pointer.fromFunction< + ffi.Bool Function( + ffi.Pointer<_ObjCBlock>, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>( + _ObjCBlock_bool_ObjCObject_ObjCObject_bool_closureTrampoline, false) + .cast(), + _ObjCBlock_bool_ObjCObject_ObjCObject_bool_registerClosure( + (ffi.Pointer arg0, ffi.Pointer arg1, + ffi.Pointer arg2) => + fn(NSObject._(arg0, lib, retain: true, release: true), NSObject._(arg1, lib, retain: true, release: true), arg2))), + lib); + static ffi.Pointer? _dartFuncTrampoline; + + bool call(NSObject arg0, NSObject arg1, ffi.Pointer arg2) => + _id.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Bool Function( + ffi.Pointer<_ObjCBlock> block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2)>>() + .asFunction< + bool Function( + ffi.Pointer<_ObjCBlock>, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>()(_id, arg0._id, arg1._id, arg2); +} + +final class NSFastEnumerationState extends ffi.Struct { + @ffi.UnsignedLong() + external int state; + + external ffi.Pointer> itemsPtr; + + external ffi.Pointer mutationsPtr; + + @ffi.Array.multi([5]) + external ffi.Array extra; +} + +class NSSet extends NSObject { + NSSet._(ffi.Pointer id, NativeMacOsFramework lib, + {bool retain = false, bool release = false}) + : super._(id, lib, retain: retain, release: release); + + /// Returns a [NSSet] that points to the same underlying object as [other]. + static NSSet castFrom(T other) { + return NSSet._(other._id, other._lib, retain: true, release: true); + } + + /// Returns a [NSSet] that wraps the given raw object pointer. + static NSSet castFromPointer( + NativeMacOsFramework lib, ffi.Pointer other, + {bool retain = false, bool release = false}) { + return NSSet._(other, lib, retain: retain, release: release); + } + + /// Returns whether [obj] is an instance of [NSSet]. + static bool isInstance(_ObjCWrapper obj) { + return obj._lib._objc_msgSend_0( + obj._id, obj._lib._sel_isKindOfClass_1, obj._lib._class_NSSet1); + } + + int get count { + return _lib._objc_msgSend_12(_id, _lib._sel_count1); + } + + NSObject? member_(NSObject object) { + final _ret = _lib._objc_msgSend_119(_id, _lib._sel_member_1, object._id); + return _ret.address == 0 + ? null + : NSObject._(_ret, _lib, retain: true, release: true); + } + + NSEnumerator objectEnumerator() { + final _ret = _lib._objc_msgSend_65(_id, _lib._sel_objectEnumerator1); + return NSEnumerator._(_ret, _lib, retain: true, release: true); + } + + @override + NSSet init() { + final _ret = _lib._objc_msgSend_2(_id, _lib._sel_init1); + return NSSet._(_ret, _lib, retain: true, release: true); + } + + NSSet initWithObjects_count_( + ffi.Pointer> objects, int cnt) { + final _ret = _lib._objc_msgSend_52( + _id, _lib._sel_initWithObjects_count_1, objects, cnt); + return NSSet._(_ret, _lib, retain: true, release: true); + } + + NSSet? initWithCoder_(NSCoder coder) { + final _ret = + _lib._objc_msgSend_53(_id, _lib._sel_initWithCoder_1, coder._id); + return _ret.address == 0 + ? null + : NSSet._(_ret, _lib, retain: true, release: true); + } + + NSArray get allObjects { + final _ret = _lib._objc_msgSend_121(_id, _lib._sel_allObjects1); + return NSArray._(_ret, _lib, retain: true, release: true); + } + + NSObject? anyObject() { + final _ret = _lib._objc_msgSend_25(_id, _lib._sel_anyObject1); + return _ret.address == 0 + ? null + : NSObject._(_ret, _lib, retain: true, release: true); + } + + bool containsObject_(NSObject anObject) { + return _lib._objc_msgSend_0(_id, _lib._sel_containsObject_1, anObject._id); + } + + NSString get description { + final _ret = _lib._objc_msgSend_57(_id, _lib._sel_description1); + return NSString._(_ret, _lib, retain: true, release: true); + } + + NSString descriptionWithLocale_(NSObject? locale) { + final _ret = _lib._objc_msgSend_58( + _id, _lib._sel_descriptionWithLocale_1, locale?._id ?? ffi.nullptr); + return NSString._(_ret, _lib, retain: true, release: true); + } + + bool intersectsSet_(NSSet otherSet) { + return _lib._objc_msgSend_139(_id, _lib._sel_intersectsSet_1, otherSet._id); + } + + bool isEqualToSet_(NSSet otherSet) { + return _lib._objc_msgSend_139(_id, _lib._sel_isEqualToSet_1, otherSet._id); + } + + bool isSubsetOfSet_(NSSet otherSet) { + return _lib._objc_msgSend_139(_id, _lib._sel_isSubsetOfSet_1, otherSet._id); + } + + void makeObjectsPerformSelector_(ffi.Pointer aSelector) { + _lib._objc_msgSend_7( + _id, _lib._sel_makeObjectsPerformSelector_1, aSelector); + } + + void makeObjectsPerformSelector_withObject_( + ffi.Pointer aSelector, NSObject? argument) { + _lib._objc_msgSend_72( + _id, + _lib._sel_makeObjectsPerformSelector_withObject_1, + aSelector, + argument?._id ?? ffi.nullptr); + } + + NSSet setByAddingObject_(NSObject anObject) { + final _ret = _lib._objc_msgSend_140( + _id, _lib._sel_setByAddingObject_1, anObject._id); + return NSSet._(_ret, _lib, retain: true, release: true); + } + + NSSet setByAddingObjectsFromSet_(NSSet other) { + final _ret = _lib._objc_msgSend_141( + _id, _lib._sel_setByAddingObjectsFromSet_1, other._id); + return NSSet._(_ret, _lib, retain: true, release: true); + } + + NSSet setByAddingObjectsFromArray_(NSArray other) { + final _ret = _lib._objc_msgSend_142( + _id, _lib._sel_setByAddingObjectsFromArray_1, other._id); + return NSSet._(_ret, _lib, retain: true, release: true); + } + + void enumerateObjectsUsingBlock_(ObjCBlock_ffiVoid_ObjCObject_bool block) { + _lib._objc_msgSend_143( + _id, _lib._sel_enumerateObjectsUsingBlock_1, block._id); + } + + void enumerateObjectsWithOptions_usingBlock_( + int opts, ObjCBlock_ffiVoid_ObjCObject_bool block) { + _lib._objc_msgSend_144(_id, + _lib._sel_enumerateObjectsWithOptions_usingBlock_1, opts, block._id); + } + + NSSet objectsPassingTest_(ObjCBlock_bool_ObjCObject_bool predicate) { + final _ret = _lib._objc_msgSend_145( + _id, _lib._sel_objectsPassingTest_1, predicate._id); + return NSSet._(_ret, _lib, retain: true, release: true); + } + + NSSet objectsWithOptions_passingTest_( + int opts, ObjCBlock_bool_ObjCObject_bool predicate) { + final _ret = _lib._objc_msgSend_146( + _id, _lib._sel_objectsWithOptions_passingTest_1, opts, predicate._id); + return NSSet._(_ret, _lib, retain: true, release: true); + } + + static NSSet set1(NativeMacOsFramework _lib) { + final _ret = _lib._objc_msgSend_2(_lib._class_NSSet1, _lib._sel_set1); + return NSSet._(_ret, _lib, retain: true, release: true); + } + + static NSSet setWithObject_(NativeMacOsFramework _lib, NSObject object) { + final _ret = _lib._objc_msgSend_106( + _lib._class_NSSet1, _lib._sel_setWithObject_1, object._id); + return NSSet._(_ret, _lib, retain: true, release: true); + } + + static NSSet setWithObjects_count_(NativeMacOsFramework _lib, + ffi.Pointer> objects, int cnt) { + final _ret = _lib._objc_msgSend_52( + _lib._class_NSSet1, _lib._sel_setWithObjects_count_1, objects, cnt); + return NSSet._(_ret, _lib, retain: true, release: true); + } + + static NSSet setWithObjects_(NativeMacOsFramework _lib, NSObject firstObj) { + final _ret = _lib._objc_msgSend_106( + _lib._class_NSSet1, _lib._sel_setWithObjects_1, firstObj._id); + return NSSet._(_ret, _lib, retain: true, release: true); + } + + static NSSet setWithSet_(NativeMacOsFramework _lib, NSSet set) { + final _ret = _lib._objc_msgSend_147( + _lib._class_NSSet1, _lib._sel_setWithSet_1, set._id); + return NSSet._(_ret, _lib, retain: true, release: true); + } + + static NSSet setWithArray_(NativeMacOsFramework _lib, NSArray array) { + final _ret = _lib._objc_msgSend_107( + _lib._class_NSSet1, _lib._sel_setWithArray_1, array._id); + return NSSet._(_ret, _lib, retain: true, release: true); + } + + NSSet initWithObjects_(NSObject firstObj) { + final _ret = + _lib._objc_msgSend_106(_id, _lib._sel_initWithObjects_1, firstObj._id); + return NSSet._(_ret, _lib, retain: true, release: true); + } + + NSSet initWithSet_(NSSet set) { + final _ret = _lib._objc_msgSend_147(_id, _lib._sel_initWithSet_1, set._id); + return NSSet._(_ret, _lib, retain: true, release: true); + } + + NSSet initWithSet_copyItems_(NSSet set, bool flag) { + final _ret = _lib._objc_msgSend_148( + _id, _lib._sel_initWithSet_copyItems_1, set._id, flag); + return NSSet._(_ret, _lib, retain: false, release: true); + } + + NSSet initWithArray_(NSArray array) { + final _ret = + _lib._objc_msgSend_107(_id, _lib._sel_initWithArray_1, array._id); + return NSSet._(_ret, _lib, retain: true, release: true); + } + + static NSSet new1(NativeMacOsFramework _lib) { + final _ret = _lib._objc_msgSend_2(_lib._class_NSSet1, _lib._sel_new1); + return NSSet._(_ret, _lib, retain: false, release: true); + } + + static NSSet allocWithZone_( + NativeMacOsFramework _lib, ffi.Pointer<_NSZone> zone) { + final _ret = _lib._objc_msgSend_3( + _lib._class_NSSet1, _lib._sel_allocWithZone_1, zone); + return NSSet._(_ret, _lib, retain: false, release: true); + } + + static NSSet alloc(NativeMacOsFramework _lib) { + final _ret = _lib._objc_msgSend_2(_lib._class_NSSet1, _lib._sel_alloc1); + return NSSet._(_ret, _lib, retain: false, release: true); + } +} + +void _ObjCBlock_ffiVoid_ObjCObject_bool_fnPtrTrampoline( + ffi.Pointer<_ObjCBlock> block, + ffi.Pointer arg0, + ffi.Pointer arg1) => + block.ref.target + .cast< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer arg0, + ffi.Pointer arg1)>>() + .asFunction< + void Function( + ffi.Pointer, ffi.Pointer)>()(arg0, arg1); +final _ObjCBlock_ffiVoid_ObjCObject_bool_closureRegistry = + , ffi.Pointer)>{}; +int _ObjCBlock_ffiVoid_ObjCObject_bool_closureRegistryIndex = 0; +ffi.Pointer _ObjCBlock_ffiVoid_ObjCObject_bool_registerClosure( + void Function(ffi.Pointer, ffi.Pointer) fn) { + final id = ++_ObjCBlock_ffiVoid_ObjCObject_bool_closureRegistryIndex; + _ObjCBlock_ffiVoid_ObjCObject_bool_closureRegistry[id] = fn; + return ffi.Pointer.fromAddress(id); +} + +void _ObjCBlock_ffiVoid_ObjCObject_bool_closureTrampoline( + ffi.Pointer<_ObjCBlock> block, + ffi.Pointer arg0, + ffi.Pointer arg1) => + _ObjCBlock_ffiVoid_ObjCObject_bool_closureRegistry[ + block.ref.target.address]!(arg0, arg1); + +class ObjCBlock_ffiVoid_ObjCObject_bool extends _ObjCBlockBase { + ObjCBlock_ffiVoid_ObjCObject_bool._( + ffi.Pointer<_ObjCBlock> id, NativeMacOsFramework lib, + {bool retain = false, bool release = true}) + : super._(id, lib, retain: retain, release: release); + + /// Creates a block from a C function pointer. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + ObjCBlock_ffiVoid_ObjCObject_bool.fromFunctionPointer( + NativeMacOsFramework lib, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer arg0, + ffi.Pointer arg1)>> + ptr) + : this._( + lib._newBlock1( + _cFuncTrampoline ??= ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer<_ObjCBlock>, + ffi.Pointer, + ffi.Pointer)>( + _ObjCBlock_ffiVoid_ObjCObject_bool_fnPtrTrampoline) + .cast(), + ptr.cast()), + lib); + static ffi.Pointer? _cFuncTrampoline; + + /// Creates a block from a Dart function. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + ObjCBlock_ffiVoid_ObjCObject_bool.fromFunction(NativeMacOsFramework lib, + void Function(NSObject, ffi.Pointer) fn) + : this._( + lib._newBlock1( + _dartFuncTrampoline ??= ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer<_ObjCBlock>, + ffi.Pointer, + ffi.Pointer)>( + _ObjCBlock_ffiVoid_ObjCObject_bool_closureTrampoline) + .cast(), + _ObjCBlock_ffiVoid_ObjCObject_bool_registerClosure( + (ffi.Pointer arg0, ffi.Pointer arg1) => + fn(NSObject._(arg0, lib, retain: true, release: true), + arg1))), + lib); + static ffi.Pointer? _dartFuncTrampoline; + + /// Creates a listener block from a Dart function. + /// + /// This is based on FFI's NativeCallable.listener, and has the same + /// capabilities and limitations. This block can be invoked from any thread, + /// but only supports void functions, and is not run synchronously. See + /// NativeCallable.listener for more details. + /// + /// Note that unlike the default behavior of NativeCallable.listener, listener + /// blocks do not keep the isolate alive. + ObjCBlock_ffiVoid_ObjCObject_bool.listener(NativeMacOsFramework lib, + void Function(NSObject, ffi.Pointer) fn) + : this._( + lib._newBlock1( + (_dartFuncListenerTrampoline ??= ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer<_ObjCBlock>, + ffi.Pointer, + ffi.Pointer)>.listener( + _ObjCBlock_ffiVoid_ObjCObject_bool_closureTrampoline) + ..keepIsolateAlive = false) + .nativeFunction + .cast(), + _ObjCBlock_ffiVoid_ObjCObject_bool_registerClosure( + (ffi.Pointer arg0, + ffi.Pointer arg1) => + fn(NSObject._(arg0, lib, retain: true, release: true), + arg1))), + lib); + static ffi.NativeCallable< + ffi.Void Function(ffi.Pointer<_ObjCBlock>, ffi.Pointer, + ffi.Pointer)>? _dartFuncListenerTrampoline; + + void call(NSObject arg0, ffi.Pointer arg1) => _id.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer<_ObjCBlock> block, + ffi.Pointer arg0, ffi.Pointer arg1)>>() + .asFunction< + void Function(ffi.Pointer<_ObjCBlock>, ffi.Pointer, + ffi.Pointer)>()(_id, arg0._id, arg1); +} + +bool _ObjCBlock_bool_ObjCObject_bool_fnPtrTrampoline( + ffi.Pointer<_ObjCBlock> block, + ffi.Pointer arg0, + ffi.Pointer arg1) => + block.ref.target + .cast< + ffi.NativeFunction< + ffi.Bool Function(ffi.Pointer arg0, + ffi.Pointer arg1)>>() + .asFunction< + bool Function( + ffi.Pointer, ffi.Pointer)>()(arg0, arg1); +final _ObjCBlock_bool_ObjCObject_bool_closureRegistry = + , ffi.Pointer)>{}; +int _ObjCBlock_bool_ObjCObject_bool_closureRegistryIndex = 0; +ffi.Pointer _ObjCBlock_bool_ObjCObject_bool_registerClosure( + bool Function(ffi.Pointer, ffi.Pointer) fn) { + final id = ++_ObjCBlock_bool_ObjCObject_bool_closureRegistryIndex; + _ObjCBlock_bool_ObjCObject_bool_closureRegistry[id] = fn; + return ffi.Pointer.fromAddress(id); +} + +bool _ObjCBlock_bool_ObjCObject_bool_closureTrampoline( + ffi.Pointer<_ObjCBlock> block, + ffi.Pointer arg0, + ffi.Pointer arg1) => + _ObjCBlock_bool_ObjCObject_bool_closureRegistry[block.ref.target.address]!( + arg0, arg1); + +class ObjCBlock_bool_ObjCObject_bool extends _ObjCBlockBase { + ObjCBlock_bool_ObjCObject_bool._( + ffi.Pointer<_ObjCBlock> id, NativeMacOsFramework lib, + {bool retain = false, bool release = true}) + : super._(id, lib, retain: retain, release: release); + + /// Creates a block from a C function pointer. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + ObjCBlock_bool_ObjCObject_bool.fromFunctionPointer( + NativeMacOsFramework lib, + ffi.Pointer< + ffi.NativeFunction< + ffi.Bool Function(ffi.Pointer arg0, + ffi.Pointer arg1)>> + ptr) + : this._( + lib._newBlock1( + _cFuncTrampoline ??= ffi.Pointer.fromFunction< + ffi.Bool Function( + ffi.Pointer<_ObjCBlock>, + ffi.Pointer, + ffi.Pointer)>( + _ObjCBlock_bool_ObjCObject_bool_fnPtrTrampoline, false) + .cast(), + ptr.cast()), + lib); + static ffi.Pointer? _cFuncTrampoline; + + /// Creates a block from a Dart function. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + ObjCBlock_bool_ObjCObject_bool.fromFunction(NativeMacOsFramework lib, + bool Function(NSObject, ffi.Pointer) fn) + : this._( + lib._newBlock1( + _dartFuncTrampoline ??= ffi.Pointer.fromFunction< + ffi.Bool Function( + ffi.Pointer<_ObjCBlock>, + ffi.Pointer, + ffi.Pointer)>( + _ObjCBlock_bool_ObjCObject_bool_closureTrampoline, false) + .cast(), + _ObjCBlock_bool_ObjCObject_bool_registerClosure( + (ffi.Pointer arg0, + ffi.Pointer arg1) => + fn(NSObject._(arg0, lib, retain: true, release: true), arg1))), + lib); + static ffi.Pointer? _dartFuncTrampoline; + + bool call(NSObject arg0, ffi.Pointer arg1) => _id.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Bool Function(ffi.Pointer<_ObjCBlock> block, + ffi.Pointer arg0, ffi.Pointer arg1)>>() + .asFunction< + bool Function(ffi.Pointer<_ObjCBlock>, ffi.Pointer, + ffi.Pointer)>()(_id, arg0._id, arg1); +} + +abstract class NSDecodingFailurePolicy { + static const int NSDecodingFailurePolicyRaiseException = 0; + static const int NSDecodingFailurePolicySetErrorAndReturn = 1; +} + +final class CGPoint extends ffi.Struct { + @ffi.Double() + external double x; + + @ffi.Double() + external double y; +} + +final class CGSize extends ffi.Struct { + @ffi.Double() + external double width; + + @ffi.Double() + external double height; +} + +final class CGRect extends ffi.Struct { + external CGPoint origin; + + external CGSize size; +} + +abstract class NSStringCompareOptions { + static const int NSCaseInsensitiveSearch = 1; + static const int NSLiteralSearch = 2; + static const int NSBackwardsSearch = 4; + static const int NSAnchoredSearch = 8; + static const int NSNumericSearch = 64; + static const int NSDiacriticInsensitiveSearch = 128; + static const int NSWidthInsensitiveSearch = 256; + static const int NSForcedOrderingSearch = 512; + static const int NSRegularExpressionSearch = 1024; +} + +class NSLocale extends NSObject { + NSLocale._(ffi.Pointer id, NativeMacOsFramework lib, + {bool retain = false, bool release = false}) + : super._(id, lib, retain: retain, release: release); + + /// Returns a [NSLocale] that points to the same underlying object as [other]. + static NSLocale castFrom(T other) { + return NSLocale._(other._id, other._lib, retain: true, release: true); + } + + /// Returns a [NSLocale] that wraps the given raw object pointer. + static NSLocale castFromPointer( + NativeMacOsFramework lib, ffi.Pointer other, + {bool retain = false, bool release = false}) { + return NSLocale._(other, lib, retain: retain, release: release); + } + + /// Returns whether [obj] is an instance of [NSLocale]. + static bool isInstance(_ObjCWrapper obj) { + return obj._lib._objc_msgSend_0( + obj._id, obj._lib._sel_isKindOfClass_1, obj._lib._class_NSLocale1); + } + + NSObject? objectForKey_(NSString key) { + final _ret = _lib._objc_msgSend_40(_id, _lib._sel_objectForKey_1, key._id); + return _ret.address == 0 + ? null + : NSObject._(_ret, _lib, retain: true, release: true); + } + + NSString? displayNameForKey_value_(NSString key, NSObject value) { + final _ret = _lib._objc_msgSend_180( + _id, _lib._sel_displayNameForKey_value_1, key._id, value._id); + return _ret.address == 0 + ? null + : NSString._(_ret, _lib, retain: true, release: true); + } + + NSLocale initWithLocaleIdentifier_(NSString string) { + final _ret = _lib._objc_msgSend_181( + _id, _lib._sel_initWithLocaleIdentifier_1, string._id); + return NSLocale._(_ret, _lib, retain: true, release: true); + } + + NSLocale? initWithCoder_(NSCoder coder) { + final _ret = + _lib._objc_msgSend_53(_id, _lib._sel_initWithCoder_1, coder._id); + return _ret.address == 0 + ? null + : NSLocale._(_ret, _lib, retain: true, release: true); + } + + /// same as NSLocaleIdentifier + NSString get localeIdentifier { + final _ret = _lib._objc_msgSend_57(_id, _lib._sel_localeIdentifier1); + return NSString._(_ret, _lib, retain: true, release: true); + } + + NSString localizedStringForLocaleIdentifier_(NSString localeIdentifier) { + final _ret = _lib._objc_msgSend_56(_id, + _lib._sel_localizedStringForLocaleIdentifier_1, localeIdentifier._id); + return NSString._(_ret, _lib, retain: true, release: true); + } + + NSString get languageCode { + final _ret = _lib._objc_msgSend_57(_id, _lib._sel_languageCode1); + return NSString._(_ret, _lib, retain: true, release: true); + } + + NSString? localizedStringForLanguageCode_(NSString languageCode) { + final _ret = _lib._objc_msgSend_182( + _id, _lib._sel_localizedStringForLanguageCode_1, languageCode._id); + return _ret.address == 0 + ? null + : NSString._(_ret, _lib, retain: true, release: true); + } + + /// Returns the identifier for the language part of the locale. For example, returns "en-US" for "en_US@rg=gbzzzz" locale. + NSString get languageIdentifier { + final _ret = _lib._objc_msgSend_57(_id, _lib._sel_languageIdentifier1); + return NSString._(_ret, _lib, retain: true, release: true); + } + + NSString? get countryCode { + final _ret = _lib._objc_msgSend_183(_id, _lib._sel_countryCode1); + return _ret.address == 0 + ? null + : NSString._(_ret, _lib, retain: true, release: true); + } + + NSString? localizedStringForCountryCode_(NSString countryCode) { + final _ret = _lib._objc_msgSend_182( + _id, _lib._sel_localizedStringForCountryCode_1, countryCode._id); + return _ret.address == 0 + ? null + : NSString._(_ret, _lib, retain: true, release: true); + } + + /// Returns the region code of the locale. + /// If the `rg` subtag is present, the value of the subtag will be used. For example, returns "GB" for "en_US@rg=gbzzzz" locale. + /// If the `localeIdentifier` doesn’t contain a region, returns `nil`. + NSString? get regionCode { + final _ret = _lib._objc_msgSend_183(_id, _lib._sel_regionCode1); + return _ret.address == 0 + ? null + : NSString._(_ret, _lib, retain: true, release: true); + } + + NSString? get scriptCode { + final _ret = _lib._objc_msgSend_183(_id, _lib._sel_scriptCode1); + return _ret.address == 0 + ? null + : NSString._(_ret, _lib, retain: true, release: true); + } + + NSString? localizedStringForScriptCode_(NSString scriptCode) { + final _ret = _lib._objc_msgSend_182( + _id, _lib._sel_localizedStringForScriptCode_1, scriptCode._id); + return _ret.address == 0 + ? null + : NSString._(_ret, _lib, retain: true, release: true); + } + + NSString? get variantCode { + final _ret = _lib._objc_msgSend_183(_id, _lib._sel_variantCode1); + return _ret.address == 0 + ? null + : NSString._(_ret, _lib, retain: true, release: true); + } + + NSString? localizedStringForVariantCode_(NSString variantCode) { + final _ret = _lib._objc_msgSend_182( + _id, _lib._sel_localizedStringForVariantCode_1, variantCode._id); + return _ret.address == 0 + ? null + : NSString._(_ret, _lib, retain: true, release: true); + } + + NSCharacterSet get exemplarCharacterSet { + final _ret = _lib._objc_msgSend_184(_id, _lib._sel_exemplarCharacterSet1); + return NSCharacterSet._(_ret, _lib, retain: true, release: true); + } + + NSString get calendarIdentifier { + final _ret = _lib._objc_msgSend_57(_id, _lib._sel_calendarIdentifier1); + return NSString._(_ret, _lib, retain: true, release: true); + } + + NSString? localizedStringForCalendarIdentifier_(NSString calendarIdentifier) { + final _ret = _lib._objc_msgSend_182( + _id, + _lib._sel_localizedStringForCalendarIdentifier_1, + calendarIdentifier._id); + return _ret.address == 0 + ? null + : NSString._(_ret, _lib, retain: true, release: true); + } + + NSString? get collationIdentifier { + final _ret = _lib._objc_msgSend_183(_id, _lib._sel_collationIdentifier1); + return _ret.address == 0 + ? null + : NSString._(_ret, _lib, retain: true, release: true); + } + + NSString? localizedStringForCollationIdentifier_( + NSString collationIdentifier) { + final _ret = _lib._objc_msgSend_182( + _id, + _lib._sel_localizedStringForCollationIdentifier_1, + collationIdentifier._id); + return _ret.address == 0 + ? null + : NSString._(_ret, _lib, retain: true, release: true); + } + + bool get usesMetricSystem { + return _lib._objc_msgSend_11(_id, _lib._sel_usesMetricSystem1); + } + + NSString get decimalSeparator { + final _ret = _lib._objc_msgSend_57(_id, _lib._sel_decimalSeparator1); + return NSString._(_ret, _lib, retain: true, release: true); + } + + NSString get groupingSeparator { + final _ret = _lib._objc_msgSend_57(_id, _lib._sel_groupingSeparator1); + return NSString._(_ret, _lib, retain: true, release: true); + } + + NSString get currencySymbol { + final _ret = _lib._objc_msgSend_57(_id, _lib._sel_currencySymbol1); + return NSString._(_ret, _lib, retain: true, release: true); + } + + NSString? get currencyCode { + final _ret = _lib._objc_msgSend_183(_id, _lib._sel_currencyCode1); + return _ret.address == 0 + ? null + : NSString._(_ret, _lib, retain: true, release: true); + } + + NSString? localizedStringForCurrencyCode_(NSString currencyCode) { + final _ret = _lib._objc_msgSend_182( + _id, _lib._sel_localizedStringForCurrencyCode_1, currencyCode._id); + return _ret.address == 0 + ? null + : NSString._(_ret, _lib, retain: true, release: true); + } + + NSString get collatorIdentifier { + final _ret = _lib._objc_msgSend_57(_id, _lib._sel_collatorIdentifier1); + return NSString._(_ret, _lib, retain: true, release: true); + } + + NSString? localizedStringForCollatorIdentifier_(NSString collatorIdentifier) { + final _ret = _lib._objc_msgSend_182( + _id, + _lib._sel_localizedStringForCollatorIdentifier_1, + collatorIdentifier._id); + return _ret.address == 0 + ? null + : NSString._(_ret, _lib, retain: true, release: true); + } + + NSString get quotationBeginDelimiter { + final _ret = _lib._objc_msgSend_57(_id, _lib._sel_quotationBeginDelimiter1); + return NSString._(_ret, _lib, retain: true, release: true); + } + + NSString get quotationEndDelimiter { + final _ret = _lib._objc_msgSend_57(_id, _lib._sel_quotationEndDelimiter1); + return NSString._(_ret, _lib, retain: true, release: true); + } + + NSString get alternateQuotationBeginDelimiter { + final _ret = + _lib._objc_msgSend_57(_id, _lib._sel_alternateQuotationBeginDelimiter1); + return NSString._(_ret, _lib, retain: true, release: true); + } + + NSString get alternateQuotationEndDelimiter { + final _ret = + _lib._objc_msgSend_57(_id, _lib._sel_alternateQuotationEndDelimiter1); + return NSString._(_ret, _lib, retain: true, release: true); + } + + /// generally you should use this property + static NSLocale getAutoupdatingCurrentLocale(NativeMacOsFramework _lib) { + final _ret = _lib._objc_msgSend_185( + _lib._class_NSLocale1, _lib._sel_autoupdatingCurrentLocale1); + return NSLocale._(_ret, _lib, retain: true, release: true); + } + + /// an object representing the user's current locale + static NSLocale getCurrentLocale(NativeMacOsFramework _lib) { + final _ret = + _lib._objc_msgSend_185(_lib._class_NSLocale1, _lib._sel_currentLocale1); + return NSLocale._(_ret, _lib, retain: true, release: true); + } + + /// the default generic root locale with little localization + static NSLocale getSystemLocale(NativeMacOsFramework _lib) { + final _ret = + _lib._objc_msgSend_185(_lib._class_NSLocale1, _lib._sel_systemLocale1); + return NSLocale._(_ret, _lib, retain: true, release: true); + } + + static NSLocale localeWithLocaleIdentifier_( + NativeMacOsFramework _lib, NSString ident) { + final _ret = _lib._objc_msgSend_181(_lib._class_NSLocale1, + _lib._sel_localeWithLocaleIdentifier_1, ident._id); + return NSLocale._(_ret, _lib, retain: true, release: true); + } + + /// do not invoke; not a valid initializer for this class + @override + NSLocale init() { + final _ret = _lib._objc_msgSend_2(_id, _lib._sel_init1); + return NSLocale._(_ret, _lib, retain: true, release: true); + } + + static NSArray getAvailableLocaleIdentifiers(NativeMacOsFramework _lib) { + final _ret = _lib._objc_msgSend_121( + _lib._class_NSLocale1, _lib._sel_availableLocaleIdentifiers1); + return NSArray._(_ret, _lib, retain: true, release: true); + } + + static NSArray getISOLanguageCodes(NativeMacOsFramework _lib) { + final _ret = _lib._objc_msgSend_121( + _lib._class_NSLocale1, _lib._sel_ISOLanguageCodes1); + return NSArray._(_ret, _lib, retain: true, release: true); + } + + static NSArray getISOCountryCodes(NativeMacOsFramework _lib) { + final _ret = _lib._objc_msgSend_121( + _lib._class_NSLocale1, _lib._sel_ISOCountryCodes1); + return NSArray._(_ret, _lib, retain: true, release: true); + } + + static NSArray getISOCurrencyCodes(NativeMacOsFramework _lib) { + final _ret = _lib._objc_msgSend_121( + _lib._class_NSLocale1, _lib._sel_ISOCurrencyCodes1); + return NSArray._(_ret, _lib, retain: true, release: true); + } + + static NSArray getCommonISOCurrencyCodes(NativeMacOsFramework _lib) { + final _ret = _lib._objc_msgSend_121( + _lib._class_NSLocale1, _lib._sel_commonISOCurrencyCodes1); + return NSArray._(_ret, _lib, retain: true, release: true); + } + + /// note that this list does not indicate what language the app is actually running in; the NSBundle.mainBundle object determines that at launch and knows that information + static NSArray getPreferredLanguages(NativeMacOsFramework _lib) { + final _ret = _lib._objc_msgSend_121( + _lib._class_NSLocale1, _lib._sel_preferredLanguages1); + return NSArray._(_ret, _lib, retain: true, release: true); + } + + static NSDictionary componentsFromLocaleIdentifier_( + NativeMacOsFramework _lib, NSString string) { + final _ret = _lib._objc_msgSend_186(_lib._class_NSLocale1, + _lib._sel_componentsFromLocaleIdentifier_1, string._id); + return NSDictionary._(_ret, _lib, retain: true, release: true); + } + + static NSString localeIdentifierFromComponents_( + NativeMacOsFramework _lib, NSDictionary dict) { + final _ret = _lib._objc_msgSend_187(_lib._class_NSLocale1, + _lib._sel_localeIdentifierFromComponents_1, dict._id); + return NSString._(_ret, _lib, retain: true, release: true); + } + + static NSString canonicalLocaleIdentifierFromString_( + NativeMacOsFramework _lib, NSString string) { + final _ret = _lib._objc_msgSend_56(_lib._class_NSLocale1, + _lib._sel_canonicalLocaleIdentifierFromString_1, string._id); + return NSString._(_ret, _lib, retain: true, release: true); + } + + static NSString canonicalLanguageIdentifierFromString_( + NativeMacOsFramework _lib, NSString string) { + final _ret = _lib._objc_msgSend_56(_lib._class_NSLocale1, + _lib._sel_canonicalLanguageIdentifierFromString_1, string._id); + return NSString._(_ret, _lib, retain: true, release: true); + } + + static NSString? localeIdentifierFromWindowsLocaleCode_( + NativeMacOsFramework _lib, int lcid) { + final _ret = _lib._objc_msgSend_188(_lib._class_NSLocale1, + _lib._sel_localeIdentifierFromWindowsLocaleCode_1, lcid); + return _ret.address == 0 + ? null + : NSString._(_ret, _lib, retain: true, release: true); + } + + static int windowsLocaleCodeFromLocaleIdentifier_( + NativeMacOsFramework _lib, NSString localeIdentifier) { + return _lib._objc_msgSend_189( + _lib._class_NSLocale1, + _lib._sel_windowsLocaleCodeFromLocaleIdentifier_1, + localeIdentifier._id); + } + + static int characterDirectionForLanguage_( + NativeMacOsFramework _lib, NSString isoLangCode) { + return _lib._objc_msgSend_190(_lib._class_NSLocale1, + _lib._sel_characterDirectionForLanguage_1, isoLangCode._id); + } + + static int lineDirectionForLanguage_( + NativeMacOsFramework _lib, NSString isoLangCode) { + return _lib._objc_msgSend_190(_lib._class_NSLocale1, + _lib._sel_lineDirectionForLanguage_1, isoLangCode._id); + } + + static NSLocale new1(NativeMacOsFramework _lib) { + final _ret = _lib._objc_msgSend_2(_lib._class_NSLocale1, _lib._sel_new1); + return NSLocale._(_ret, _lib, retain: false, release: true); + } + + static NSLocale allocWithZone_( + NativeMacOsFramework _lib, ffi.Pointer<_NSZone> zone) { + final _ret = _lib._objc_msgSend_3( + _lib._class_NSLocale1, _lib._sel_allocWithZone_1, zone); + return NSLocale._(_ret, _lib, retain: false, release: true); + } + + static NSLocale alloc(NativeMacOsFramework _lib) { + final _ret = _lib._objc_msgSend_2(_lib._class_NSLocale1, _lib._sel_alloc1); + return NSLocale._(_ret, _lib, retain: false, release: true); + } +} + +class NSCharacterSet extends _ObjCWrapper { + NSCharacterSet._(ffi.Pointer id, NativeMacOsFramework lib, + {bool retain = false, bool release = false}) + : super._(id, lib, retain: retain, release: release); + + /// Returns a [NSCharacterSet] that points to the same underlying object as [other]. + static NSCharacterSet castFrom(T other) { + return NSCharacterSet._(other._id, other._lib, retain: true, release: true); + } + + /// Returns a [NSCharacterSet] that wraps the given raw object pointer. + static NSCharacterSet castFromPointer( + NativeMacOsFramework lib, ffi.Pointer other, + {bool retain = false, bool release = false}) { + return NSCharacterSet._(other, lib, retain: retain, release: release); + } + + /// Returns whether [obj] is an instance of [NSCharacterSet]. + static bool isInstance(_ObjCWrapper obj) { + return obj._lib._objc_msgSend_0(obj._id, obj._lib._sel_isKindOfClass_1, + obj._lib._class_NSCharacterSet1); + } +} + +abstract class NSLocaleLanguageDirection { + static const int NSLocaleLanguageDirectionUnknown = 0; + static const int NSLocaleLanguageDirectionLeftToRight = 1; + static const int NSLocaleLanguageDirectionRightToLeft = 2; + static const int NSLocaleLanguageDirectionTopToBottom = 3; + static const int NSLocaleLanguageDirectionBottomToTop = 4; +} + +abstract class NSStringEnumerationOptions { + static const int NSStringEnumerationByLines = 0; + static const int NSStringEnumerationByParagraphs = 1; + static const int NSStringEnumerationByComposedCharacterSequences = 2; + static const int NSStringEnumerationByWords = 3; + static const int NSStringEnumerationBySentences = 4; + static const int NSStringEnumerationByCaretPositions = 5; + static const int NSStringEnumerationByDeletionClusters = 6; + static const int NSStringEnumerationReverse = 256; + static const int NSStringEnumerationSubstringNotRequired = 512; + static const int NSStringEnumerationLocalized = 1024; +} + +void _ObjCBlock_ffiVoid_NSString_NSRange_NSRange_bool_fnPtrTrampoline( + ffi.Pointer<_ObjCBlock> block, + ffi.Pointer arg0, + _NSRange arg1, + _NSRange arg2, + ffi.Pointer arg3) => + block.ref.target + .cast< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer arg0, _NSRange arg1, + _NSRange arg2, ffi.Pointer arg3)>>() + .asFunction< + void Function(ffi.Pointer, _NSRange, _NSRange, + ffi.Pointer)>()(arg0, arg1, arg2, arg3); +final _ObjCBlock_ffiVoid_NSString_NSRange_NSRange_bool_closureRegistry = , _NSRange, _NSRange, ffi.Pointer)>{}; +int _ObjCBlock_ffiVoid_NSString_NSRange_NSRange_bool_closureRegistryIndex = 0; +ffi.Pointer + _ObjCBlock_ffiVoid_NSString_NSRange_NSRange_bool_registerClosure( + void Function(ffi.Pointer, _NSRange, _NSRange, + ffi.Pointer) + fn) { + final id = + ++_ObjCBlock_ffiVoid_NSString_NSRange_NSRange_bool_closureRegistryIndex; + _ObjCBlock_ffiVoid_NSString_NSRange_NSRange_bool_closureRegistry[id] = fn; + return ffi.Pointer.fromAddress(id); +} + +void _ObjCBlock_ffiVoid_NSString_NSRange_NSRange_bool_closureTrampoline( + ffi.Pointer<_ObjCBlock> block, + ffi.Pointer arg0, + _NSRange arg1, + _NSRange arg2, + ffi.Pointer arg3) => + _ObjCBlock_ffiVoid_NSString_NSRange_NSRange_bool_closureRegistry[ + block.ref.target.address]!(arg0, arg1, arg2, arg3); + +class ObjCBlock_ffiVoid_NSString_NSRange_NSRange_bool extends _ObjCBlockBase { + ObjCBlock_ffiVoid_NSString_NSRange_NSRange_bool._( + ffi.Pointer<_ObjCBlock> id, NativeMacOsFramework lib, + {bool retain = false, bool release = true}) + : super._(id, lib, retain: retain, release: release); + + /// Creates a block from a C function pointer. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + ObjCBlock_ffiVoid_NSString_NSRange_NSRange_bool.fromFunctionPointer( + NativeMacOsFramework lib, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer arg0, _NSRange arg1, + _NSRange arg2, ffi.Pointer arg3)>> + ptr) + : this._( + lib._newBlock1( + _cFuncTrampoline ??= ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer<_ObjCBlock>, + ffi.Pointer, + _NSRange, + _NSRange, + ffi.Pointer)>( + _ObjCBlock_ffiVoid_NSString_NSRange_NSRange_bool_fnPtrTrampoline) + .cast(), + ptr.cast()), + lib); + static ffi.Pointer? _cFuncTrampoline; + + /// Creates a block from a Dart function. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + ObjCBlock_ffiVoid_NSString_NSRange_NSRange_bool.fromFunction( + NativeMacOsFramework lib, + void Function(NSString?, _NSRange, _NSRange, ffi.Pointer) fn) + : this._( + lib._newBlock1( + _dartFuncTrampoline ??= ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer<_ObjCBlock>, + ffi.Pointer, + _NSRange, + _NSRange, + ffi.Pointer)>( + _ObjCBlock_ffiVoid_NSString_NSRange_NSRange_bool_closureTrampoline) + .cast(), + _ObjCBlock_ffiVoid_NSString_NSRange_NSRange_bool_registerClosure( + (ffi.Pointer arg0, _NSRange arg1, _NSRange arg2, + ffi.Pointer arg3) => + fn(arg0.address == 0 ? null : NSString._(arg0, lib, retain: true, release: true), arg1, arg2, arg3))), + lib); + static ffi.Pointer? _dartFuncTrampoline; + + /// Creates a listener block from a Dart function. + /// + /// This is based on FFI's NativeCallable.listener, and has the same + /// capabilities and limitations. This block can be invoked from any thread, + /// but only supports void functions, and is not run synchronously. See + /// NativeCallable.listener for more details. + /// + /// Note that unlike the default behavior of NativeCallable.listener, listener + /// blocks do not keep the isolate alive. + ObjCBlock_ffiVoid_NSString_NSRange_NSRange_bool.listener( + NativeMacOsFramework lib, + void Function(NSString?, _NSRange, _NSRange, ffi.Pointer) fn) + : this._( + lib._newBlock1( + (_dartFuncListenerTrampoline ??= ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer<_ObjCBlock>, + ffi.Pointer, + _NSRange, + _NSRange, + ffi.Pointer)>.listener( + _ObjCBlock_ffiVoid_NSString_NSRange_NSRange_bool_closureTrampoline) + ..keepIsolateAlive = false) + .nativeFunction + .cast(), + _ObjCBlock_ffiVoid_NSString_NSRange_NSRange_bool_registerClosure( + (ffi.Pointer arg0, _NSRange arg1, _NSRange arg2, + ffi.Pointer arg3) => + fn(arg0.address == 0 ? null : NSString._(arg0, lib, retain: true, release: true), arg1, arg2, arg3))), + lib); + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer<_ObjCBlock>, + ffi.Pointer, + _NSRange, + _NSRange, + ffi.Pointer)>? _dartFuncListenerTrampoline; + + void call(NSString? arg0, _NSRange arg1, _NSRange arg2, + ffi.Pointer arg3) => + _id.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer<_ObjCBlock> block, + ffi.Pointer arg0, + _NSRange arg1, + _NSRange arg2, + ffi.Pointer arg3)>>() + .asFunction< + void Function( + ffi.Pointer<_ObjCBlock>, + ffi.Pointer, + _NSRange, + _NSRange, + ffi.Pointer)>()( + _id, arg0?._id ?? ffi.nullptr, arg1, arg2, arg3); +} + +void _ObjCBlock_ffiVoid_NSString_bool_fnPtrTrampoline( + ffi.Pointer<_ObjCBlock> block, + ffi.Pointer arg0, + ffi.Pointer arg1) => + block.ref.target + .cast< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer arg0, + ffi.Pointer arg1)>>() + .asFunction< + void Function( + ffi.Pointer, ffi.Pointer)>()(arg0, arg1); +final _ObjCBlock_ffiVoid_NSString_bool_closureRegistry = + , ffi.Pointer)>{}; +int _ObjCBlock_ffiVoid_NSString_bool_closureRegistryIndex = 0; +ffi.Pointer _ObjCBlock_ffiVoid_NSString_bool_registerClosure( + void Function(ffi.Pointer, ffi.Pointer) fn) { + final id = ++_ObjCBlock_ffiVoid_NSString_bool_closureRegistryIndex; + _ObjCBlock_ffiVoid_NSString_bool_closureRegistry[id] = fn; + return ffi.Pointer.fromAddress(id); +} + +void _ObjCBlock_ffiVoid_NSString_bool_closureTrampoline( + ffi.Pointer<_ObjCBlock> block, + ffi.Pointer arg0, + ffi.Pointer arg1) => + _ObjCBlock_ffiVoid_NSString_bool_closureRegistry[block.ref.target.address]!( + arg0, arg1); + +class ObjCBlock_ffiVoid_NSString_bool extends _ObjCBlockBase { + ObjCBlock_ffiVoid_NSString_bool._( + ffi.Pointer<_ObjCBlock> id, NativeMacOsFramework lib, + {bool retain = false, bool release = true}) + : super._(id, lib, retain: retain, release: release); + + /// Creates a block from a C function pointer. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + ObjCBlock_ffiVoid_NSString_bool.fromFunctionPointer( + NativeMacOsFramework lib, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer arg0, + ffi.Pointer arg1)>> + ptr) + : this._( + lib._newBlock1( + _cFuncTrampoline ??= ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer<_ObjCBlock>, + ffi.Pointer, + ffi.Pointer)>( + _ObjCBlock_ffiVoid_NSString_bool_fnPtrTrampoline) + .cast(), + ptr.cast()), + lib); + static ffi.Pointer? _cFuncTrampoline; + + /// Creates a block from a Dart function. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + ObjCBlock_ffiVoid_NSString_bool.fromFunction(NativeMacOsFramework lib, + void Function(NSString, ffi.Pointer) fn) + : this._( + lib._newBlock1( + _dartFuncTrampoline ??= ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer<_ObjCBlock>, + ffi.Pointer, + ffi.Pointer)>( + _ObjCBlock_ffiVoid_NSString_bool_closureTrampoline) + .cast(), + _ObjCBlock_ffiVoid_NSString_bool_registerClosure( + (ffi.Pointer arg0, ffi.Pointer arg1) => + fn(NSString._(arg0, lib, retain: true, release: true), + arg1))), + lib); + static ffi.Pointer? _dartFuncTrampoline; + + /// Creates a listener block from a Dart function. + /// + /// This is based on FFI's NativeCallable.listener, and has the same + /// capabilities and limitations. This block can be invoked from any thread, + /// but only supports void functions, and is not run synchronously. See + /// NativeCallable.listener for more details. + /// + /// Note that unlike the default behavior of NativeCallable.listener, listener + /// blocks do not keep the isolate alive. + ObjCBlock_ffiVoid_NSString_bool.listener(NativeMacOsFramework lib, + void Function(NSString, ffi.Pointer) fn) + : this._( + lib._newBlock1( + (_dartFuncListenerTrampoline ??= ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer<_ObjCBlock>, + ffi.Pointer, + ffi.Pointer)>.listener( + _ObjCBlock_ffiVoid_NSString_bool_closureTrampoline) + ..keepIsolateAlive = false) + .nativeFunction + .cast(), + _ObjCBlock_ffiVoid_NSString_bool_registerClosure( + (ffi.Pointer arg0, + ffi.Pointer arg1) => + fn(NSString._(arg0, lib, retain: true, release: true), + arg1))), + lib); + static ffi.NativeCallable< + ffi.Void Function(ffi.Pointer<_ObjCBlock>, ffi.Pointer, + ffi.Pointer)>? _dartFuncListenerTrampoline; + + void call(NSString arg0, ffi.Pointer arg1) => _id.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer<_ObjCBlock> block, + ffi.Pointer arg0, ffi.Pointer arg1)>>() + .asFunction< + void Function(ffi.Pointer<_ObjCBlock>, ffi.Pointer, + ffi.Pointer)>()(_id, arg0._id, arg1); +} + +abstract class NSStringEncodingConversionOptions { + static const int NSStringEncodingConversionAllowLossy = 1; + static const int NSStringEncodingConversionExternalRepresentation = 2; +} + +void _ObjCBlock_ffiVoid_ffiUnsignedShort_ffiUnsignedLong_fnPtrTrampoline( + ffi.Pointer<_ObjCBlock> block, + ffi.Pointer arg0, + int arg1) => + block.ref.target + .cast< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer arg0, + ffi.UnsignedLong arg1)>>() + .asFunction, int)>()( + arg0, arg1); +final _ObjCBlock_ffiVoid_ffiUnsignedShort_ffiUnsignedLong_closureRegistry = + , int)>{}; +int _ObjCBlock_ffiVoid_ffiUnsignedShort_ffiUnsignedLong_closureRegistryIndex = + 0; +ffi.Pointer + _ObjCBlock_ffiVoid_ffiUnsignedShort_ffiUnsignedLong_registerClosure( + void Function(ffi.Pointer, int) fn) { + final id = + ++_ObjCBlock_ffiVoid_ffiUnsignedShort_ffiUnsignedLong_closureRegistryIndex; + _ObjCBlock_ffiVoid_ffiUnsignedShort_ffiUnsignedLong_closureRegistry[id] = fn; + return ffi.Pointer.fromAddress(id); +} + +void _ObjCBlock_ffiVoid_ffiUnsignedShort_ffiUnsignedLong_closureTrampoline( + ffi.Pointer<_ObjCBlock> block, + ffi.Pointer arg0, + int arg1) => + _ObjCBlock_ffiVoid_ffiUnsignedShort_ffiUnsignedLong_closureRegistry[ + block.ref.target.address]!(arg0, arg1); + +class ObjCBlock_ffiVoid_ffiUnsignedShort_ffiUnsignedLong + extends _ObjCBlockBase { + ObjCBlock_ffiVoid_ffiUnsignedShort_ffiUnsignedLong._( + ffi.Pointer<_ObjCBlock> id, NativeMacOsFramework lib, + {bool retain = false, bool release = true}) + : super._(id, lib, retain: retain, release: release); + + /// Creates a block from a C function pointer. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + ObjCBlock_ffiVoid_ffiUnsignedShort_ffiUnsignedLong.fromFunctionPointer( + NativeMacOsFramework lib, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer arg0, + ffi.UnsignedLong arg1)>> + ptr) + : this._( + lib._newBlock1( + _cFuncTrampoline ??= ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer<_ObjCBlock>, + ffi.Pointer, + ffi.UnsignedLong)>( + _ObjCBlock_ffiVoid_ffiUnsignedShort_ffiUnsignedLong_fnPtrTrampoline) + .cast(), + ptr.cast()), + lib); + static ffi.Pointer? _cFuncTrampoline; + + /// Creates a block from a Dart function. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + ObjCBlock_ffiVoid_ffiUnsignedShort_ffiUnsignedLong.fromFunction( + NativeMacOsFramework lib, + void Function(ffi.Pointer, int) fn) + : this._( + lib._newBlock1( + _dartFuncTrampoline ??= ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer<_ObjCBlock>, + ffi.Pointer, + ffi.UnsignedLong)>( + _ObjCBlock_ffiVoid_ffiUnsignedShort_ffiUnsignedLong_closureTrampoline) + .cast(), + _ObjCBlock_ffiVoid_ffiUnsignedShort_ffiUnsignedLong_registerClosure( + (ffi.Pointer arg0, int arg1) => + fn(arg0, arg1))), + lib); + static ffi.Pointer? _dartFuncTrampoline; + + /// Creates a listener block from a Dart function. + /// + /// This is based on FFI's NativeCallable.listener, and has the same + /// capabilities and limitations. This block can be invoked from any thread, + /// but only supports void functions, and is not run synchronously. See + /// NativeCallable.listener for more details. + /// + /// Note that unlike the default behavior of NativeCallable.listener, listener + /// blocks do not keep the isolate alive. + ObjCBlock_ffiVoid_ffiUnsignedShort_ffiUnsignedLong.listener( + NativeMacOsFramework lib, + void Function(ffi.Pointer, int) fn) + : this._( + lib._newBlock1( + (_dartFuncListenerTrampoline ??= ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer<_ObjCBlock>, + ffi.Pointer, + ffi.UnsignedLong)>.listener( + _ObjCBlock_ffiVoid_ffiUnsignedShort_ffiUnsignedLong_closureTrampoline) + ..keepIsolateAlive = false) + .nativeFunction + .cast(), + _ObjCBlock_ffiVoid_ffiUnsignedShort_ffiUnsignedLong_registerClosure( + (ffi.Pointer arg0, int arg1) => + fn(arg0, arg1))), + lib); + static ffi.NativeCallable< + ffi.Void Function(ffi.Pointer<_ObjCBlock>, ffi.Pointer, + ffi.UnsignedLong)>? _dartFuncListenerTrampoline; + + void call(ffi.Pointer arg0, int arg1) => _id.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer<_ObjCBlock> block, + ffi.Pointer arg0, + ffi.UnsignedLong arg1)>>() + .asFunction< + void Function(ffi.Pointer<_ObjCBlock>, ffi.Pointer, + int)>()(_id, arg0, arg1); +} + +void _ObjCBlock_ffiVoid_ffiVoid_ffiUnsignedLong_fnPtrTrampoline( + ffi.Pointer<_ObjCBlock> block, ffi.Pointer arg0, int arg1) => + block.ref.target + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer arg0, ffi.UnsignedLong arg1)>>() + .asFunction, int)>()(arg0, arg1); +final _ObjCBlock_ffiVoid_ffiVoid_ffiUnsignedLong_closureRegistry = + , int)>{}; +int _ObjCBlock_ffiVoid_ffiVoid_ffiUnsignedLong_closureRegistryIndex = 0; +ffi.Pointer + _ObjCBlock_ffiVoid_ffiVoid_ffiUnsignedLong_registerClosure( + void Function(ffi.Pointer, int) fn) { + final id = ++_ObjCBlock_ffiVoid_ffiVoid_ffiUnsignedLong_closureRegistryIndex; + _ObjCBlock_ffiVoid_ffiVoid_ffiUnsignedLong_closureRegistry[id] = fn; + return ffi.Pointer.fromAddress(id); +} + +void _ObjCBlock_ffiVoid_ffiVoid_ffiUnsignedLong_closureTrampoline( + ffi.Pointer<_ObjCBlock> block, ffi.Pointer arg0, int arg1) => + _ObjCBlock_ffiVoid_ffiVoid_ffiUnsignedLong_closureRegistry[ + block.ref.target.address]!(arg0, arg1); + +class ObjCBlock_ffiVoid_ffiVoid_ffiUnsignedLong extends _ObjCBlockBase { + ObjCBlock_ffiVoid_ffiVoid_ffiUnsignedLong._( + ffi.Pointer<_ObjCBlock> id, NativeMacOsFramework lib, + {bool retain = false, bool release = true}) + : super._(id, lib, retain: retain, release: release); + + /// Creates a block from a C function pointer. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + ObjCBlock_ffiVoid_ffiVoid_ffiUnsignedLong.fromFunctionPointer( + NativeMacOsFramework lib, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer arg0, ffi.UnsignedLong arg1)>> + ptr) + : this._( + lib._newBlock1( + _cFuncTrampoline ??= ffi.Pointer.fromFunction< + ffi.Void Function(ffi.Pointer<_ObjCBlock>, + ffi.Pointer, ffi.UnsignedLong)>( + _ObjCBlock_ffiVoid_ffiVoid_ffiUnsignedLong_fnPtrTrampoline) + .cast(), + ptr.cast()), + lib); + static ffi.Pointer? _cFuncTrampoline; + + /// Creates a block from a Dart function. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + ObjCBlock_ffiVoid_ffiVoid_ffiUnsignedLong.fromFunction( + NativeMacOsFramework lib, void Function(ffi.Pointer, int) fn) + : this._( + lib._newBlock1( + _dartFuncTrampoline ??= ffi.Pointer.fromFunction< + ffi.Void Function(ffi.Pointer<_ObjCBlock>, + ffi.Pointer, ffi.UnsignedLong)>( + _ObjCBlock_ffiVoid_ffiVoid_ffiUnsignedLong_closureTrampoline) + .cast(), + _ObjCBlock_ffiVoid_ffiVoid_ffiUnsignedLong_registerClosure( + (ffi.Pointer arg0, int arg1) => fn(arg0, arg1))), + lib); + static ffi.Pointer? _dartFuncTrampoline; + + /// Creates a listener block from a Dart function. + /// + /// This is based on FFI's NativeCallable.listener, and has the same + /// capabilities and limitations. This block can be invoked from any thread, + /// but only supports void functions, and is not run synchronously. See + /// NativeCallable.listener for more details. + /// + /// Note that unlike the default behavior of NativeCallable.listener, listener + /// blocks do not keep the isolate alive. + ObjCBlock_ffiVoid_ffiVoid_ffiUnsignedLong.listener( + NativeMacOsFramework lib, void Function(ffi.Pointer, int) fn) + : this._( + lib._newBlock1( + (_dartFuncListenerTrampoline ??= ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer<_ObjCBlock>, + ffi.Pointer, + ffi.UnsignedLong)>.listener( + _ObjCBlock_ffiVoid_ffiVoid_ffiUnsignedLong_closureTrampoline) + ..keepIsolateAlive = false) + .nativeFunction + .cast(), + _ObjCBlock_ffiVoid_ffiVoid_ffiUnsignedLong_registerClosure( + (ffi.Pointer arg0, int arg1) => fn(arg0, arg1))), + lib); + static ffi.NativeCallable< + ffi.Void Function(ffi.Pointer<_ObjCBlock>, ffi.Pointer, + ffi.UnsignedLong)>? _dartFuncListenerTrampoline; + + void call(ffi.Pointer arg0, int arg1) => _id.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer<_ObjCBlock> block, + ffi.Pointer arg0, ffi.UnsignedLong arg1)>>() + .asFunction< + void Function(ffi.Pointer<_ObjCBlock>, ffi.Pointer, + int)>()(_id, arg0, arg1); +} + +class NSValue extends NSObject { + NSValue._(ffi.Pointer id, NativeMacOsFramework lib, + {bool retain = false, bool release = false}) + : super._(id, lib, retain: retain, release: release); + + /// Returns a [NSValue] that points to the same underlying object as [other]. + static NSValue castFrom(T other) { + return NSValue._(other._id, other._lib, retain: true, release: true); + } + + /// Returns a [NSValue] that wraps the given raw object pointer. + static NSValue castFromPointer( + NativeMacOsFramework lib, ffi.Pointer other, + {bool retain = false, bool release = false}) { + return NSValue._(other, lib, retain: retain, release: release); + } + + /// Returns whether [obj] is an instance of [NSValue]. + static bool isInstance(_ObjCWrapper obj) { + return obj._lib._objc_msgSend_0( + obj._id, obj._lib._sel_isKindOfClass_1, obj._lib._class_NSValue1); + } + + void getValue_size_(ffi.Pointer value, int size) { + _lib._objc_msgSend_24(_id, _lib._sel_getValue_size_1, value, size); + } + + ffi.Pointer get objCType { + return _lib._objc_msgSend_206(_id, _lib._sel_objCType1); + } + + NSValue initWithBytes_objCType_( + ffi.Pointer value, ffi.Pointer type) { + final _ret = _lib._objc_msgSend_253( + _id, _lib._sel_initWithBytes_objCType_1, value, type); + return NSValue._(_ret, _lib, retain: true, release: true); + } + + NSValue? initWithCoder_(NSCoder coder) { + final _ret = + _lib._objc_msgSend_53(_id, _lib._sel_initWithCoder_1, coder._id); + return _ret.address == 0 + ? null + : NSValue._(_ret, _lib, retain: true, release: true); + } + + static NSValue valueWithBytes_objCType_(NativeMacOsFramework _lib, + ffi.Pointer value, ffi.Pointer type) { + final _ret = _lib._objc_msgSend_254( + _lib._class_NSValue1, _lib._sel_valueWithBytes_objCType_1, value, type); + return NSValue._(_ret, _lib, retain: true, release: true); + } + + static NSValue value_withObjCType_(NativeMacOsFramework _lib, + ffi.Pointer value, ffi.Pointer type) { + final _ret = _lib._objc_msgSend_254( + _lib._class_NSValue1, _lib._sel_value_withObjCType_1, value, type); + return NSValue._(_ret, _lib, retain: true, release: true); + } + + static NSValue valueWithNonretainedObject_( + NativeMacOsFramework _lib, NSObject? anObject) { + final _ret = _lib._objc_msgSend_255(_lib._class_NSValue1, + _lib._sel_valueWithNonretainedObject_1, anObject?._id ?? ffi.nullptr); + return NSValue._(_ret, _lib, retain: true, release: true); + } + + NSObject? get nonretainedObjectValue { + final _ret = _lib._objc_msgSend_25(_id, _lib._sel_nonretainedObjectValue1); + return _ret.address == 0 + ? null + : NSObject._(_ret, _lib, retain: true, release: true); + } + + static NSValue valueWithPointer_( + NativeMacOsFramework _lib, ffi.Pointer pointer) { + final _ret = _lib._objc_msgSend_256( + _lib._class_NSValue1, _lib._sel_valueWithPointer_1, pointer); + return NSValue._(_ret, _lib, retain: true, release: true); + } + + ffi.Pointer get pointerValue { + return _lib._objc_msgSend_15(_id, _lib._sel_pointerValue1); + } + + bool isEqualToValue_(NSValue value) { + return _lib._objc_msgSend_257(_id, _lib._sel_isEqualToValue_1, value._id); + } + + void getValue_(ffi.Pointer value) { + _lib._objc_msgSend_258(_id, _lib._sel_getValue_1, value); + } + + static NSValue valueWithRange_(NativeMacOsFramework _lib, _NSRange range) { + final _ret = _lib._objc_msgSend_259( + _lib._class_NSValue1, _lib._sel_valueWithRange_1, range); + return NSValue._(_ret, _lib, retain: true, release: true); + } + + void getRangeValue(ffi.Pointer<_NSRange> stret) { + _lib._objc_msgSend_260(stret, _id, _lib._sel_rangeValue1); + } + + static NSValue valueWithPoint_(NativeMacOsFramework _lib, CGPoint point) { + final _ret = _lib._objc_msgSend_261( + _lib._class_NSValue1, _lib._sel_valueWithPoint_1, point); + return NSValue._(_ret, _lib, retain: true, release: true); + } + + static NSValue valueWithSize_(NativeMacOsFramework _lib, CGSize size) { + final _ret = _lib._objc_msgSend_262( + _lib._class_NSValue1, _lib._sel_valueWithSize_1, size); + return NSValue._(_ret, _lib, retain: true, release: true); + } + + static NSValue valueWithRect_(NativeMacOsFramework _lib, CGRect rect) { + final _ret = _lib._objc_msgSend_263( + _lib._class_NSValue1, _lib._sel_valueWithRect_1, rect); + return NSValue._(_ret, _lib, retain: true, release: true); + } + + static NSValue valueWithEdgeInsets_( + NativeMacOsFramework _lib, NSEdgeInsets insets) { + final _ret = _lib._objc_msgSend_264( + _lib._class_NSValue1, _lib._sel_valueWithEdgeInsets_1, insets); + return NSValue._(_ret, _lib, retain: true, release: true); + } + + void getPointValue(ffi.Pointer stret) { + _lib._objc_msgSend_158(stret, _id, _lib._sel_pointValue1); + } + + void getSizeValue(ffi.Pointer stret) { + _lib._objc_msgSend_160(stret, _id, _lib._sel_sizeValue1); + } + + void getRectValue(ffi.Pointer stret) { + _lib._objc_msgSend_162(stret, _id, _lib._sel_rectValue1); + } + + void getEdgeInsetsValue(ffi.Pointer stret) { + _lib._objc_msgSend_265(stret, _id, _lib._sel_edgeInsetsValue1); + } + + @override + NSValue init() { + final _ret = _lib._objc_msgSend_2(_id, _lib._sel_init1); + return NSValue._(_ret, _lib, retain: true, release: true); + } + + static NSValue new1(NativeMacOsFramework _lib) { + final _ret = _lib._objc_msgSend_2(_lib._class_NSValue1, _lib._sel_new1); + return NSValue._(_ret, _lib, retain: false, release: true); + } + + static NSValue allocWithZone_( + NativeMacOsFramework _lib, ffi.Pointer<_NSZone> zone) { + final _ret = _lib._objc_msgSend_3( + _lib._class_NSValue1, _lib._sel_allocWithZone_1, zone); + return NSValue._(_ret, _lib, retain: false, release: true); + } + + static NSValue alloc(NativeMacOsFramework _lib) { + final _ret = _lib._objc_msgSend_2(_lib._class_NSValue1, _lib._sel_alloc1); + return NSValue._(_ret, _lib, retain: false, release: true); + } +} + +final class NSEdgeInsets extends ffi.Struct { + @ffi.Double() + external double top; + + @ffi.Double() + external double left; + + @ffi.Double() + external double bottom; + + @ffi.Double() + external double right; +} + +class NSNumber extends NSValue { + NSNumber._(ffi.Pointer id, NativeMacOsFramework lib, + {bool retain = false, bool release = false}) + : super._(id, lib, retain: retain, release: release); + + /// Returns a [NSNumber] that points to the same underlying object as [other]. + static NSNumber castFrom(T other) { + return NSNumber._(other._id, other._lib, retain: true, release: true); + } + + /// Returns a [NSNumber] that wraps the given raw object pointer. + static NSNumber castFromPointer( + NativeMacOsFramework lib, ffi.Pointer other, + {bool retain = false, bool release = false}) { + return NSNumber._(other, lib, retain: retain, release: release); + } + + /// Returns whether [obj] is an instance of [NSNumber]. + static bool isInstance(_ObjCWrapper obj) { + return obj._lib._objc_msgSend_0( + obj._id, obj._lib._sel_isKindOfClass_1, obj._lib._class_NSNumber1); + } + + @override + NSNumber? initWithCoder_(NSCoder coder) { + final _ret = + _lib._objc_msgSend_53(_id, _lib._sel_initWithCoder_1, coder._id); + return _ret.address == 0 + ? null + : NSNumber._(_ret, _lib, retain: true, release: true); + } + + NSNumber initWithChar_(int value) { + final _ret = _lib._objc_msgSend_266(_id, _lib._sel_initWithChar_1, value); + return NSNumber._(_ret, _lib, retain: true, release: true); + } + + NSNumber initWithUnsignedChar_(int value) { + final _ret = + _lib._objc_msgSend_267(_id, _lib._sel_initWithUnsignedChar_1, value); + return NSNumber._(_ret, _lib, retain: true, release: true); + } + + NSNumber initWithShort_(int value) { + final _ret = _lib._objc_msgSend_268(_id, _lib._sel_initWithShort_1, value); + return NSNumber._(_ret, _lib, retain: true, release: true); + } + + NSNumber initWithUnsignedShort_(int value) { + final _ret = + _lib._objc_msgSend_269(_id, _lib._sel_initWithUnsignedShort_1, value); + return NSNumber._(_ret, _lib, retain: true, release: true); + } + + NSNumber initWithInt_(int value) { + final _ret = _lib._objc_msgSend_270(_id, _lib._sel_initWithInt_1, value); + return NSNumber._(_ret, _lib, retain: true, release: true); + } + + NSNumber initWithUnsignedInt_(int value) { + final _ret = + _lib._objc_msgSend_271(_id, _lib._sel_initWithUnsignedInt_1, value); + return NSNumber._(_ret, _lib, retain: true, release: true); + } + + NSNumber initWithLong_(int value) { + final _ret = _lib._objc_msgSend_272(_id, _lib._sel_initWithLong_1, value); + return NSNumber._(_ret, _lib, retain: true, release: true); + } + + NSNumber initWithUnsignedLong_(int value) { + final _ret = + _lib._objc_msgSend_273(_id, _lib._sel_initWithUnsignedLong_1, value); + return NSNumber._(_ret, _lib, retain: true, release: true); + } + + NSNumber initWithLongLong_(int value) { + final _ret = + _lib._objc_msgSend_274(_id, _lib._sel_initWithLongLong_1, value); + return NSNumber._(_ret, _lib, retain: true, release: true); + } + + NSNumber initWithUnsignedLongLong_(int value) { + final _ret = _lib._objc_msgSend_275( + _id, _lib._sel_initWithUnsignedLongLong_1, value); + return NSNumber._(_ret, _lib, retain: true, release: true); + } + + NSNumber initWithFloat_(double value) { + final _ret = _lib._objc_msgSend_276(_id, _lib._sel_initWithFloat_1, value); + return NSNumber._(_ret, _lib, retain: true, release: true); + } + + NSNumber initWithDouble_(double value) { + final _ret = _lib._objc_msgSend_277(_id, _lib._sel_initWithDouble_1, value); + return NSNumber._(_ret, _lib, retain: true, release: true); + } + + NSNumber initWithBool_(bool value) { + final _ret = _lib._objc_msgSend_278(_id, _lib._sel_initWithBool_1, value); + return NSNumber._(_ret, _lib, retain: true, release: true); + } + + NSNumber initWithInteger_(int value) { + final _ret = + _lib._objc_msgSend_272(_id, _lib._sel_initWithInteger_1, value); + return NSNumber._(_ret, _lib, retain: true, release: true); + } + + NSNumber initWithUnsignedInteger_(int value) { + final _ret = + _lib._objc_msgSend_273(_id, _lib._sel_initWithUnsignedInteger_1, value); + return NSNumber._(_ret, _lib, retain: true, release: true); + } + + int get charValue { + return _lib._objc_msgSend_279(_id, _lib._sel_charValue1); + } + + int get unsignedCharValue { + return _lib._objc_msgSend_280(_id, _lib._sel_unsignedCharValue1); + } + + int get shortValue { + return _lib._objc_msgSend_281(_id, _lib._sel_shortValue1); + } + + int get unsignedShortValue { + return _lib._objc_msgSend_282(_id, _lib._sel_unsignedShortValue1); + } + + int get intValue { + return _lib._objc_msgSend_199(_id, _lib._sel_intValue1); + } + + int get unsignedIntValue { + return _lib._objc_msgSend_30(_id, _lib._sel_unsignedIntValue1); + } + + int get longValue { + return _lib._objc_msgSend_200(_id, _lib._sel_longValue1); + } + + int get unsignedLongValue { + return _lib._objc_msgSend_12(_id, _lib._sel_unsignedLongValue1); + } + + int get longLongValue { + return _lib._objc_msgSend_201(_id, _lib._sel_longLongValue1); + } + + int get unsignedLongLongValue { + return _lib._objc_msgSend_283(_id, _lib._sel_unsignedLongLongValue1); + } + + double get floatValue { + return _lib._objc_msgSend_198(_id, _lib._sel_floatValue1); + } + + double get doubleValue { + return _lib._objc_msgSend_197(_id, _lib._sel_doubleValue1); + } + + bool get boolValue { + return _lib._objc_msgSend_11(_id, _lib._sel_boolValue1); + } + + int get integerValue { + return _lib._objc_msgSend_200(_id, _lib._sel_integerValue1); + } + + int get unsignedIntegerValue { + return _lib._objc_msgSend_12(_id, _lib._sel_unsignedIntegerValue1); + } + + NSString get stringValue { + final _ret = _lib._objc_msgSend_57(_id, _lib._sel_stringValue1); + return NSString._(_ret, _lib, retain: true, release: true); + } + + int compare_(NSNumber otherNumber) { + return _lib._objc_msgSend_284(_id, _lib._sel_compare_1, otherNumber._id); + } + + bool isEqualToNumber_(NSNumber number) { + return _lib._objc_msgSend_285(_id, _lib._sel_isEqualToNumber_1, number._id); + } + + NSString descriptionWithLocale_(NSObject? locale) { + final _ret = _lib._objc_msgSend_58( + _id, _lib._sel_descriptionWithLocale_1, locale?._id ?? ffi.nullptr); + return NSString._(_ret, _lib, retain: true, release: true); + } + + static NSNumber numberWithChar_(NativeMacOsFramework _lib, int value) { + final _ret = _lib._objc_msgSend_266( + _lib._class_NSNumber1, _lib._sel_numberWithChar_1, value); + return NSNumber._(_ret, _lib, retain: true, release: true); + } + + static NSNumber numberWithUnsignedChar_( + NativeMacOsFramework _lib, int value) { + final _ret = _lib._objc_msgSend_267( + _lib._class_NSNumber1, _lib._sel_numberWithUnsignedChar_1, value); + return NSNumber._(_ret, _lib, retain: true, release: true); + } + + static NSNumber numberWithShort_(NativeMacOsFramework _lib, int value) { + final _ret = _lib._objc_msgSend_268( + _lib._class_NSNumber1, _lib._sel_numberWithShort_1, value); + return NSNumber._(_ret, _lib, retain: true, release: true); + } + + static NSNumber numberWithUnsignedShort_( + NativeMacOsFramework _lib, int value) { + final _ret = _lib._objc_msgSend_269( + _lib._class_NSNumber1, _lib._sel_numberWithUnsignedShort_1, value); + return NSNumber._(_ret, _lib, retain: true, release: true); + } + + static NSNumber numberWithInt_(NativeMacOsFramework _lib, int value) { + final _ret = _lib._objc_msgSend_270( + _lib._class_NSNumber1, _lib._sel_numberWithInt_1, value); + return NSNumber._(_ret, _lib, retain: true, release: true); + } + + static NSNumber numberWithUnsignedInt_(NativeMacOsFramework _lib, int value) { + final _ret = _lib._objc_msgSend_271( + _lib._class_NSNumber1, _lib._sel_numberWithUnsignedInt_1, value); + return NSNumber._(_ret, _lib, retain: true, release: true); + } + + static NSNumber numberWithLong_(NativeMacOsFramework _lib, int value) { + final _ret = _lib._objc_msgSend_272( + _lib._class_NSNumber1, _lib._sel_numberWithLong_1, value); + return NSNumber._(_ret, _lib, retain: true, release: true); + } + + static NSNumber numberWithUnsignedLong_( + NativeMacOsFramework _lib, int value) { + final _ret = _lib._objc_msgSend_273( + _lib._class_NSNumber1, _lib._sel_numberWithUnsignedLong_1, value); + return NSNumber._(_ret, _lib, retain: true, release: true); + } + + static NSNumber numberWithLongLong_(NativeMacOsFramework _lib, int value) { + final _ret = _lib._objc_msgSend_274( + _lib._class_NSNumber1, _lib._sel_numberWithLongLong_1, value); + return NSNumber._(_ret, _lib, retain: true, release: true); + } + + static NSNumber numberWithUnsignedLongLong_( + NativeMacOsFramework _lib, int value) { + final _ret = _lib._objc_msgSend_275( + _lib._class_NSNumber1, _lib._sel_numberWithUnsignedLongLong_1, value); + return NSNumber._(_ret, _lib, retain: true, release: true); + } + + static NSNumber numberWithFloat_(NativeMacOsFramework _lib, double value) { + final _ret = _lib._objc_msgSend_276( + _lib._class_NSNumber1, _lib._sel_numberWithFloat_1, value); + return NSNumber._(_ret, _lib, retain: true, release: true); + } + + static NSNumber numberWithDouble_(NativeMacOsFramework _lib, double value) { + final _ret = _lib._objc_msgSend_277( + _lib._class_NSNumber1, _lib._sel_numberWithDouble_1, value); + return NSNumber._(_ret, _lib, retain: true, release: true); + } + + static NSNumber numberWithBool_(NativeMacOsFramework _lib, bool value) { + final _ret = _lib._objc_msgSend_278( + _lib._class_NSNumber1, _lib._sel_numberWithBool_1, value); + return NSNumber._(_ret, _lib, retain: true, release: true); + } + + static NSNumber numberWithInteger_(NativeMacOsFramework _lib, int value) { + final _ret = _lib._objc_msgSend_272( + _lib._class_NSNumber1, _lib._sel_numberWithInteger_1, value); + return NSNumber._(_ret, _lib, retain: true, release: true); + } + + static NSNumber numberWithUnsignedInteger_( + NativeMacOsFramework _lib, int value) { + final _ret = _lib._objc_msgSend_273( + _lib._class_NSNumber1, _lib._sel_numberWithUnsignedInteger_1, value); + return NSNumber._(_ret, _lib, retain: true, release: true); + } + + @override + NSNumber initWithBytes_objCType_( + ffi.Pointer value, ffi.Pointer type) { + final _ret = _lib._objc_msgSend_253( + _id, _lib._sel_initWithBytes_objCType_1, value, type); + return NSNumber._(_ret, _lib, retain: true, release: true); + } + + static NSValue valueWithBytes_objCType_(NativeMacOsFramework _lib, + ffi.Pointer value, ffi.Pointer type) { + final _ret = _lib._objc_msgSend_254(_lib._class_NSNumber1, + _lib._sel_valueWithBytes_objCType_1, value, type); + return NSValue._(_ret, _lib, retain: true, release: true); + } + + static NSValue value_withObjCType_(NativeMacOsFramework _lib, + ffi.Pointer value, ffi.Pointer type) { + final _ret = _lib._objc_msgSend_254( + _lib._class_NSNumber1, _lib._sel_value_withObjCType_1, value, type); + return NSValue._(_ret, _lib, retain: true, release: true); + } + + static NSValue valueWithNonretainedObject_( + NativeMacOsFramework _lib, NSObject? anObject) { + final _ret = _lib._objc_msgSend_255(_lib._class_NSNumber1, + _lib._sel_valueWithNonretainedObject_1, anObject?._id ?? ffi.nullptr); + return NSValue._(_ret, _lib, retain: true, release: true); + } + + static NSValue valueWithPointer_( + NativeMacOsFramework _lib, ffi.Pointer pointer) { + final _ret = _lib._objc_msgSend_256( + _lib._class_NSNumber1, _lib._sel_valueWithPointer_1, pointer); + return NSValue._(_ret, _lib, retain: true, release: true); + } + + static NSValue valueWithRange_(NativeMacOsFramework _lib, _NSRange range) { + final _ret = _lib._objc_msgSend_259( + _lib._class_NSNumber1, _lib._sel_valueWithRange_1, range); + return NSValue._(_ret, _lib, retain: true, release: true); + } + + static NSValue valueWithPoint_(NativeMacOsFramework _lib, CGPoint point) { + final _ret = _lib._objc_msgSend_261( + _lib._class_NSNumber1, _lib._sel_valueWithPoint_1, point); + return NSValue._(_ret, _lib, retain: true, release: true); + } + + static NSValue valueWithSize_(NativeMacOsFramework _lib, CGSize size) { + final _ret = _lib._objc_msgSend_262( + _lib._class_NSNumber1, _lib._sel_valueWithSize_1, size); + return NSValue._(_ret, _lib, retain: true, release: true); + } + + static NSValue valueWithRect_(NativeMacOsFramework _lib, CGRect rect) { + final _ret = _lib._objc_msgSend_263( + _lib._class_NSNumber1, _lib._sel_valueWithRect_1, rect); + return NSValue._(_ret, _lib, retain: true, release: true); + } + + static NSValue valueWithEdgeInsets_( + NativeMacOsFramework _lib, NSEdgeInsets insets) { + final _ret = _lib._objc_msgSend_264( + _lib._class_NSNumber1, _lib._sel_valueWithEdgeInsets_1, insets); + return NSValue._(_ret, _lib, retain: true, release: true); + } + + @override + NSNumber init() { + final _ret = _lib._objc_msgSend_2(_id, _lib._sel_init1); + return NSNumber._(_ret, _lib, retain: true, release: true); + } + + static NSNumber new1(NativeMacOsFramework _lib) { + final _ret = _lib._objc_msgSend_2(_lib._class_NSNumber1, _lib._sel_new1); + return NSNumber._(_ret, _lib, retain: false, release: true); + } + + static NSNumber allocWithZone_( + NativeMacOsFramework _lib, ffi.Pointer<_NSZone> zone) { + final _ret = _lib._objc_msgSend_3( + _lib._class_NSNumber1, _lib._sel_allocWithZone_1, zone); + return NSNumber._(_ret, _lib, retain: false, release: true); + } + + static NSNumber alloc(NativeMacOsFramework _lib) { + final _ret = _lib._objc_msgSend_2(_lib._class_NSNumber1, _lib._sel_alloc1); + return NSNumber._(_ret, _lib, retain: false, release: true); + } +} + +class NSMutableArray extends NSArray { + NSMutableArray._(ffi.Pointer id, NativeMacOsFramework lib, + {bool retain = false, bool release = false}) + : super._(id, lib, retain: retain, release: release); + + /// Returns a [NSMutableArray] that points to the same underlying object as [other]. + static NSMutableArray castFrom(T other) { + return NSMutableArray._(other._id, other._lib, retain: true, release: true); + } + + /// Returns a [NSMutableArray] that wraps the given raw object pointer. + static NSMutableArray castFromPointer( + NativeMacOsFramework lib, ffi.Pointer other, + {bool retain = false, bool release = false}) { + return NSMutableArray._(other, lib, retain: retain, release: release); + } + + /// Returns whether [obj] is an instance of [NSMutableArray]. + static bool isInstance(_ObjCWrapper obj) { + return obj._lib._objc_msgSend_0(obj._id, obj._lib._sel_isKindOfClass_1, + obj._lib._class_NSMutableArray1); + } + + void addObject_(NSObject anObject) { + _lib._objc_msgSend_21(_id, _lib._sel_addObject_1, anObject._id); + } + + void insertObject_atIndex_(NSObject anObject, int index) { + _lib._objc_msgSend_286( + _id, _lib._sel_insertObject_atIndex_1, anObject._id, index); + } + + void removeLastObject() { + _lib._objc_msgSend_1(_id, _lib._sel_removeLastObject1); + } + + void removeObjectAtIndex_(int index) { + _lib._objc_msgSend_287(_id, _lib._sel_removeObjectAtIndex_1, index); + } + + void replaceObjectAtIndex_withObject_(int index, NSObject anObject) { + _lib._objc_msgSend_288( + _id, _lib._sel_replaceObjectAtIndex_withObject_1, index, anObject._id); + } + + @override + NSMutableArray init() { + final _ret = _lib._objc_msgSend_2(_id, _lib._sel_init1); + return NSMutableArray._(_ret, _lib, retain: true, release: true); + } + + NSMutableArray initWithCapacity_(int numItems) { + final _ret = + _lib._objc_msgSend_51(_id, _lib._sel_initWithCapacity_1, numItems); + return NSMutableArray._(_ret, _lib, retain: true, release: true); + } + + @override + NSMutableArray? initWithCoder_(NSCoder coder) { + final _ret = + _lib._objc_msgSend_53(_id, _lib._sel_initWithCoder_1, coder._id); + return _ret.address == 0 + ? null + : NSMutableArray._(_ret, _lib, retain: true, release: true); + } + + void addObjectsFromArray_(NSArray otherArray) { + _lib._objc_msgSend_289( + _id, _lib._sel_addObjectsFromArray_1, otherArray._id); + } + + void exchangeObjectAtIndex_withObjectAtIndex_(int idx1, int idx2) { + _lib._objc_msgSend_290( + _id, _lib._sel_exchangeObjectAtIndex_withObjectAtIndex_1, idx1, idx2); + } + + void removeAllObjects() { + _lib._objc_msgSend_1(_id, _lib._sel_removeAllObjects1); + } + + void removeObject_inRange_(NSObject anObject, _NSRange range) { + _lib._objc_msgSend_291( + _id, _lib._sel_removeObject_inRange_1, anObject._id, range); + } + + void removeObject_(NSObject anObject) { + _lib._objc_msgSend_21(_id, _lib._sel_removeObject_1, anObject._id); + } + + void removeObjectIdenticalTo_inRange_(NSObject anObject, _NSRange range) { + _lib._objc_msgSend_291( + _id, _lib._sel_removeObjectIdenticalTo_inRange_1, anObject._id, range); + } + + void removeObjectIdenticalTo_(NSObject anObject) { + _lib._objc_msgSend_21( + _id, _lib._sel_removeObjectIdenticalTo_1, anObject._id); + } + + void removeObjectsFromIndices_numIndices_( + ffi.Pointer indices, int cnt) { + _lib._objc_msgSend_292( + _id, _lib._sel_removeObjectsFromIndices_numIndices_1, indices, cnt); + } + + void removeObjectsInArray_(NSArray otherArray) { + _lib._objc_msgSend_289( + _id, _lib._sel_removeObjectsInArray_1, otherArray._id); + } + + void removeObjectsInRange_(_NSRange range) { + _lib._objc_msgSend_293(_id, _lib._sel_removeObjectsInRange_1, range); + } + + void replaceObjectsInRange_withObjectsFromArray_range_( + _NSRange range, NSArray otherArray, _NSRange otherRange) { + _lib._objc_msgSend_294( + _id, + _lib._sel_replaceObjectsInRange_withObjectsFromArray_range_1, + range, + otherArray._id, + otherRange); + } + + void replaceObjectsInRange_withObjectsFromArray_( + _NSRange range, NSArray otherArray) { + _lib._objc_msgSend_295( + _id, + _lib._sel_replaceObjectsInRange_withObjectsFromArray_1, + range, + otherArray._id); + } + + void setArray_(NSArray otherArray) { + _lib._objc_msgSend_289(_id, _lib._sel_setArray_1, otherArray._id); + } + + void sortUsingFunction_context_( + ffi.Pointer< + ffi.NativeFunction< + ffi.Long Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>> + compare, + ffi.Pointer context) { + _lib._objc_msgSend_296( + _id, _lib._sel_sortUsingFunction_context_1, compare, context); + } + + void sortUsingSelector_(ffi.Pointer comparator) { + _lib._objc_msgSend_7(_id, _lib._sel_sortUsingSelector_1, comparator); + } + + void insertObjects_atIndexes_(NSArray objects, NSIndexSet indexes) { + _lib._objc_msgSend_297( + _id, _lib._sel_insertObjects_atIndexes_1, objects._id, indexes._id); + } + + void removeObjectsAtIndexes_(NSIndexSet indexes) { + _lib._objc_msgSend_298( + _id, _lib._sel_removeObjectsAtIndexes_1, indexes._id); + } + + void replaceObjectsAtIndexes_withObjects_( + NSIndexSet indexes, NSArray objects) { + _lib._objc_msgSend_299(_id, _lib._sel_replaceObjectsAtIndexes_withObjects_1, + indexes._id, objects._id); + } + + void setObject_atIndexedSubscript_(NSObject obj, int idx) { + _lib._objc_msgSend_286( + _id, _lib._sel_setObject_atIndexedSubscript_1, obj._id, idx); + } + + void sortUsingComparator_( + ObjCBlock_NSComparisonResult_ObjCObject_ObjCObject cmptr) { + _lib._objc_msgSend_300(_id, _lib._sel_sortUsingComparator_1, cmptr._id); + } + + void sortWithOptions_usingComparator_( + int opts, ObjCBlock_NSComparisonResult_ObjCObject_ObjCObject cmptr) { + _lib._objc_msgSend_301( + _id, _lib._sel_sortWithOptions_usingComparator_1, opts, cmptr._id); + } + + static NSMutableArray arrayWithCapacity_( + NativeMacOsFramework _lib, int numItems) { + final _ret = _lib._objc_msgSend_51( + _lib._class_NSMutableArray1, _lib._sel_arrayWithCapacity_1, numItems); + return NSMutableArray._(_ret, _lib, retain: true, release: true); + } + + static NSMutableArray? arrayWithContentsOfFile_( + NativeMacOsFramework _lib, NSString path) { + final _ret = _lib._objc_msgSend_302(_lib._class_NSMutableArray1, + _lib._sel_arrayWithContentsOfFile_1, path._id); + return _ret.address == 0 + ? null + : NSMutableArray._(_ret, _lib, retain: true, release: true); + } + + static NSMutableArray? arrayWithContentsOfURL_( + NativeMacOsFramework _lib, NSURL url) { + final _ret = _lib._objc_msgSend_303(_lib._class_NSMutableArray1, + _lib._sel_arrayWithContentsOfURL_1, url._id); + return _ret.address == 0 + ? null + : NSMutableArray._(_ret, _lib, retain: true, release: true); + } + + NSMutableArray? initWithContentsOfFile_(NSString path) { + final _ret = _lib._objc_msgSend_302( + _id, _lib._sel_initWithContentsOfFile_1, path._id); + return _ret.address == 0 + ? null + : NSMutableArray._(_ret, _lib, retain: true, release: true); + } + + NSMutableArray? initWithContentsOfURL_(NSURL url) { + final _ret = + _lib._objc_msgSend_303(_id, _lib._sel_initWithContentsOfURL_1, url._id); + return _ret.address == 0 + ? null + : NSMutableArray._(_ret, _lib, retain: true, release: true); + } + + void applyDifference_(NSObject difference) { + _lib._objc_msgSend_21(_id, _lib._sel_applyDifference_1, difference._id); + } + + @override + NSMutableArray initWithObjects_count_( + ffi.Pointer> objects, int cnt) { + final _ret = _lib._objc_msgSend_52( + _id, _lib._sel_initWithObjects_count_1, objects, cnt); + return NSMutableArray._(_ret, _lib, retain: true, release: true); + } + + static NSMutableArray array(NativeMacOsFramework _lib) { + final _ret = + _lib._objc_msgSend_2(_lib._class_NSMutableArray1, _lib._sel_array1); + return NSMutableArray._(_ret, _lib, retain: true, release: true); + } + + static NSMutableArray arrayWithObject_( + NativeMacOsFramework _lib, NSObject anObject) { + final _ret = _lib._objc_msgSend_106( + _lib._class_NSMutableArray1, _lib._sel_arrayWithObject_1, anObject._id); + return NSMutableArray._(_ret, _lib, retain: true, release: true); + } + + static NSMutableArray arrayWithObjects_count_(NativeMacOsFramework _lib, + ffi.Pointer> objects, int cnt) { + final _ret = _lib._objc_msgSend_52(_lib._class_NSMutableArray1, + _lib._sel_arrayWithObjects_count_1, objects, cnt); + return NSMutableArray._(_ret, _lib, retain: true, release: true); + } + + static NSMutableArray arrayWithObjects_( + NativeMacOsFramework _lib, NSObject firstObj) { + final _ret = _lib._objc_msgSend_106(_lib._class_NSMutableArray1, + _lib._sel_arrayWithObjects_1, firstObj._id); + return NSMutableArray._(_ret, _lib, retain: true, release: true); + } + + static NSMutableArray arrayWithArray_( + NativeMacOsFramework _lib, NSArray array) { + final _ret = _lib._objc_msgSend_107( + _lib._class_NSMutableArray1, _lib._sel_arrayWithArray_1, array._id); + return NSMutableArray._(_ret, _lib, retain: true, release: true); + } + + @override + NSMutableArray initWithObjects_(NSObject firstObj) { + final _ret = + _lib._objc_msgSend_106(_id, _lib._sel_initWithObjects_1, firstObj._id); + return NSMutableArray._(_ret, _lib, retain: true, release: true); + } + + @override + NSMutableArray initWithArray_(NSArray array) { + final _ret = + _lib._objc_msgSend_107(_id, _lib._sel_initWithArray_1, array._id); + return NSMutableArray._(_ret, _lib, retain: true, release: true); + } + + @override + NSMutableArray initWithArray_copyItems_(NSArray array, bool flag) { + final _ret = _lib._objc_msgSend_108( + _id, _lib._sel_initWithArray_copyItems_1, array._id, flag); + return NSMutableArray._(_ret, _lib, retain: false, release: true); + } + + static NSArray? arrayWithContentsOfURL_error_(NativeMacOsFramework _lib, + NSURL url, ffi.Pointer> error) { + final _ret = _lib._objc_msgSend_109(_lib._class_NSMutableArray1, + _lib._sel_arrayWithContentsOfURL_error_1, url._id, error); + return _ret.address == 0 + ? null + : NSArray._(_ret, _lib, retain: true, release: true); + } + + static NSMutableArray new1(NativeMacOsFramework _lib) { + final _ret = + _lib._objc_msgSend_2(_lib._class_NSMutableArray1, _lib._sel_new1); + return NSMutableArray._(_ret, _lib, retain: false, release: true); + } + + static NSMutableArray allocWithZone_( + NativeMacOsFramework _lib, ffi.Pointer<_NSZone> zone) { + final _ret = _lib._objc_msgSend_3( + _lib._class_NSMutableArray1, _lib._sel_allocWithZone_1, zone); + return NSMutableArray._(_ret, _lib, retain: false, release: true); + } + + static NSMutableArray alloc(NativeMacOsFramework _lib) { + final _ret = + _lib._objc_msgSend_2(_lib._class_NSMutableArray1, _lib._sel_alloc1); + return NSMutableArray._(_ret, _lib, retain: false, release: true); + } +} + +class NSItemProvider extends NSObject { + NSItemProvider._(ffi.Pointer id, NativeMacOsFramework lib, + {bool retain = false, bool release = false}) + : super._(id, lib, retain: retain, release: release); + + /// Returns a [NSItemProvider] that points to the same underlying object as [other]. + static NSItemProvider castFrom(T other) { + return NSItemProvider._(other._id, other._lib, retain: true, release: true); + } + + /// Returns a [NSItemProvider] that wraps the given raw object pointer. + static NSItemProvider castFromPointer( + NativeMacOsFramework lib, ffi.Pointer other, + {bool retain = false, bool release = false}) { + return NSItemProvider._(other, lib, retain: retain, release: release); + } + + /// Returns whether [obj] is an instance of [NSItemProvider]. + static bool isInstance(_ObjCWrapper obj) { + return obj._lib._objc_msgSend_0(obj._id, obj._lib._sel_isKindOfClass_1, + obj._lib._class_NSItemProvider1); + } + + @override + NSItemProvider init() { + final _ret = _lib._objc_msgSend_2(_id, _lib._sel_init1); + return NSItemProvider._(_ret, _lib, retain: true, release: true); + } + + void registerDataRepresentationForTypeIdentifier_visibility_loadHandler_( + NSString typeIdentifier, + int visibility, + ObjCBlock_NSProgress_ffiVoidNSDataNSError loadHandler) { + _lib._objc_msgSend_323( + _id, + _lib._sel_registerDataRepresentationForTypeIdentifier_visibility_loadHandler_1, + typeIdentifier._id, + visibility, + loadHandler._id); + } + + void + registerFileRepresentationForTypeIdentifier_fileOptions_visibility_loadHandler_( + NSString typeIdentifier, + int fileOptions, + int visibility, + ObjCBlock_NSProgress_ffiVoidNSURLboolNSError loadHandler) { + _lib._objc_msgSend_324( + _id, + _lib._sel_registerFileRepresentationForTypeIdentifier_fileOptions_visibility_loadHandler_1, + typeIdentifier._id, + fileOptions, + visibility, + loadHandler._id); + } + + NSArray get registeredTypeIdentifiers { + final _ret = + _lib._objc_msgSend_121(_id, _lib._sel_registeredTypeIdentifiers1); + return NSArray._(_ret, _lib, retain: true, release: true); + } + + NSArray registeredTypeIdentifiersWithFileOptions_(int fileOptions) { + final _ret = _lib._objc_msgSend_325( + _id, _lib._sel_registeredTypeIdentifiersWithFileOptions_1, fileOptions); + return NSArray._(_ret, _lib, retain: true, release: true); + } + + bool hasItemConformingToTypeIdentifier_(NSString typeIdentifier) { + return _lib._objc_msgSend_39( + _id, _lib._sel_hasItemConformingToTypeIdentifier_1, typeIdentifier._id); + } + + bool hasRepresentationConformingToTypeIdentifier_fileOptions_( + NSString typeIdentifier, int fileOptions) { + return _lib._objc_msgSend_326( + _id, + _lib._sel_hasRepresentationConformingToTypeIdentifier_fileOptions_1, + typeIdentifier._id, + fileOptions); + } + + NSProgress loadDataRepresentationForTypeIdentifier_completionHandler_( + NSString typeIdentifier, + ObjCBlock_ffiVoid_NSData_NSError completionHandler) { + final _ret = _lib._objc_msgSend_327( + _id, + _lib._sel_loadDataRepresentationForTypeIdentifier_completionHandler_1, + typeIdentifier._id, + completionHandler._id); + return NSProgress._(_ret, _lib, retain: true, release: true); + } + + NSProgress loadFileRepresentationForTypeIdentifier_completionHandler_( + NSString typeIdentifier, + ObjCBlock_ffiVoid_NSURL_NSError completionHandler) { + final _ret = _lib._objc_msgSend_328( + _id, + _lib._sel_loadFileRepresentationForTypeIdentifier_completionHandler_1, + typeIdentifier._id, + completionHandler._id); + return NSProgress._(_ret, _lib, retain: true, release: true); + } + + NSProgress loadInPlaceFileRepresentationForTypeIdentifier_completionHandler_( + NSString typeIdentifier, + ObjCBlock_ffiVoid_NSURL_bool_NSError completionHandler) { + final _ret = _lib._objc_msgSend_329( + _id, + _lib._sel_loadInPlaceFileRepresentationForTypeIdentifier_completionHandler_1, + typeIdentifier._id, + completionHandler._id); + return NSProgress._(_ret, _lib, retain: true, release: true); + } + + NSString? get suggestedName { + final _ret = _lib._objc_msgSend_183(_id, _lib._sel_suggestedName1); + return _ret.address == 0 + ? null + : NSString._(_ret, _lib, retain: true, release: true); + } + + set suggestedName(NSString? value) { + return _lib._objc_msgSend_317( + _id, _lib._sel_setSuggestedName_1, value?._id ?? ffi.nullptr); + } + + NSItemProvider initWithObject_(NSObject object) { + final _ret = + _lib._objc_msgSend_106(_id, _lib._sel_initWithObject_1, object._id); + return NSItemProvider._(_ret, _lib, retain: true, release: true); + } + + void registerObject_visibility_(NSObject object, int visibility) { + _lib._objc_msgSend_330( + _id, _lib._sel_registerObject_visibility_1, object._id, visibility); + } + + void registerObjectOfClass_visibility_loadHandler_( + NSObject aClass, + int visibility, + ObjCBlock_NSProgress_ffiVoidObjCObjectNSError loadHandler) { + _lib._objc_msgSend_331( + _id, + _lib._sel_registerObjectOfClass_visibility_loadHandler_1, + aClass._id, + visibility, + loadHandler._id); + } + + bool canLoadObjectOfClass_(NSObject aClass) { + return _lib._objc_msgSend_0( + _id, _lib._sel_canLoadObjectOfClass_1, aClass._id); + } + + NSProgress loadObjectOfClass_completionHandler_( + NSObject aClass, ObjCBlock_ffiVoid_ObjCObject_NSError completionHandler) { + final _ret = _lib._objc_msgSend_332( + _id, + _lib._sel_loadObjectOfClass_completionHandler_1, + aClass._id, + completionHandler._id); + return NSProgress._(_ret, _lib, retain: true, release: true); + } + + NSItemProvider initWithItem_typeIdentifier_( + NSObject? item, NSString? typeIdentifier) { + final _ret = _lib._objc_msgSend_333( + _id, + _lib._sel_initWithItem_typeIdentifier_1, + item?._id ?? ffi.nullptr, + typeIdentifier?._id ?? ffi.nullptr); + return NSItemProvider._(_ret, _lib, retain: true, release: true); + } + + NSItemProvider? initWithContentsOfURL_(NSURL fileURL) { + final _ret = _lib._objc_msgSend_248( + _id, _lib._sel_initWithContentsOfURL_1, fileURL._id); + return _ret.address == 0 + ? null + : NSItemProvider._(_ret, _lib, retain: true, release: true); + } + + void registerItemForTypeIdentifier_loadHandler_( + NSString typeIdentifier, + ObjCBlock_ffiVoid_ffiVoidObjCObjectNSError_ObjCObject_NSDictionary + loadHandler) { + _lib._objc_msgSend_334( + _id, + _lib._sel_registerItemForTypeIdentifier_loadHandler_1, + typeIdentifier._id, + loadHandler._id); + } + + void loadItemForTypeIdentifier_options_completionHandler_( + NSString typeIdentifier, + NSDictionary? options, + ObjCBlock_ffiVoid_ObjCObject_NSError1? completionHandler) { + _lib._objc_msgSend_335( + _id, + _lib._sel_loadItemForTypeIdentifier_options_completionHandler_1, + typeIdentifier._id, + options?._id ?? ffi.nullptr, + completionHandler?._id ?? ffi.nullptr); + } + + ObjCBlock_ffiVoid_ffiVoidObjCObjectNSError_ObjCObject_NSDictionary? + get previewImageHandler { + final _ret = _lib._objc_msgSend_336(_id, _lib._sel_previewImageHandler1); + return _ret.address == 0 + ? null + : ObjCBlock_ffiVoid_ffiVoidObjCObjectNSError_ObjCObject_NSDictionary._( + _ret, _lib, + retain: true, release: true); + } + + set previewImageHandler( + ObjCBlock_ffiVoid_ffiVoidObjCObjectNSError_ObjCObject_NSDictionary? + value) { + return _lib._objc_msgSend_337( + _id, _lib._sel_setPreviewImageHandler_1, value?._id ?? ffi.nullptr); + } + + void loadPreviewImageWithOptions_completionHandler_(NSDictionary options, + ObjCBlock_ffiVoid_ObjCObject_NSError1 completionHandler) { + _lib._objc_msgSend_338( + _id, + _lib._sel_loadPreviewImageWithOptions_completionHandler_1, + options._id, + completionHandler._id); + } + + static NSItemProvider new1(NativeMacOsFramework _lib) { + final _ret = + _lib._objc_msgSend_2(_lib._class_NSItemProvider1, _lib._sel_new1); + return NSItemProvider._(_ret, _lib, retain: false, release: true); + } + + static NSItemProvider allocWithZone_( + NativeMacOsFramework _lib, ffi.Pointer<_NSZone> zone) { + final _ret = _lib._objc_msgSend_3( + _lib._class_NSItemProvider1, _lib._sel_allocWithZone_1, zone); + return NSItemProvider._(_ret, _lib, retain: false, release: true); + } + + static NSItemProvider alloc(NativeMacOsFramework _lib) { + final _ret = + _lib._objc_msgSend_2(_lib._class_NSItemProvider1, _lib._sel_alloc1); + return NSItemProvider._(_ret, _lib, retain: false, release: true); + } +} + +abstract class NSItemProviderRepresentationVisibility { + static const int NSItemProviderRepresentationVisibilityAll = 0; + static const int NSItemProviderRepresentationVisibilityTeam = 1; + static const int NSItemProviderRepresentationVisibilityGroup = 2; + static const int NSItemProviderRepresentationVisibilityOwnProcess = 3; +} + +ffi.Pointer< + ObjCObject> _ObjCBlock_NSProgress_ffiVoidNSDataNSError_fnPtrTrampoline( + ffi.Pointer<_ObjCBlock> block, ffi.Pointer<_ObjCBlock> arg0) => + block.ref.target + .cast< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer<_ObjCBlock> arg0)>>() + .asFunction< + ffi.Pointer Function(ffi.Pointer<_ObjCBlock>)>()(arg0); +final _ObjCBlock_NSProgress_ffiVoidNSDataNSError_closureRegistry = + Function(ffi.Pointer<_ObjCBlock>)>{}; +int _ObjCBlock_NSProgress_ffiVoidNSDataNSError_closureRegistryIndex = 0; +ffi.Pointer + _ObjCBlock_NSProgress_ffiVoidNSDataNSError_registerClosure( + ffi.Pointer Function(ffi.Pointer<_ObjCBlock>) fn) { + final id = ++_ObjCBlock_NSProgress_ffiVoidNSDataNSError_closureRegistryIndex; + _ObjCBlock_NSProgress_ffiVoidNSDataNSError_closureRegistry[id] = fn; + return ffi.Pointer.fromAddress(id); +} + +ffi.Pointer + _ObjCBlock_NSProgress_ffiVoidNSDataNSError_closureTrampoline( + ffi.Pointer<_ObjCBlock> block, ffi.Pointer<_ObjCBlock> arg0) => + _ObjCBlock_NSProgress_ffiVoidNSDataNSError_closureRegistry[ + block.ref.target.address]!(arg0); + +class ObjCBlock_NSProgress_ffiVoidNSDataNSError extends _ObjCBlockBase { + ObjCBlock_NSProgress_ffiVoidNSDataNSError._( + ffi.Pointer<_ObjCBlock> id, NativeMacOsFramework lib, + {bool retain = false, bool release = true}) + : super._(id, lib, retain: retain, release: release); + + /// Creates a block from a C function pointer. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + ObjCBlock_NSProgress_ffiVoidNSDataNSError.fromFunctionPointer( + NativeMacOsFramework lib, + ffi.Pointer< + ffi + .NativeFunction< + ffi.Pointer< + ObjCObject> + Function(ffi.Pointer<_ObjCBlock> arg0)>> + ptr) + : this._( + lib._newBlock1( + _cFuncTrampoline ??= ffi.Pointer.fromFunction< + ffi.Pointer Function( + ffi.Pointer<_ObjCBlock>, + ffi.Pointer<_ObjCBlock>)>( + _ObjCBlock_NSProgress_ffiVoidNSDataNSError_fnPtrTrampoline) + .cast(), + ptr.cast()), + lib); + static ffi.Pointer? _cFuncTrampoline; + + /// Creates a block from a Dart function. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + ObjCBlock_NSProgress_ffiVoidNSDataNSError.fromFunction( + NativeMacOsFramework lib, + NSProgress? Function(ObjCBlock_ffiVoid_NSData_NSError) fn) + : this._( + lib._newBlock1( + _dartFuncTrampoline ??= ffi.Pointer.fromFunction< + ffi.Pointer Function( + ffi.Pointer<_ObjCBlock>, ffi.Pointer<_ObjCBlock>)>( + _ObjCBlock_NSProgress_ffiVoidNSDataNSError_closureTrampoline) + .cast(), + _ObjCBlock_NSProgress_ffiVoidNSDataNSError_registerClosure((ffi + .Pointer<_ObjCBlock> + arg0) => + fn(ObjCBlock_ffiVoid_NSData_NSError._(arg0, lib, retain: true, release: true)) + ?._retainAndReturnId() ?? + ffi.nullptr)), + lib); + static ffi.Pointer? _dartFuncTrampoline; + + NSProgress? call(ObjCBlock_ffiVoid_NSData_NSError arg0) => _id.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer<_ObjCBlock> block, + ffi.Pointer<_ObjCBlock> arg0)>>() + .asFunction Function(ffi.Pointer<_ObjCBlock>, ffi.Pointer<_ObjCBlock>)>() + (_id, arg0._id) + .address == + 0 + ? null + : NSProgress._( + _id.ref.invoke + .cast Function(ffi.Pointer<_ObjCBlock> block, ffi.Pointer<_ObjCBlock> arg0)>>() + .asFunction Function(ffi.Pointer<_ObjCBlock>, ffi.Pointer<_ObjCBlock>)>()(_id, arg0._id), + _lib, + retain: false, + release: true); +} + +class NSProgress extends NSObject { + NSProgress._(ffi.Pointer id, NativeMacOsFramework lib, + {bool retain = false, bool release = false}) + : super._(id, lib, retain: retain, release: release); + + /// Returns a [NSProgress] that points to the same underlying object as [other]. + static NSProgress castFrom(T other) { + return NSProgress._(other._id, other._lib, retain: true, release: true); + } + + /// Returns a [NSProgress] that wraps the given raw object pointer. + static NSProgress castFromPointer( + NativeMacOsFramework lib, ffi.Pointer other, + {bool retain = false, bool release = false}) { + return NSProgress._(other, lib, retain: retain, release: release); + } + + /// Returns whether [obj] is an instance of [NSProgress]. + static bool isInstance(_ObjCWrapper obj) { + return obj._lib._objc_msgSend_0( + obj._id, obj._lib._sel_isKindOfClass_1, obj._lib._class_NSProgress1); + } + + static NSProgress? currentProgress(NativeMacOsFramework _lib) { + final _ret = _lib._objc_msgSend_304( + _lib._class_NSProgress1, _lib._sel_currentProgress1); + return _ret.address == 0 + ? null + : NSProgress._(_ret, _lib, retain: true, release: true); + } + + static NSProgress progressWithTotalUnitCount_( + NativeMacOsFramework _lib, int unitCount) { + final _ret = _lib._objc_msgSend_305(_lib._class_NSProgress1, + _lib._sel_progressWithTotalUnitCount_1, unitCount); + return NSProgress._(_ret, _lib, retain: true, release: true); + } + + static NSProgress discreteProgressWithTotalUnitCount_( + NativeMacOsFramework _lib, int unitCount) { + final _ret = _lib._objc_msgSend_305(_lib._class_NSProgress1, + _lib._sel_discreteProgressWithTotalUnitCount_1, unitCount); + return NSProgress._(_ret, _lib, retain: true, release: true); + } + + static NSProgress progressWithTotalUnitCount_parent_pendingUnitCount_( + NativeMacOsFramework _lib, + int unitCount, + NSProgress parent, + int portionOfParentTotalUnitCount) { + final _ret = _lib._objc_msgSend_306( + _lib._class_NSProgress1, + _lib._sel_progressWithTotalUnitCount_parent_pendingUnitCount_1, + unitCount, + parent._id, + portionOfParentTotalUnitCount); + return NSProgress._(_ret, _lib, retain: true, release: true); + } + + NSProgress initWithParent_userInfo_( + NSProgress? parentProgressOrNil, NSObject? userInfoOrNil) { + final _ret = _lib._objc_msgSend_307( + _id, + _lib._sel_initWithParent_userInfo_1, + parentProgressOrNil?._id ?? ffi.nullptr, + userInfoOrNil?._id ?? ffi.nullptr); + return NSProgress._(_ret, _lib, retain: true, release: true); + } + + void becomeCurrentWithPendingUnitCount_(int unitCount) { + _lib._objc_msgSend_308( + _id, _lib._sel_becomeCurrentWithPendingUnitCount_1, unitCount); + } + + void performAsCurrentWithPendingUnitCount_usingBlock_( + int unitCount, ObjCBlock_ffiVoid work) { + _lib._objc_msgSend_309( + _id, + _lib._sel_performAsCurrentWithPendingUnitCount_usingBlock_1, + unitCount, + work._id); + } + + void resignCurrent() { + _lib._objc_msgSend_1(_id, _lib._sel_resignCurrent1); + } + + void addChild_withPendingUnitCount_(NSProgress child, int inUnitCount) { + _lib._objc_msgSend_310( + _id, _lib._sel_addChild_withPendingUnitCount_1, child._id, inUnitCount); + } + + int get totalUnitCount { + return _lib._objc_msgSend_311(_id, _lib._sel_totalUnitCount1); + } + + set totalUnitCount(int value) { + return _lib._objc_msgSend_312(_id, _lib._sel_setTotalUnitCount_1, value); + } + + int get completedUnitCount { + return _lib._objc_msgSend_311(_id, _lib._sel_completedUnitCount1); + } + + set completedUnitCount(int value) { + return _lib._objc_msgSend_312( + _id, _lib._sel_setCompletedUnitCount_1, value); + } + + NSString get localizedDescription { + final _ret = _lib._objc_msgSend_57(_id, _lib._sel_localizedDescription1); + return NSString._(_ret, _lib, retain: true, release: true); + } + + set localizedDescription(NSString value) { + return _lib._objc_msgSend_313( + _id, _lib._sel_setLocalizedDescription_1, value._id); + } + + NSString get localizedAdditionalDescription { + final _ret = + _lib._objc_msgSend_57(_id, _lib._sel_localizedAdditionalDescription1); + return NSString._(_ret, _lib, retain: true, release: true); + } + + set localizedAdditionalDescription(NSString value) { + return _lib._objc_msgSend_313( + _id, _lib._sel_setLocalizedAdditionalDescription_1, value._id); + } + + bool get cancellable { + return _lib._objc_msgSend_11(_id, _lib._sel_isCancellable1); + } + + set cancellable(bool value) { + return _lib._objc_msgSend_314(_id, _lib._sel_setCancellable_1, value); + } + + bool get pausable { + return _lib._objc_msgSend_11(_id, _lib._sel_isPausable1); + } + + set pausable(bool value) { + return _lib._objc_msgSend_314(_id, _lib._sel_setPausable_1, value); + } + + bool get cancelled { + return _lib._objc_msgSend_11(_id, _lib._sel_isCancelled1); + } + + bool get paused { + return _lib._objc_msgSend_11(_id, _lib._sel_isPaused1); + } + + ObjCBlock_ffiVoid? get cancellationHandler { + final _ret = _lib._objc_msgSend_315(_id, _lib._sel_cancellationHandler1); + return _ret.address == 0 + ? null + : ObjCBlock_ffiVoid._(_ret, _lib, retain: true, release: true); + } + + set cancellationHandler(ObjCBlock_ffiVoid? value) { + return _lib._objc_msgSend_316( + _id, _lib._sel_setCancellationHandler_1, value?._id ?? ffi.nullptr); + } + + ObjCBlock_ffiVoid? get pausingHandler { + final _ret = _lib._objc_msgSend_315(_id, _lib._sel_pausingHandler1); + return _ret.address == 0 + ? null + : ObjCBlock_ffiVoid._(_ret, _lib, retain: true, release: true); + } + + set pausingHandler(ObjCBlock_ffiVoid? value) { + return _lib._objc_msgSend_316( + _id, _lib._sel_setPausingHandler_1, value?._id ?? ffi.nullptr); + } + + ObjCBlock_ffiVoid? get resumingHandler { + final _ret = _lib._objc_msgSend_315(_id, _lib._sel_resumingHandler1); + return _ret.address == 0 + ? null + : ObjCBlock_ffiVoid._(_ret, _lib, retain: true, release: true); + } + + set resumingHandler(ObjCBlock_ffiVoid? value) { + return _lib._objc_msgSend_316( + _id, _lib._sel_setResumingHandler_1, value?._id ?? ffi.nullptr); + } + + void setUserInfoObject_forKey_(NSObject? objectOrNil, NSString key) { + _lib._objc_msgSend_31(_id, _lib._sel_setUserInfoObject_forKey_1, + objectOrNil?._id ?? ffi.nullptr, key._id); + } + + bool get indeterminate { + return _lib._objc_msgSend_11(_id, _lib._sel_isIndeterminate1); + } + + double get fractionCompleted { + return _lib._objc_msgSend_197(_id, _lib._sel_fractionCompleted1); + } + + bool get finished { + return _lib._objc_msgSend_11(_id, _lib._sel_isFinished1); + } + + void cancel() { + _lib._objc_msgSend_1(_id, _lib._sel_cancel1); + } + + void pause() { + _lib._objc_msgSend_1(_id, _lib._sel_pause1); + } + + void resume() { + _lib._objc_msgSend_1(_id, _lib._sel_resume1); + } + + NSObject get userInfo { + final _ret = _lib._objc_msgSend_2(_id, _lib._sel_userInfo1); + return NSObject._(_ret, _lib, retain: true, release: true); + } + + NSString? get kind { + final _ret = _lib._objc_msgSend_183(_id, _lib._sel_kind1); + return _ret.address == 0 + ? null + : NSString._(_ret, _lib, retain: true, release: true); + } + + set kind(NSString? value) { + return _lib._objc_msgSend_317( + _id, _lib._sel_setKind_1, value?._id ?? ffi.nullptr); + } + + NSNumber? get estimatedTimeRemaining { + final _ret = _lib._objc_msgSend_318(_id, _lib._sel_estimatedTimeRemaining1); + return _ret.address == 0 + ? null + : NSNumber._(_ret, _lib, retain: true, release: true); + } + + set estimatedTimeRemaining(NSNumber? value) { + return _lib._objc_msgSend_319( + _id, _lib._sel_setEstimatedTimeRemaining_1, value?._id ?? ffi.nullptr); + } + + NSNumber? get throughput { + final _ret = _lib._objc_msgSend_318(_id, _lib._sel_throughput1); + return _ret.address == 0 + ? null + : NSNumber._(_ret, _lib, retain: true, release: true); + } + + set throughput(NSNumber? value) { + return _lib._objc_msgSend_319( + _id, _lib._sel_setThroughput_1, value?._id ?? ffi.nullptr); + } + + NSString? get fileOperationKind { + final _ret = _lib._objc_msgSend_183(_id, _lib._sel_fileOperationKind1); + return _ret.address == 0 + ? null + : NSString._(_ret, _lib, retain: true, release: true); + } + + set fileOperationKind(NSString? value) { + return _lib._objc_msgSend_317( + _id, _lib._sel_setFileOperationKind_1, value?._id ?? ffi.nullptr); + } + + NSURL? get fileURL { + final _ret = _lib._objc_msgSend_320(_id, _lib._sel_fileURL1); + return _ret.address == 0 + ? null + : NSURL._(_ret, _lib, retain: true, release: true); + } + + set fileURL(NSURL? value) { + return _lib._objc_msgSend_321( + _id, _lib._sel_setFileURL_1, value?._id ?? ffi.nullptr); + } + + NSNumber? get fileTotalCount { + final _ret = _lib._objc_msgSend_318(_id, _lib._sel_fileTotalCount1); + return _ret.address == 0 + ? null + : NSNumber._(_ret, _lib, retain: true, release: true); + } + + set fileTotalCount(NSNumber? value) { + return _lib._objc_msgSend_319( + _id, _lib._sel_setFileTotalCount_1, value?._id ?? ffi.nullptr); + } + + NSNumber? get fileCompletedCount { + final _ret = _lib._objc_msgSend_318(_id, _lib._sel_fileCompletedCount1); + return _ret.address == 0 + ? null + : NSNumber._(_ret, _lib, retain: true, release: true); + } + + set fileCompletedCount(NSNumber? value) { + return _lib._objc_msgSend_319( + _id, _lib._sel_setFileCompletedCount_1, value?._id ?? ffi.nullptr); + } + + void publish() { + _lib._objc_msgSend_1(_id, _lib._sel_publish1); + } + + void unpublish() { + _lib._objc_msgSend_1(_id, _lib._sel_unpublish1); + } + + static NSObject addSubscriberForFileURL_withPublishingHandler_( + NativeMacOsFramework _lib, + NSURL url, + ObjCBlock_ffiVoid_NSProgress publishingHandler) { + final _ret = _lib._objc_msgSend_322( + _lib._class_NSProgress1, + _lib._sel_addSubscriberForFileURL_withPublishingHandler_1, + url._id, + publishingHandler._id); + return NSObject._(_ret, _lib, retain: true, release: true); + } + + static void removeSubscriber_( + NativeMacOsFramework _lib, NSObject subscriber) { + _lib._objc_msgSend_21( + _lib._class_NSProgress1, _lib._sel_removeSubscriber_1, subscriber._id); + } + + bool get old { + return _lib._objc_msgSend_11(_id, _lib._sel_isOld1); + } + + @override + NSProgress init() { + final _ret = _lib._objc_msgSend_2(_id, _lib._sel_init1); + return NSProgress._(_ret, _lib, retain: true, release: true); + } + + static NSProgress new1(NativeMacOsFramework _lib) { + final _ret = _lib._objc_msgSend_2(_lib._class_NSProgress1, _lib._sel_new1); + return NSProgress._(_ret, _lib, retain: false, release: true); + } + + static NSProgress allocWithZone_( + NativeMacOsFramework _lib, ffi.Pointer<_NSZone> zone) { + final _ret = _lib._objc_msgSend_3( + _lib._class_NSProgress1, _lib._sel_allocWithZone_1, zone); + return NSProgress._(_ret, _lib, retain: false, release: true); + } + + static NSProgress alloc(NativeMacOsFramework _lib) { + final _ret = + _lib._objc_msgSend_2(_lib._class_NSProgress1, _lib._sel_alloc1); + return NSProgress._(_ret, _lib, retain: false, release: true); + } +} + +void _ObjCBlock_ffiVoid_fnPtrTrampoline( + ffi.Pointer<_ObjCBlock> block, +) => + block.ref.target + .cast>() + .asFunction()(); +final _ObjCBlock_ffiVoid_closureRegistry = {}; +int _ObjCBlock_ffiVoid_closureRegistryIndex = 0; +ffi.Pointer _ObjCBlock_ffiVoid_registerClosure(void Function() fn) { + final id = ++_ObjCBlock_ffiVoid_closureRegistryIndex; + _ObjCBlock_ffiVoid_closureRegistry[id] = fn; + return ffi.Pointer.fromAddress(id); +} + +void _ObjCBlock_ffiVoid_closureTrampoline( + ffi.Pointer<_ObjCBlock> block, +) => + _ObjCBlock_ffiVoid_closureRegistry[block.ref.target.address]!(); + +class ObjCBlock_ffiVoid extends _ObjCBlockBase { + ObjCBlock_ffiVoid._(ffi.Pointer<_ObjCBlock> id, NativeMacOsFramework lib, + {bool retain = false, bool release = true}) + : super._(id, lib, retain: retain, release: release); + + /// Creates a block from a C function pointer. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + ObjCBlock_ffiVoid.fromFunctionPointer(NativeMacOsFramework lib, + ffi.Pointer> ptr) + : this._( + lib._newBlock1( + _cFuncTrampoline ??= ffi.Pointer.fromFunction< + ffi.Void Function(ffi.Pointer<_ObjCBlock>)>( + _ObjCBlock_ffiVoid_fnPtrTrampoline) + .cast(), + ptr.cast()), + lib); + static ffi.Pointer? _cFuncTrampoline; + + /// Creates a block from a Dart function. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + ObjCBlock_ffiVoid.fromFunction(NativeMacOsFramework lib, void Function() fn) + : this._( + lib._newBlock1( + _dartFuncTrampoline ??= ffi.Pointer.fromFunction< + ffi.Void Function(ffi.Pointer<_ObjCBlock>)>( + _ObjCBlock_ffiVoid_closureTrampoline) + .cast(), + _ObjCBlock_ffiVoid_registerClosure(() => fn())), + lib); + static ffi.Pointer? _dartFuncTrampoline; + + /// Creates a listener block from a Dart function. + /// + /// This is based on FFI's NativeCallable.listener, and has the same + /// capabilities and limitations. This block can be invoked from any thread, + /// but only supports void functions, and is not run synchronously. See + /// NativeCallable.listener for more details. + /// + /// Note that unlike the default behavior of NativeCallable.listener, listener + /// blocks do not keep the isolate alive. + ObjCBlock_ffiVoid.listener(NativeMacOsFramework lib, void Function() fn) + : this._( + lib._newBlock1( + (_dartFuncListenerTrampoline ??= ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer<_ObjCBlock>)>.listener( + _ObjCBlock_ffiVoid_closureTrampoline) + ..keepIsolateAlive = false) + .nativeFunction + .cast(), + _ObjCBlock_ffiVoid_registerClosure(() => fn())), + lib); + static ffi.NativeCallable)>? + _dartFuncListenerTrampoline; + + void call() => _id.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer<_ObjCBlock> block)>>() + .asFunction)>()( + _id, + ); +} + +ffi.Pointer<_ObjCBlock> _ObjCBlock_ffiVoid_NSProgress_fnPtrTrampoline( + ffi.Pointer<_ObjCBlock> block, ffi.Pointer arg0) => + block.ref.target + .cast< + ffi.NativeFunction< + ffi.Pointer<_ObjCBlock> Function( + ffi.Pointer arg0)>>() + .asFunction< + ffi.Pointer<_ObjCBlock> Function(ffi.Pointer)>()(arg0); +final _ObjCBlock_ffiVoid_NSProgress_closureRegistry = + Function(ffi.Pointer)>{}; +int _ObjCBlock_ffiVoid_NSProgress_closureRegistryIndex = 0; +ffi.Pointer _ObjCBlock_ffiVoid_NSProgress_registerClosure( + ffi.Pointer<_ObjCBlock> Function(ffi.Pointer) fn) { + final id = ++_ObjCBlock_ffiVoid_NSProgress_closureRegistryIndex; + _ObjCBlock_ffiVoid_NSProgress_closureRegistry[id] = fn; + return ffi.Pointer.fromAddress(id); +} + +ffi.Pointer<_ObjCBlock> _ObjCBlock_ffiVoid_NSProgress_closureTrampoline( + ffi.Pointer<_ObjCBlock> block, ffi.Pointer arg0) => + _ObjCBlock_ffiVoid_NSProgress_closureRegistry[block.ref.target.address]!( + arg0); + +class ObjCBlock_ffiVoid_NSProgress extends _ObjCBlockBase { + ObjCBlock_ffiVoid_NSProgress._( + ffi.Pointer<_ObjCBlock> id, NativeMacOsFramework lib, + {bool retain = false, bool release = true}) + : super._(id, lib, retain: retain, release: release); + + /// Creates a block from a C function pointer. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + ObjCBlock_ffiVoid_NSProgress.fromFunctionPointer( + NativeMacOsFramework lib, + ffi.Pointer< + ffi.NativeFunction< + ffi.Pointer<_ObjCBlock> Function( + ffi.Pointer arg0)>> + ptr) + : this._( + lib._newBlock1( + _cFuncTrampoline ??= ffi.Pointer.fromFunction< + ffi.Pointer<_ObjCBlock> Function( + ffi.Pointer<_ObjCBlock>, + ffi.Pointer)>( + _ObjCBlock_ffiVoid_NSProgress_fnPtrTrampoline) + .cast(), + ptr.cast()), + lib); + static ffi.Pointer? _cFuncTrampoline; + + /// Creates a block from a Dart function. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + ObjCBlock_ffiVoid_NSProgress.fromFunction( + NativeMacOsFramework lib, ObjCBlock_ffiVoid? Function(NSProgress) fn) + : this._( + lib._newBlock1( + _dartFuncTrampoline ??= ffi.Pointer.fromFunction< + ffi.Pointer<_ObjCBlock> Function( + ffi.Pointer<_ObjCBlock>, + ffi.Pointer)>( + _ObjCBlock_ffiVoid_NSProgress_closureTrampoline) + .cast(), + _ObjCBlock_ffiVoid_NSProgress_registerClosure( + (ffi.Pointer arg0) => + fn(NSProgress._(arg0, lib, retain: true, release: true)) + ?._retainAndReturnId() ?? + ffi.nullptr)), + lib); + static ffi.Pointer? _dartFuncTrampoline; + + ObjCBlock_ffiVoid? call(NSProgress arg0) => _id.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Pointer<_ObjCBlock> Function( + ffi.Pointer<_ObjCBlock> block, + ffi.Pointer arg0)>>() + .asFunction Function(ffi.Pointer<_ObjCBlock>, ffi.Pointer)>() + (_id, arg0._id) + .address == + 0 + ? null + : ObjCBlock_ffiVoid._( + _id.ref.invoke + .cast Function(ffi.Pointer<_ObjCBlock> block, ffi.Pointer arg0)>>() + .asFunction Function(ffi.Pointer<_ObjCBlock>, ffi.Pointer)>()(_id, arg0._id), + _lib, + retain: false, + release: true); +} + +void _ObjCBlock_ffiVoid_NSData_NSError_fnPtrTrampoline( + ffi.Pointer<_ObjCBlock> block, + ffi.Pointer arg0, + ffi.Pointer arg1) => + block.ref.target + .cast< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer arg0, + ffi.Pointer arg1)>>() + .asFunction< + void Function(ffi.Pointer, + ffi.Pointer)>()(arg0, arg1); +final _ObjCBlock_ffiVoid_NSData_NSError_closureRegistry = + , ffi.Pointer)>{}; +int _ObjCBlock_ffiVoid_NSData_NSError_closureRegistryIndex = 0; +ffi.Pointer _ObjCBlock_ffiVoid_NSData_NSError_registerClosure( + void Function(ffi.Pointer, ffi.Pointer) fn) { + final id = ++_ObjCBlock_ffiVoid_NSData_NSError_closureRegistryIndex; + _ObjCBlock_ffiVoid_NSData_NSError_closureRegistry[id] = fn; + return ffi.Pointer.fromAddress(id); +} + +void _ObjCBlock_ffiVoid_NSData_NSError_closureTrampoline( + ffi.Pointer<_ObjCBlock> block, + ffi.Pointer arg0, + ffi.Pointer arg1) => + _ObjCBlock_ffiVoid_NSData_NSError_closureRegistry[ + block.ref.target.address]!(arg0, arg1); + +class ObjCBlock_ffiVoid_NSData_NSError extends _ObjCBlockBase { + ObjCBlock_ffiVoid_NSData_NSError._( + ffi.Pointer<_ObjCBlock> id, NativeMacOsFramework lib, + {bool retain = false, bool release = true}) + : super._(id, lib, retain: retain, release: release); + + /// Creates a block from a C function pointer. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + ObjCBlock_ffiVoid_NSData_NSError.fromFunctionPointer( + NativeMacOsFramework lib, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer arg0, + ffi.Pointer arg1)>> + ptr) + : this._( + lib._newBlock1( + _cFuncTrampoline ??= ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer<_ObjCBlock>, + ffi.Pointer, + ffi.Pointer)>( + _ObjCBlock_ffiVoid_NSData_NSError_fnPtrTrampoline) + .cast(), + ptr.cast()), + lib); + static ffi.Pointer? _cFuncTrampoline; + + /// Creates a block from a Dart function. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + ObjCBlock_ffiVoid_NSData_NSError.fromFunction( + NativeMacOsFramework lib, void Function(NSData?, NSError?) fn) + : this._( + lib._newBlock1( + _dartFuncTrampoline ??= + ffi.Pointer.fromFunction, ffi.Pointer, ffi.Pointer)>( + _ObjCBlock_ffiVoid_NSData_NSError_closureTrampoline) + .cast(), + _ObjCBlock_ffiVoid_NSData_NSError_registerClosure( + (ffi.Pointer arg0, ffi.Pointer arg1) => fn( + arg0.address == 0 + ? null + : NSData._(arg0, lib, retain: true, release: true), + arg1.address == 0 + ? null + : NSError._(arg1, lib, retain: true, release: true)))), + lib); + static ffi.Pointer? _dartFuncTrampoline; + + /// Creates a listener block from a Dart function. + /// + /// This is based on FFI's NativeCallable.listener, and has the same + /// capabilities and limitations. This block can be invoked from any thread, + /// but only supports void functions, and is not run synchronously. See + /// NativeCallable.listener for more details. + /// + /// Note that unlike the default behavior of NativeCallable.listener, listener + /// blocks do not keep the isolate alive. + ObjCBlock_ffiVoid_NSData_NSError.listener( + NativeMacOsFramework lib, void Function(NSData?, NSError?) fn) + : this._( + lib._newBlock1( + (_dartFuncListenerTrampoline ??= + ffi.NativeCallable, ffi.Pointer, ffi.Pointer)>.listener( + _ObjCBlock_ffiVoid_NSData_NSError_closureTrampoline) + ..keepIsolateAlive = false) + .nativeFunction + .cast(), + _ObjCBlock_ffiVoid_NSData_NSError_registerClosure( + (ffi.Pointer arg0, ffi.Pointer arg1) => fn( + arg0.address == 0 + ? null + : NSData._(arg0, lib, retain: true, release: true), + arg1.address == 0 + ? null + : NSError._(arg1, lib, + retain: true, release: true)))), + lib); + static ffi.NativeCallable< + ffi.Void Function(ffi.Pointer<_ObjCBlock>, ffi.Pointer, + ffi.Pointer)>? _dartFuncListenerTrampoline; + + void call(NSData? arg0, NSError? arg1) => _id.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer<_ObjCBlock> block, + ffi.Pointer arg0, + ffi.Pointer arg1)>>() + .asFunction< + void Function(ffi.Pointer<_ObjCBlock>, ffi.Pointer, + ffi.Pointer)>()( + _id, arg0?._id ?? ffi.nullptr, arg1?._id ?? ffi.nullptr); +} + +abstract class NSItemProviderFileOptions { + static const int NSItemProviderFileOptionOpenInPlace = 1; +} + +ffi.Pointer + _ObjCBlock_NSProgress_ffiVoidNSURLboolNSError_fnPtrTrampoline( + ffi.Pointer<_ObjCBlock> block, ffi.Pointer<_ObjCBlock> arg0) => + block.ref.target + .cast< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer<_ObjCBlock> arg0)>>() + .asFunction< + ffi.Pointer Function( + ffi.Pointer<_ObjCBlock>)>()(arg0); +final _ObjCBlock_NSProgress_ffiVoidNSURLboolNSError_closureRegistry = + Function(ffi.Pointer<_ObjCBlock>)>{}; +int _ObjCBlock_NSProgress_ffiVoidNSURLboolNSError_closureRegistryIndex = 0; +ffi.Pointer + _ObjCBlock_NSProgress_ffiVoidNSURLboolNSError_registerClosure( + ffi.Pointer Function(ffi.Pointer<_ObjCBlock>) fn) { + final id = + ++_ObjCBlock_NSProgress_ffiVoidNSURLboolNSError_closureRegistryIndex; + _ObjCBlock_NSProgress_ffiVoidNSURLboolNSError_closureRegistry[id] = fn; + return ffi.Pointer.fromAddress(id); +} + +ffi.Pointer + _ObjCBlock_NSProgress_ffiVoidNSURLboolNSError_closureTrampoline( + ffi.Pointer<_ObjCBlock> block, ffi.Pointer<_ObjCBlock> arg0) => + _ObjCBlock_NSProgress_ffiVoidNSURLboolNSError_closureRegistry[ + block.ref.target.address]!(arg0); + +class ObjCBlock_NSProgress_ffiVoidNSURLboolNSError extends _ObjCBlockBase { + ObjCBlock_NSProgress_ffiVoidNSURLboolNSError._( + ffi.Pointer<_ObjCBlock> id, NativeMacOsFramework lib, + {bool retain = false, bool release = true}) + : super._(id, lib, retain: retain, release: release); + + /// Creates a block from a C function pointer. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + ObjCBlock_NSProgress_ffiVoidNSURLboolNSError.fromFunctionPointer( + NativeMacOsFramework lib, + ffi.Pointer< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer<_ObjCBlock> arg0)>> + ptr) + : this._( + lib._newBlock1( + _cFuncTrampoline ??= ffi.Pointer.fromFunction< + ffi.Pointer Function( + ffi.Pointer<_ObjCBlock>, + ffi.Pointer<_ObjCBlock>)>( + _ObjCBlock_NSProgress_ffiVoidNSURLboolNSError_fnPtrTrampoline) + .cast(), + ptr.cast()), + lib); + static ffi.Pointer? _cFuncTrampoline; + + /// Creates a block from a Dart function. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + ObjCBlock_NSProgress_ffiVoidNSURLboolNSError.fromFunction( + NativeMacOsFramework lib, + NSProgress? Function(ObjCBlock_ffiVoid_NSURL_bool_NSError) fn) + : this._( + lib._newBlock1( + _dartFuncTrampoline ??= ffi.Pointer.fromFunction< + ffi.Pointer Function( + ffi.Pointer<_ObjCBlock>, + ffi.Pointer<_ObjCBlock>)>( + _ObjCBlock_NSProgress_ffiVoidNSURLboolNSError_closureTrampoline) + .cast(), + _ObjCBlock_NSProgress_ffiVoidNSURLboolNSError_registerClosure( + (ffi.Pointer<_ObjCBlock> arg0) => + fn(ObjCBlock_ffiVoid_NSURL_bool_NSError._(arg0, lib, retain: true, release: true)) + ?._retainAndReturnId() ?? + ffi.nullptr)), + lib); + static ffi.Pointer? _dartFuncTrampoline; + + NSProgress? call(ObjCBlock_ffiVoid_NSURL_bool_NSError arg0) => _id.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer<_ObjCBlock> block, + ffi.Pointer<_ObjCBlock> arg0)>>() + .asFunction Function(ffi.Pointer<_ObjCBlock>, ffi.Pointer<_ObjCBlock>)>() + (_id, arg0._id) + .address == + 0 + ? null + : NSProgress._( + _id.ref.invoke + .cast Function(ffi.Pointer<_ObjCBlock> block, ffi.Pointer<_ObjCBlock> arg0)>>() + .asFunction Function(ffi.Pointer<_ObjCBlock>, ffi.Pointer<_ObjCBlock>)>()(_id, arg0._id), + _lib, + retain: false, + release: true); +} + +void _ObjCBlock_ffiVoid_NSURL_bool_NSError_fnPtrTrampoline( + ffi.Pointer<_ObjCBlock> block, + ffi.Pointer arg0, + bool arg1, + ffi.Pointer arg2) => + block.ref.target + .cast< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer arg0, ffi.Bool arg1, + ffi.Pointer arg2)>>() + .asFunction< + void Function(ffi.Pointer, bool, + ffi.Pointer)>()(arg0, arg1, arg2); +final _ObjCBlock_ffiVoid_NSURL_bool_NSError_closureRegistry = , bool, ffi.Pointer)>{}; +int _ObjCBlock_ffiVoid_NSURL_bool_NSError_closureRegistryIndex = 0; +ffi.Pointer _ObjCBlock_ffiVoid_NSURL_bool_NSError_registerClosure( + void Function(ffi.Pointer, bool, ffi.Pointer) fn) { + final id = ++_ObjCBlock_ffiVoid_NSURL_bool_NSError_closureRegistryIndex; + _ObjCBlock_ffiVoid_NSURL_bool_NSError_closureRegistry[id] = fn; + return ffi.Pointer.fromAddress(id); +} + +void _ObjCBlock_ffiVoid_NSURL_bool_NSError_closureTrampoline( + ffi.Pointer<_ObjCBlock> block, + ffi.Pointer arg0, + bool arg1, + ffi.Pointer arg2) => + _ObjCBlock_ffiVoid_NSURL_bool_NSError_closureRegistry[ + block.ref.target.address]!(arg0, arg1, arg2); + +class ObjCBlock_ffiVoid_NSURL_bool_NSError extends _ObjCBlockBase { + ObjCBlock_ffiVoid_NSURL_bool_NSError._( + ffi.Pointer<_ObjCBlock> id, NativeMacOsFramework lib, + {bool retain = false, bool release = true}) + : super._(id, lib, retain: retain, release: release); + + /// Creates a block from a C function pointer. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + ObjCBlock_ffiVoid_NSURL_bool_NSError.fromFunctionPointer( + NativeMacOsFramework lib, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer arg0, ffi.Bool arg1, + ffi.Pointer arg2)>> + ptr) + : this._( + lib._newBlock1( + _cFuncTrampoline ??= ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer<_ObjCBlock>, + ffi.Pointer, + ffi.Bool, + ffi.Pointer)>( + _ObjCBlock_ffiVoid_NSURL_bool_NSError_fnPtrTrampoline) + .cast(), + ptr.cast()), + lib); + static ffi.Pointer? _cFuncTrampoline; + + /// Creates a block from a Dart function. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + ObjCBlock_ffiVoid_NSURL_bool_NSError.fromFunction( + NativeMacOsFramework lib, void Function(NSURL?, bool, NSError?) fn) + : this._( + lib._newBlock1( + _dartFuncTrampoline ??= + ffi.Pointer.fromFunction, ffi.Pointer, ffi.Bool, ffi.Pointer)>( + _ObjCBlock_ffiVoid_NSURL_bool_NSError_closureTrampoline) + .cast(), + _ObjCBlock_ffiVoid_NSURL_bool_NSError_registerClosure( + (ffi.Pointer arg0, bool arg1, ffi.Pointer arg2) => fn( + arg0.address == 0 + ? null + : NSURL._(arg0, lib, retain: true, release: true), + arg1, + arg2.address == 0 + ? null + : NSError._(arg2, lib, retain: true, release: true)))), + lib); + static ffi.Pointer? _dartFuncTrampoline; + + /// Creates a listener block from a Dart function. + /// + /// This is based on FFI's NativeCallable.listener, and has the same + /// capabilities and limitations. This block can be invoked from any thread, + /// but only supports void functions, and is not run synchronously. See + /// NativeCallable.listener for more details. + /// + /// Note that unlike the default behavior of NativeCallable.listener, listener + /// blocks do not keep the isolate alive. + ObjCBlock_ffiVoid_NSURL_bool_NSError.listener( + NativeMacOsFramework lib, void Function(NSURL?, bool, NSError?) fn) + : this._( + lib._newBlock1( + (_dartFuncListenerTrampoline ??= + ffi.NativeCallable, ffi.Pointer, ffi.Bool, ffi.Pointer)>.listener( + _ObjCBlock_ffiVoid_NSURL_bool_NSError_closureTrampoline) + ..keepIsolateAlive = false) + .nativeFunction + .cast(), + _ObjCBlock_ffiVoid_NSURL_bool_NSError_registerClosure( + (ffi.Pointer arg0, bool arg1, ffi.Pointer arg2) => fn( + arg0.address == 0 + ? null + : NSURL._(arg0, lib, retain: true, release: true), + arg1, + arg2.address == 0 + ? null + : NSError._(arg2, lib, retain: true, release: true)))), + lib); + static ffi.NativeCallable< + ffi.Void Function(ffi.Pointer<_ObjCBlock>, ffi.Pointer, + ffi.Bool, ffi.Pointer)>? _dartFuncListenerTrampoline; + + void call(NSURL? arg0, bool arg1, NSError? arg2) => _id.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer<_ObjCBlock> block, + ffi.Pointer arg0, + ffi.Bool arg1, + ffi.Pointer arg2)>>() + .asFunction< + void Function(ffi.Pointer<_ObjCBlock>, ffi.Pointer, + bool, ffi.Pointer)>()( + _id, arg0?._id ?? ffi.nullptr, arg1, arg2?._id ?? ffi.nullptr); +} + +void _ObjCBlock_ffiVoid_NSURL_NSError_fnPtrTrampoline( + ffi.Pointer<_ObjCBlock> block, + ffi.Pointer arg0, + ffi.Pointer arg1) => + block.ref.target + .cast< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer arg0, + ffi.Pointer arg1)>>() + .asFunction< + void Function(ffi.Pointer, + ffi.Pointer)>()(arg0, arg1); +final _ObjCBlock_ffiVoid_NSURL_NSError_closureRegistry = + , ffi.Pointer)>{}; +int _ObjCBlock_ffiVoid_NSURL_NSError_closureRegistryIndex = 0; +ffi.Pointer _ObjCBlock_ffiVoid_NSURL_NSError_registerClosure( + void Function(ffi.Pointer, ffi.Pointer) fn) { + final id = ++_ObjCBlock_ffiVoid_NSURL_NSError_closureRegistryIndex; + _ObjCBlock_ffiVoid_NSURL_NSError_closureRegistry[id] = fn; + return ffi.Pointer.fromAddress(id); +} + +void _ObjCBlock_ffiVoid_NSURL_NSError_closureTrampoline( + ffi.Pointer<_ObjCBlock> block, + ffi.Pointer arg0, + ffi.Pointer arg1) => + _ObjCBlock_ffiVoid_NSURL_NSError_closureRegistry[block.ref.target.address]!( + arg0, arg1); + +class ObjCBlock_ffiVoid_NSURL_NSError extends _ObjCBlockBase { + ObjCBlock_ffiVoid_NSURL_NSError._( + ffi.Pointer<_ObjCBlock> id, NativeMacOsFramework lib, + {bool retain = false, bool release = true}) + : super._(id, lib, retain: retain, release: release); + + /// Creates a block from a C function pointer. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + ObjCBlock_ffiVoid_NSURL_NSError.fromFunctionPointer( + NativeMacOsFramework lib, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer arg0, + ffi.Pointer arg1)>> + ptr) + : this._( + lib._newBlock1( + _cFuncTrampoline ??= ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer<_ObjCBlock>, + ffi.Pointer, + ffi.Pointer)>( + _ObjCBlock_ffiVoid_NSURL_NSError_fnPtrTrampoline) + .cast(), + ptr.cast()), + lib); + static ffi.Pointer? _cFuncTrampoline; + + /// Creates a block from a Dart function. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + ObjCBlock_ffiVoid_NSURL_NSError.fromFunction( + NativeMacOsFramework lib, void Function(NSURL?, NSError?) fn) + : this._( + lib._newBlock1( + _dartFuncTrampoline ??= + ffi.Pointer.fromFunction, ffi.Pointer, ffi.Pointer)>( + _ObjCBlock_ffiVoid_NSURL_NSError_closureTrampoline) + .cast(), + _ObjCBlock_ffiVoid_NSURL_NSError_registerClosure( + (ffi.Pointer arg0, ffi.Pointer arg1) => fn( + arg0.address == 0 + ? null + : NSURL._(arg0, lib, retain: true, release: true), + arg1.address == 0 + ? null + : NSError._(arg1, lib, retain: true, release: true)))), + lib); + static ffi.Pointer? _dartFuncTrampoline; + + /// Creates a listener block from a Dart function. + /// + /// This is based on FFI's NativeCallable.listener, and has the same + /// capabilities and limitations. This block can be invoked from any thread, + /// but only supports void functions, and is not run synchronously. See + /// NativeCallable.listener for more details. + /// + /// Note that unlike the default behavior of NativeCallable.listener, listener + /// blocks do not keep the isolate alive. + ObjCBlock_ffiVoid_NSURL_NSError.listener( + NativeMacOsFramework lib, void Function(NSURL?, NSError?) fn) + : this._( + lib._newBlock1( + (_dartFuncListenerTrampoline ??= + ffi.NativeCallable, ffi.Pointer, ffi.Pointer)>.listener( + _ObjCBlock_ffiVoid_NSURL_NSError_closureTrampoline) + ..keepIsolateAlive = false) + .nativeFunction + .cast(), + _ObjCBlock_ffiVoid_NSURL_NSError_registerClosure( + (ffi.Pointer arg0, ffi.Pointer arg1) => fn( + arg0.address == 0 + ? null + : NSURL._(arg0, lib, retain: true, release: true), + arg1.address == 0 + ? null + : NSError._(arg1, lib, retain: true, release: true)))), + lib); + static ffi.NativeCallable< + ffi.Void Function(ffi.Pointer<_ObjCBlock>, ffi.Pointer, + ffi.Pointer)>? _dartFuncListenerTrampoline; + + void call(NSURL? arg0, NSError? arg1) => _id.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer<_ObjCBlock> block, + ffi.Pointer arg0, + ffi.Pointer arg1)>>() + .asFunction< + void Function(ffi.Pointer<_ObjCBlock>, ffi.Pointer, + ffi.Pointer)>()( + _id, arg0?._id ?? ffi.nullptr, arg1?._id ?? ffi.nullptr); +} + +ffi.Pointer + _ObjCBlock_NSProgress_ffiVoidObjCObjectNSError_fnPtrTrampoline( + ffi.Pointer<_ObjCBlock> block, ffi.Pointer<_ObjCBlock> arg0) => + block.ref.target + .cast< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer<_ObjCBlock> arg0)>>() + .asFunction< + ffi.Pointer Function( + ffi.Pointer<_ObjCBlock>)>()(arg0); +final _ObjCBlock_NSProgress_ffiVoidObjCObjectNSError_closureRegistry = + Function(ffi.Pointer<_ObjCBlock>)>{}; +int _ObjCBlock_NSProgress_ffiVoidObjCObjectNSError_closureRegistryIndex = 0; +ffi.Pointer + _ObjCBlock_NSProgress_ffiVoidObjCObjectNSError_registerClosure( + ffi.Pointer Function(ffi.Pointer<_ObjCBlock>) fn) { + final id = + ++_ObjCBlock_NSProgress_ffiVoidObjCObjectNSError_closureRegistryIndex; + _ObjCBlock_NSProgress_ffiVoidObjCObjectNSError_closureRegistry[id] = fn; + return ffi.Pointer.fromAddress(id); +} + +ffi.Pointer + _ObjCBlock_NSProgress_ffiVoidObjCObjectNSError_closureTrampoline( + ffi.Pointer<_ObjCBlock> block, ffi.Pointer<_ObjCBlock> arg0) => + _ObjCBlock_NSProgress_ffiVoidObjCObjectNSError_closureRegistry[ + block.ref.target.address]!(arg0); + +class ObjCBlock_NSProgress_ffiVoidObjCObjectNSError extends _ObjCBlockBase { + ObjCBlock_NSProgress_ffiVoidObjCObjectNSError._( + ffi.Pointer<_ObjCBlock> id, NativeMacOsFramework lib, + {bool retain = false, bool release = true}) + : super._(id, lib, retain: retain, release: release); + + /// Creates a block from a C function pointer. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + ObjCBlock_NSProgress_ffiVoidObjCObjectNSError.fromFunctionPointer( + NativeMacOsFramework lib, + ffi.Pointer< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer<_ObjCBlock> arg0)>> + ptr) + : this._( + lib._newBlock1( + _cFuncTrampoline ??= ffi.Pointer.fromFunction< + ffi.Pointer Function( + ffi.Pointer<_ObjCBlock>, + ffi.Pointer<_ObjCBlock>)>( + _ObjCBlock_NSProgress_ffiVoidObjCObjectNSError_fnPtrTrampoline) + .cast(), + ptr.cast()), + lib); + static ffi.Pointer? _cFuncTrampoline; + + /// Creates a block from a Dart function. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + ObjCBlock_NSProgress_ffiVoidObjCObjectNSError.fromFunction( + NativeMacOsFramework lib, + NSProgress? Function(ObjCBlock_ffiVoid_ObjCObject_NSError) fn) + : this._( + lib._newBlock1( + _dartFuncTrampoline ??= ffi.Pointer.fromFunction< + ffi.Pointer Function( + ffi.Pointer<_ObjCBlock>, + ffi.Pointer<_ObjCBlock>)>( + _ObjCBlock_NSProgress_ffiVoidObjCObjectNSError_closureTrampoline) + .cast(), + _ObjCBlock_NSProgress_ffiVoidObjCObjectNSError_registerClosure( + (ffi.Pointer<_ObjCBlock> arg0) => + fn(ObjCBlock_ffiVoid_ObjCObject_NSError._(arg0, lib, retain: true, release: true)) + ?._retainAndReturnId() ?? + ffi.nullptr)), + lib); + static ffi.Pointer? _dartFuncTrampoline; + + NSProgress? call(ObjCBlock_ffiVoid_ObjCObject_NSError arg0) => _id.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer<_ObjCBlock> block, + ffi.Pointer<_ObjCBlock> arg0)>>() + .asFunction Function(ffi.Pointer<_ObjCBlock>, ffi.Pointer<_ObjCBlock>)>() + (_id, arg0._id) + .address == + 0 + ? null + : NSProgress._( + _id.ref.invoke + .cast Function(ffi.Pointer<_ObjCBlock> block, ffi.Pointer<_ObjCBlock> arg0)>>() + .asFunction Function(ffi.Pointer<_ObjCBlock>, ffi.Pointer<_ObjCBlock>)>()(_id, arg0._id), + _lib, + retain: false, + release: true); +} + +void _ObjCBlock_ffiVoid_ObjCObject_NSError_fnPtrTrampoline( + ffi.Pointer<_ObjCBlock> block, + ffi.Pointer arg0, + ffi.Pointer arg1) => + block.ref.target + .cast< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer arg0, + ffi.Pointer arg1)>>() + .asFunction< + void Function(ffi.Pointer, + ffi.Pointer)>()(arg0, arg1); +final _ObjCBlock_ffiVoid_ObjCObject_NSError_closureRegistry = + , ffi.Pointer)>{}; +int _ObjCBlock_ffiVoid_ObjCObject_NSError_closureRegistryIndex = 0; +ffi.Pointer _ObjCBlock_ffiVoid_ObjCObject_NSError_registerClosure( + void Function(ffi.Pointer, ffi.Pointer) fn) { + final id = ++_ObjCBlock_ffiVoid_ObjCObject_NSError_closureRegistryIndex; + _ObjCBlock_ffiVoid_ObjCObject_NSError_closureRegistry[id] = fn; + return ffi.Pointer.fromAddress(id); +} + +void _ObjCBlock_ffiVoid_ObjCObject_NSError_closureTrampoline( + ffi.Pointer<_ObjCBlock> block, + ffi.Pointer arg0, + ffi.Pointer arg1) => + _ObjCBlock_ffiVoid_ObjCObject_NSError_closureRegistry[ + block.ref.target.address]!(arg0, arg1); + +class ObjCBlock_ffiVoid_ObjCObject_NSError extends _ObjCBlockBase { + ObjCBlock_ffiVoid_ObjCObject_NSError._( + ffi.Pointer<_ObjCBlock> id, NativeMacOsFramework lib, + {bool retain = false, bool release = true}) + : super._(id, lib, retain: retain, release: release); + + /// Creates a block from a C function pointer. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + ObjCBlock_ffiVoid_ObjCObject_NSError.fromFunctionPointer( + NativeMacOsFramework lib, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer arg0, + ffi.Pointer arg1)>> + ptr) + : this._( + lib._newBlock1( + _cFuncTrampoline ??= ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer<_ObjCBlock>, + ffi.Pointer, + ffi.Pointer)>( + _ObjCBlock_ffiVoid_ObjCObject_NSError_fnPtrTrampoline) + .cast(), + ptr.cast()), + lib); + static ffi.Pointer? _cFuncTrampoline; + + /// Creates a block from a Dart function. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + ObjCBlock_ffiVoid_ObjCObject_NSError.fromFunction( + NativeMacOsFramework lib, void Function(NSObject?, NSError?) fn) + : this._( + lib._newBlock1( + _dartFuncTrampoline ??= ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer<_ObjCBlock>, + ffi.Pointer, + ffi.Pointer)>( + _ObjCBlock_ffiVoid_ObjCObject_NSError_closureTrampoline) + .cast(), + _ObjCBlock_ffiVoid_ObjCObject_NSError_registerClosure( + (ffi.Pointer arg0, ffi.Pointer arg1) => fn( + arg0.address == 0 ? null : NSObject._(arg0, lib, retain: true, release: true), + arg1.address == 0 ? null : NSError._(arg1, lib, retain: true, release: true)))), + lib); + static ffi.Pointer? _dartFuncTrampoline; + + /// Creates a listener block from a Dart function. + /// + /// This is based on FFI's NativeCallable.listener, and has the same + /// capabilities and limitations. This block can be invoked from any thread, + /// but only supports void functions, and is not run synchronously. See + /// NativeCallable.listener for more details. + /// + /// Note that unlike the default behavior of NativeCallable.listener, listener + /// blocks do not keep the isolate alive. + ObjCBlock_ffiVoid_ObjCObject_NSError.listener( + NativeMacOsFramework lib, void Function(NSObject?, NSError?) fn) + : this._( + lib._newBlock1( + (_dartFuncListenerTrampoline ??= ffi + .NativeCallable, ffi.Pointer, ffi.Pointer)>.listener( + _ObjCBlock_ffiVoid_ObjCObject_NSError_closureTrampoline) + ..keepIsolateAlive = false) + .nativeFunction + .cast(), + _ObjCBlock_ffiVoid_ObjCObject_NSError_registerClosure( + (ffi.Pointer arg0, ffi.Pointer arg1) => fn( + arg0.address == 0 + ? null + : NSObject._(arg0, lib, retain: true, release: true), + arg1.address == 0 ? null : NSError._(arg1, lib, retain: true, release: true)))), + lib); + static ffi.NativeCallable< + ffi.Void Function(ffi.Pointer<_ObjCBlock>, ffi.Pointer, + ffi.Pointer)>? _dartFuncListenerTrampoline; + + void call(NSObject? arg0, NSError? arg1) => _id.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer<_ObjCBlock> block, + ffi.Pointer arg0, + ffi.Pointer arg1)>>() + .asFunction< + void Function(ffi.Pointer<_ObjCBlock>, ffi.Pointer, + ffi.Pointer)>()( + _id, arg0?._id ?? ffi.nullptr, arg1?._id ?? ffi.nullptr); +} + +void + _ObjCBlock_ffiVoid_ffiVoidObjCObjectNSError_ObjCObject_NSDictionary_fnPtrTrampoline( + ffi.Pointer<_ObjCBlock> block, + ffi.Pointer<_ObjCBlock> arg0, + ffi.Pointer arg1, + ffi.Pointer arg2) => + block.ref.target + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer<_ObjCBlock> arg0, + ffi.Pointer arg1, + ffi.Pointer arg2)>>() + .asFunction< + void Function(ffi.Pointer<_ObjCBlock>, ffi.Pointer, + ffi.Pointer)>()(arg0, arg1, arg2); +final _ObjCBlock_ffiVoid_ffiVoidObjCObjectNSError_ObjCObject_NSDictionary_closureRegistry = + , ffi.Pointer, + ffi.Pointer)>{}; +int _ObjCBlock_ffiVoid_ffiVoidObjCObjectNSError_ObjCObject_NSDictionary_closureRegistryIndex = + 0; +ffi.Pointer + _ObjCBlock_ffiVoid_ffiVoidObjCObjectNSError_ObjCObject_NSDictionary_registerClosure( + void Function(ffi.Pointer<_ObjCBlock>, ffi.Pointer, + ffi.Pointer) + fn) { + final id = + ++_ObjCBlock_ffiVoid_ffiVoidObjCObjectNSError_ObjCObject_NSDictionary_closureRegistryIndex; + _ObjCBlock_ffiVoid_ffiVoidObjCObjectNSError_ObjCObject_NSDictionary_closureRegistry[ + id] = fn; + return ffi.Pointer.fromAddress(id); +} + +void _ObjCBlock_ffiVoid_ffiVoidObjCObjectNSError_ObjCObject_NSDictionary_closureTrampoline( + ffi.Pointer<_ObjCBlock> block, + ffi.Pointer<_ObjCBlock> arg0, + ffi.Pointer arg1, + ffi.Pointer arg2) => + _ObjCBlock_ffiVoid_ffiVoidObjCObjectNSError_ObjCObject_NSDictionary_closureRegistry[ + block.ref.target.address]!(arg0, arg1, arg2); + +class ObjCBlock_ffiVoid_ffiVoidObjCObjectNSError_ObjCObject_NSDictionary + extends _ObjCBlockBase { + ObjCBlock_ffiVoid_ffiVoidObjCObjectNSError_ObjCObject_NSDictionary._( + ffi.Pointer<_ObjCBlock> id, NativeMacOsFramework lib, + {bool retain = false, bool release = true}) + : super._(id, lib, retain: retain, release: release); + + /// Creates a block from a C function pointer. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + ObjCBlock_ffiVoid_ffiVoidObjCObjectNSError_ObjCObject_NSDictionary.fromFunctionPointer( + NativeMacOsFramework lib, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer<_ObjCBlock> arg0, + ffi.Pointer arg1, + ffi.Pointer arg2)>> + ptr) + : this._( + lib._newBlock1( + _cFuncTrampoline ??= ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer<_ObjCBlock>, + ffi.Pointer<_ObjCBlock>, + ffi.Pointer, + ffi.Pointer)>( + _ObjCBlock_ffiVoid_ffiVoidObjCObjectNSError_ObjCObject_NSDictionary_fnPtrTrampoline) + .cast(), + ptr.cast()), + lib); + static ffi.Pointer? _cFuncTrampoline; + + /// Creates a block from a Dart function. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + ObjCBlock_ffiVoid_ffiVoidObjCObjectNSError_ObjCObject_NSDictionary.fromFunction( + NativeMacOsFramework lib, + void Function(ObjCBlock_ffiVoid_ObjCObject_NSError1, NSObject, NSDictionary) + fn) + : this._( + lib._newBlock1( + _dartFuncTrampoline ??= + ffi.Pointer.fromFunction, ffi.Pointer<_ObjCBlock>, ffi.Pointer, ffi.Pointer)>( + _ObjCBlock_ffiVoid_ffiVoidObjCObjectNSError_ObjCObject_NSDictionary_closureTrampoline) + .cast(), + _ObjCBlock_ffiVoid_ffiVoidObjCObjectNSError_ObjCObject_NSDictionary_registerClosure( + (ffi.Pointer<_ObjCBlock> arg0, ffi.Pointer arg1, ffi.Pointer arg2) => fn( + ObjCBlock_ffiVoid_ObjCObject_NSError1._(arg0, lib, retain: true, release: true), + NSObject._(arg1, lib, retain: true, release: true), + NSDictionary._(arg2, lib, retain: true, release: true)))), + lib); + static ffi.Pointer? _dartFuncTrampoline; + + /// Creates a listener block from a Dart function. + /// + /// This is based on FFI's NativeCallable.listener, and has the same + /// capabilities and limitations. This block can be invoked from any thread, + /// but only supports void functions, and is not run synchronously. See + /// NativeCallable.listener for more details. + /// + /// Note that unlike the default behavior of NativeCallable.listener, listener + /// blocks do not keep the isolate alive. + ObjCBlock_ffiVoid_ffiVoidObjCObjectNSError_ObjCObject_NSDictionary.listener( + NativeMacOsFramework lib, + void Function(ObjCBlock_ffiVoid_ObjCObject_NSError1, NSObject, NSDictionary) + fn) + : this._( + lib._newBlock1( + (_dartFuncListenerTrampoline ??= ffi.NativeCallable, ffi.Pointer<_ObjCBlock>, ffi.Pointer, ffi.Pointer)>.listener( + _ObjCBlock_ffiVoid_ffiVoidObjCObjectNSError_ObjCObject_NSDictionary_closureTrampoline) + ..keepIsolateAlive = false) + .nativeFunction + .cast(), + _ObjCBlock_ffiVoid_ffiVoidObjCObjectNSError_ObjCObject_NSDictionary_registerClosure( + (ffi.Pointer<_ObjCBlock> arg0, ffi.Pointer arg1, + ffi.Pointer arg2) => + fn( + ObjCBlock_ffiVoid_ObjCObject_NSError1._(arg0, lib, retain: true, release: true), + NSObject._(arg1, lib, retain: true, release: true), + NSDictionary._(arg2, lib, retain: true, release: true)))), + lib); + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer<_ObjCBlock>, + ffi.Pointer<_ObjCBlock>, + ffi.Pointer, + ffi.Pointer)>? _dartFuncListenerTrampoline; + + void call(ObjCBlock_ffiVoid_ObjCObject_NSError1 arg0, NSObject arg1, + NSDictionary arg2) => + _id.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer<_ObjCBlock> block, + ffi.Pointer<_ObjCBlock> arg0, + ffi.Pointer arg1, + ffi.Pointer arg2)>>() + .asFunction< + void Function( + ffi.Pointer<_ObjCBlock>, + ffi.Pointer<_ObjCBlock>, + ffi.Pointer, + ffi.Pointer)>()( + _id, arg0._id, arg1._id, arg2._id); +} + +void _ObjCBlock_ffiVoid_ObjCObject_NSError1_fnPtrTrampoline( + ffi.Pointer<_ObjCBlock> block, + ffi.Pointer arg0, + ffi.Pointer arg1) => + block.ref.target + .cast< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer arg0, + ffi.Pointer arg1)>>() + .asFunction< + void Function(ffi.Pointer, + ffi.Pointer)>()(arg0, arg1); +final _ObjCBlock_ffiVoid_ObjCObject_NSError1_closureRegistry = + , ffi.Pointer)>{}; +int _ObjCBlock_ffiVoid_ObjCObject_NSError1_closureRegistryIndex = 0; +ffi.Pointer _ObjCBlock_ffiVoid_ObjCObject_NSError1_registerClosure( + void Function(ffi.Pointer, ffi.Pointer) fn) { + final id = ++_ObjCBlock_ffiVoid_ObjCObject_NSError1_closureRegistryIndex; + _ObjCBlock_ffiVoid_ObjCObject_NSError1_closureRegistry[id] = fn; + return ffi.Pointer.fromAddress(id); +} + +void _ObjCBlock_ffiVoid_ObjCObject_NSError1_closureTrampoline( + ffi.Pointer<_ObjCBlock> block, + ffi.Pointer arg0, + ffi.Pointer arg1) => + _ObjCBlock_ffiVoid_ObjCObject_NSError1_closureRegistry[ + block.ref.target.address]!(arg0, arg1); + +class ObjCBlock_ffiVoid_ObjCObject_NSError1 extends _ObjCBlockBase { + ObjCBlock_ffiVoid_ObjCObject_NSError1._( + ffi.Pointer<_ObjCBlock> id, NativeMacOsFramework lib, + {bool retain = false, bool release = true}) + : super._(id, lib, retain: retain, release: release); + + /// Creates a block from a C function pointer. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + ObjCBlock_ffiVoid_ObjCObject_NSError1.fromFunctionPointer( + NativeMacOsFramework lib, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer arg0, + ffi.Pointer arg1)>> + ptr) + : this._( + lib._newBlock1( + _cFuncTrampoline ??= ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer<_ObjCBlock>, + ffi.Pointer, + ffi.Pointer)>( + _ObjCBlock_ffiVoid_ObjCObject_NSError1_fnPtrTrampoline) + .cast(), + ptr.cast()), + lib); + static ffi.Pointer? _cFuncTrampoline; + + /// Creates a block from a Dart function. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + ObjCBlock_ffiVoid_ObjCObject_NSError1.fromFunction( + NativeMacOsFramework lib, void Function(NSObject?, NSError) fn) + : this._( + lib._newBlock1( + _dartFuncTrampoline ??= ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer<_ObjCBlock>, + ffi.Pointer, + ffi.Pointer)>( + _ObjCBlock_ffiVoid_ObjCObject_NSError1_closureTrampoline) + .cast(), + _ObjCBlock_ffiVoid_ObjCObject_NSError1_registerClosure( + (ffi.Pointer arg0, ffi.Pointer arg1) => fn( + arg0.address == 0 ? null : NSObject._(arg0, lib, retain: true, release: true), + NSError._(arg1, lib, retain: true, release: true)))), + lib); + static ffi.Pointer? _dartFuncTrampoline; + + /// Creates a listener block from a Dart function. + /// + /// This is based on FFI's NativeCallable.listener, and has the same + /// capabilities and limitations. This block can be invoked from any thread, + /// but only supports void functions, and is not run synchronously. See + /// NativeCallable.listener for more details. + /// + /// Note that unlike the default behavior of NativeCallable.listener, listener + /// blocks do not keep the isolate alive. + ObjCBlock_ffiVoid_ObjCObject_NSError1.listener( + NativeMacOsFramework lib, void Function(NSObject?, NSError) fn) + : this._( + lib._newBlock1( + (_dartFuncListenerTrampoline ??= ffi + .NativeCallable, ffi.Pointer, ffi.Pointer)>.listener( + _ObjCBlock_ffiVoid_ObjCObject_NSError1_closureTrampoline) + ..keepIsolateAlive = false) + .nativeFunction + .cast(), + _ObjCBlock_ffiVoid_ObjCObject_NSError1_registerClosure( + (ffi.Pointer arg0, ffi.Pointer arg1) => fn( + arg0.address == 0 + ? null + : NSObject._(arg0, lib, retain: true, release: true), + NSError._(arg1, lib, retain: true, release: true)))), + lib); + static ffi.NativeCallable< + ffi.Void Function(ffi.Pointer<_ObjCBlock>, ffi.Pointer, + ffi.Pointer)>? _dartFuncListenerTrampoline; + + void call(NSObject? arg0, NSError arg1) => _id.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer<_ObjCBlock> block, + ffi.Pointer arg0, + ffi.Pointer arg1)>>() + .asFunction< + void Function(ffi.Pointer<_ObjCBlock>, ffi.Pointer, + ffi.Pointer)>()( + _id, arg0?._id ?? ffi.nullptr, arg1._id); +} + +class NSMutableString extends NSString { + NSMutableString._(ffi.Pointer id, NativeMacOsFramework lib, + {bool retain = false, bool release = false}) + : super._(id, lib, retain: retain, release: release); + + /// Returns a [NSMutableString] that points to the same underlying object as [other]. + static NSMutableString castFrom(T other) { + return NSMutableString._(other._id, other._lib, + retain: true, release: true); + } + + /// Returns a [NSMutableString] that wraps the given raw object pointer. + static NSMutableString castFromPointer( + NativeMacOsFramework lib, ffi.Pointer other, + {bool retain = false, bool release = false}) { + return NSMutableString._(other, lib, retain: retain, release: release); + } + + /// Returns whether [obj] is an instance of [NSMutableString]. + static bool isInstance(_ObjCWrapper obj) { + return obj._lib._objc_msgSend_0(obj._id, obj._lib._sel_isKindOfClass_1, + obj._lib._class_NSMutableString1); + } + + void replaceCharactersInRange_withString_(_NSRange range, NSString aString) { + _lib._objc_msgSend_339(_id, _lib._sel_replaceCharactersInRange_withString_1, + range, aString._id); + } + + void insertString_atIndex_(NSString aString, int loc) { + _lib._objc_msgSend_340( + _id, _lib._sel_insertString_atIndex_1, aString._id, loc); + } + + void deleteCharactersInRange_(_NSRange range) { + _lib._objc_msgSend_293(_id, _lib._sel_deleteCharactersInRange_1, range); + } + + void appendString_(NSString aString) { + _lib._objc_msgSend_341(_id, _lib._sel_appendString_1, aString._id); + } + + void appendFormat_(NSString format) { + _lib._objc_msgSend_341(_id, _lib._sel_appendFormat_1, format._id); + } + + void setString_(NSString aString) { + _lib._objc_msgSend_341(_id, _lib._sel_setString_1, aString._id); + } + + int replaceOccurrencesOfString_withString_options_range_(NSString target, + NSString replacement, int options, _NSRange searchRange) { + return _lib._objc_msgSend_342( + _id, + _lib._sel_replaceOccurrencesOfString_withString_options_range_1, + target._id, + replacement._id, + options, + searchRange); + } + + bool applyTransform_reverse_range_updatedRange_(NSString transform, + bool reverse, _NSRange range, ffi.Pointer<_NSRange> resultingRange) { + return _lib._objc_msgSend_343( + _id, + _lib._sel_applyTransform_reverse_range_updatedRange_1, + transform._id, + reverse, + range, + resultingRange); + } + + NSMutableString initWithCapacity_(int capacity) { + final _ret = + _lib._objc_msgSend_344(_id, _lib._sel_initWithCapacity_1, capacity); + return NSMutableString._(_ret, _lib, retain: true, release: true); + } + + static NSMutableString stringWithCapacity_( + NativeMacOsFramework _lib, int capacity) { + final _ret = _lib._objc_msgSend_344( + _lib._class_NSMutableString1, _lib._sel_stringWithCapacity_1, capacity); + return NSMutableString._(_ret, _lib, retain: true, release: true); + } + + @override + NSMutableString init() { + final _ret = _lib._objc_msgSend_2(_id, _lib._sel_init1); + return NSMutableString._(_ret, _lib, retain: true, release: true); + } + + @override + NSMutableString? initWithCoder_(NSCoder coder) { + final _ret = + _lib._objc_msgSend_53(_id, _lib._sel_initWithCoder_1, coder._id); + return _ret.address == 0 + ? null + : NSMutableString._(_ret, _lib, retain: true, release: true); + } + + static ffi.Pointer getAvailableStringEncodings( + NativeMacOsFramework _lib) { + return _lib._objc_msgSend_212( + _lib._class_NSMutableString1, _lib._sel_availableStringEncodings1); + } + + static NSString localizedNameOfStringEncoding_( + NativeMacOsFramework _lib, int encoding) { + final _ret = _lib._objc_msgSend_169(_lib._class_NSMutableString1, + _lib._sel_localizedNameOfStringEncoding_1, encoding); + return NSString._(_ret, _lib, retain: true, release: true); + } + + static int getDefaultCStringEncoding(NativeMacOsFramework _lib) { + return _lib._objc_msgSend_12( + _lib._class_NSMutableString1, _lib._sel_defaultCStringEncoding1); + } + + @override + NSMutableString initWithCharactersNoCopy_length_freeWhenDone_( + ffi.Pointer characters, int length, bool freeBuffer) { + final _ret = _lib._objc_msgSend_224( + _id, + _lib._sel_initWithCharactersNoCopy_length_freeWhenDone_1, + characters, + length, + freeBuffer); + return NSMutableString._(_ret, _lib, retain: false, release: true); + } + + @override + NSMutableString initWithCharactersNoCopy_length_deallocator_( + ffi.Pointer chars, + int len, + ObjCBlock_ffiVoid_ffiUnsignedShort_ffiUnsignedLong? deallocator) { + final _ret = _lib._objc_msgSend_225( + _id, + _lib._sel_initWithCharactersNoCopy_length_deallocator_1, + chars, + len, + deallocator?._id ?? ffi.nullptr); + return NSMutableString._(_ret, _lib, retain: false, release: true); + } + + @override + NSMutableString initWithCharacters_length_( + ffi.Pointer characters, int length) { + final _ret = _lib._objc_msgSend_226( + _id, _lib._sel_initWithCharacters_length_1, characters, length); + return NSMutableString._(_ret, _lib, retain: true, release: true); + } + + @override + NSMutableString? initWithUTF8String_( + ffi.Pointer nullTerminatedCString) { + final _ret = _lib._objc_msgSend_227( + _id, _lib._sel_initWithUTF8String_1, nullTerminatedCString); + return _ret.address == 0 + ? null + : NSMutableString._(_ret, _lib, retain: true, release: true); + } + + @override + NSMutableString initWithString_(NSString aString) { + final _ret = + _lib._objc_msgSend_181(_id, _lib._sel_initWithString_1, aString._id); + return NSMutableString._(_ret, _lib, retain: true, release: true); + } + + @override + NSMutableString initWithFormat_(NSString format) { + final _ret = + _lib._objc_msgSend_181(_id, _lib._sel_initWithFormat_1, format._id); + return NSMutableString._(_ret, _lib, retain: true, release: true); + } + + @override + NSMutableString initWithFormat_arguments_( + NSString format, ffi.Pointer argList) { + final _ret = _lib._objc_msgSend_228( + _id, _lib._sel_initWithFormat_arguments_1, format._id, argList); + return NSMutableString._(_ret, _lib, retain: true, release: true); + } + + @override + NSMutableString initWithFormat_locale_(NSString format, NSObject? locale) { + final _ret = _lib._objc_msgSend_229(_id, _lib._sel_initWithFormat_locale_1, + format._id, locale?._id ?? ffi.nullptr); + return NSMutableString._(_ret, _lib, retain: true, release: true); + } + + @override + NSMutableString initWithFormat_locale_arguments_( + NSString format, NSObject? locale, ffi.Pointer argList) { + final _ret = _lib._objc_msgSend_230( + _id, + _lib._sel_initWithFormat_locale_arguments_1, + format._id, + locale?._id ?? ffi.nullptr, + argList); + return NSMutableString._(_ret, _lib, retain: true, release: true); + } + + @override + NSMutableString? initWithValidatedFormat_validFormatSpecifiers_error_( + NSString format, + NSString validFormatSpecifiers, + ffi.Pointer> error) { + final _ret = _lib._objc_msgSend_231( + _id, + _lib._sel_initWithValidatedFormat_validFormatSpecifiers_error_1, + format._id, + validFormatSpecifiers._id, + error); + return _ret.address == 0 + ? null + : NSMutableString._(_ret, _lib, retain: true, release: true); + } + + @override + NSMutableString? initWithValidatedFormat_validFormatSpecifiers_locale_error_( + NSString format, + NSString validFormatSpecifiers, + NSObject? locale, + ffi.Pointer> error) { + final _ret = _lib._objc_msgSend_232( + _id, + _lib._sel_initWithValidatedFormat_validFormatSpecifiers_locale_error_1, + format._id, + validFormatSpecifiers._id, + locale?._id ?? ffi.nullptr, + error); + return _ret.address == 0 + ? null + : NSMutableString._(_ret, _lib, retain: true, release: true); + } + + @override + NSMutableString? + initWithValidatedFormat_validFormatSpecifiers_arguments_error_( + NSString format, + NSString validFormatSpecifiers, + ffi.Pointer argList, + ffi.Pointer> error) { + final _ret = _lib._objc_msgSend_233( + _id, + _lib._sel_initWithValidatedFormat_validFormatSpecifiers_arguments_error_1, + format._id, + validFormatSpecifiers._id, + argList, + error); + return _ret.address == 0 + ? null + : NSMutableString._(_ret, _lib, retain: true, release: true); + } + + @override + NSMutableString? + initWithValidatedFormat_validFormatSpecifiers_locale_arguments_error_( + NSString format, + NSString validFormatSpecifiers, + NSObject? locale, + ffi.Pointer argList, + ffi.Pointer> error) { + final _ret = _lib._objc_msgSend_234( + _id, + _lib._sel_initWithValidatedFormat_validFormatSpecifiers_locale_arguments_error_1, + format._id, + validFormatSpecifiers._id, + locale?._id ?? ffi.nullptr, + argList, + error); + return _ret.address == 0 + ? null + : NSMutableString._(_ret, _lib, retain: true, release: true); + } + + @override + NSMutableString? initWithData_encoding_(NSData data, int encoding) { + final _ret = _lib._objc_msgSend_235( + _id, _lib._sel_initWithData_encoding_1, data._id, encoding); + return _ret.address == 0 + ? null + : NSMutableString._(_ret, _lib, retain: true, release: true); + } + + @override + NSMutableString? initWithBytes_length_encoding_( + ffi.Pointer bytes, int len, int encoding) { + final _ret = _lib._objc_msgSend_236( + _id, _lib._sel_initWithBytes_length_encoding_1, bytes, len, encoding); + return _ret.address == 0 + ? null + : NSMutableString._(_ret, _lib, retain: true, release: true); + } + + @override + NSMutableString? initWithBytesNoCopy_length_encoding_freeWhenDone_( + ffi.Pointer bytes, int len, int encoding, bool freeBuffer) { + final _ret = _lib._objc_msgSend_237( + _id, + _lib._sel_initWithBytesNoCopy_length_encoding_freeWhenDone_1, + bytes, + len, + encoding, + freeBuffer); + return _ret.address == 0 + ? null + : NSMutableString._(_ret, _lib, retain: false, release: true); + } + + @override + NSMutableString? initWithBytesNoCopy_length_encoding_deallocator_( + ffi.Pointer bytes, + int len, + int encoding, + ObjCBlock_ffiVoid_ffiVoid_ffiUnsignedLong? deallocator) { + final _ret = _lib._objc_msgSend_238( + _id, + _lib._sel_initWithBytesNoCopy_length_encoding_deallocator_1, + bytes, + len, + encoding, + deallocator?._id ?? ffi.nullptr); + return _ret.address == 0 + ? null + : NSMutableString._(_ret, _lib, retain: false, release: true); + } + + static NSMutableString string(NativeMacOsFramework _lib) { + final _ret = + _lib._objc_msgSend_2(_lib._class_NSMutableString1, _lib._sel_string1); + return NSMutableString._(_ret, _lib, retain: true, release: true); + } + + static NSMutableString stringWithString_( + NativeMacOsFramework _lib, NSString string) { + final _ret = _lib._objc_msgSend_181( + _lib._class_NSMutableString1, _lib._sel_stringWithString_1, string._id); + return NSMutableString._(_ret, _lib, retain: true, release: true); + } + + static NSMutableString stringWithCharacters_length_(NativeMacOsFramework _lib, + ffi.Pointer characters, int length) { + final _ret = _lib._objc_msgSend_226(_lib._class_NSMutableString1, + _lib._sel_stringWithCharacters_length_1, characters, length); + return NSMutableString._(_ret, _lib, retain: true, release: true); + } + + static NSMutableString? stringWithUTF8String_( + NativeMacOsFramework _lib, ffi.Pointer nullTerminatedCString) { + final _ret = _lib._objc_msgSend_227(_lib._class_NSMutableString1, + _lib._sel_stringWithUTF8String_1, nullTerminatedCString); + return _ret.address == 0 + ? null + : NSMutableString._(_ret, _lib, retain: true, release: true); + } + + static NSMutableString stringWithFormat_( + NativeMacOsFramework _lib, NSString format) { + final _ret = _lib._objc_msgSend_181( + _lib._class_NSMutableString1, _lib._sel_stringWithFormat_1, format._id); + return NSMutableString._(_ret, _lib, retain: true, release: true); + } + + static NSMutableString localizedStringWithFormat_( + NativeMacOsFramework _lib, NSString format) { + final _ret = _lib._objc_msgSend_181(_lib._class_NSMutableString1, + _lib._sel_localizedStringWithFormat_1, format._id); + return NSMutableString._(_ret, _lib, retain: true, release: true); + } + + static NSMutableString? + stringWithValidatedFormat_validFormatSpecifiers_error_( + NativeMacOsFramework _lib, + NSString format, + NSString validFormatSpecifiers, + ffi.Pointer> error) { + final _ret = _lib._objc_msgSend_231( + _lib._class_NSMutableString1, + _lib._sel_stringWithValidatedFormat_validFormatSpecifiers_error_1, + format._id, + validFormatSpecifiers._id, + error); + return _ret.address == 0 + ? null + : NSMutableString._(_ret, _lib, retain: true, release: true); + } + + static NSMutableString? + localizedStringWithValidatedFormat_validFormatSpecifiers_error_( + NativeMacOsFramework _lib, + NSString format, + NSString validFormatSpecifiers, + ffi.Pointer> error) { + final _ret = _lib._objc_msgSend_231( + _lib._class_NSMutableString1, + _lib._sel_localizedStringWithValidatedFormat_validFormatSpecifiers_error_1, + format._id, + validFormatSpecifiers._id, + error); + return _ret.address == 0 + ? null + : NSMutableString._(_ret, _lib, retain: true, release: true); + } + + @override + NSMutableString? initWithCString_encoding_( + ffi.Pointer nullTerminatedCString, int encoding) { + final _ret = _lib._objc_msgSend_239(_id, + _lib._sel_initWithCString_encoding_1, nullTerminatedCString, encoding); + return _ret.address == 0 + ? null + : NSMutableString._(_ret, _lib, retain: true, release: true); + } + + static NSMutableString? stringWithCString_encoding_( + NativeMacOsFramework _lib, ffi.Pointer cString, int enc) { + final _ret = _lib._objc_msgSend_239(_lib._class_NSMutableString1, + _lib._sel_stringWithCString_encoding_1, cString, enc); + return _ret.address == 0 + ? null + : NSMutableString._(_ret, _lib, retain: true, release: true); + } + + @override + NSMutableString? initWithContentsOfURL_encoding_error_( + NSURL url, int enc, ffi.Pointer> error) { + final _ret = _lib._objc_msgSend_240(_id, + _lib._sel_initWithContentsOfURL_encoding_error_1, url._id, enc, error); + return _ret.address == 0 + ? null + : NSMutableString._(_ret, _lib, retain: true, release: true); + } + + @override + NSMutableString? initWithContentsOfFile_encoding_error_( + NSString path, int enc, ffi.Pointer> error) { + final _ret = _lib._objc_msgSend_241( + _id, + _lib._sel_initWithContentsOfFile_encoding_error_1, + path._id, + enc, + error); + return _ret.address == 0 + ? null + : NSMutableString._(_ret, _lib, retain: true, release: true); + } + + static NSMutableString? stringWithContentsOfURL_encoding_error_( + NativeMacOsFramework _lib, + NSURL url, + int enc, + ffi.Pointer> error) { + final _ret = _lib._objc_msgSend_240( + _lib._class_NSMutableString1, + _lib._sel_stringWithContentsOfURL_encoding_error_1, + url._id, + enc, + error); + return _ret.address == 0 + ? null + : NSMutableString._(_ret, _lib, retain: true, release: true); + } + + static NSMutableString? stringWithContentsOfFile_encoding_error_( + NativeMacOsFramework _lib, + NSString path, + int enc, + ffi.Pointer> error) { + final _ret = _lib._objc_msgSend_241( + _lib._class_NSMutableString1, + _lib._sel_stringWithContentsOfFile_encoding_error_1, + path._id, + enc, + error); + return _ret.address == 0 + ? null + : NSMutableString._(_ret, _lib, retain: true, release: true); + } + + @override + NSMutableString? initWithContentsOfURL_usedEncoding_error_( + NSURL url, + ffi.Pointer enc, + ffi.Pointer> error) { + final _ret = _lib._objc_msgSend_242( + _id, + _lib._sel_initWithContentsOfURL_usedEncoding_error_1, + url._id, + enc, + error); + return _ret.address == 0 + ? null + : NSMutableString._(_ret, _lib, retain: true, release: true); + } + + @override + NSMutableString? initWithContentsOfFile_usedEncoding_error_( + NSString path, + ffi.Pointer enc, + ffi.Pointer> error) { + final _ret = _lib._objc_msgSend_243( + _id, + _lib._sel_initWithContentsOfFile_usedEncoding_error_1, + path._id, + enc, + error); + return _ret.address == 0 + ? null + : NSMutableString._(_ret, _lib, retain: true, release: true); + } + + static NSMutableString? stringWithContentsOfURL_usedEncoding_error_( + NativeMacOsFramework _lib, + NSURL url, + ffi.Pointer enc, + ffi.Pointer> error) { + final _ret = _lib._objc_msgSend_242( + _lib._class_NSMutableString1, + _lib._sel_stringWithContentsOfURL_usedEncoding_error_1, + url._id, + enc, + error); + return _ret.address == 0 + ? null + : NSMutableString._(_ret, _lib, retain: true, release: true); + } + + static NSMutableString? stringWithContentsOfFile_usedEncoding_error_( + NativeMacOsFramework _lib, + NSString path, + ffi.Pointer enc, + ffi.Pointer> error) { + final _ret = _lib._objc_msgSend_243( + _lib._class_NSMutableString1, + _lib._sel_stringWithContentsOfFile_usedEncoding_error_1, + path._id, + enc, + error); + return _ret.address == 0 + ? null + : NSMutableString._(_ret, _lib, retain: true, release: true); + } + + static int + stringEncodingForData_encodingOptions_convertedString_usedLossyConversion_( + NativeMacOsFramework _lib, + NSData data, + NSDictionary? opts, + ffi.Pointer> string, + ffi.Pointer usedLossyConversion) { + return _lib._objc_msgSend_244( + _lib._class_NSMutableString1, + _lib._sel_stringEncodingForData_encodingOptions_convertedString_usedLossyConversion_1, + data._id, + opts?._id ?? ffi.nullptr, + string, + usedLossyConversion); + } + + static NSObject? stringWithContentsOfFile_( + NativeMacOsFramework _lib, NSString path) { + final _ret = _lib._objc_msgSend_40(_lib._class_NSMutableString1, + _lib._sel_stringWithContentsOfFile_1, path._id); + return _ret.address == 0 + ? null + : NSObject._(_ret, _lib, retain: true, release: true); + } + + static NSObject? stringWithContentsOfURL_( + NativeMacOsFramework _lib, NSURL url) { + final _ret = _lib._objc_msgSend_248(_lib._class_NSMutableString1, + _lib._sel_stringWithContentsOfURL_1, url._id); + return _ret.address == 0 + ? null + : NSObject._(_ret, _lib, retain: true, release: true); + } + + static NSObject? stringWithCString_length_( + NativeMacOsFramework _lib, ffi.Pointer bytes, int length) { + final _ret = _lib._objc_msgSend_239(_lib._class_NSMutableString1, + _lib._sel_stringWithCString_length_1, bytes, length); + return _ret.address == 0 + ? null + : NSObject._(_ret, _lib, retain: true, release: true); + } + + static NSObject? stringWithCString_( + NativeMacOsFramework _lib, ffi.Pointer bytes) { + final _ret = _lib._objc_msgSend_227( + _lib._class_NSMutableString1, _lib._sel_stringWithCString_1, bytes); + return _ret.address == 0 + ? null + : NSObject._(_ret, _lib, retain: true, release: true); + } + + static NSMutableString new1(NativeMacOsFramework _lib) { + final _ret = + _lib._objc_msgSend_2(_lib._class_NSMutableString1, _lib._sel_new1); + return NSMutableString._(_ret, _lib, retain: false, release: true); + } + + static NSMutableString allocWithZone_( + NativeMacOsFramework _lib, ffi.Pointer<_NSZone> zone) { + final _ret = _lib._objc_msgSend_3( + _lib._class_NSMutableString1, _lib._sel_allocWithZone_1, zone); + return NSMutableString._(_ret, _lib, retain: false, release: true); + } + + static NSMutableString alloc(NativeMacOsFramework _lib) { + final _ret = + _lib._objc_msgSend_2(_lib._class_NSMutableString1, _lib._sel_alloc1); + return NSMutableString._(_ret, _lib, retain: false, release: true); + } +} + +class NSMutableDictionary extends NSDictionary { + NSMutableDictionary._(ffi.Pointer id, NativeMacOsFramework lib, + {bool retain = false, bool release = false}) + : super._(id, lib, retain: retain, release: release); + + /// Returns a [NSMutableDictionary] that points to the same underlying object as [other]. + static NSMutableDictionary castFrom(T other) { + return NSMutableDictionary._(other._id, other._lib, + retain: true, release: true); + } + + /// Returns a [NSMutableDictionary] that wraps the given raw object pointer. + static NSMutableDictionary castFromPointer( + NativeMacOsFramework lib, ffi.Pointer other, + {bool retain = false, bool release = false}) { + return NSMutableDictionary._(other, lib, retain: retain, release: release); + } + + /// Returns whether [obj] is an instance of [NSMutableDictionary]. + static bool isInstance(_ObjCWrapper obj) { + return obj._lib._objc_msgSend_0(obj._id, obj._lib._sel_isKindOfClass_1, + obj._lib._class_NSMutableDictionary1); + } + + void removeObjectForKey_(NSObject aKey) { + _lib._objc_msgSend_21(_id, _lib._sel_removeObjectForKey_1, aKey._id); + } + + void setObject_forKey_(NSObject anObject, NSObject aKey) { + _lib._objc_msgSend_345( + _id, _lib._sel_setObject_forKey_1, anObject._id, aKey._id); + } + + @override + NSMutableDictionary init() { + final _ret = _lib._objc_msgSend_2(_id, _lib._sel_init1); + return NSMutableDictionary._(_ret, _lib, retain: true, release: true); + } + + NSMutableDictionary initWithCapacity_(int numItems) { + final _ret = + _lib._objc_msgSend_51(_id, _lib._sel_initWithCapacity_1, numItems); + return NSMutableDictionary._(_ret, _lib, retain: true, release: true); + } + + @override + NSMutableDictionary? initWithCoder_(NSCoder coder) { + final _ret = + _lib._objc_msgSend_53(_id, _lib._sel_initWithCoder_1, coder._id); + return _ret.address == 0 + ? null + : NSMutableDictionary._(_ret, _lib, retain: true, release: true); + } + + void addEntriesFromDictionary_(NSDictionary otherDictionary) { + _lib._objc_msgSend_346( + _id, _lib._sel_addEntriesFromDictionary_1, otherDictionary._id); + } + + void removeAllObjects() { + _lib._objc_msgSend_1(_id, _lib._sel_removeAllObjects1); + } + + void removeObjectsForKeys_(NSArray keyArray) { + _lib._objc_msgSend_289(_id, _lib._sel_removeObjectsForKeys_1, keyArray._id); + } + + void setDictionary_(NSDictionary otherDictionary) { + _lib._objc_msgSend_346(_id, _lib._sel_setDictionary_1, otherDictionary._id); + } + + void setObject_forKeyedSubscript_(NSObject? obj, NSObject key) { + _lib._objc_msgSend_347(_id, _lib._sel_setObject_forKeyedSubscript_1, + obj?._id ?? ffi.nullptr, key._id); + } + + static NSMutableDictionary dictionaryWithCapacity_( + NativeMacOsFramework _lib, int numItems) { + final _ret = _lib._objc_msgSend_51(_lib._class_NSMutableDictionary1, + _lib._sel_dictionaryWithCapacity_1, numItems); + return NSMutableDictionary._(_ret, _lib, retain: true, release: true); + } + + static NSMutableDictionary? dictionaryWithContentsOfFile_( + NativeMacOsFramework _lib, NSString path) { + final _ret = _lib._objc_msgSend_348(_lib._class_NSMutableDictionary1, + _lib._sel_dictionaryWithContentsOfFile_1, path._id); + return _ret.address == 0 + ? null + : NSMutableDictionary._(_ret, _lib, retain: true, release: true); + } + + static NSMutableDictionary? dictionaryWithContentsOfURL_( + NativeMacOsFramework _lib, NSURL url) { + final _ret = _lib._objc_msgSend_349(_lib._class_NSMutableDictionary1, + _lib._sel_dictionaryWithContentsOfURL_1, url._id); + return _ret.address == 0 + ? null + : NSMutableDictionary._(_ret, _lib, retain: true, release: true); + } + + NSMutableDictionary? initWithContentsOfFile_(NSString path) { + final _ret = _lib._objc_msgSend_348( + _id, _lib._sel_initWithContentsOfFile_1, path._id); + return _ret.address == 0 + ? null + : NSMutableDictionary._(_ret, _lib, retain: true, release: true); + } + + NSMutableDictionary? initWithContentsOfURL_(NSURL url) { + final _ret = + _lib._objc_msgSend_349(_id, _lib._sel_initWithContentsOfURL_1, url._id); + return _ret.address == 0 + ? null + : NSMutableDictionary._(_ret, _lib, retain: true, release: true); + } + + static NSMutableDictionary dictionaryWithSharedKeySet_( + NativeMacOsFramework _lib, NSObject keyset) { + final _ret = _lib._objc_msgSend_350(_lib._class_NSMutableDictionary1, + _lib._sel_dictionaryWithSharedKeySet_1, keyset._id); + return NSMutableDictionary._(_ret, _lib, retain: true, release: true); + } + + @override + NSMutableDictionary initWithObjects_forKeys_count_( + ffi.Pointer> objects, + ffi.Pointer> keys, + int cnt) { + final _ret = _lib._objc_msgSend_120( + _id, _lib._sel_initWithObjects_forKeys_count_1, objects, keys, cnt); + return NSMutableDictionary._(_ret, _lib, retain: true, release: true); + } + + static NSMutableDictionary dictionary(NativeMacOsFramework _lib) { + final _ret = _lib._objc_msgSend_2( + _lib._class_NSMutableDictionary1, _lib._sel_dictionary1); + return NSMutableDictionary._(_ret, _lib, retain: true, release: true); + } + + static NSMutableDictionary dictionaryWithObject_forKey_( + NativeMacOsFramework _lib, NSObject object, NSObject key) { + final _ret = _lib._objc_msgSend_132(_lib._class_NSMutableDictionary1, + _lib._sel_dictionaryWithObject_forKey_1, object._id, key._id); + return NSMutableDictionary._(_ret, _lib, retain: true, release: true); + } + + static NSMutableDictionary dictionaryWithObjects_forKeys_count_( + NativeMacOsFramework _lib, + ffi.Pointer> objects, + ffi.Pointer> keys, + int cnt) { + final _ret = _lib._objc_msgSend_120(_lib._class_NSMutableDictionary1, + _lib._sel_dictionaryWithObjects_forKeys_count_1, objects, keys, cnt); + return NSMutableDictionary._(_ret, _lib, retain: true, release: true); + } + + static NSMutableDictionary dictionaryWithObjectsAndKeys_( + NativeMacOsFramework _lib, NSObject firstObject) { + final _ret = _lib._objc_msgSend_106(_lib._class_NSMutableDictionary1, + _lib._sel_dictionaryWithObjectsAndKeys_1, firstObject._id); + return NSMutableDictionary._(_ret, _lib, retain: true, release: true); + } + + static NSMutableDictionary dictionaryWithDictionary_( + NativeMacOsFramework _lib, NSDictionary dict) { + final _ret = _lib._objc_msgSend_133(_lib._class_NSMutableDictionary1, + _lib._sel_dictionaryWithDictionary_1, dict._id); + return NSMutableDictionary._(_ret, _lib, retain: true, release: true); + } + + static NSMutableDictionary dictionaryWithObjects_forKeys_( + NativeMacOsFramework _lib, NSArray objects, NSArray keys) { + final _ret = _lib._objc_msgSend_134(_lib._class_NSMutableDictionary1, + _lib._sel_dictionaryWithObjects_forKeys_1, objects._id, keys._id); + return NSMutableDictionary._(_ret, _lib, retain: true, release: true); + } + + @override + NSMutableDictionary initWithObjectsAndKeys_(NSObject firstObject) { + final _ret = _lib._objc_msgSend_106( + _id, _lib._sel_initWithObjectsAndKeys_1, firstObject._id); + return NSMutableDictionary._(_ret, _lib, retain: true, release: true); + } + + @override + NSMutableDictionary initWithDictionary_(NSDictionary otherDictionary) { + final _ret = _lib._objc_msgSend_133( + _id, _lib._sel_initWithDictionary_1, otherDictionary._id); + return NSMutableDictionary._(_ret, _lib, retain: true, release: true); + } + + @override + NSMutableDictionary initWithDictionary_copyItems_( + NSDictionary otherDictionary, bool flag) { + final _ret = _lib._objc_msgSend_135(_id, + _lib._sel_initWithDictionary_copyItems_1, otherDictionary._id, flag); + return NSMutableDictionary._(_ret, _lib, retain: false, release: true); + } + + @override + NSMutableDictionary initWithObjects_forKeys_(NSArray objects, NSArray keys) { + final _ret = _lib._objc_msgSend_134( + _id, _lib._sel_initWithObjects_forKeys_1, objects._id, keys._id); + return NSMutableDictionary._(_ret, _lib, retain: true, release: true); + } + + static NSDictionary? dictionaryWithContentsOfURL_error_( + NativeMacOsFramework _lib, + NSURL url, + ffi.Pointer> error) { + final _ret = _lib._objc_msgSend_136(_lib._class_NSMutableDictionary1, + _lib._sel_dictionaryWithContentsOfURL_error_1, url._id, error); + return _ret.address == 0 + ? null + : NSDictionary._(_ret, _lib, retain: true, release: true); + } + + static NSObject sharedKeySetForKeys_( + NativeMacOsFramework _lib, NSArray keys) { + final _ret = _lib._objc_msgSend_107(_lib._class_NSMutableDictionary1, + _lib._sel_sharedKeySetForKeys_1, keys._id); + return NSObject._(_ret, _lib, retain: true, release: true); + } + + static NSMutableDictionary new1(NativeMacOsFramework _lib) { + final _ret = + _lib._objc_msgSend_2(_lib._class_NSMutableDictionary1, _lib._sel_new1); + return NSMutableDictionary._(_ret, _lib, retain: false, release: true); + } + + static NSMutableDictionary allocWithZone_( + NativeMacOsFramework _lib, ffi.Pointer<_NSZone> zone) { + final _ret = _lib._objc_msgSend_3( + _lib._class_NSMutableDictionary1, _lib._sel_allocWithZone_1, zone); + return NSMutableDictionary._(_ret, _lib, retain: false, release: true); + } + + static NSMutableDictionary alloc(NativeMacOsFramework _lib) { + final _ret = _lib._objc_msgSend_2( + _lib._class_NSMutableDictionary1, _lib._sel_alloc1); + return NSMutableDictionary._(_ret, _lib, retain: false, release: true); + } +} + +class NSMutableSet extends NSSet { + NSMutableSet._(ffi.Pointer id, NativeMacOsFramework lib, + {bool retain = false, bool release = false}) + : super._(id, lib, retain: retain, release: release); + + /// Returns a [NSMutableSet] that points to the same underlying object as [other]. + static NSMutableSet castFrom(T other) { + return NSMutableSet._(other._id, other._lib, retain: true, release: true); + } + + /// Returns a [NSMutableSet] that wraps the given raw object pointer. + static NSMutableSet castFromPointer( + NativeMacOsFramework lib, ffi.Pointer other, + {bool retain = false, bool release = false}) { + return NSMutableSet._(other, lib, retain: retain, release: release); + } + + /// Returns whether [obj] is an instance of [NSMutableSet]. + static bool isInstance(_ObjCWrapper obj) { + return obj._lib._objc_msgSend_0( + obj._id, obj._lib._sel_isKindOfClass_1, obj._lib._class_NSMutableSet1); + } + + void addObject_(NSObject object) { + _lib._objc_msgSend_21(_id, _lib._sel_addObject_1, object._id); + } + + void removeObject_(NSObject object) { + _lib._objc_msgSend_21(_id, _lib._sel_removeObject_1, object._id); + } + + @override + NSMutableSet? initWithCoder_(NSCoder coder) { + final _ret = + _lib._objc_msgSend_53(_id, _lib._sel_initWithCoder_1, coder._id); + return _ret.address == 0 + ? null + : NSMutableSet._(_ret, _lib, retain: true, release: true); + } + + @override + NSMutableSet init() { + final _ret = _lib._objc_msgSend_2(_id, _lib._sel_init1); + return NSMutableSet._(_ret, _lib, retain: true, release: true); + } + + NSMutableSet initWithCapacity_(int numItems) { + final _ret = + _lib._objc_msgSend_51(_id, _lib._sel_initWithCapacity_1, numItems); + return NSMutableSet._(_ret, _lib, retain: true, release: true); + } + + void addObjectsFromArray_(NSArray array) { + _lib._objc_msgSend_289(_id, _lib._sel_addObjectsFromArray_1, array._id); + } + + void intersectSet_(NSSet otherSet) { + _lib._objc_msgSend_351(_id, _lib._sel_intersectSet_1, otherSet._id); + } + + void minusSet_(NSSet otherSet) { + _lib._objc_msgSend_351(_id, _lib._sel_minusSet_1, otherSet._id); + } + + void removeAllObjects() { + _lib._objc_msgSend_1(_id, _lib._sel_removeAllObjects1); + } + + void unionSet_(NSSet otherSet) { + _lib._objc_msgSend_351(_id, _lib._sel_unionSet_1, otherSet._id); + } + + void setSet_(NSSet otherSet) { + _lib._objc_msgSend_351(_id, _lib._sel_setSet_1, otherSet._id); + } + + static NSMutableSet setWithCapacity_( + NativeMacOsFramework _lib, int numItems) { + final _ret = _lib._objc_msgSend_51( + _lib._class_NSMutableSet1, _lib._sel_setWithCapacity_1, numItems); + return NSMutableSet._(_ret, _lib, retain: true, release: true); + } + + @override + NSMutableSet initWithObjects_count_( + ffi.Pointer> objects, int cnt) { + final _ret = _lib._objc_msgSend_52( + _id, _lib._sel_initWithObjects_count_1, objects, cnt); + return NSMutableSet._(_ret, _lib, retain: true, release: true); + } + + static NSMutableSet set1(NativeMacOsFramework _lib) { + final _ret = + _lib._objc_msgSend_2(_lib._class_NSMutableSet1, _lib._sel_set1); + return NSMutableSet._(_ret, _lib, retain: true, release: true); + } + + static NSMutableSet setWithObject_( + NativeMacOsFramework _lib, NSObject object) { + final _ret = _lib._objc_msgSend_106( + _lib._class_NSMutableSet1, _lib._sel_setWithObject_1, object._id); + return NSMutableSet._(_ret, _lib, retain: true, release: true); + } + + static NSMutableSet setWithObjects_count_(NativeMacOsFramework _lib, + ffi.Pointer> objects, int cnt) { + final _ret = _lib._objc_msgSend_52(_lib._class_NSMutableSet1, + _lib._sel_setWithObjects_count_1, objects, cnt); + return NSMutableSet._(_ret, _lib, retain: true, release: true); + } + + static NSMutableSet setWithObjects_( + NativeMacOsFramework _lib, NSObject firstObj) { + final _ret = _lib._objc_msgSend_106( + _lib._class_NSMutableSet1, _lib._sel_setWithObjects_1, firstObj._id); + return NSMutableSet._(_ret, _lib, retain: true, release: true); + } + + static NSMutableSet setWithSet_(NativeMacOsFramework _lib, NSSet set) { + final _ret = _lib._objc_msgSend_147( + _lib._class_NSMutableSet1, _lib._sel_setWithSet_1, set._id); + return NSMutableSet._(_ret, _lib, retain: true, release: true); + } + + static NSMutableSet setWithArray_(NativeMacOsFramework _lib, NSArray array) { + final _ret = _lib._objc_msgSend_107( + _lib._class_NSMutableSet1, _lib._sel_setWithArray_1, array._id); + return NSMutableSet._(_ret, _lib, retain: true, release: true); + } + + @override + NSMutableSet initWithObjects_(NSObject firstObj) { + final _ret = + _lib._objc_msgSend_106(_id, _lib._sel_initWithObjects_1, firstObj._id); + return NSMutableSet._(_ret, _lib, retain: true, release: true); + } + + @override + NSMutableSet initWithSet_(NSSet set) { + final _ret = _lib._objc_msgSend_147(_id, _lib._sel_initWithSet_1, set._id); + return NSMutableSet._(_ret, _lib, retain: true, release: true); + } + + @override + NSMutableSet initWithSet_copyItems_(NSSet set, bool flag) { + final _ret = _lib._objc_msgSend_148( + _id, _lib._sel_initWithSet_copyItems_1, set._id, flag); + return NSMutableSet._(_ret, _lib, retain: false, release: true); + } + + @override + NSMutableSet initWithArray_(NSArray array) { + final _ret = + _lib._objc_msgSend_107(_id, _lib._sel_initWithArray_1, array._id); + return NSMutableSet._(_ret, _lib, retain: true, release: true); + } + + static NSMutableSet new1(NativeMacOsFramework _lib) { + final _ret = + _lib._objc_msgSend_2(_lib._class_NSMutableSet1, _lib._sel_new1); + return NSMutableSet._(_ret, _lib, retain: false, release: true); + } + + static NSMutableSet allocWithZone_( + NativeMacOsFramework _lib, ffi.Pointer<_NSZone> zone) { + final _ret = _lib._objc_msgSend_3( + _lib._class_NSMutableSet1, _lib._sel_allocWithZone_1, zone); + return NSMutableSet._(_ret, _lib, retain: false, release: true); + } + + static NSMutableSet alloc(NativeMacOsFramework _lib) { + final _ret = + _lib._objc_msgSend_2(_lib._class_NSMutableSet1, _lib._sel_alloc1); + return NSMutableSet._(_ret, _lib, retain: false, release: true); + } +} + +class NSNotification extends NSObject { + NSNotification._(ffi.Pointer id, NativeMacOsFramework lib, + {bool retain = false, bool release = false}) + : super._(id, lib, retain: retain, release: release); + + /// Returns a [NSNotification] that points to the same underlying object as [other]. + static NSNotification castFrom(T other) { + return NSNotification._(other._id, other._lib, retain: true, release: true); + } + + /// Returns a [NSNotification] that wraps the given raw object pointer. + static NSNotification castFromPointer( + NativeMacOsFramework lib, ffi.Pointer other, + {bool retain = false, bool release = false}) { + return NSNotification._(other, lib, retain: retain, release: release); + } + + /// Returns whether [obj] is an instance of [NSNotification]. + static bool isInstance(_ObjCWrapper obj) { + return obj._lib._objc_msgSend_0(obj._id, obj._lib._sel_isKindOfClass_1, + obj._lib._class_NSNotification1); + } + + NSString get name { + final _ret = _lib._objc_msgSend_57(_id, _lib._sel_name1); + return NSString._(_ret, _lib, retain: true, release: true); + } + + NSObject? get object { + final _ret = _lib._objc_msgSend_25(_id, _lib._sel_object1); + return _ret.address == 0 + ? null + : NSObject._(_ret, _lib, retain: true, release: true); + } + + NSDictionary? get userInfo { + final _ret = _lib._objc_msgSend_245(_id, _lib._sel_userInfo1); + return _ret.address == 0 + ? null + : NSDictionary._(_ret, _lib, retain: true, release: true); + } + + NSNotification initWithName_object_userInfo_( + NSString name, NSObject? object, NSDictionary? userInfo) { + final _ret = _lib._objc_msgSend_352( + _id, + _lib._sel_initWithName_object_userInfo_1, + name._id, + object?._id ?? ffi.nullptr, + userInfo?._id ?? ffi.nullptr); + return NSNotification._(_ret, _lib, retain: true, release: true); + } + + NSNotification? initWithCoder_(NSCoder coder) { + final _ret = + _lib._objc_msgSend_53(_id, _lib._sel_initWithCoder_1, coder._id); + return _ret.address == 0 + ? null + : NSNotification._(_ret, _lib, retain: true, release: true); + } + + static NSNotification notificationWithName_object_( + NativeMacOsFramework _lib, NSString aName, NSObject? anObject) { + final _ret = _lib._objc_msgSend_229( + _lib._class_NSNotification1, + _lib._sel_notificationWithName_object_1, + aName._id, + anObject?._id ?? ffi.nullptr); + return NSNotification._(_ret, _lib, retain: true, release: true); + } + + static NSNotification notificationWithName_object_userInfo_( + NativeMacOsFramework _lib, + NSString aName, + NSObject? anObject, + NSDictionary? aUserInfo) { + final _ret = _lib._objc_msgSend_352( + _lib._class_NSNotification1, + _lib._sel_notificationWithName_object_userInfo_1, + aName._id, + anObject?._id ?? ffi.nullptr, + aUserInfo?._id ?? ffi.nullptr); + return NSNotification._(_ret, _lib, retain: true, release: true); + } + + @override + NSNotification init() { + final _ret = _lib._objc_msgSend_2(_id, _lib._sel_init1); + return NSNotification._(_ret, _lib, retain: true, release: true); + } + + static NSNotification new1(NativeMacOsFramework _lib) { + final _ret = + _lib._objc_msgSend_2(_lib._class_NSNotification1, _lib._sel_new1); + return NSNotification._(_ret, _lib, retain: false, release: true); + } + + static NSNotification allocWithZone_( + NativeMacOsFramework _lib, ffi.Pointer<_NSZone> zone) { + final _ret = _lib._objc_msgSend_3( + _lib._class_NSNotification1, _lib._sel_allocWithZone_1, zone); + return NSNotification._(_ret, _lib, retain: false, release: true); + } + + static NSNotification alloc(NativeMacOsFramework _lib) { + final _ret = + _lib._objc_msgSend_2(_lib._class_NSNotification1, _lib._sel_alloc1); + return NSNotification._(_ret, _lib, retain: false, release: true); + } +} + +/// Because NSBundle caches allocated instances, subclasses should be prepared +/// to receive an already initialized object back from [super initWithPath:] +class NSBundle extends NSObject { + NSBundle._(ffi.Pointer id, NativeMacOsFramework lib, + {bool retain = false, bool release = false}) + : super._(id, lib, retain: retain, release: release); + + /// Returns a [NSBundle] that points to the same underlying object as [other]. + static NSBundle castFrom(T other) { + return NSBundle._(other._id, other._lib, retain: true, release: true); + } + + /// Returns a [NSBundle] that wraps the given raw object pointer. + static NSBundle castFromPointer( + NativeMacOsFramework lib, ffi.Pointer other, + {bool retain = false, bool release = false}) { + return NSBundle._(other, lib, retain: retain, release: release); + } + + /// Returns whether [obj] is an instance of [NSBundle]. + static bool isInstance(_ObjCWrapper obj) { + return obj._lib._objc_msgSend_0( + obj._id, obj._lib._sel_isKindOfClass_1, obj._lib._class_NSBundle1); + } + + /// Methods for creating or retrieving bundle instances. + static NSBundle getMainBundle(NativeMacOsFramework _lib) { + final _ret = + _lib._objc_msgSend_353(_lib._class_NSBundle1, _lib._sel_mainBundle1); + return NSBundle._(_ret, _lib, retain: true, release: true); + } + + static NSBundle? bundleWithPath_(NativeMacOsFramework _lib, NSString path) { + final _ret = _lib._objc_msgSend_40( + _lib._class_NSBundle1, _lib._sel_bundleWithPath_1, path._id); + return _ret.address == 0 + ? null + : NSBundle._(_ret, _lib, retain: true, release: true); + } + + NSBundle? initWithPath_(NSString path) { + final _ret = _lib._objc_msgSend_40(_id, _lib._sel_initWithPath_1, path._id); + return _ret.address == 0 + ? null + : NSBundle._(_ret, _lib, retain: true, release: true); + } + + static NSBundle? bundleWithURL_(NativeMacOsFramework _lib, NSURL url) { + final _ret = _lib._objc_msgSend_248( + _lib._class_NSBundle1, _lib._sel_bundleWithURL_1, url._id); + return _ret.address == 0 + ? null + : NSBundle._(_ret, _lib, retain: true, release: true); + } + + NSBundle? initWithURL_(NSURL url) { + final _ret = _lib._objc_msgSend_248(_id, _lib._sel_initWithURL_1, url._id); + return _ret.address == 0 + ? null + : NSBundle._(_ret, _lib, retain: true, release: true); + } + + static NSBundle bundleForClass_(NativeMacOsFramework _lib, NSObject aClass) { + final _ret = _lib._objc_msgSend_354( + _lib._class_NSBundle1, _lib._sel_bundleForClass_1, aClass._id); + return NSBundle._(_ret, _lib, retain: true, release: true); + } + + static NSBundle? bundleWithIdentifier_( + NativeMacOsFramework _lib, NSString identifier) { + final _ret = _lib._objc_msgSend_355(_lib._class_NSBundle1, + _lib._sel_bundleWithIdentifier_1, identifier._id); + return _ret.address == 0 + ? null + : NSBundle._(_ret, _lib, retain: true, release: true); + } + + static NSArray getAllBundles(NativeMacOsFramework _lib) { + final _ret = + _lib._objc_msgSend_121(_lib._class_NSBundle1, _lib._sel_allBundles1); + return NSArray._(_ret, _lib, retain: true, release: true); + } + + static NSArray getAllFrameworks(NativeMacOsFramework _lib) { + final _ret = + _lib._objc_msgSend_121(_lib._class_NSBundle1, _lib._sel_allFrameworks1); + return NSArray._(_ret, _lib, retain: true, release: true); + } + + /// Methods for loading and unloading bundles. + bool load() { + return _lib._objc_msgSend_11(_id, _lib._sel_load1); + } + + bool get loaded { + return _lib._objc_msgSend_11(_id, _lib._sel_isLoaded1); + } + + bool unload() { + return _lib._objc_msgSend_11(_id, _lib._sel_unload1); + } + + bool preflightAndReturnError_(ffi.Pointer> error) { + return _lib._objc_msgSend_356( + _id, _lib._sel_preflightAndReturnError_1, error); + } + + bool loadAndReturnError_(ffi.Pointer> error) { + return _lib._objc_msgSend_356(_id, _lib._sel_loadAndReturnError_1, error); + } + + /// Methods for locating various components of a bundle. + NSURL get bundleURL { + final _ret = _lib._objc_msgSend_357(_id, _lib._sel_bundleURL1); + return NSURL._(_ret, _lib, retain: true, release: true); + } + + NSURL? get resourceURL { + final _ret = _lib._objc_msgSend_320(_id, _lib._sel_resourceURL1); + return _ret.address == 0 + ? null + : NSURL._(_ret, _lib, retain: true, release: true); + } + + NSURL? get executableURL { + final _ret = _lib._objc_msgSend_320(_id, _lib._sel_executableURL1); + return _ret.address == 0 + ? null + : NSURL._(_ret, _lib, retain: true, release: true); + } + + NSURL? URLForAuxiliaryExecutable_(NSString executableName) { + final _ret = _lib._objc_msgSend_358( + _id, _lib._sel_URLForAuxiliaryExecutable_1, executableName._id); + return _ret.address == 0 + ? null + : NSURL._(_ret, _lib, retain: true, release: true); + } + + NSURL? get privateFrameworksURL { + final _ret = _lib._objc_msgSend_320(_id, _lib._sel_privateFrameworksURL1); + return _ret.address == 0 + ? null + : NSURL._(_ret, _lib, retain: true, release: true); + } + + NSURL? get sharedFrameworksURL { + final _ret = _lib._objc_msgSend_320(_id, _lib._sel_sharedFrameworksURL1); + return _ret.address == 0 + ? null + : NSURL._(_ret, _lib, retain: true, release: true); + } + + NSURL? get sharedSupportURL { + final _ret = _lib._objc_msgSend_320(_id, _lib._sel_sharedSupportURL1); + return _ret.address == 0 + ? null + : NSURL._(_ret, _lib, retain: true, release: true); + } + + NSURL? get builtInPlugInsURL { + final _ret = _lib._objc_msgSend_320(_id, _lib._sel_builtInPlugInsURL1); + return _ret.address == 0 + ? null + : NSURL._(_ret, _lib, retain: true, release: true); + } + + NSURL? get appStoreReceiptURL { + final _ret = _lib._objc_msgSend_320(_id, _lib._sel_appStoreReceiptURL1); + return _ret.address == 0 + ? null + : NSURL._(_ret, _lib, retain: true, release: true); + } + + NSString get bundlePath { + final _ret = _lib._objc_msgSend_57(_id, _lib._sel_bundlePath1); + return NSString._(_ret, _lib, retain: true, release: true); + } + + NSString? get resourcePath { + final _ret = _lib._objc_msgSend_183(_id, _lib._sel_resourcePath1); + return _ret.address == 0 + ? null + : NSString._(_ret, _lib, retain: true, release: true); + } + + NSString? get executablePath { + final _ret = _lib._objc_msgSend_183(_id, _lib._sel_executablePath1); + return _ret.address == 0 + ? null + : NSString._(_ret, _lib, retain: true, release: true); + } + + NSString? pathForAuxiliaryExecutable_(NSString executableName) { + final _ret = _lib._objc_msgSend_182( + _id, _lib._sel_pathForAuxiliaryExecutable_1, executableName._id); + return _ret.address == 0 + ? null + : NSString._(_ret, _lib, retain: true, release: true); + } + + NSString? get privateFrameworksPath { + final _ret = _lib._objc_msgSend_183(_id, _lib._sel_privateFrameworksPath1); + return _ret.address == 0 + ? null + : NSString._(_ret, _lib, retain: true, release: true); + } + + NSString? get sharedFrameworksPath { + final _ret = _lib._objc_msgSend_183(_id, _lib._sel_sharedFrameworksPath1); + return _ret.address == 0 + ? null + : NSString._(_ret, _lib, retain: true, release: true); + } + + NSString? get sharedSupportPath { + final _ret = _lib._objc_msgSend_183(_id, _lib._sel_sharedSupportPath1); + return _ret.address == 0 + ? null + : NSString._(_ret, _lib, retain: true, release: true); + } + + NSString? get builtInPlugInsPath { + final _ret = _lib._objc_msgSend_183(_id, _lib._sel_builtInPlugInsPath1); + return _ret.address == 0 + ? null + : NSString._(_ret, _lib, retain: true, release: true); + } + + /// Methods for locating bundle resources. Instance methods locate resources in the bundle indicated by the receiver; class methods take an argument pointing to a bundle on disk. In the class methods, bundleURL is a URL pointing to the location of a bundle on disk, and may not be nil; bundlePath is the path equivalent of bundleURL, an absolute path pointing to the location of a bundle on disk. By contrast, subpath is a relative path to a subdirectory inside the relevant global or localized resource directory, and should be nil if the resource file in question is not in a subdirectory. Where appropriate, localizationName is the name of a .lproj directory in the bundle, minus the .lproj extension; passing nil for localizationName retrieves only global resources, whereas using a method without this argument retrieves both global and localized resources (using the standard localization search algorithm). + static NSURL? URLForResource_withExtension_subdirectory_inBundleWithURL_( + NativeMacOsFramework _lib, + NSString? name, + NSString? ext, + NSString? subpath, + NSURL bundleURL) { + final _ret = _lib._objc_msgSend_359( + _lib._class_NSBundle1, + _lib._sel_URLForResource_withExtension_subdirectory_inBundleWithURL_1, + name?._id ?? ffi.nullptr, + ext?._id ?? ffi.nullptr, + subpath?._id ?? ffi.nullptr, + bundleURL._id); + return _ret.address == 0 + ? null + : NSURL._(_ret, _lib, retain: true, release: true); + } + + static NSArray? URLsForResourcesWithExtension_subdirectory_inBundleWithURL_( + NativeMacOsFramework _lib, + NSString? ext, + NSString? subpath, + NSURL bundleURL) { + final _ret = _lib._objc_msgSend_360( + _lib._class_NSBundle1, + _lib._sel_URLsForResourcesWithExtension_subdirectory_inBundleWithURL_1, + ext?._id ?? ffi.nullptr, + subpath?._id ?? ffi.nullptr, + bundleURL._id); + return _ret.address == 0 + ? null + : NSArray._(_ret, _lib, retain: true, release: true); + } + + NSURL? URLForResource_withExtension_(NSString? name, NSString? ext) { + final _ret = _lib._objc_msgSend_361( + _id, + _lib._sel_URLForResource_withExtension_1, + name?._id ?? ffi.nullptr, + ext?._id ?? ffi.nullptr); + return _ret.address == 0 + ? null + : NSURL._(_ret, _lib, retain: true, release: true); + } + + NSURL? URLForResource_withExtension_subdirectory_( + NSString? name, NSString? ext, NSString? subpath) { + final _ret = _lib._objc_msgSend_362( + _id, + _lib._sel_URLForResource_withExtension_subdirectory_1, + name?._id ?? ffi.nullptr, + ext?._id ?? ffi.nullptr, + subpath?._id ?? ffi.nullptr); + return _ret.address == 0 + ? null + : NSURL._(_ret, _lib, retain: true, release: true); + } + + NSURL? URLForResource_withExtension_subdirectory_localization_(NSString? name, + NSString? ext, NSString? subpath, NSString? localizationName) { + final _ret = _lib._objc_msgSend_363( + _id, + _lib._sel_URLForResource_withExtension_subdirectory_localization_1, + name?._id ?? ffi.nullptr, + ext?._id ?? ffi.nullptr, + subpath?._id ?? ffi.nullptr, + localizationName?._id ?? ffi.nullptr); + return _ret.address == 0 + ? null + : NSURL._(_ret, _lib, retain: true, release: true); + } + + NSArray? URLsForResourcesWithExtension_subdirectory_( + NSString? ext, NSString? subpath) { + final _ret = _lib._objc_msgSend_364( + _id, + _lib._sel_URLsForResourcesWithExtension_subdirectory_1, + ext?._id ?? ffi.nullptr, + subpath?._id ?? ffi.nullptr); + return _ret.address == 0 + ? null + : NSArray._(_ret, _lib, retain: true, release: true); + } + + NSArray? URLsForResourcesWithExtension_subdirectory_localization_( + NSString? ext, NSString? subpath, NSString? localizationName) { + final _ret = _lib._objc_msgSend_365( + _id, + _lib._sel_URLsForResourcesWithExtension_subdirectory_localization_1, + ext?._id ?? ffi.nullptr, + subpath?._id ?? ffi.nullptr, + localizationName?._id ?? ffi.nullptr); + return _ret.address == 0 + ? null + : NSArray._(_ret, _lib, retain: true, release: true); + } + + static NSString? pathForResource_ofType_inDirectory_( + NativeMacOsFramework _lib, + NSString? name, + NSString? ext, + NSString bundlePath) { + final _ret = _lib._objc_msgSend_366( + _lib._class_NSBundle1, + _lib._sel_pathForResource_ofType_inDirectory_1, + name?._id ?? ffi.nullptr, + ext?._id ?? ffi.nullptr, + bundlePath._id); + return _ret.address == 0 + ? null + : NSString._(_ret, _lib, retain: true, release: true); + } + + static NSArray pathsForResourcesOfType_inDirectory_( + NativeMacOsFramework _lib, NSString? ext, NSString bundlePath) { + final _ret = _lib._objc_msgSend_367( + _lib._class_NSBundle1, + _lib._sel_pathsForResourcesOfType_inDirectory_1, + ext?._id ?? ffi.nullptr, + bundlePath._id); + return NSArray._(_ret, _lib, retain: true, release: true); + } + + NSString? pathForResource_ofType_(NSString? name, NSString? ext) { + final _ret = _lib._objc_msgSend_368(_id, _lib._sel_pathForResource_ofType_1, + name?._id ?? ffi.nullptr, ext?._id ?? ffi.nullptr); + return _ret.address == 0 + ? null + : NSString._(_ret, _lib, retain: true, release: true); + } + + NSString? pathForResource_ofType_inDirectory_forLocalization_(NSString? name, + NSString? ext, NSString? subpath, NSString? localizationName) { + final _ret = _lib._objc_msgSend_369( + _id, + _lib._sel_pathForResource_ofType_inDirectory_forLocalization_1, + name?._id ?? ffi.nullptr, + ext?._id ?? ffi.nullptr, + subpath?._id ?? ffi.nullptr, + localizationName?._id ?? ffi.nullptr); + return _ret.address == 0 + ? null + : NSString._(_ret, _lib, retain: true, release: true); + } + + NSArray pathsForResourcesOfType_inDirectory_forLocalization_( + NSString? ext, NSString? subpath, NSString? localizationName) { + final _ret = _lib._objc_msgSend_370( + _id, + _lib._sel_pathsForResourcesOfType_inDirectory_forLocalization_1, + ext?._id ?? ffi.nullptr, + subpath?._id ?? ffi.nullptr, + localizationName?._id ?? ffi.nullptr); + return NSArray._(_ret, _lib, retain: true, release: true); + } + + /// Methods for retrieving localized strings. + NSString localizedStringForKey_value_table_( + NSString key, NSString? value, NSString? tableName) { + final _ret = _lib._objc_msgSend_371( + _id, + _lib._sel_localizedStringForKey_value_table_1, + key._id, + value?._id ?? ffi.nullptr, + tableName?._id ?? ffi.nullptr); + return NSString._(_ret, _lib, retain: true, release: true); + } + + NSAttributedString localizedAttributedStringForKey_value_table_( + NSString key, NSString? value, NSString? tableName) { + final _ret = _lib._objc_msgSend_372( + _id, + _lib._sel_localizedAttributedStringForKey_value_table_1, + key._id, + value?._id ?? ffi.nullptr, + tableName?._id ?? ffi.nullptr); + return NSAttributedString._(_ret, _lib, retain: true, release: true); + } + + /// Methods for obtaining various information about a bundle. + NSString? get bundleIdentifier { + final _ret = _lib._objc_msgSend_183(_id, _lib._sel_bundleIdentifier1); + return _ret.address == 0 + ? null + : NSString._(_ret, _lib, retain: true, release: true); + } + + NSDictionary? get infoDictionary { + final _ret = _lib._objc_msgSend_245(_id, _lib._sel_infoDictionary1); + return _ret.address == 0 + ? null + : NSDictionary._(_ret, _lib, retain: true, release: true); + } + + NSDictionary? get localizedInfoDictionary { + final _ret = + _lib._objc_msgSend_245(_id, _lib._sel_localizedInfoDictionary1); + return _ret.address == 0 + ? null + : NSDictionary._(_ret, _lib, retain: true, release: true); + } + + NSObject? objectForInfoDictionaryKey_(NSString key) { + final _ret = _lib._objc_msgSend_40( + _id, _lib._sel_objectForInfoDictionaryKey_1, key._id); + return _ret.address == 0 + ? null + : NSObject._(_ret, _lib, retain: true, release: true); + } + + NSObject? classNamed_(NSString className) { + final _ret = + _lib._objc_msgSend_40(_id, _lib._sel_classNamed_1, className._id); + return _ret.address == 0 + ? null + : NSObject._(_ret, _lib, retain: true, release: true); + } + + NSObject? get principalClass { + final _ret = _lib._objc_msgSend_25(_id, _lib._sel_principalClass1); + return _ret.address == 0 + ? null + : NSObject._(_ret, _lib, retain: true, release: true); + } + + /// a subset of this bundle's localizations, re-ordered into the preferred order for this process's current execution environment; the main bundle's preferred localizations indicate the language (of text) the user is most likely seeing in the UI + NSArray get preferredLocalizations { + final _ret = _lib._objc_msgSend_121(_id, _lib._sel_preferredLocalizations1); + return NSArray._(_ret, _lib, retain: true, release: true); + } + + /// list of language names this bundle appears to be localized to + NSArray get localizations { + final _ret = _lib._objc_msgSend_121(_id, _lib._sel_localizations1); + return NSArray._(_ret, _lib, retain: true, release: true); + } + + NSString? get developmentLocalization { + final _ret = + _lib._objc_msgSend_183(_id, _lib._sel_developmentLocalization1); + return _ret.address == 0 + ? null + : NSString._(_ret, _lib, retain: true, release: true); + } + + static NSArray preferredLocalizationsFromArray_( + NativeMacOsFramework _lib, NSArray localizationsArray) { + final _ret = _lib._objc_msgSend_55(_lib._class_NSBundle1, + _lib._sel_preferredLocalizationsFromArray_1, localizationsArray._id); + return NSArray._(_ret, _lib, retain: true, release: true); + } + + static NSArray preferredLocalizationsFromArray_forPreferences_( + NativeMacOsFramework _lib, + NSArray localizationsArray, + NSArray? preferencesArray) { + final _ret = _lib._objc_msgSend_373( + _lib._class_NSBundle1, + _lib._sel_preferredLocalizationsFromArray_forPreferences_1, + localizationsArray._id, + preferencesArray?._id ?? ffi.nullptr); + return NSArray._(_ret, _lib, retain: true, release: true); + } + + NSArray? get executableArchitectures { + final _ret = + _lib._objc_msgSend_374(_id, _lib._sel_executableArchitectures1); + return _ret.address == 0 + ? null + : NSArray._(_ret, _lib, retain: true, release: true); + } + + /// Set a preservation priority for tags that are included in this bundle for the On Demand Resources system. Preservation priorities may be between 0.0 and 1.0, with higher values being the last choice for purging by the system. The exact meaning of this value is up to your application as it only has meaning within the set of tags your application uses. + /// + /// The default value is 0.0. + /// + /// This method will throw an exception if the receiver bundle has no on demand resource tag information. + void setPreservationPriority_forTags_(double priority, NSSet tags) { + _lib._objc_msgSend_375( + _id, _lib._sel_setPreservationPriority_forTags_1, priority, tags._id); + } + + double preservationPriorityForTag_(NSString tag) { + return _lib._objc_msgSend_46( + _id, _lib._sel_preservationPriorityForTag_1, tag._id); + } + + @override + NSBundle init() { + final _ret = _lib._objc_msgSend_2(_id, _lib._sel_init1); + return NSBundle._(_ret, _lib, retain: true, release: true); + } + + static NSBundle new1(NativeMacOsFramework _lib) { + final _ret = _lib._objc_msgSend_2(_lib._class_NSBundle1, _lib._sel_new1); + return NSBundle._(_ret, _lib, retain: false, release: true); + } + + static NSBundle allocWithZone_( + NativeMacOsFramework _lib, ffi.Pointer<_NSZone> zone) { + final _ret = _lib._objc_msgSend_3( + _lib._class_NSBundle1, _lib._sel_allocWithZone_1, zone); + return NSBundle._(_ret, _lib, retain: false, release: true); + } + + static NSBundle alloc(NativeMacOsFramework _lib) { + final _ret = _lib._objc_msgSend_2(_lib._class_NSBundle1, _lib._sel_alloc1); + return NSBundle._(_ret, _lib, retain: false, release: true); + } +} + +class NSAttributedString extends _ObjCWrapper { + NSAttributedString._(ffi.Pointer id, NativeMacOsFramework lib, + {bool retain = false, bool release = false}) + : super._(id, lib, retain: retain, release: release); + + /// Returns a [NSAttributedString] that points to the same underlying object as [other]. + static NSAttributedString castFrom(T other) { + return NSAttributedString._(other._id, other._lib, + retain: true, release: true); + } + + /// Returns a [NSAttributedString] that wraps the given raw object pointer. + static NSAttributedString castFromPointer( + NativeMacOsFramework lib, ffi.Pointer other, + {bool retain = false, bool release = false}) { + return NSAttributedString._(other, lib, retain: retain, release: release); + } + + /// Returns whether [obj] is an instance of [NSAttributedString]. + static bool isInstance(_ObjCWrapper obj) { + return obj._lib._objc_msgSend_0(obj._id, obj._lib._sel_isKindOfClass_1, + obj._lib._class_NSAttributedString1); + } +} + +class NSDate extends NSObject { + NSDate._(ffi.Pointer id, NativeMacOsFramework lib, + {bool retain = false, bool release = false}) + : super._(id, lib, retain: retain, release: release); + + /// Returns a [NSDate] that points to the same underlying object as [other]. + static NSDate castFrom(T other) { + return NSDate._(other._id, other._lib, retain: true, release: true); + } + + /// Returns a [NSDate] that wraps the given raw object pointer. + static NSDate castFromPointer( + NativeMacOsFramework lib, ffi.Pointer other, + {bool retain = false, bool release = false}) { + return NSDate._(other, lib, retain: retain, release: release); + } + + /// Returns whether [obj] is an instance of [NSDate]. + static bool isInstance(_ObjCWrapper obj) { + return obj._lib._objc_msgSend_0( + obj._id, obj._lib._sel_isKindOfClass_1, obj._lib._class_NSDate1); + } + + double get timeIntervalSinceReferenceDate { + return _lib._objc_msgSend_197( + _id, _lib._sel_timeIntervalSinceReferenceDate1); + } + + @override + NSDate init() { + final _ret = _lib._objc_msgSend_2(_id, _lib._sel_init1); + return NSDate._(_ret, _lib, retain: true, release: true); + } + + NSDate initWithTimeIntervalSinceReferenceDate_(double ti) { + final _ret = _lib._objc_msgSend_376( + _id, _lib._sel_initWithTimeIntervalSinceReferenceDate_1, ti); + return NSDate._(_ret, _lib, retain: true, release: true); + } + + NSDate? initWithCoder_(NSCoder coder) { + final _ret = + _lib._objc_msgSend_53(_id, _lib._sel_initWithCoder_1, coder._id); + return _ret.address == 0 + ? null + : NSDate._(_ret, _lib, retain: true, release: true); + } + + double timeIntervalSinceDate_(NSDate anotherDate) { + return _lib._objc_msgSend_377( + _id, _lib._sel_timeIntervalSinceDate_1, anotherDate._id); + } + + double get timeIntervalSinceNow { + return _lib._objc_msgSend_197(_id, _lib._sel_timeIntervalSinceNow1); + } + + double get timeIntervalSince1970 { + return _lib._objc_msgSend_197(_id, _lib._sel_timeIntervalSince19701); + } + + NSObject addTimeInterval_(double seconds) { + final _ret = + _lib._objc_msgSend_376(_id, _lib._sel_addTimeInterval_1, seconds); + return NSObject._(_ret, _lib, retain: true, release: true); + } + + NSDate dateByAddingTimeInterval_(double ti) { + final _ret = + _lib._objc_msgSend_376(_id, _lib._sel_dateByAddingTimeInterval_1, ti); + return NSDate._(_ret, _lib, retain: true, release: true); + } + + NSDate earlierDate_(NSDate anotherDate) { + final _ret = + _lib._objc_msgSend_378(_id, _lib._sel_earlierDate_1, anotherDate._id); + return NSDate._(_ret, _lib, retain: true, release: true); + } + + NSDate laterDate_(NSDate anotherDate) { + final _ret = + _lib._objc_msgSend_378(_id, _lib._sel_laterDate_1, anotherDate._id); + return NSDate._(_ret, _lib, retain: true, release: true); + } + + int compare_(NSDate other) { + return _lib._objc_msgSend_379(_id, _lib._sel_compare_1, other._id); + } + + bool isEqualToDate_(NSDate otherDate) { + return _lib._objc_msgSend_380( + _id, _lib._sel_isEqualToDate_1, otherDate._id); + } + + NSString get description { + final _ret = _lib._objc_msgSend_57(_id, _lib._sel_description1); + return NSString._(_ret, _lib, retain: true, release: true); + } + + NSString descriptionWithLocale_(NSObject? locale) { + final _ret = _lib._objc_msgSend_58( + _id, _lib._sel_descriptionWithLocale_1, locale?._id ?? ffi.nullptr); + return NSString._(_ret, _lib, retain: true, release: true); + } + + static NSDate date(NativeMacOsFramework _lib) { + final _ret = _lib._objc_msgSend_2(_lib._class_NSDate1, _lib._sel_date1); + return NSDate._(_ret, _lib, retain: true, release: true); + } + + static NSDate dateWithTimeIntervalSinceNow_( + NativeMacOsFramework _lib, double secs) { + final _ret = _lib._objc_msgSend_376( + _lib._class_NSDate1, _lib._sel_dateWithTimeIntervalSinceNow_1, secs); + return NSDate._(_ret, _lib, retain: true, release: true); + } + + static NSDate dateWithTimeIntervalSinceReferenceDate_( + NativeMacOsFramework _lib, double ti) { + final _ret = _lib._objc_msgSend_376(_lib._class_NSDate1, + _lib._sel_dateWithTimeIntervalSinceReferenceDate_1, ti); + return NSDate._(_ret, _lib, retain: true, release: true); + } + + static NSDate dateWithTimeIntervalSince1970_( + NativeMacOsFramework _lib, double secs) { + final _ret = _lib._objc_msgSend_376( + _lib._class_NSDate1, _lib._sel_dateWithTimeIntervalSince1970_1, secs); + return NSDate._(_ret, _lib, retain: true, release: true); + } + + static NSDate dateWithTimeInterval_sinceDate_( + NativeMacOsFramework _lib, double secsToBeAdded, NSDate date) { + final _ret = _lib._objc_msgSend_381(_lib._class_NSDate1, + _lib._sel_dateWithTimeInterval_sinceDate_1, secsToBeAdded, date._id); + return NSDate._(_ret, _lib, retain: true, release: true); + } + + static NSDate getDistantFuture(NativeMacOsFramework _lib) { + final _ret = + _lib._objc_msgSend_382(_lib._class_NSDate1, _lib._sel_distantFuture1); + return NSDate._(_ret, _lib, retain: true, release: true); + } + + static NSDate getDistantPast(NativeMacOsFramework _lib) { + final _ret = + _lib._objc_msgSend_382(_lib._class_NSDate1, _lib._sel_distantPast1); + return NSDate._(_ret, _lib, retain: true, release: true); + } + + static NSDate getNow(NativeMacOsFramework _lib) { + final _ret = _lib._objc_msgSend_382(_lib._class_NSDate1, _lib._sel_now1); + return NSDate._(_ret, _lib, retain: true, release: true); + } + + NSDate initWithTimeIntervalSinceNow_(double secs) { + final _ret = _lib._objc_msgSend_376( + _id, _lib._sel_initWithTimeIntervalSinceNow_1, secs); + return NSDate._(_ret, _lib, retain: true, release: true); + } + + NSDate initWithTimeIntervalSince1970_(double secs) { + final _ret = _lib._objc_msgSend_376( + _id, _lib._sel_initWithTimeIntervalSince1970_1, secs); + return NSDate._(_ret, _lib, retain: true, release: true); + } + + NSDate initWithTimeInterval_sinceDate_(double secsToBeAdded, NSDate date) { + final _ret = _lib._objc_msgSend_381(_id, + _lib._sel_initWithTimeInterval_sinceDate_1, secsToBeAdded, date._id); + return NSDate._(_ret, _lib, retain: true, release: true); + } + + static NSDate new1(NativeMacOsFramework _lib) { + final _ret = _lib._objc_msgSend_2(_lib._class_NSDate1, _lib._sel_new1); + return NSDate._(_ret, _lib, retain: false, release: true); + } + + static NSDate allocWithZone_( + NativeMacOsFramework _lib, ffi.Pointer<_NSZone> zone) { + final _ret = _lib._objc_msgSend_3( + _lib._class_NSDate1, _lib._sel_allocWithZone_1, zone); + return NSDate._(_ret, _lib, retain: false, release: true); + } + + static NSDate alloc(NativeMacOsFramework _lib) { + final _ret = _lib._objc_msgSend_2(_lib._class_NSDate1, _lib._sel_alloc1); + return NSDate._(_ret, _lib, retain: false, release: true); + } +} + +class NSProcessInfo extends NSObject { + NSProcessInfo._(ffi.Pointer id, NativeMacOsFramework lib, + {bool retain = false, bool release = false}) + : super._(id, lib, retain: retain, release: release); + + /// Returns a [NSProcessInfo] that points to the same underlying object as [other]. + static NSProcessInfo castFrom(T other) { + return NSProcessInfo._(other._id, other._lib, retain: true, release: true); + } + + /// Returns a [NSProcessInfo] that wraps the given raw object pointer. + static NSProcessInfo castFromPointer( + NativeMacOsFramework lib, ffi.Pointer other, + {bool retain = false, bool release = false}) { + return NSProcessInfo._(other, lib, retain: retain, release: release); + } + + /// Returns whether [obj] is an instance of [NSProcessInfo]. + static bool isInstance(_ObjCWrapper obj) { + return obj._lib._objc_msgSend_0( + obj._id, obj._lib._sel_isKindOfClass_1, obj._lib._class_NSProcessInfo1); + } + + static NSProcessInfo getProcessInfo(NativeMacOsFramework _lib) { + final _ret = _lib._objc_msgSend_383( + _lib._class_NSProcessInfo1, _lib._sel_processInfo1); + return NSProcessInfo._(_ret, _lib, retain: true, release: true); + } + + NSDictionary get environment { + final _ret = _lib._objc_msgSend_384(_id, _lib._sel_environment1); + return NSDictionary._(_ret, _lib, retain: true, release: true); + } + + NSArray get arguments { + final _ret = _lib._objc_msgSend_121(_id, _lib._sel_arguments1); + return NSArray._(_ret, _lib, retain: true, release: true); + } + + NSString get hostName { + final _ret = _lib._objc_msgSend_57(_id, _lib._sel_hostName1); + return NSString._(_ret, _lib, retain: true, release: true); + } + + NSString get processName { + final _ret = _lib._objc_msgSend_57(_id, _lib._sel_processName1); + return NSString._(_ret, _lib, retain: true, release: true); + } + + set processName(NSString value) { + return _lib._objc_msgSend_313(_id, _lib._sel_setProcessName_1, value._id); + } + + int get processIdentifier { + return _lib._objc_msgSend_199(_id, _lib._sel_processIdentifier1); + } + + NSString get globallyUniqueString { + final _ret = _lib._objc_msgSend_57(_id, _lib._sel_globallyUniqueString1); + return NSString._(_ret, _lib, retain: true, release: true); + } + + int operatingSystem() { + return _lib._objc_msgSend_12(_id, _lib._sel_operatingSystem1); + } + + NSString operatingSystemName() { + final _ret = _lib._objc_msgSend_57(_id, _lib._sel_operatingSystemName1); + return NSString._(_ret, _lib, retain: true, release: true); + } + + /// Human readable, localized; appropriate for displaying to user or using in bug emails and such; NOT appropriate for parsing + NSString get operatingSystemVersionString { + final _ret = + _lib._objc_msgSend_57(_id, _lib._sel_operatingSystemVersionString1); + return NSString._(_ret, _lib, retain: true, release: true); + } + + void getOperatingSystemVersion(ffi.Pointer stret) { + _lib._objc_msgSend_385(stret, _id, _lib._sel_operatingSystemVersion1); + } + + int get processorCount { + return _lib._objc_msgSend_12(_id, _lib._sel_processorCount1); + } + + int get activeProcessorCount { + return _lib._objc_msgSend_12(_id, _lib._sel_activeProcessorCount1); + } + + int get physicalMemory { + return _lib._objc_msgSend_283(_id, _lib._sel_physicalMemory1); + } + + bool isOperatingSystemAtLeastVersion_(NSOperatingSystemVersion version) { + return _lib._objc_msgSend_386( + _id, _lib._sel_isOperatingSystemAtLeastVersion_1, version); + } + + double get systemUptime { + return _lib._objc_msgSend_197(_id, _lib._sel_systemUptime1); + } + + /// Disable or reenable the ability to be quickly killed. The default implementations of these methods increment or decrement, respectively, a counter whose value is 1 when the process is first created. When the counter's value is 0 the application is considered to be safely killable and may be killed by the operating system without any notification or event being sent to the process first. If an application's Info.plist has an NSSupportsSuddenTermination entry whose value is true then NSApplication invokes -enableSuddenTermination automatically during application launch, which typically renders the process killable right away. You can also manually invoke -enableSuddenTermination right away in, for example, agents or daemons that don't depend on AppKit. After that, you can invoke these methods whenever the process has work it must do before it terminates. For example: + /// - NSUserDefaults uses these to prevent process killing between the time at which a default has been set and the time at which the preferences file including that default has been written to disk. + /// - NSDocument uses these to prevent process killing between the time at which the user has made a change to a document and the time at which the user's change has been written to disk. + /// - You can use these whenever your application defers work that must be done before the application terminates. If for example your application ever defers writing something to disk, and it has an NSSupportsSuddenTermination entry in its Info.plist so as not to contribute to user-visible delays at logout or shutdown time, it must invoke -disableSuddenTermination when the writing is first deferred and -enableSuddenTermination after the writing is actually done. + void disableSuddenTermination() { + _lib._objc_msgSend_1(_id, _lib._sel_disableSuddenTermination1); + } + + void enableSuddenTermination() { + _lib._objc_msgSend_1(_id, _lib._sel_enableSuddenTermination1); + } + + /// Increment or decrement the counter tracking the number of automatic quit opt-out requests. When this counter is greater than zero, the app will be considered 'active' and ineligible for automatic termination. + /// An example of using this would be disabling autoquitting when the user of an instant messaging application signs on, due to it requiring a background connection to be maintained even if the app is otherwise inactive. + /// Each pair of calls should have a matching "reason" argument, which can be used to easily track why an application is or is not automatically terminable. + /// A given reason can be used more than once at the same time (for example: two files are transferring over the network, each one disables automatic termination with the reason @"file transfer in progress") + void disableAutomaticTermination_(NSString reason) { + _lib._objc_msgSend_341( + _id, _lib._sel_disableAutomaticTermination_1, reason._id); + } + + void enableAutomaticTermination_(NSString reason) { + _lib._objc_msgSend_341( + _id, _lib._sel_enableAutomaticTermination_1, reason._id); + } + + /// Marks the calling app as supporting automatic termination. Without calling this or setting the equivalent Info.plist key (NSSupportsAutomaticTermination), the above methods (disableAutomaticTermination:/enableAutomaticTermination:) have no effect, + /// although the counter tracking automatic termination opt-outs is still kept up to date to ensure correctness if this is called later. Currently, passing NO has no effect. + /// This should be called during -applicationDidFinishLaunching or earlier. + bool get automaticTerminationSupportEnabled { + return _lib._objc_msgSend_11( + _id, _lib._sel_automaticTerminationSupportEnabled1); + } + + /// Marks the calling app as supporting automatic termination. Without calling this or setting the equivalent Info.plist key (NSSupportsAutomaticTermination), the above methods (disableAutomaticTermination:/enableAutomaticTermination:) have no effect, + /// although the counter tracking automatic termination opt-outs is still kept up to date to ensure correctness if this is called later. Currently, passing NO has no effect. + /// This should be called during -applicationDidFinishLaunching or earlier. + set automaticTerminationSupportEnabled(bool value) { + return _lib._objc_msgSend_314( + _id, _lib._sel_setAutomaticTerminationSupportEnabled_1, value); + } + + /// Pass in an activity to this API, and a non-NULL, non-empty reason string. Indicate completion of the activity by calling the corresponding endActivity: method with the result of the beginActivityWithOptions:reason: method. The reason string is used for debugging. + NSObject beginActivityWithOptions_reason_(int options, NSString reason) { + final _ret = _lib._objc_msgSend_387( + _id, _lib._sel_beginActivityWithOptions_reason_1, options, reason._id); + return NSObject._(_ret, _lib, retain: true, release: true); + } + + /// The argument to this method is the result of beginActivityWithOptions:reason:. + void endActivity_(NSObject activity) { + _lib._objc_msgSend_21(_id, _lib._sel_endActivity_1, activity._id); + } + + /// Synchronously perform an activity. The activity will be automatically ended after your block argument returns. The reason string is used for debugging. + void performActivityWithOptions_reason_usingBlock_( + int options, NSString reason, ObjCBlock_ffiVoid block) { + _lib._objc_msgSend_388( + _id, + _lib._sel_performActivityWithOptions_reason_usingBlock_1, + options, + reason._id, + block._id); + } + + /// Perform an expiring background task, which obtains an expiring task assertion on iOS. The block contains any work which needs to be completed as a background-priority task. The block will be scheduled on a system-provided concurrent queue. After a system-specified time, the block will be called with the `expired` parameter set to YES. The `expired` parameter will also be YES if the system decides to prematurely terminate a previous non-expiration invocation of the block. + void performExpiringActivityWithReason_usingBlock_( + NSString reason, ObjCBlock_ffiVoid_bool block) { + _lib._objc_msgSend_389( + _id, + _lib._sel_performExpiringActivityWithReason_usingBlock_1, + reason._id, + block._id); + } + + NSString get userName { + final _ret = _lib._objc_msgSend_57(_id, _lib._sel_userName1); + return NSString._(_ret, _lib, retain: true, release: true); + } + + NSString get fullUserName { + final _ret = _lib._objc_msgSend_57(_id, _lib._sel_fullUserName1); + return NSString._(_ret, _lib, retain: true, release: true); + } + + /// Retrieve the current thermal state of the system. On systems where thermal state is unknown or unsupported, the value returned from the thermalState property is always NSProcessInfoThermalStateNominal. + int get thermalState { + return _lib._objc_msgSend_390(_id, _lib._sel_thermalState1); + } + + /// Retrieve the current setting of the system for the low power mode setting. On systems where the low power mode is unknown or unsupported, the value returned from the lowPowerModeEnabled property is always NO + bool get lowPowerModeEnabled { + return _lib._objc_msgSend_11(_id, _lib._sel_isLowPowerModeEnabled1); + } + + bool get macCatalystApp { + return _lib._objc_msgSend_11(_id, _lib._sel_isMacCatalystApp1); + } + + bool get iOSAppOnMac { + return _lib._objc_msgSend_11(_id, _lib._sel_isiOSAppOnMac1); + } + + @override + NSProcessInfo init() { + final _ret = _lib._objc_msgSend_2(_id, _lib._sel_init1); + return NSProcessInfo._(_ret, _lib, retain: true, release: true); + } + + static NSProcessInfo new1(NativeMacOsFramework _lib) { + final _ret = + _lib._objc_msgSend_2(_lib._class_NSProcessInfo1, _lib._sel_new1); + return NSProcessInfo._(_ret, _lib, retain: false, release: true); + } + + static NSProcessInfo allocWithZone_( + NativeMacOsFramework _lib, ffi.Pointer<_NSZone> zone) { + final _ret = _lib._objc_msgSend_3( + _lib._class_NSProcessInfo1, _lib._sel_allocWithZone_1, zone); + return NSProcessInfo._(_ret, _lib, retain: false, release: true); + } + + static NSProcessInfo alloc(NativeMacOsFramework _lib) { + final _ret = + _lib._objc_msgSend_2(_lib._class_NSProcessInfo1, _lib._sel_alloc1); + return NSProcessInfo._(_ret, _lib, retain: false, release: true); + } +} + +final class NSOperatingSystemVersion extends ffi.Struct { + @ffi.Long() + external int majorVersion; + + @ffi.Long() + external int minorVersion; + + @ffi.Long() + external int patchVersion; +} + +/// The system has heuristics to improve battery life, performance, and responsiveness of applications for the benefit of the user. This API can be used to give hints to the system that your application has special requirements. In response to creating one of these activities, the system will disable some or all of the heuristics so your application can finish quickly while still providing responsive behavior if the user needs it. +/// +/// These activities can be used when your application is performing a long-running operation. If the activity can take different amounts of time (for example, calculating the next move in a chess game), it should use this API. This will ensure correct behavior when the amount of data or the capabilities of the user's computer varies. You should put your activity into one of two major categories: +/// +/// User initiated: These are finite length activities that the user has explicitly started. Examples include exporting or downloading a user specified file. +/// +/// Background: These are finite length activities that are part of the normal operation of your application but are not explicitly started by the user. Examples include autosaving, indexing, and automatic downloading of files. +/// +/// In addition, if your application requires high priority IO, you can include the 'NSActivityLatencyCritical' flag (using a bitwise or). This should be reserved for activities like audio or video recording. +/// +/// If your activity takes place synchronously inside an event callback on the main thread, you do not need to use this API. +/// +/// Be aware that failing to end these activities for an extended period of time can have significant negative impacts to the performance of your user's computer, so be sure to use only the minimum amount of time required. User preferences may override your application’s request. +/// +/// This API can also be used to control auto termination or sudden termination. +/// +/// id activity = [NSProcessInfo.processInfo beginActivityWithOptions:NSActivityAutomaticTerminationDisabled reason:@"Good Reason"]; +/// // work +/// [NSProcessInfo.processInfo endActivity:activity]; +/// +/// is equivalent to: +/// +/// [NSProcessInfo.processInfo disableAutomaticTermination:@"Good Reason"]; +/// // work +/// [NSProcessInfo.processInfo enableAutomaticTermination:@"Good Reason"] +/// +/// Since this API returns an object, it may be easier to pair begins and ends. If the object is deallocated before the -endActivity: call, the activity will be automatically ended. +/// +/// This API also provides a mechanism to disable system-wide idle sleep and display idle sleep. These can have a large impact on the user experience, so be sure not to forget to end activities that disable sleep (including NSActivityUserInitiated). +abstract class NSActivityOptions { + /// Used for activities that require the screen to stay powered on. + static const int NSActivityIdleDisplaySleepDisabled = 1099511627776; + + /// Used for activities that require the computer to not idle sleep. This is included in NSActivityUserInitiated. + static const int NSActivityIdleSystemSleepDisabled = 1048576; + + /// Prevents sudden termination. This is included in NSActivityUserInitiated. + static const int NSActivitySuddenTerminationDisabled = 16384; + + /// Prevents automatic termination. This is included in NSActivityUserInitiated. + static const int NSActivityAutomaticTerminationDisabled = 32768; + + /// Emits an os_signpost begin and end during the activity lifetime, intended to be used to track animation activity + static const int NSActivityAnimationTrackingEnabled = 35184372088832; + + /// Emits an os_signpost begin and end during the activity lifetime, intended to be used to track general activity + static const int NSActivityTrackingEnabled = 70368744177664; + + /// App is performing a user-requested action. + static const int NSActivityUserInitiated = 16777215; + static const int NSActivityUserInitiatedAllowingIdleSystemSleep = 15728639; + + /// App has initiated some kind of work, but not as the direct result of user request. + static const int NSActivityBackground = 255; + + /// Used for activities that require the highest amount of timer and I/O precision available. Very few applications should need to use this constant. + static const int NSActivityLatencyCritical = 1095216660480; + static const int NSActivityUserInteractive = 1095233437695; +} + +void _ObjCBlock_ffiVoid_bool_fnPtrTrampoline( + ffi.Pointer<_ObjCBlock> block, bool arg0) => + block.ref.target + .cast>() + .asFunction()(arg0); +final _ObjCBlock_ffiVoid_bool_closureRegistry = {}; +int _ObjCBlock_ffiVoid_bool_closureRegistryIndex = 0; +ffi.Pointer _ObjCBlock_ffiVoid_bool_registerClosure( + void Function(bool) fn) { + final id = ++_ObjCBlock_ffiVoid_bool_closureRegistryIndex; + _ObjCBlock_ffiVoid_bool_closureRegistry[id] = fn; + return ffi.Pointer.fromAddress(id); +} + +void _ObjCBlock_ffiVoid_bool_closureTrampoline( + ffi.Pointer<_ObjCBlock> block, bool arg0) => + _ObjCBlock_ffiVoid_bool_closureRegistry[block.ref.target.address]!(arg0); + +class ObjCBlock_ffiVoid_bool extends _ObjCBlockBase { + ObjCBlock_ffiVoid_bool._(ffi.Pointer<_ObjCBlock> id, NativeMacOsFramework lib, + {bool retain = false, bool release = true}) + : super._(id, lib, retain: retain, release: release); + + /// Creates a block from a C function pointer. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + ObjCBlock_ffiVoid_bool.fromFunctionPointer(NativeMacOsFramework lib, + ffi.Pointer> ptr) + : this._( + lib._newBlock1( + _cFuncTrampoline ??= ffi.Pointer.fromFunction< + ffi.Void Function(ffi.Pointer<_ObjCBlock>, + ffi.Bool)>(_ObjCBlock_ffiVoid_bool_fnPtrTrampoline) + .cast(), + ptr.cast()), + lib); + static ffi.Pointer? _cFuncTrampoline; + + /// Creates a block from a Dart function. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + ObjCBlock_ffiVoid_bool.fromFunction( + NativeMacOsFramework lib, void Function(bool) fn) + : this._( + lib._newBlock1( + _dartFuncTrampoline ??= ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer<_ObjCBlock>, ffi.Bool)>( + _ObjCBlock_ffiVoid_bool_closureTrampoline) + .cast(), + _ObjCBlock_ffiVoid_bool_registerClosure( + (bool arg0) => fn(arg0))), + lib); + static ffi.Pointer? _dartFuncTrampoline; + + /// Creates a listener block from a Dart function. + /// + /// This is based on FFI's NativeCallable.listener, and has the same + /// capabilities and limitations. This block can be invoked from any thread, + /// but only supports void functions, and is not run synchronously. See + /// NativeCallable.listener for more details. + /// + /// Note that unlike the default behavior of NativeCallable.listener, listener + /// blocks do not keep the isolate alive. + ObjCBlock_ffiVoid_bool.listener( + NativeMacOsFramework lib, void Function(bool) fn) + : this._( + lib._newBlock1( + (_dartFuncListenerTrampoline ??= ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer<_ObjCBlock>, ffi.Bool)>.listener( + _ObjCBlock_ffiVoid_bool_closureTrampoline) + ..keepIsolateAlive = false) + .nativeFunction + .cast(), + _ObjCBlock_ffiVoid_bool_registerClosure( + (bool arg0) => fn(arg0))), + lib); + static ffi + .NativeCallable, ffi.Bool)>? + _dartFuncListenerTrampoline; + + void call(bool arg0) => _id.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer<_ObjCBlock> block, ffi.Bool arg0)>>() + .asFunction, bool)>()(_id, arg0); +} + +/// Describes the current thermal state of the system. +abstract class NSProcessInfoThermalState { + /// No corrective action is needed. + static const int NSProcessInfoThermalStateNominal = 0; + + /// The system has reached a state where fans may become audible (on systems which have fans). Recommendation: Defer non-user-visible activity. + static const int NSProcessInfoThermalStateFair = 1; + + /// Fans are running at maximum speed (on systems which have fans), system performance may be impacted. Recommendation: reduce application's usage of CPU, GPU and I/O, if possible. Switch to lower quality visual effects, reduce frame rates. + static const int NSProcessInfoThermalStateSerious = 2; + + /// System performance is significantly impacted and the system needs to cool down. Recommendation: reduce application's usage of CPU, GPU, and I/O to the minimum level needed to respond to user actions. Consider stopping use of camera and other peripherals if your application is using them. + static const int NSProcessInfoThermalStateCritical = 3; +} + +class NSScreen extends NSObject { + NSScreen._(ffi.Pointer id, NativeMacOsFramework lib, + {bool retain = false, bool release = false}) + : super._(id, lib, retain: retain, release: release); + + /// Returns a [NSScreen] that points to the same underlying object as [other]. + static NSScreen castFrom(T other) { + return NSScreen._(other._id, other._lib, retain: true, release: true); + } + + /// Returns a [NSScreen] that wraps the given raw object pointer. + static NSScreen castFromPointer( + NativeMacOsFramework lib, ffi.Pointer other, + {bool retain = false, bool release = false}) { + return NSScreen._(other, lib, retain: retain, release: release); + } + + /// Returns whether [obj] is an instance of [NSScreen]. + static bool isInstance(_ObjCWrapper obj) { + return obj._lib._objc_msgSend_0( + obj._id, obj._lib._sel_isKindOfClass_1, obj._lib._class_NSScreen1); + } + + /// All screens; first one is "zero" screen + static NSArray getScreens(NativeMacOsFramework _lib) { + final _ret = + _lib._objc_msgSend_121(_lib._class_NSScreen1, _lib._sel_screens1); + return NSArray._(_ret, _lib, retain: true, release: true); + } + + /// Screen with key window + static NSScreen? getMainScreen(NativeMacOsFramework _lib) { + final _ret = + _lib._objc_msgSend_391(_lib._class_NSScreen1, _lib._sel_mainScreen1); + return _ret.address == 0 + ? null + : NSScreen._(_ret, _lib, retain: true, release: true); + } + + static NSScreen? getDeepestScreen(NativeMacOsFramework _lib) { + final _ret = + _lib._objc_msgSend_391(_lib._class_NSScreen1, _lib._sel_deepestScreen1); + return _ret.address == 0 + ? null + : NSScreen._(_ret, _lib, retain: true, release: true); + } + + /// screensHaveSeparateSpaces returns YES if each screen has its own set of spaces. This is a system setting and does not necessarily imply that there are multiple screens, nor that there are multiple spaces on any one screen + static bool getScreensHaveSeparateSpaces(NativeMacOsFramework _lib) { + return _lib._objc_msgSend_11( + _lib._class_NSScreen1, _lib._sel_screensHaveSeparateSpaces1); + } + + int get depth { + return _lib._objc_msgSend_392(_id, _lib._sel_depth1); + } + + void getFrame(ffi.Pointer stret) { + _lib._objc_msgSend_162(stret, _id, _lib._sel_frame1); + } + + void getVisibleFrame(ffi.Pointer stret) { + _lib._objc_msgSend_162(stret, _id, _lib._sel_visibleFrame1); + } + + NSDictionary get deviceDescription { + final _ret = _lib._objc_msgSend_384(_id, _lib._sel_deviceDescription1); + return NSDictionary._(_ret, _lib, retain: true, release: true); + } + + NSColorSpace? get colorSpace { + final _ret = _lib._objc_msgSend_393(_id, _lib._sel_colorSpace1); + return _ret.address == 0 + ? null + : NSColorSpace._(_ret, _lib, retain: true, release: true); + } + + /// 0 terminated + ffi.Pointer get supportedWindowDepths { + return _lib._objc_msgSend_394(_id, _lib._sel_supportedWindowDepths1); + } + + /// canRepresentDisplayGamut: returns YES if the colorSpace of the receiving screen is capable of representing the given display gamut + bool canRepresentDisplayGamut_(int displayGamut) { + return _lib._objc_msgSend_395( + _id, _lib._sel_canRepresentDisplayGamut_1, displayGamut); + } + + /// Convert to/from the device pixel aligned coordinates system of a display + void convertRectToBacking_(ffi.Pointer stret, CGRect rect) { + _lib._objc_msgSend_396(stret, _id, _lib._sel_convertRectToBacking_1, rect); + } + + void convertRectFromBacking_(ffi.Pointer stret, CGRect rect) { + _lib._objc_msgSend_396( + stret, _id, _lib._sel_convertRectFromBacking_1, rect); + } + + /// Uses NSIntegralRectWithOptions() to produce a pixel aligned rectangle on the target screen from the given input rectangle in global screen coordinates. + void backingAlignedRect_options_( + ffi.Pointer stret, CGRect rect, int options) { + _lib._objc_msgSend_397( + stret, _id, _lib._sel_backingAlignedRect_options_1, rect, options); + } + + /// Returns the scale factor representing the number of backing store pixels corresponding to each linear unit in screen space on this NSScreen. This method is provided for rare cases when the explicit scale factor is needed. Please use -convert*ToBacking: methods whenever possible. + double get backingScaleFactor { + return _lib._objc_msgSend_197(_id, _lib._sel_backingScaleFactor1); + } + + NSString get localizedName { + final _ret = _lib._objc_msgSend_57(_id, _lib._sel_localizedName1); + return NSString._(_ret, _lib, retain: true, release: true); + } + + /// Indicates the obscured distance from each edge of the screen + void getSafeAreaInsets(ffi.Pointer stret) { + _lib._objc_msgSend_265(stret, _id, _lib._sel_safeAreaInsets1); + } + + /// The following two rects are at the top of the screen, outside the rectangle defined by safeAreaInsets, but also unobscured. These rects are empty if there are no additional unobscured areas + void getAuxiliaryTopLeftArea(ffi.Pointer stret) { + _lib._objc_msgSend_162(stret, _id, _lib._sel_auxiliaryTopLeftArea1); + } + + void getAuxiliaryTopRightArea(ffi.Pointer stret) { + _lib._objc_msgSend_162(stret, _id, _lib._sel_auxiliaryTopRightArea1); + } + + /// Returns the current maximum color component value for the screen. Typically the maximum is 1.0, but if any rendering context on the screen has requested extended dynamic range, it may return a value greater than 1.0, depending on system capabilities and other conditions. Only rendering contexts that support extended dynamic range can use values greater than 1.0. When the value changes, NSApplicationDidChangeScreenParametersNotification will be posted. + double get maximumExtendedDynamicRangeColorComponentValue { + return _lib._objc_msgSend_197( + _id, _lib._sel_maximumExtendedDynamicRangeColorComponentValue1); + } + + /// Returns the maximum color component value that the screen is capable of when extended dynamic range is enabled, regardless of whether or not extended dynamic range is currently enabled. + double get maximumPotentialExtendedDynamicRangeColorComponentValue { + return _lib._objc_msgSend_197(_id, + _lib._sel_maximumPotentialExtendedDynamicRangeColorComponentValue1); + } + + /// Returns the current maximum color component value for reference rendering to the screen. If values beyond this are used, the display hardware may adjust content to fit into its dynamic range. For screens that do not support reference rendering, this will return 0. + double get maximumReferenceExtendedDynamicRangeColorComponentValue { + return _lib._objc_msgSend_197(_id, + _lib._sel_maximumReferenceExtendedDynamicRangeColorComponentValue1); + } + + /// The maximum frames per second this screen supports. + int get maximumFramesPerSecond { + return _lib._objc_msgSend_200(_id, _lib._sel_maximumFramesPerSecond1); + } + + /// The minimum refresh interval this screen supports, in seconds. + /// + /// This is the shortest amount of time a frame will be present on screen. + /// minimumRefreshInterval and maximumRefreshInterval will be the same for displays that do not support variable refresh rates. + double get minimumRefreshInterval { + return _lib._objc_msgSend_197(_id, _lib._sel_minimumRefreshInterval1); + } + + /// The maximum refresh interval this screen supports, in seconds. + /// + /// minimumRefreshInterval and maximumRefreshInterval will be the same for displays that do not support variable refresh rates. + double get maximumRefreshInterval { + return _lib._objc_msgSend_197(_id, _lib._sel_maximumRefreshInterval1); + } + + /// The update granularity of the screen's current mode, in seconds. + /// + /// The display will update at the next boundary defined by the granularity, after the minimum refresh interval has been reached. When 0, the display can update at any time between the minimum and maximum refresh rate intervals of the screen. Fixed refresh rate screen modes will return the refresh interval as the update granularity (e.g. 16.66ms for 60Hz refresh rates), meaning updates only occur at refresh rate boundaries. + double get displayUpdateGranularity { + return _lib._objc_msgSend_197(_id, _lib._sel_displayUpdateGranularity1); + } + + /// The time at which the last framebuffer update occurred on the display, in seconds since startup that the system has been awake. + double get lastDisplayUpdateTimestamp { + return _lib._objc_msgSend_197(_id, _lib._sel_lastDisplayUpdateTimestamp1); + } + + /// Returns a new display link whose callback will be invoked in-sync with the display the screen is on. Note that views and windows can move between screens and you may want to get a display link directly from NSView or NSWindow which will track those changes automatically. + CADisplayLink displayLinkWithTarget_selector_( + NSObject target, ffi.Pointer selector) { + final _ret = _lib._objc_msgSend_398( + _id, _lib._sel_displayLinkWithTarget_selector_1, target._id, selector); + return CADisplayLink._(_ret, _lib, retain: true, release: true); + } + + /// This method is deprecated and should not be used by applications targeting Mac OS X 10.7 or later. + /// The implementation of this method will always return 1.0. Please use -convertRectToBacking: or -backingScaleFactor instead. + double userSpaceScaleFactor() { + return _lib._objc_msgSend_197(_id, _lib._sel_userSpaceScaleFactor1); + } + + @override + NSScreen init() { + final _ret = _lib._objc_msgSend_2(_id, _lib._sel_init1); + return NSScreen._(_ret, _lib, retain: true, release: true); + } + + static NSScreen new1(NativeMacOsFramework _lib) { + final _ret = _lib._objc_msgSend_2(_lib._class_NSScreen1, _lib._sel_new1); + return NSScreen._(_ret, _lib, retain: false, release: true); + } + + static NSScreen allocWithZone_( + NativeMacOsFramework _lib, ffi.Pointer<_NSZone> zone) { + final _ret = _lib._objc_msgSend_3( + _lib._class_NSScreen1, _lib._sel_allocWithZone_1, zone); + return NSScreen._(_ret, _lib, retain: false, release: true); + } + + static NSScreen alloc(NativeMacOsFramework _lib) { + final _ret = _lib._objc_msgSend_2(_lib._class_NSScreen1, _lib._sel_alloc1); + return NSScreen._(_ret, _lib, retain: false, release: true); + } +} + +abstract class NSWindowDepth { + static const int NSWindowDepthTwentyfourBitRGB = 520; + static const int NSWindowDepthSixtyfourBitRGB = 528; + static const int NSWindowDepthOnehundredtwentyeightBitRGB = 544; +} + +class NSColorSpace extends _ObjCWrapper { + NSColorSpace._(ffi.Pointer id, NativeMacOsFramework lib, + {bool retain = false, bool release = false}) + : super._(id, lib, retain: retain, release: release); + + /// Returns a [NSColorSpace] that points to the same underlying object as [other]. + static NSColorSpace castFrom(T other) { + return NSColorSpace._(other._id, other._lib, retain: true, release: true); + } + + /// Returns a [NSColorSpace] that wraps the given raw object pointer. + static NSColorSpace castFromPointer( + NativeMacOsFramework lib, ffi.Pointer other, + {bool retain = false, bool release = false}) { + return NSColorSpace._(other, lib, retain: retain, release: release); + } + + /// Returns whether [obj] is an instance of [NSColorSpace]. + static bool isInstance(_ObjCWrapper obj) { + return obj._lib._objc_msgSend_0( + obj._id, obj._lib._sel_isKindOfClass_1, obj._lib._class_NSColorSpace1); + } +} + +abstract class NSDisplayGamut { + static const int NSDisplayGamutSRGB = 1; + static const int NSDisplayGamutP3 = 2; +} + +abstract class NSAlignmentOptions { + static const int NSAlignMinXInward = 1; + static const int NSAlignMinYInward = 2; + static const int NSAlignMaxXInward = 4; + static const int NSAlignMaxYInward = 8; + static const int NSAlignWidthInward = 16; + static const int NSAlignHeightInward = 32; + static const int NSAlignMinXOutward = 256; + static const int NSAlignMinYOutward = 512; + static const int NSAlignMaxXOutward = 1024; + static const int NSAlignMaxYOutward = 2048; + static const int NSAlignWidthOutward = 4096; + static const int NSAlignHeightOutward = 8192; + static const int NSAlignMinXNearest = 65536; + static const int NSAlignMinYNearest = 131072; + static const int NSAlignMaxXNearest = 262144; + static const int NSAlignMaxYNearest = 524288; + static const int NSAlignWidthNearest = 1048576; + static const int NSAlignHeightNearest = 2097152; + static const int NSAlignRectFlipped = -9223372036854775808; + static const int NSAlignAllEdgesInward = 15; + static const int NSAlignAllEdgesOutward = 3840; + static const int NSAlignAllEdgesNearest = 983040; +} + +class CADisplayLink extends _ObjCWrapper { + CADisplayLink._(ffi.Pointer id, NativeMacOsFramework lib, + {bool retain = false, bool release = false}) + : super._(id, lib, retain: retain, release: release); + + /// Returns a [CADisplayLink] that points to the same underlying object as [other]. + static CADisplayLink castFrom(T other) { + return CADisplayLink._(other._id, other._lib, retain: true, release: true); + } + + /// Returns a [CADisplayLink] that wraps the given raw object pointer. + static CADisplayLink castFromPointer( + NativeMacOsFramework lib, ffi.Pointer other, + {bool retain = false, bool release = false}) { + return CADisplayLink._(other, lib, retain: retain, release: release); + } + + /// Returns whether [obj] is an instance of [CADisplayLink]. + static bool isInstance(_ObjCWrapper obj) { + return obj._lib._objc_msgSend_0( + obj._id, obj._lib._sel_isKindOfClass_1, obj._lib._class_CADisplayLink1); + } +} + +typedef CFTypeRef1 = ffi.Pointer; + +const String kIOPlatformUUIDKey = 'IOPlatformUUID'; + +const int IO_OBJECT_NULL = 0; diff --git a/apps/cli/lib/src/platform/macos_utils.dart b/apps/cli/lib/src/platform/macos_utils.dart new file mode 100644 index 000000000..6ca23d81f --- /dev/null +++ b/apps/cli/lib/src/platform/macos_utils.dart @@ -0,0 +1,76 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + +import 'dart:ffi'; + +import 'package:celest_cli/src/platform/macos_bindings.g.dart'; +import 'package:ffi/ffi.dart'; + +/// Helpers for [CFData]. +extension CFDataRefX on Pointer { + /// Converts a [CFData] to a Dart String. + String? toDartString(NativeMacOsFramework lib) { + if (this == nullptr) return null; + final bytePtr = lib.CFDataGetBytePtr(this); + if (bytePtr == nullptr) return null; + return bytePtr.cast().toDartString(); + } +} + +/// Helpers for [CFString]. +extension CFStringPointerX on Pointer { + /// Converts a [CFString] to a Dart String. + String? toDartString(NativeMacOsFramework lib) { + if (this == nullptr) return null; + final cStringPtr = lib.CFStringGetCStringPtr( + this, + CFStringBuiltInEncodings.kCFStringEncodingUTF8, + ); + if (cStringPtr != nullptr) { + return cStringPtr.cast().toDartString(); + } + // Call CFStringGetCString as a backup. + // See: https://developer.apple.com/documentation/corefoundation/1542133-cfstringgetcstringptr + final strLen = lib.CFStringGetLength(this); + final maxLen = + lib.CFStringGetMaximumSizeForEncoding( + strLen, + CFStringBuiltInEncodings.kCFStringEncodingUTF8, + ) + + 1 /* terminating NUL byte */; + final buffer = calloc(maxLen); + try { + final ret = lib.CFStringGetCString( + this, + buffer, + maxLen, + CFStringBuiltInEncodings.kCFStringEncodingUTF8, + ); + if (ret == 0 /* FALSE */ ) { + return null; + } + return buffer.cast().toDartString(); + } finally { + calloc.free(buffer); + } + } +} + +/// Helper to create a [CFString] from a Dart [String]. +extension CFStringCreate on String { + /// Creates a [CFString] from this. + Pointer toCFString({ + required NativeMacOsFramework lib, + required Arena arena, + }) { + final cfString = lib.CFStringCreateWithCString( + nullptr, + toNativeUtf8(allocator: arena).cast(), + CFStringBuiltInEncodings.kCFStringEncodingUTF8, + ); + arena.onReleaseAll(() { + lib.CFRelease(cfString.cast()); + }); + return cfString; + } +} diff --git a/apps/cli/lib/src/platform/windows_folders.dart b/apps/cli/lib/src/platform/windows_folders.dart new file mode 100644 index 000000000..ee1f3f296 --- /dev/null +++ b/apps/cli/lib/src/platform/windows_folders.dart @@ -0,0 +1,247 @@ +// Copied from: +// https://github.com/flutter/packages/blob/36a7b99381f85e86914e82c75fc7d9038ed96cca/packages/path_provider/path_provider_windows/lib/src/folders.dart + +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:celest_cli/src/platform/windows_paths.dart'; +import 'package:win32/win32.dart'; + +// ignore_for_file: non_constant_identifier_names + +// ignore: avoid_classes_with_only_static_members +/// A class containing the GUID references for each of the documented Windows +/// known folders. A property of this class may be passed to the `getPath` +/// method in the [PathProviderWindows] class to retrieve a known folder from +/// Windows. +class WindowsKnownFolder { + /// The file system directory that is used to store administrative tools for + /// an individual user. The MMC will save customized consoles to this + /// directory, and it will roam with the user. + static String get AdminTools => FOLDERID_AdminTools; + + /// The file system directory that acts as a staging area for files waiting to + /// be written to a CD. A typical path is C:\Documents and + /// Settings\username\Local Settings\Application Data\Microsoft\CD Burning. + static String get CDBurning => FOLDERID_CDBurning; + + /// The file system directory that contains administrative tools for all users + /// of the computer. + static String get CommonAdminTools => FOLDERID_CommonAdminTools; + + /// The file system directory that contains the directories for the common + /// program groups that appear on the Start menu for all users. A typical path + /// is C:\Documents and Settings\All Users\Start Menu\Programs. + static String get CommonPrograms => FOLDERID_CommonPrograms; + + /// The file system directory that contains the programs and folders that + /// appear on the Start menu for all users. A typical path is C:\Documents and + /// Settings\All Users\Start Menu. + static String get CommonStartMenu => FOLDERID_CommonStartMenu; + + /// The file system directory that contains the programs that appear in the + /// Startup folder for all users. A typical path is C:\Documents and + /// Settings\All Users\Start Menu\Programs\Startup. + static String get CommonStartup => FOLDERID_CommonStartup; + + /// The file system directory that contains the templates that are available + /// to all users. A typical path is C:\Documents and Settings\All + /// Users\Templates. + static String get CommonTemplates => FOLDERID_CommonTemplates; + + /// The virtual folder that represents My Computer, containing everything on + /// the local computer: storage devices, printers, and Control Panel. The + /// folder can also contain mapped network drives. + static String get ComputerFolder => FOLDERID_ComputerFolder; + + /// The virtual folder that represents Network Connections, that contains + /// network and dial-up connections. + static String get ConnectionsFolder => FOLDERID_ConnectionsFolder; + + /// The virtual folder that contains icons for the Control Panel applications. + static String get ControlPanelFolder => FOLDERID_ControlPanelFolder; + + /// The file system directory that serves as a common repository for Internet + /// cookies. A typical path is C:\Documents and Settings\username\Cookies. + static String get Cookies => FOLDERID_Cookies; + + /// The virtual folder that represents the Windows desktop, the root of the + /// namespace. + static String get Desktop => FOLDERID_Desktop; + + /// The virtual folder that represents the My Documents desktop item. + static String get Documents => FOLDERID_Documents; + + /// The file system directory that serves as a repository for Internet + /// downloads. + static String get Downloads => FOLDERID_Downloads; + + /// The file system directory that serves as a common repository for the + /// user's favorite items. A typical path is C:\Documents and + /// Settings\username\Favorites. + static String get Favorites => FOLDERID_Favorites; + + /// A virtual folder that contains fonts. A typical path is C:\Windows\Fonts. + static String get Fonts => FOLDERID_Fonts; + + /// The file system directory that serves as a common repository for Internet + /// history items. + static String get History => FOLDERID_History; + + /// The file system directory that serves as a common repository for temporary + /// Internet files. A typical path is C:\Documents and Settings\username\Local + /// Settings\Temporary Internet Files. + static String get InternetCache => FOLDERID_InternetCache; + + /// A virtual folder for Internet Explorer. + static String get InternetFolder => FOLDERID_InternetFolder; + + /// The file system directory that serves as a data repository for local + /// (nonroaming) applications. A typical path is C:\Documents and + /// Settings\username\Local Settings\Application Data. + static String get LocalAppData => FOLDERID_LocalAppData; + + /// The file system directory that serves as a common repository for music + /// files. A typical path is C:\Documents and Settings\User\My Documents\My + /// Music. + static String get Music => FOLDERID_Music; + + /// A file system directory that contains the link objects that may exist in + /// the My Network Places virtual folder. A typical path is C:\Documents and + /// Settings\username\NetHood. + static String get NetHood => FOLDERID_NetHood; + + /// The folder that represents other computers in your workgroup. + static String get NetworkFolder => FOLDERID_NetworkFolder; + + /// The file system directory that serves as a common repository for image + /// files. A typical path is C:\Documents and Settings\username\My + /// Documents\My Pictures. + static String get Pictures => FOLDERID_Pictures; + + /// The file system directory that contains the link objects that can exist in + /// the Printers virtual folder. A typical path is C:\Documents and + /// Settings\username\PrintHood. + static String get PrintHood => FOLDERID_PrintHood; + + /// The virtual folder that contains installed printers. + static String get PrintersFolder => FOLDERID_PrintersFolder; + + /// The user's profile folder. A typical path is C:\Users\username. + /// Applications should not create files or folders at this level. + static String get Profile => FOLDERID_Profile; + + /// The file system directory that contains application data for all users. A + /// typical path is C:\Documents and Settings\All Users\Application Data. This + /// folder is used for application data that is not user specific. For + /// example, an application can store a spell-check dictionary, a database of + /// clip art, or a log file in the CSIDL_COMMON_APPDATA folder. This + /// information will not roam and is available to anyone using the computer. + static String get ProgramData => FOLDERID_ProgramData; + + /// The Program Files folder. A typical path is C:\Program Files. + static String get ProgramFiles => FOLDERID_ProgramFiles; + + /// The common Program Files folder. A typical path is C:\Program + /// Files\Common. + static String get ProgramFilesCommon => FOLDERID_ProgramFilesCommon; + + /// On 64-bit systems, a link to the common Program Files folder. A typical path is + /// C:\Program Files\Common Files. + static String get ProgramFilesCommonX64 => FOLDERID_ProgramFilesCommonX64; + + /// On 64-bit systems, a link to the 32-bit common Program Files folder. A + /// typical path is C:\Program Files (x86)\Common Files. On 32-bit systems, a + /// link to the Common Program Files folder. + static String get ProgramFilesCommonX86 => FOLDERID_ProgramFilesCommonX86; + + /// On 64-bit systems, a link to the Program Files folder. A typical path is + /// C:\Program Files. + static String get ProgramFilesX64 => FOLDERID_ProgramFilesX64; + + /// On 64-bit systems, a link to the 32-bit Program Files folder. A typical + /// path is C:\Program Files (x86). On 32-bit systems, a link to the Common + /// Program Files folder. + static String get ProgramFilesX86 => FOLDERID_ProgramFilesX86; + + /// The file system directory that contains the user's program groups (which + /// are themselves file system directories). + static String get Programs => FOLDERID_Programs; + + /// The file system directory that contains files and folders that appear on + /// the desktop for all users. A typical path is C:\Documents and Settings\All + /// Users\Desktop. + static String get PublicDesktop => FOLDERID_PublicDesktop; + + /// The file system directory that contains documents that are common to all + /// users. A typical path is C:\Documents and Settings\All Users\Documents. + static String get PublicDocuments => FOLDERID_PublicDocuments; + + /// The file system directory that serves as a repository for music files + /// common to all users. A typical path is C:\Documents and Settings\All + /// Users\Documents\My Music. + static String get PublicMusic => FOLDERID_PublicMusic; + + /// The file system directory that serves as a repository for image files + /// common to all users. A typical path is C:\Documents and Settings\All + /// Users\Documents\My Pictures. + static String get PublicPictures => FOLDERID_PublicPictures; + + /// The file system directory that serves as a repository for video files + /// common to all users. A typical path is C:\Documents and Settings\All + /// Users\Documents\My Videos. + static String get PublicVideos => FOLDERID_PublicVideos; + + /// The file system directory that contains shortcuts to the user's most + /// recently used documents. A typical path is C:\Documents and + /// Settings\username\My Recent Documents. + static String get Recent => FOLDERID_Recent; + + /// The virtual folder that contains the objects in the user's Recycle Bin. + static String get RecycleBinFolder => FOLDERID_RecycleBinFolder; + + /// The file system directory that contains resource data. A typical path is + /// C:\Windows\Resources. + static String get ResourceDir => FOLDERID_ResourceDir; + + /// The file system directory that serves as a common repository for + /// application-specific data. A typical path is C:\Documents and + /// Settings\username\Application Data. + static String get RoamingAppData => FOLDERID_RoamingAppData; + + /// The file system directory that contains Send To menu items. A typical path + /// is C:\Documents and Settings\username\SendTo. + static String get SendTo => FOLDERID_SendTo; + + /// The file system directory that contains Start menu items. A typical path + /// is C:\Documents and Settings\username\Start Menu. + static String get StartMenu => FOLDERID_StartMenu; + + /// The file system directory that corresponds to the user's Startup program + /// group. The system starts these programs whenever the associated user logs + /// on. A typical path is C:\Documents and Settings\username\Start + /// Menu\Programs\Startup. + static String get Startup => FOLDERID_Startup; + + /// The Windows System folder. A typical path is C:\Windows\System32. + static String get System => FOLDERID_System; + + /// The 32-bit Windows System folder. On 32-bit systems, this is typically + /// C:\Windows\system32. On 64-bit systems, this is typically + /// C:\Windows\syswow64. + static String get SystemX86 => FOLDERID_SystemX86; + + /// The file system directory that serves as a common repository for document + /// templates. A typical path is C:\Documents and Settings\username\Templates. + static String get Templates => FOLDERID_Templates; + + /// The file system directory that serves as a common repository for video + /// files. A typical path is C:\Documents and Settings\username\My + /// Documents\My Videos. + static String get Videos => FOLDERID_Videos; + + /// The Windows directory or SYSROOT. This corresponds to the %windir% or + /// %SYSTEMROOT% environment variables. A typical path is C:\Windows. + static String get Windows => FOLDERID_Windows; +} diff --git a/apps/cli/lib/src/platform/windows_paths.dart b/apps/cli/lib/src/platform/windows_paths.dart new file mode 100644 index 000000000..9aa8eacac --- /dev/null +++ b/apps/cli/lib/src/platform/windows_paths.dart @@ -0,0 +1,271 @@ +// Copied from: +// https://github.com/flutter/packages/blob/36a7b99381f85e86914e82c75fc7d9038ed96cca/packages/path_provider/path_provider_windows/lib/src/path_provider_windows_real.dart + +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// ignore_for_file: prefer_asserts_with_message + +import 'dart:ffi'; +import 'dart:io'; + +import 'package:celest_cli/src/platform/windows_folders.dart'; +import 'package:ffi/ffi.dart'; +import 'package:meta/meta.dart'; +import 'package:path/path.dart' as path; +import 'package:win32/win32.dart'; + +/// Constant for en-US language used in VersionInfo keys. +@visibleForTesting +const String languageEn = '0409'; + +/// Constant for CP1252 encoding used in VersionInfo keys +@visibleForTesting +const String encodingCP1252 = '04e4'; + +/// Constant for Unicode encoding used in VersionInfo keys +@visibleForTesting +const String encodingUnicode = '04b0'; + +/// Wraps the Win32 VerQueryValue API call. +/// +/// This class exists to allow injecting alternate metadata in tests without +/// building multiple custom test binaries. +@visibleForTesting +class VersionInfoQuerier { + /// Returns the value for [key] in [versionInfo]s in section with given + /// language and encoding, or null if there is no such entry, + /// or if versionInfo is null. + /// + /// See https://docs.microsoft.com/en-us/windows/win32/menurc/versioninfo-resource + /// for list of possible language and encoding values. + String? getStringValue( + Pointer? versionInfo, + String key, { + required String language, + required String encoding, + }) { + assert(language.isNotEmpty); + assert(encoding.isNotEmpty); + if (versionInfo == null) { + return null; + } + final keyPath = TEXT('\\StringFileInfo\\$language$encoding\\$key'); + final length = calloc(); + final valueAddress = calloc>(); + try { + if (VerQueryValue(versionInfo, keyPath, valueAddress, length) == 0) { + return null; + } + return valueAddress.value.toDartString(); + } finally { + calloc + ..free(keyPath) + ..free(length) + ..free(valueAddress); + } + } +} + +/// The Windows implementation of path provider. +/// +/// This class implements the `package:path_provider` functionality for Windows. +class PathProviderWindows { + /// The object to use for performing VerQueryValue calls. + @visibleForTesting + VersionInfoQuerier versionInfoQuerier = VersionInfoQuerier(); + + /// This is typically the same as the TMP environment variable. + String? getTemporaryPath() { + final buffer = calloc(MAX_PATH + 1).cast(); + String path; + + try { + final length = GetTempPath(MAX_PATH, buffer); + + if (length == 0) { + final error = GetLastError(); + throw WindowsException(error); + } else { + path = buffer.toDartString(); + + // GetTempPath adds a trailing backslash, but SHGetKnownFolderPath does + // not. Strip off trailing backslash for consistency with other methods + // here. + if (path.endsWith(r'\')) { + path = path.substring(0, path.length - 1); + } + } + + // Ensure that the directory exists, since GetTempPath doesn't. + final directory = Directory(path); + if (!directory.existsSync()) { + directory.createSync(recursive: true); + } + + return path; + } finally { + calloc.free(buffer); + } + } + + String? getApplicationSupportPath() => + _createApplicationSubdirectory(WindowsKnownFolder.RoamingAppData); + + String? getApplicationDocumentsPath() => + getPath(WindowsKnownFolder.Documents); + + String? getApplicationCachePath() => + _createApplicationSubdirectory(WindowsKnownFolder.LocalAppData); + + String? getDownloadsPath() => getPath(WindowsKnownFolder.Downloads); + + /// Retrieve any known folder from Windows. + /// + /// folderID is a GUID that represents a specific known folder ID, drawn from + /// [WindowsKnownFolder]. + String? getPath(String folderID) { + final pathPtrPtr = calloc>(); + final knownFolderID = calloc()..ref.setGUID(folderID); + + try { + final hr = SHGetKnownFolderPath( + knownFolderID, + KF_FLAG_DEFAULT, + NULL, + pathPtrPtr, + ); + + if (FAILED(hr)) { + if (hr == E_INVALIDARG || hr == E_FAIL) { + throw WindowsException(hr); + } + return null; + } + + final path = pathPtrPtr.value.toDartString(); + return path; + } finally { + calloc + ..free(pathPtrPtr) + ..free(knownFolderID); + } + } + + String? _getStringValue(Pointer? infoBuffer, String key) => + versionInfoQuerier.getStringValue( + infoBuffer, + key, + language: languageEn, + encoding: encodingCP1252, + ) ?? + versionInfoQuerier.getStringValue( + infoBuffer, + key, + language: languageEn, + encoding: encodingUnicode, + ); + + /// Returns the relative path string to append to the root directory returned + /// by Win32 APIs for application storage (such as RoamingAppDir) to get a + /// directory that is unique to the application. + /// + /// The convention is to use company-name\product-name\. This will use that if + /// possible, using the data in the VERSIONINFO resource, with the following + /// fallbacks: + /// - If the company name isn't there, that component will be dropped. + /// - If the product name isn't there, it will use the exe's filename (without + /// extension). + String _getApplicationSpecificSubdirectory() { + String? companyName; + String? productName; + + final moduleNameBuffer = wsalloc(MAX_PATH + 1); + final unused = calloc(); + Pointer? infoBuffer; + try { + // Get the module name. + final moduleNameLength = GetModuleFileName(0, moduleNameBuffer, MAX_PATH); + if (moduleNameLength == 0) { + final error = GetLastError(); + throw WindowsException(error); + } + + // From that, load the VERSIONINFO resource + final infoSize = GetFileVersionInfoSize(moduleNameBuffer, unused); + if (infoSize != 0) { + infoBuffer = calloc(infoSize); + if (GetFileVersionInfo(moduleNameBuffer, 0, infoSize, infoBuffer) == + 0) { + calloc.free(infoBuffer); + infoBuffer = null; + } + } + companyName = _sanitizedDirectoryName( + _getStringValue(infoBuffer, 'CompanyName'), + ); + productName = _sanitizedDirectoryName( + _getStringValue(infoBuffer, 'ProductName'), + ); + + // If there was no product name, use the executable name. + productName ??= path.basenameWithoutExtension( + moduleNameBuffer.toDartString(), + ); + + return companyName != null + ? path.join(companyName, productName) + : productName; + } finally { + calloc + ..free(moduleNameBuffer) + ..free(unused); + if (infoBuffer != null) { + calloc.free(infoBuffer); + } + } + } + + /// Makes [rawString] safe as a directory component. See + /// https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file#naming-conventions + /// + /// If after sanitizing the string is empty, returns null. + String? _sanitizedDirectoryName(String? rawString) { + if (rawString == null) { + return null; + } + var sanitized = rawString + // Replace banned characters. + .replaceAll(RegExp(r'[<>:"/\\|?*]'), '_') + // Remove trailing whitespace. + .trimRight() + // Ensure that it does not end with a '.'. + .replaceAll(RegExp(r'[.]+$'), ''); + const kMaxComponentLength = 255; + if (sanitized.length > kMaxComponentLength) { + sanitized = sanitized.substring(0, kMaxComponentLength); + } + return sanitized.isEmpty ? null : sanitized; + } + + String? _createApplicationSubdirectory(String folderId) { + final baseDir = getPath(folderId); + if (baseDir == null) { + return null; + } + final directory = Directory( + path.join(baseDir, _getApplicationSpecificSubdirectory()), + ); + // Ensure that the directory exists if possible, since it will on other + // platforms. If the name is longer than MAXPATH, creating will fail, so + // skip that step; it's up to the client to decide what to do with the path + // in that case (e.g., using a short path). + if (directory.path.length <= MAX_PATH) { + if (!directory.existsSync()) { + directory.createSync(recursive: true); + } + } + return directory.path; + } +} diff --git a/apps/cli/lib/src/process/logging_process_manager.dart b/apps/cli/lib/src/process/logging_process_manager.dart new file mode 100644 index 000000000..cbedba066 --- /dev/null +++ b/apps/cli/lib/src/process/logging_process_manager.dart @@ -0,0 +1,75 @@ +import 'dart:convert'; +import 'dart:io'; + +import 'package:logging/logging.dart'; +import 'package:process/process.dart'; + +final class LoggingProcessManager extends LocalProcessManager { + const LoggingProcessManager(); + + static final Logger _logger = Logger('ProcessManager'); + + @override + Future run( + List command, { + String? workingDirectory, + Map? environment, + bool includeParentEnvironment = true, + bool runInShell = false, + Encoding? stdoutEncoding = systemEncoding, + Encoding? stderrEncoding = systemEncoding, + }) { + _logger.finest('run: ${command.join(' ')}'); + return super.run( + command, + workingDirectory: workingDirectory, + environment: environment, + includeParentEnvironment: includeParentEnvironment, + runInShell: runInShell, + stdoutEncoding: stdoutEncoding, + stderrEncoding: stderrEncoding, + ); + } + + @override + ProcessResult runSync( + List command, { + String? workingDirectory, + Map? environment, + bool includeParentEnvironment = true, + bool runInShell = false, + Encoding? stdoutEncoding = systemEncoding, + Encoding? stderrEncoding = systemEncoding, + }) { + _logger.finest('runSync: ${command.join(' ')}'); + return super.runSync( + command, + workingDirectory: workingDirectory, + environment: environment, + includeParentEnvironment: includeParentEnvironment, + runInShell: runInShell, + stdoutEncoding: stdoutEncoding, + stderrEncoding: stderrEncoding, + ); + } + + @override + Future start( + List command, { + String? workingDirectory, + Map? environment, + bool includeParentEnvironment = true, + bool runInShell = false, + ProcessStartMode mode = ProcessStartMode.normal, + }) { + _logger.finest('start: ${command.join(' ')}'); + return super.start( + command, + workingDirectory: workingDirectory, + environment: environment, + includeParentEnvironment: includeParentEnvironment, + runInShell: runInShell, + mode: mode, + ); + } +} diff --git a/apps/cli/lib/src/process/port_finder.dart b/apps/cli/lib/src/process/port_finder.dart new file mode 100644 index 000000000..892cd2132 --- /dev/null +++ b/apps/cli/lib/src/process/port_finder.dart @@ -0,0 +1,125 @@ +import 'dart:async'; +import 'dart:io'; + +abstract base class PortFinder { + const factory PortFinder(int initialPort) = DefaultPortFinder; + + const PortFinder._(); + + static const int maxPort = 65535; + static final List _ips = [ + InternetAddress.anyIPv4, + InternetAddress.loopbackIPv4, + ]; + + static Future checkPort(int port, [InternetAddress? ip]) async { + RangeError.checkValueInInterval(port, 0, maxPort, 'port', 'Invalid port'); + try { + final ips = ip == null ? _ips : [ip]; + for (final ip in ips) { + final socket = await ServerSocket.bind(ip, port); + await socket.close(); + } + return true; + } on SocketException { + return false; + } + } + + Future checkOrUpdatePort(int? port, {List? excluding}) async { + if (port != null && await checkPort(port)) { + if (excluding == null || !excluding.contains(port)) { + return port; + } + } + port = await findOpenPort(port); + if (excluding != null) { + while (excluding.contains(port)) { + port = await findOpenPort(port! + 1); + } + } + return port!; + } + + Future findOpenPort([int? startingPort]); +} + +/// {@template celest_cli.default_port_finder} +/// Finds an open port starting from [initialPort], incrementing by one until +/// [PortFinder.maxPort] is reached. +/// {@endtemplate} +final class DefaultPortFinder extends PortFinder { + /// {@macro celest_cli.default_port_finder} + const DefaultPortFinder(this.initialPort) + : assert(initialPort != 0, 'Use RandomPortFinder instead'), + assert( + initialPort > 0 && initialPort <= PortFinder.maxPort, + 'Invalid port. Must be >=0 <=${PortFinder.maxPort}.', + ), + super._(); + + /// The initial port to start searching from. + final int initialPort; + + @override + Future findOpenPort([int? startingPort]) async { + Future findOpenPort() async { + for ( + var port = startingPort ?? initialPort; + port <= PortFinder.maxPort; + port++ + ) { + if (await PortFinder.checkPort(port)) { + return port; + } + } + throw StateError( + 'No open ports found in range: >=$initialPort <=${PortFinder.maxPort}.', + ); + } + + return findOpenPort().timeout( + const Duration(seconds: 1), + onTimeout: () { + throw TimeoutException('Could not find an open port.'); + }, + ); + } +} + +/// {@template celest_cli.random_port_finder} +/// Finds a random, open port. +/// {@endtemplate} +final class RandomPortFinder extends PortFinder { + /// {@macro celest_cli.random_port_finder} + const RandomPortFinder() : super._(); + + static Future _randomPort() async { + final socket = await ServerSocket.bind(InternetAddress.loopbackIPv4, 0); + final port = socket.port; + await socket.close(); + return port; + } + + @override + Future findOpenPort([int? startingPort]) async { + if (startingPort != null && await PortFinder.checkPort(startingPort)) { + return startingPort; + } + + Future findOpenPort() async { + var port = await _randomPort(); + while (!await PortFinder.checkPort(port)) { + port = await _randomPort(); + } + return port; + } + + return findOpenPort().timeout( + const Duration(seconds: 1), + onTimeout: () { + throw TimeoutException('Could not find an open port.'); + }, + ); + } +} diff --git a/apps/cli/lib/src/process/process_info.dart b/apps/cli/lib/src/process/process_info.dart new file mode 100644 index 000000000..1c03b7e4d --- /dev/null +++ b/apps/cli/lib/src/process/process_info.dart @@ -0,0 +1,279 @@ +// Mostly copied from dartdev +// https://github.com/dart-lang/sdk/blob/904c8c2c39bf19841fb0fb1f4f527d9d42fee7f3/pkg/dartdev/lib/src/processes.dart + +import 'dart:convert'; + +import 'package:celest_cli/src/context.dart'; +import 'package:celest_cli/src/utils/error.dart'; +import 'package:logging/logging.dart'; + +final class Processes { + Processes._(this._processes); + + Processes._empty() : _processes = const []; + + static final _logger = Logger('Processes'); + + static Future load() async { + return switch (platform.operatingSystem) { + 'macos' || 'linux' => _loadUnix(), + 'windows' => _loadWindows(), + _ => unreachable(), + }; + } + + static Future _loadUnix() async { + final portInfoRes = await processManager.run( + [ + if (platform.environment.containsKey('CI')) 'sudo', + 'lsof', + '-nP', + '-iTCP', + '-sTCP:LISTEN', + ], + stdoutEncoding: utf8, + stderrEncoding: utf8, + ); + if (portInfoRes.exitCode != 0) { + _logger.finer( + 'Failed to get port info: ${portInfoRes.stdout}\n${portInfoRes.stderr}', + ); + return Processes._empty(); + } + final portInfo = Map.fromEntries( + LineSplitter.split(portInfoRes.stdout as String) + .skip(1) + .map((line) => line.trim()) + .where((line) => line.isNotEmpty) + .map(_PortInfo.parseUnix) + .where((portInfo) => portInfo.port != -1) + .map((portInfo) => MapEntry(portInfo.pid, portInfo.port)) + .toList(), + ); + final processesRes = await processManager.run( + [if (platform.environment.containsKey('CI')) 'sudo', 'ps', '-ef'], + stdoutEncoding: utf8, + stderrEncoding: utf8, + ); + if (processesRes.exitCode != 0) { + _logger.finer( + 'Failed to get processes: ${processesRes.stdout}\n${processesRes.stderr}', + ); + return Processes._empty(); + } + final processes = + LineSplitter.split(processesRes.stdout as String) + .skip(1) + .map((line) => line.trim()) + .where((line) => line.isNotEmpty) + .map((line) => ProcessInfo.parseUnix(line, portInfo)) + .toList(); + return Processes._(processes); + } + + static Future _loadWindows() async { + final portInfoRes = await processManager.run( + ['netstat', '-a', '-n', '-o'], + stdoutEncoding: utf8, + stderrEncoding: utf8, + ); + final portInfo = Map.fromEntries( + LineSplitter.split(portInfoRes.stdout as String) + .map((line) => line.trim()) + .where((line) => line.startsWith('TCP')) + .map(_PortInfo.parseWindows) + .nonNulls + .where((portInfo) => portInfo.port != -1) + .map((portInfo) => MapEntry(portInfo.pid, portInfo.port)) + .toList(), + ); + final processesRes = await processManager.run( + ['WMIC', 'path', 'win32_process', 'get', 'Processid,Commandline'], + stdoutEncoding: utf8, + stderrEncoding: utf8, + ); + if (processesRes.exitCode != 0) { + _logger.finer( + 'Failed to get processes: ${processesRes.stdout}\n${processesRes.stderr}', + ); + return Processes._empty(); + } + final processes = + LineSplitter.split(processesRes.stdout as String) + .skip(1) + .map((line) => line.trim()) + .where((line) => line.isNotEmpty) + .map((line) => ProcessInfo.parseWindows(line, portInfo)) + .nonNulls + .toList(); + return Processes._(processes); + } + + final List _processes; + + late final Map byPort = { + for (final process in _processes) + if (process.port case final port?) port: process, + }; + late final Map byPid = { + for (final process in _processes) process.pid: process, + }; +} + +final class ProcessInfo { + const ProcessInfo._({ + required this.pid, + required this.command, + required this.commandLine, + required this.port, + }); + + final int pid; + final String command; + final String commandLine; + final int? port; + + bool get isCelest => commandLine.contains('celest'); + + static ProcessInfo parseUnix(String line, Map portInfo) { + // 501 59214 758 0 11:52AM ttys002 0:00.00 grep celest + line = line.replaceAll(_whitespace, ' '); + + String nextWord() { + final index = line.indexOf(' '); + final word = line.substring(0, index); + line = line.substring(index + 1); + return word; + } + + nextWord(); // uid + final pid = int.parse(nextWord()); + nextWord(); // parentPid + nextWord(); // cpu + nextWord(); // startTime + nextWord(); // tty + nextWord(); // elapsedTime + final commandLine = line.trim(); + + return ProcessInfo._( + pid: pid, + command: _getCommandFrom(commandLine), + commandLine: commandLine, + port: portInfo[pid], + ); + } + + static ProcessInfo? parseWindows(String line, Map portInfo) { + // 640 + // winlogon.exe 712 + // C:\Windows\System32\svchost.exe -k LocalSystemNetworkRestricted -p -s NcbService 1136 + line = line.replaceAll(_whitespace, ' '); + + final parts = line.split(' '); + final pid = int.parse(parts.removeLast()); + final command = parts.isEmpty ? '' : parts.removeAt(0); + final commandLine = '$command ${parts.join(' ')}'; + + return ProcessInfo._( + pid: pid, + command: command, + commandLine: commandLine, + port: portInfo[pid], + ); + } + + @override + String toString() { + final buf = StringBuffer(); + buf.write('pid: $pid, '); + if (port != null) { + buf.write('port: $port, '); + } + buf.write('command: $commandLine'); + return buf.toString(); + } +} + +final class _PortInfo { + const _PortInfo({required this.pid, required this.port}); + + final int pid; + final int port; + + static _PortInfo parseUnix(String line) { + // rapportd 407 dillonnys 9u IPv4 0xc74632764e253baf 0t0 TCP *:49152 (LISTEN) + line = line.replaceAll(_whitespace, ' '); + + String nextWord() { + final index = line.indexOf(' '); + final word = line.substring(0, index); + line = line.substring(index + 1); + return word; + } + + nextWord(); // command + final pid = int.parse(nextWord()); + nextWord(); // user + nextWord(); // fd + nextWord(); // type + nextWord(); // device + nextWord(); // size + final node = nextWord(); + assert(node == 'TCP'); + + // *:49152 + // 127.0.0.1:49153 + // [::1]:8888 + final rawPortMap = nextWord(); + final portSeparator = rawPortMap.lastIndexOf(':'); + final address = rawPortMap.substring(0, portSeparator); + final rawPort = rawPortMap.substring(portSeparator + 1); + final port = switch (address) { + '0.0.0.0' || '127.0.0.1' || '*' || '[::1]' => int.parse(rawPort), + _ => -1, + }; + + return _PortInfo(pid: pid, port: port); + } + + static _PortInfo? parseWindows(String line) { + // TCP 0.0.0.0:135 0.0.0.0:0 LISTENING 824 + line = line.replaceAll(_whitespace, ' '); + + String nextWord() { + final index = line.indexOf(' '); + final word = line.substring(0, index); + if (index + 1 < line.length) { + line = line.substring(index + 1); + } else { + line = ''; + } + return word; + } + + final protocol = nextWord(); + assert(protocol == 'TCP'); + final rawPortMap = nextWord(); + final portSeparator = rawPortMap.lastIndexOf(':'); + final address = rawPortMap.substring(0, portSeparator); + final rawPort = rawPortMap.substring(portSeparator + 1); + final port = switch (address) { + '0.0.0.0' || '127.0.0.1' || '*' || '[::1]' => int.parse(rawPort), + _ => -1, + }; + nextWord(); // foreign address + + // state can be empty. always followed by port. + final stateOrPid = nextWord(); + final pid = int.tryParse(stateOrPid) ?? int.parse(line.trim()); + + return _PortInfo(pid: pid, port: port); + } +} + +final _whitespace = RegExp(r'\s+'); + +String _getCommandFrom(String commandLine) { + final command = commandLine.split(' ').first; + return command.split(platform.pathSeparator).last; +} diff --git a/apps/cli/lib/src/releases/celest_release_info.dart b/apps/cli/lib/src/releases/celest_release_info.dart new file mode 100644 index 000000000..b7cfa1298 --- /dev/null +++ b/apps/cli/lib/src/releases/celest_release_info.dart @@ -0,0 +1,55 @@ +import 'package:celest_cli/src/releases/version_converter.dart'; +import 'package:json_annotation/json_annotation.dart'; +import 'package:pub_semver/pub_semver.dart'; + +part 'celest_release_info.g.dart'; + +enum CelestReleaseSchemaVersion { v1 } + +const _serializable = JsonSerializable( + explicitToJson: true, + includeIfNull: false, + converters: [VersionConverter()], +); + +@_serializable +final class CelestReleasesInfo { + const CelestReleasesInfo({ + this.schemaVersion = CelestReleaseSchemaVersion.v1, + required this.latest, + this.latestDev, + required this.releases, + }); + + factory CelestReleasesInfo.fromJson(Map json) => + _$CelestReleasesInfoFromJson(json); + + static final baseUri = Uri.parse( + 'https://storage.googleapis.com/celest-release-artifacts/', + ); + + final CelestReleaseSchemaVersion schemaVersion; + final CelestReleaseInfo latest; + final CelestReleaseInfo? latestDev; + final Map releases; + + Map toJson() => _$CelestReleasesInfoToJson(this); +} + +@_serializable +final class CelestReleaseInfo { + const CelestReleaseInfo({required this.version, this.installer, this.zip}) + : assert( + installer != null || zip != null, + 'Either installer or zip must be provided.', + ); + + factory CelestReleaseInfo.fromJson(Map json) => + _$CelestReleaseInfoFromJson(json); + + final Version version; + final String? zip; + final String? installer; + + Map toJson() => _$CelestReleaseInfoToJson(this); +} diff --git a/apps/cli/lib/src/releases/celest_release_info.g.dart b/apps/cli/lib/src/releases/celest_release_info.g.dart new file mode 100644 index 000000000..96ce9973a --- /dev/null +++ b/apps/cli/lib/src/releases/celest_release_info.g.dart @@ -0,0 +1,69 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'celest_release_info.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +CelestReleasesInfo _$CelestReleasesInfoFromJson(Map json) => + CelestReleasesInfo( + schemaVersion: $enumDecodeNullable( + _$CelestReleaseSchemaVersionEnumMap, json['schemaVersion']) ?? + CelestReleaseSchemaVersion.v1, + latest: + CelestReleaseInfo.fromJson(json['latest'] as Map), + latestDev: json['latestDev'] == null + ? null + : CelestReleaseInfo.fromJson( + json['latestDev'] as Map), + releases: (json['releases'] as Map).map( + (k, e) => + MapEntry(k, CelestReleaseInfo.fromJson(e as Map)), + ), + ); + +Map _$CelestReleasesInfoToJson(CelestReleasesInfo instance) { + final val = { + 'schemaVersion': + _$CelestReleaseSchemaVersionEnumMap[instance.schemaVersion]!, + 'latest': instance.latest.toJson(), + }; + + void writeNotNull(String key, dynamic value) { + if (value != null) { + val[key] = value; + } + } + + writeNotNull('latestDev', instance.latestDev?.toJson()); + val['releases'] = instance.releases.map((k, e) => MapEntry(k, e.toJson())); + return val; +} + +const _$CelestReleaseSchemaVersionEnumMap = { + CelestReleaseSchemaVersion.v1: 'v1', +}; + +CelestReleaseInfo _$CelestReleaseInfoFromJson(Map json) => + CelestReleaseInfo( + version: const VersionConverter().fromJson(json['version'] as String), + installer: json['installer'] as String?, + zip: json['zip'] as String?, + ); + +Map _$CelestReleaseInfoToJson(CelestReleaseInfo instance) { + final val = { + 'version': const VersionConverter().toJson(instance.version), + }; + + void writeNotNull(String key, dynamic value) { + if (value != null) { + val[key] = value; + } + } + + writeNotNull('zip', instance.zip); + writeNotNull('installer', instance.installer); + return val; +} diff --git a/apps/cli/lib/src/releases/latest_release.dart b/apps/cli/lib/src/releases/latest_release.dart new file mode 100644 index 000000000..8dd9ff1c1 --- /dev/null +++ b/apps/cli/lib/src/releases/latest_release.dart @@ -0,0 +1,44 @@ +import 'dart:convert'; +import 'dart:ffi'; + +import 'package:celest_cli/src/context.dart'; +import 'package:celest_cli/src/exceptions.dart'; +import 'package:celest_cli/src/releases/celest_release_info.dart'; +import 'package:collection/collection.dart'; +import 'package:pub_semver/pub_semver.dart'; + +final _releasesEndpoint = CelestReleasesInfo.baseUri.resolve( + '${Abi.current()}/releases.json', +); + +Future retrieveCliReleases() async { + final releasesResp = await httpClient.get(_releasesEndpoint); + if (releasesResp.statusCode != 200) { + throw CliException( + 'Failed to fetch the latest releases. Please check your internet ' + 'connection and try again.', + additionalContext: { + 'statusCode': releasesResp.statusCode.toString(), + 'body': releasesResp.body, + }, + ); + } + + final releasesJson = jsonDecode(releasesResp.body) as Map; + return CelestReleasesInfo.fromJson(releasesJson); +} + +Future retrieveLatestRelease( + String packageVersion, { + bool includeDev = false, +}) async { + final releasesInfo = await retrieveCliReleases(); + final currentVersion = Version.parse(packageVersion); + if (currentVersion.isPreRelease || includeDev) { + return maxBy([ + if (releasesInfo.latestDev case final latestDev?) latestDev, + ...releasesInfo.releases.values, + ], (release) => release.version)!; + } + return releasesInfo.latest; +} diff --git a/apps/cli/lib/src/releases/version_converter.dart b/apps/cli/lib/src/releases/version_converter.dart new file mode 100644 index 000000000..60d870b2d --- /dev/null +++ b/apps/cli/lib/src/releases/version_converter.dart @@ -0,0 +1,12 @@ +import 'package:json_annotation/json_annotation.dart'; +import 'package:pub_semver/pub_semver.dart'; + +final class VersionConverter implements JsonConverter { + const VersionConverter(); + + @override + Version fromJson(String json) => Version.parse(json); + + @override + String toJson(Version object) => object.toString(); +} diff --git a/apps/cli/lib/src/sdk/dart_sdk.dart b/apps/cli/lib/src/sdk/dart_sdk.dart new file mode 100644 index 000000000..0abae6736 --- /dev/null +++ b/apps/cli/lib/src/sdk/dart_sdk.dart @@ -0,0 +1,370 @@ +// Below is modified from Dart SDK `package:dartdev` + +import 'dart:ffi'; +import 'dart:io'; + +import 'package:celest_cli/src/context.dart'; +import 'package:celest_cli/src/exceptions.dart'; +import 'package:celest_cli/src/sdk/dart_sdk.dart'; +import 'package:logging/logging.dart'; +import 'package:process/process.dart'; +// ignore: implementation_imports +import 'package:process/src/interface/common.dart'; +import 'package:pub_semver/pub_semver.dart'; + +export 'package:celest_ast/celest_ast.dart' show SdkType; + +/// A utility class for finding and referencing paths within the Dart SDK. +class Sdk { + factory Sdk(String sdkRoot, {required SdkType sdkType, Version? version}) => + switch (sdkType) { + SdkType.dart => Sdk.dart(sdkRoot, version: version), + SdkType.flutter => Sdk.flutter(sdkRoot, version: version), + _ => throw ArgumentError.value(sdkType, 'sdkType'), + }; + + Sdk._({required this.sdkPath, this.flutterSdkRoot, Version? version}) + : sdkType = flutterSdkRoot == null ? SdkType.dart : SdkType.flutter, + _version = version; + + Sdk.flutter(String sdkRoot, {Version? version}) + : this._( + sdkPath: p.join(sdkRoot, 'bin', 'cache', 'dart-sdk'), + flutterSdkRoot: sdkRoot, + version: version, + ); + + Sdk.dart(this.sdkPath, {Version? version}) + : flutterSdkRoot = null, + sdkType = SdkType.dart, + _version = version; + + static Sdk current = load(); + + /// Path to SDK directory. + final String sdkPath; + + final SdkType sdkType; + + /// The SDK's semantic versioning version (x.y.z-a.b.channel). + Version get version => _version ??= _parseVersion(sdkPath); + + Version? _version; + + /// The Flutter SDK's semantic versioning version (x.y.z-a.b.channel). + late final Version? flutterVersion = + flutterSdkRoot == null ? null : _parseVersion(flutterSdkRoot!); + + /// If using the Flutter SDK, the root directory of the Flutter SDK. + /// + /// This is used in executions of `pub` to ensure that pub can correctly + /// fallback to the Flutter SDK as needed. + final String? flutterSdkRoot; + + /// The identifier of the current platform for Flutter artifacts. + late final String flutterOsArtifacts = () { + final osDir = switch (Abi.current()) { + Abi.macosX64 || Abi.macosArm64 => 'darwin-x64', + Abi.linuxX64 || Abi.linuxArm64 => 'linux-x64', + Abi.windowsX64 || Abi.windowsArm64 => 'windows-x64', + final unknownAbi => throw UnsupportedError('Unknown ABI: $unknownAbi'), + }; + return p.join( + flutterSdkRoot!, + 'bin', + 'cache', + 'artifacts', + 'engine', + osDir, + ); + }(); + + Version _parseVersion(String path) { + final versionFile = localFileSystem.file(p.join(path, 'version')); + if (!versionFile.existsSync()) { + throw StateError( + 'Could not find Dart SDK version file at ${versionFile.path}.', + ); + } + return Version.parse(versionFile.readAsStringSync().trim()); + } + + String get dart => p.join(sdkPath, 'bin', 'dart'); + + String get dartAotRuntime => p.join(sdkPath, 'bin', 'dartaotruntime'); + + String get analysisServerSnapshot => + p.absolute(sdkPath, 'bin', 'snapshots', 'analysis_server.dart.snapshot'); + + String get dart2jsSnapshot => + p.absolute(sdkPath, 'bin', 'snapshots', 'dart2js.dart.snapshot'); + + String get ddsSnapshot => + p.absolute(sdkPath, 'bin', 'snapshots', 'dds.dart.snapshot'); + + String get ddsAotSnapshot => + p.absolute(sdkPath, 'bin', 'snapshots', 'dds_aot.dart.snapshot'); + + String get frontendServerSnapshot => + p.absolute(sdkPath, 'bin', 'snapshots', 'frontend_server.dart.snapshot'); + + String? get flutterPatchedSdk => + flutterSdkRoot == null + ? null + : p.absolute( + flutterSdkRoot!, + 'bin', + 'cache', + 'artifacts', + 'engine', + 'common', + 'flutter_patched_sdk', + ); + + String get flutterTester => p.join(flutterOsArtifacts, 'flutter_tester'); + + // flutterSdkRoot == null + // ? p.absolute( + // sdkPath, + // 'bin', + // 'snapshots', + // 'frontend_server.dart.snapshot', + // ) + // : p.absolute( + // flutterSdkRoot!, + // 'bin', + // 'cache', + // 'artifacts', + // 'engine', + // flutterArtifactOS, + // 'frontend_server.dart.snapshot', + // ); + + String get frontendServerAotSnapshot => p.absolute( + sdkPath, + 'bin', + 'snapshots', + 'frontend_server_aot.dart.snapshot', + ); + + // flutterSdkRoot == null + // ? p.absolute( + // sdkPath, + // 'bin', + // 'snapshots', + // 'frontend_server_aot.dart.snapshot', + // ) + // : p.absolute( + // flutterSdkRoot!, + // 'bin', + // 'cache', + // 'artifacts', + // 'engine', + // flutterArtifactOS, + // 'frontend_server_aot.dart.snapshot', + // ); + + String get genKernelAotSnapshot => + p.join(sdkPath, 'bin', 'snapshots', 'gen_kernel_aot.dart.snapshot'); + + String get genSnapshot => p.absolute(sdkPath, 'bin', 'utils', 'gen_snapshot'); + + String get devToolsBinaries => + p.absolute(sdkPath, 'bin', 'resources', 'devtools'); + + String? get flutterPlatformDill => + flutterSdkRoot == null + ? null + : p.absolute( + flutterSdkRoot!, + 'bin', + 'cache', + 'artifacts', + 'engine', + 'common', + 'flutter_patched_sdk', + 'platform_strong.dill', + ); + + String? get flutterPlatformProductDill => + flutterSdkRoot == null + ? null + : p.absolute( + flutterSdkRoot!, + 'bin', + 'cache', + 'artifacts', + 'engine', + 'common', + 'flutter_patched_sdk_product', + 'platform_strong.dill', + ); + + String get vmPlatformDill => + p.absolute(sdkPath, 'lib', '_internal', 'vm_platform_strong.dill'); + + String get vmPlatformProductDill => p.absolute( + sdkPath, + 'lib', + '_internal', + 'vm_platform_strong_product.dill', + ); + + /// The version when the new bytecode format and compiler was [introduced](https://github.com/dart-lang/sdk/commit/3abf78212c480cbbbfd43f6382ff262532c90e4d). + /// + /// Currently, the SDK does not bundle the `dart2bytecode` tool, so this + /// version just signifies the runtime version that supports the new bytecode + /// format. + static final bytecodeVersion = Version.parse('3.6.0-133.0.dev'); + + /// Whether or not the current SDK supports the new bytecode format. + /// + /// Trying to use the `dart2bytecode` tool on an SDK that does not support + /// the new bytecode format will result in an error. + bool get supportsBytecode { + return version >= bytecodeVersion; + } + + /// Follows links when resolving an executable's [path]. + static String _resolveLinks(String path) { + if (fileSystem.isLinkSync(path)) { + return p.canonicalize(fileSystem.link(path).resolveSymbolicLinksSync()); + } + return p.canonicalize(path); + } + + static Sdk load() { + // Find SDK path. + + bool isValid(String sdkPath) => + fileSystem.isDirectorySync(p.join(sdkPath, 'bin', 'snapshots')); + + String? flutterPath; + try { + flutterPath = getExecutablePath( + 'flutter', + fileSystem.currentDirectory.path, + platform: platform, + fs: fileSystem, + throwOnFailure: true, + ); + } on ProcessPackageExecutableNotFoundException catch (e) { + _logger.finest('Could not find Flutter SDK in PATH.', e); + } + if (flutterPath != null) { + flutterPath = _resolveLinks(flutterPath); + final sdkPath = p.canonicalize( + p.join(p.dirname(flutterPath), 'cache', 'dart-sdk'), + ); + _logger.finest('Checking if Flutter: $flutterPath -> $sdkPath'); + if (!isValid(sdkPath)) { + throw const CliException('Could not find Flutter SDK.'); + } + return Sdk._( + sdkPath: sdkPath, + flutterSdkRoot: p.canonicalize(p.dirname(p.dirname(flutterPath))), + ); + } + + // The common case, and how cli_util.dart computes the Dart SDK directory, + // [path.dirname] called twice on Platform.resolvedExecutable. We confirm by + // asserting that the directory `./bin/snapshots/` exists in this directory: + final resolvedExecutable = _resolveLinks(platform.resolvedExecutable); + + var sdkPath = p.dirname(p.dirname(resolvedExecutable)); + _logger.finest( + 'Checking resolved executable: $resolvedExecutable -> $sdkPath', + ); + String? flutterSdkRoot; + if (!isValid(sdkPath)) { + // If the common case fails, we try to find the SDK path by looking for + // the `dart` executable in the PATH environment variable. + String? dartPath; + try { + dartPath = getExecutablePath( + 'dart', + fileSystem.currentDirectory.path, + platform: platform, + fs: fileSystem, + throwOnFailure: true, + ); + } on ProcessPackageExecutableNotFoundException catch (e) { + _logger.finest('Could not find Dart SDK in PATH.', e); + } + if (dartPath == null) { + throw const CliException('Could not find Dart SDK.'); + } + dartPath = _resolveLinks(dartPath); + sdkPath = switch (p.basename(dartPath)) { + // `dart` and `flutter` are aliased to /usr/bin/snap on Ubuntu snap installation. + // See `/snap/flutter/current/env.sh` + 'snap' => p.join( + platform.environment['HOME']!, + 'snap', + 'flutter', + 'common', + 'flutter', + 'bin', + 'cache', + 'dart-sdk', + ), + // `sdk/bin/dart` -> `sdk` + _ => p.dirname(p.dirname(dartPath)), + }; + _logger.finest('Checking resolved PATH: $dartPath -> $sdkPath'); + if (!isValid(sdkPath)) { + // Check if using Dart from Flutter SDK. + // `flutter/bin/dart` -> `flutter/bin/cache/dart-sdk` + sdkPath = p.join(p.dirname(dartPath), 'cache', 'dart-sdk'); + _logger.finest('Checking if Flutter: $dartPath -> $sdkPath'); + if (!isValid(sdkPath)) { + throw const CliException('Could not find Dart SDK.'); + } + flutterSdkRoot = p.dirname(p.dirname(dartPath)); + } + } + + _logger.finest('Found Dart SDK: $sdkPath'); + + return Sdk._( + sdkPath: p.canonicalize(sdkPath), + flutterSdkRoot: + flutterSdkRoot == null ? null : p.canonicalize(flutterSdkRoot), + ); + } + + static final _logger = Logger('Sdk'); +} + +/// Information about the current runtime. +class Runtime { + Runtime._(this.version, this.channel); + + static Runtime current = _createSingleton(); + + /// The SDK's semantic versioning version (x.y.z-a.b.channel). + final String version; + + /// The SDK's release channel (`be`, `dev`, `beta`, `stable`). + /// + /// May be null if [Platform.version] does not have the expected format. + final String? channel; + + static Runtime _createSingleton() { + final versionString = platform.version; + // Expected format: "version (channel) ..." + var version = versionString; + String? channel; + final versionEnd = versionString.indexOf(' '); + if (versionEnd > 0) { + version = versionString.substring(0, versionEnd); + var channelEnd = versionString.indexOf(' ', versionEnd + 1); + if (channelEnd < 0) channelEnd = versionString.length; + if (versionString.startsWith('(', versionEnd + 1) && + versionString.startsWith(')', channelEnd - 1)) { + channel = versionString.substring(versionEnd + 2, channelEnd - 1); + } + } + return Runtime._(version, channel); + } +} diff --git a/apps/cli/lib/src/sdk/sdk_finder.dart b/apps/cli/lib/src/sdk/sdk_finder.dart new file mode 100644 index 000000000..06d7c53bb --- /dev/null +++ b/apps/cli/lib/src/sdk/sdk_finder.dart @@ -0,0 +1,320 @@ +import 'dart:io'; + +import 'package:celest_ast/celest_ast.dart'; +import 'package:celest_cli/src/context.dart'; +import 'package:dcli/dcli.dart' as dcli; +import 'package:logging/logging.dart'; +import 'package:process/process.dart'; +// ignore: implementation_imports +import 'package:process/src/interface/common.dart'; +import 'package:pub_semver/pub_semver.dart'; + +abstract interface class SdkFinder { + const SdkFinder(); + + Future> findSdk(); +} + +sealed class SdkFinderResult { + const SdkFinderResult(); + + LocalSdk? get sdk => null; +} + +final class LocalSdk { + const LocalSdk({ + required this.type, + required this.path, + required this.version, + }); + + final T type; + final String path; + final Version version; + + @override + String toString() => '$type $version at $path'; +} + +final class SdkFound extends SdkFinderResult { + SdkFound(this.sdk); + + @override + final LocalSdk sdk; + + @override + String toString() => 'Found SDK: $sdk'; +} + +final class SdkNotFound extends SdkFinderResult { + const SdkNotFound({this.searchPath = const [], this.candidates = const []}); + + final List searchPath; + final List candidates; + + @override + String toString() { + final buffer = StringBuffer('Could not find SDK'); + if (candidates.isNotEmpty) { + buffer.writeln(' candidates:'); + for (final candidate in candidates) { + buffer.writeln(' - $candidate'); + } + } + if (searchPath.isNotEmpty) { + buffer.writeln(' search path:'); + for (final path in searchPath) { + buffer.writeln(' - $path'); + } + } + return buffer.toString(); + } +} + +typedef DartSdkResult = SdkFinderResult; +typedef DartSdk = LocalSdk; + +final class DartSdkFinder implements SdkFinder { + const DartSdkFinder(); + + static final Logger _logger = Logger('Sdk'); + + /// Follows links when resolving an executable's [path]. + static String _resolveLinks(String path) { + if (localFileSystem.isLinkSync(path)) { + return p.canonicalize( + localFileSystem.link(path).resolveSymbolicLinksSync(), + ); + } + return p.canonicalize(path); + } + + static bool isValid(String sdkPath) => + localFileSystem.isDirectorySync(p.join(sdkPath, 'bin', 'snapshots')); + + static Future _found(SdkType type, String sdkPath) async { + final versionStr = + await localFileSystem + .directory(sdkPath) + .childFile('version') + .readAsString(); + return LocalSdk( + type: type, + path: sdkPath, + version: Version.parse(versionStr.trim()), + ); + } + + Future _findFlutterExe() async { + late String flutterPath; + try { + flutterPath = + getExecutablePath( + 'flutter', + localFileSystem.currentDirectory.path, + platform: platform, + fs: localFileSystem, + throwOnFailure: true, + )!; // never null when `throwOnFailure: true` + } on ProcessPackageExecutableNotFoundException catch (e) { + _logger.finest('Could not find Flutter SDK in PATH.', e); + return SdkNotFound(searchPath: e.candidates); + } + + final searchPath = []; + final candidates = []; + + candidates.add(flutterPath); + flutterPath = _resolveLinks(flutterPath); + candidates.add(flutterPath); + final sdkPath = p.canonicalize( + p.join(p.dirname(flutterPath), 'cache', 'dart-sdk'), + ); + + searchPath.add(sdkPath); + _logger.finest('Checking if Flutter: $flutterPath -> $sdkPath'); + if (isValid(sdkPath)) { + final flutterSdkPath = p.canonicalize(p.dirname(p.dirname(flutterPath))); + return SdkFound(await _found(SdkType.flutter, flutterSdkPath)); + } + + return SdkNotFound(searchPath: searchPath, candidates: candidates); + } + + Future _findDartExe() async { + late String dartPath; + try { + dartPath = + getExecutablePath( + 'dart', + localFileSystem.currentDirectory.path, + platform: platform, + fs: localFileSystem, + throwOnFailure: true, + )!; // never null when `throwOnFailure: true` + } on ProcessPackageExecutableNotFoundException catch (e) { + _logger.finest('Could not find Dart SDK in PATH.', e); + return SdkNotFound(searchPath: e.searchPath, candidates: e.candidates); + } + + final searchPath = []; + final candidates = []; + + dartPath = _resolveLinks(dartPath); + candidates.add(dartPath); + var sdkPath = switch (p.basename(dartPath)) { + // `dart` and `flutter` are aliased to /usr/bin/snap on Ubuntu snap installation. + // See `/snap/flutter/current/env.sh` + 'snap' => p.join( + platform.environment['HOME']!, + 'snap', + 'flutter', + 'common', + 'flutter', + 'bin', + 'cache', + 'dart-sdk', + ), + // `sdk/bin/dart` -> `sdk` + _ => p.dirname(p.dirname(dartPath)), + }; + searchPath.add(sdkPath); + + _logger.finest('Checking if Dart: $dartPath -> $sdkPath'); + if (isValid(sdkPath)) { + return SdkFound(await _found(SdkType.dart, sdkPath)); + } + + // Check if using Dart from Flutter SDK. + // `flutter/bin/dart` -> `flutter/bin/cache/dart-sdk` + sdkPath = p.join(p.dirname(dartPath), 'cache', 'dart-sdk'); + searchPath.add(sdkPath); + + _logger.finest('Checking if Flutter: $dartPath -> $sdkPath'); + if (isValid(sdkPath)) { + final flutterSdkPath = p.dirname(p.dirname(dartPath)); + return SdkFound(await _found(SdkType.flutter, flutterSdkPath)); + } + + return SdkNotFound(searchPath: searchPath, candidates: candidates); + } + + @override + Future> findSdk() async { + storage.clear(); + // Check for existing Flutter SDK preference. + if (storage.read('sdk.flutter.preferred') + case final preferredFlutterPath?) { + // Ensure the preferred path is still valid. + final sdkPath = p.join(preferredFlutterPath, 'bin', 'cache', 'dart-sdk'); + if (isValid(sdkPath)) { + return SdkFound(await _found(SdkType.flutter, preferredFlutterPath)); + } else { + _logger.finest( + 'Invalid preferred Flutter SDK path: $preferredFlutterPath', + ); + // Otherwise, clear the preference. + storage.delete('sdk.flutter.preferred'); + storage.delete('sdk.dart.preferred'); + } + } + + // Do the same check for Dart + if (storage.read('sdk.dart.preferred') case final preferredDartPath?) { + if (isValid(preferredDartPath)) { + return SdkFound(await _found(SdkType.dart, preferredDartPath)); + } else { + _logger.finest('Invalid preferred Dart SDK path: $preferredDartPath'); + storage.delete('sdk.dart.preferred'); + } + } + + final fullSearchPath = []; + final allCandidates = []; + + // Start by looking for the Flutter SDK. + // + // If we find it, we'll have found the Dart SDK as well. + try { + final flutterExeResult = await _findFlutterExe(); + switch (flutterExeResult) { + case SdkFound(): + return flutterExeResult; + case SdkNotFound(:final searchPath, :final candidates): + fullSearchPath.addAll(searchPath); + allCandidates.addAll(candidates); + } + } on Object catch (e, st) { + _logger.finest('Unexpected error searching for Flutter SDK', e, st); + } + + // The common case, and how cli_util.dart computes the Dart SDK directory, + // [path.dirname] called twice on Platform.resolvedExecutable. We confirm by + // asserting that the directory `./bin/snapshots/` exists in this directory: + final resolvedExecutable = _resolveLinks(platform.resolvedExecutable); + + final sdkPath = p.dirname(p.dirname(resolvedExecutable)); + _logger.finest( + 'Checking resolved executable: $resolvedExecutable -> $sdkPath', + ); + if (isValid(sdkPath)) { + return SdkFound(await _found(SdkType.dart, sdkPath)); + } + + // If the common case fails, we try to find the SDK path by looking for + // the `dart` executable in the PATH environment variable. + try { + final dartExeResult = await _findDartExe(); + switch (dartExeResult) { + case SdkFound(): + return dartExeResult; + case SdkNotFound(:final searchPath, :final candidates): + fullSearchPath.addAll(searchPath); + allCandidates.addAll(candidates); + } + } on Object catch (e, st) { + _logger.finest('Unexpected error searching for Dart SDK', e, st); + } + + // If we get here, we couldn't find the SDK. + // + // Prompt the user as a last resort. + _logger.finest( + 'Could not find the Flutter or Dart SDK.', + SdkNotFound(searchPath: fullSearchPath, candidates: allCandidates), + ); + cliLogger.err('Could not find the Flutter SDK.'); + final alreadyInstalled = dcli.confirm( + 'Have you installed it already?', + defaultValue: true, + ); + if (alreadyInstalled) { + final homeDir = platform.environment['HOME']; + String? flutterSdkPath; + while (flutterSdkPath == null) { + flutterSdkPath = dcli.ask('Please enter the path to the Flutter SDK:'); + if (flutterSdkPath.startsWith('~/')) { + flutterSdkPath = p.join(homeDir!, flutterSdkPath.substring(2)); + } + flutterSdkPath = p.canonicalize(flutterSdkPath); + final sdkPath = p.join(flutterSdkPath, 'bin', 'cache', 'dart-sdk'); + if (!isValid(sdkPath)) { + cliLogger.err('Invalid Flutter SDK path: $flutterSdkPath'); + flutterSdkPath = null; + continue; + } + final sdk = await _found(SdkType.flutter, flutterSdkPath); + + // Save the preference for later so we don't need to prompt again. + storage.write('sdk.flutter.preferred', flutterSdkPath); + storage.write('sdk.dart.preferred', sdkPath); + return SdkFound(sdk); + } + } + + // TODO(dnys1): Consider installing it for them. + cliLogger.warn('Please install the Flutter SDK before continuing.'); + cliLogger.info('https://flutter.dev/docs/get-started/install'); + await Future(() => exit(1)); + } +} diff --git a/apps/cli/lib/src/sdk/versions.dart b/apps/cli/lib/src/sdk/versions.dart new file mode 100644 index 000000000..c59b3774e --- /dev/null +++ b/apps/cli/lib/src/sdk/versions.dart @@ -0,0 +1,7 @@ +import 'package:pub_semver/pub_semver.dart'; + +/// The minimum supported Dart SDK version. +final minSupportedDartSdk = Version(3, 4, 0); + +/// The minimum supported Flutter SDK version. +final minSupportedFlutterSdk = Version(3, 22, 0); diff --git a/apps/cli/lib/src/storage/storage.dart b/apps/cli/lib/src/storage/storage.dart new file mode 100644 index 000000000..966119a8d --- /dev/null +++ b/apps/cli/lib/src/storage/storage.dart @@ -0,0 +1,39 @@ +import 'package:native_storage/native_storage.dart' as core; +import 'package:uuid/uuid.dart'; + +extension type Storage._(core.NativeStorage _impl) + implements core.NativeStorage { + factory Storage() { + return Storage._(core.NativeStorage(namespace: cliNamespace)); + } + + Storage.memory() : this._(core.NativeMemoryStorage(namespace: cliNamespace)); + + /// This will not be included in the generated binary, so we must provide it. + static const String cliNamespace = 'dev.celest.cli'; +} + +extension CelestStorage on core.NativeStorage { + Future<({String distinctId, String deviceId})> init() async { + final storage = isolated; + var (distinctId, deviceId) = await ( + storage.read('distinctId'), + storage.read('deviceId'), + ).wait; + if (deviceId == null) { + deviceId = const Uuid().v7(); + await storage.write('deviceId', deviceId); + } + if (distinctId == null) { + distinctId = deviceId; + await storage.write('distinctId', deviceId); + } + return (distinctId: distinctId, deviceId: deviceId); + } + + Future readDeviceId() async => (await init()).deviceId; + Future readDistinctId() async => (await init()).distinctId; + Future writeDistinctId(String distinctId) async { + await isolated.write('distinctId', distinctId); + } +} diff --git a/apps/cli/lib/src/types/dart_types.dart b/apps/cli/lib/src/types/dart_types.dart new file mode 100644 index 000000000..4ea30a987 --- /dev/null +++ b/apps/cli/lib/src/types/dart_types.dart @@ -0,0 +1,1073 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + +import 'dart:async'; +import 'dart:convert' as convert; +import 'dart:io' as io; +import 'dart:typed_data'; + +import 'package:built_collection/built_collection.dart' as built_collection; +import 'package:built_value/built_value.dart' as built_value; +import 'package:built_value/json_object.dart' as built_value_json_object; +import 'package:built_value/serializer.dart' as built_value_serializer; +import 'package:celest/celest.dart' as celest; +import 'package:celest/src/runtime/serve.dart' as celest_runtime; +import 'package:celest_auth/celest_auth.dart' as celest_auth; +import 'package:celest_cli/src/types/type_checker.dart'; +import 'package:celest_cli/src/utils/reference.dart'; +import 'package:celest_core/celest_core.dart' as celest_core; +import 'package:celest_core/src/util/globals.dart' as celest_globals; +import 'package:code_builder/code_builder.dart'; +import 'package:collection/collection.dart' as collection; +import 'package:fixnum/fixnum.dart'; +import 'package:http/http.dart' as http; +import 'package:http_parser/http_parser.dart' as http_parser; +import 'package:libcoder/libcoder.dart' as libcoder; +import 'package:meta/meta.dart' as meta; +import 'package:native_storage/native_storage.dart' as native_storage; +import 'package:path/path.dart' as path; +import 'package:shelf/shelf.dart' as shelf; + +final class DartTypeReference extends Reference { + const DartTypeReference(super.symbol, [super.url, this.wireType]); + + String get typeUri => '$url#$symbol'; + final Reference? wireType; + + static final _checkerCache = {}; + + TypeChecker get checker => _checkerCache[this] ??= _checker; + TypeChecker get _checker { + assert(url != null); + return TypeChecker.fromUrl(typeUri); + } +} + +final _allTypes = () { + final container = _DartTypeContainer(); + container.add(DartTypes.core.bigInt); + container.add(DartTypes.core.bool); + container.add(DartTypes.core.dateTime); + container.add(DartTypes.core.deprecated); + container.add(DartTypes.core.double); + container.add(DartTypes.core.duration); + container.add(DartTypes.core.dynamic); + container.add(DartTypes.core.exception); + container.add(DartTypes.core.function); + container.add(DartTypes.core.int); + container.add(DartTypes.core.mapEntry); + container.add(DartTypes.core.never); + container.add(DartTypes.core.null$); + container.add(DartTypes.core.object); + container.add(DartTypes.core.override); + container.add(DartTypes.core.regExp); + container.add(DartTypes.core.stackTrace); + container.add(DartTypes.core.stateError); + container.add(DartTypes.core.string); + container.add(DartTypes.core.type); + container.add(DartTypes.core.uri); + container.add(DartTypes.core.uriData); + container.add(DartTypes.core.void$); + container.add(DartTypes.typedData.uint8List); + return container; +}(); + +class _DartTypeContainer { + final Map _types = {}; + + void add(DartTypeReference type) { + _types[type.typeUri] = type; + } +} + +/// Common type references used throughout code generation. +abstract class DartTypes { + DartTypes._(); + + static DartTypeReference? fromUri(String uri) => _allTypes._types[uri]; + + /// `dart:core` types. + static const core = _Core(); + + /// `dart:async` types. + static const async = _Async(); + + /// `package:built_value` types. + static const builtValue = BuiltValueType._(); + + /// `package:celest` types. + static const celest = _Celest(); + + /// `package:celest_auth` types. + static const celestAuth = _CelestAuth(); + + /// `package:collection` types. + static const collection = _Collection(); + + /// `dart:convert` types. + static const convert = _Convert(); + + /// `package:cross_file` types. + static const crossFile = _XFile(); + + /// `package:drift` types. + static const drift = _Drift(); + + /// `package:fixnum` types. + static const fixNum = FixNum(); + + /// `package:flutter` types. + static const flutter = _Flutter(); + + /// `package:functions_framework` types. + static const functionsFramework = _FunctionsFramework(); + + /// Access to various global values. + static const globals = _Globals(); + + /// `package:http` types. + static const http = _Http(); + + /// `package:http_parser` types. + static const httpParser = _HttpParser(); + + /// `dart:io` types. + static const io = _Io(); + + /// `dart:isolate` types. + static const isolate = _Isolate(); + + /// `package:libcoder` types. + static const libcoder = _Libcoder(); + + /// `package:meta` types. + static const meta = _Meta(); + + /// `package:native_storage` types. + static const nativeStorage = _NativeStorage(); + + /// `package:path` types. + static const path = _Path(); + + /// `package:shelf` types. + static const shelf = _Shelf(); + + /// `package:shelf_router` types. + static const shelfRouter = ShelfRouter(); + + /// `package:test` types. + static const test = _Test(); + + /// `dart:typed_data` types. + static const typedData = _TypedData(); +} + +/// `dart:core` types +class _Core { + const _Core(); + + static const _url = 'dart:core'; + + /// Creates a [ArgumentError] reference. + DartTypeReference get argumentError => + const DartTypeReference('ArgumentError', _url); + + /// Creates a [AssertionError] reference. + DartTypeReference get assertionError => + const DartTypeReference('AssertionError', _url); + + /// Creates a [BigInt] reference. + DartTypeReference get bigInt => DartTypeReference('BigInt', _url, string); + + /// Creates a [bool] reference. + DartTypeReference get bool => const DartTypeReference('bool', _url); + + /// Creates a [ConcurrentModificationError] reference. + DartTypeReference get concurrentModificationError => + const DartTypeReference('ConcurrentModificationError', _url); + + /// Creates a [DateTime] reference. + DartTypeReference get dateTime => DartTypeReference('DateTime', _url, string); + + /// Creates a [Deprecated] reference. + DartTypeReference get deprecated => + const DartTypeReference('Deprecated', _url); + + /// Creates a [double] reference. + DartTypeReference get double => const DartTypeReference('double', _url); + + /// Creates a [Duration] reference. + DartTypeReference get duration => + DartTypeReference('Duration', _url, map(string, object.nullable)); + + /// Creates a [dynamic] reference. + DartTypeReference get dynamic => const DartTypeReference('dynamic', _url); + + /// Creates a [Error] reference. + DartTypeReference get error => const DartTypeReference('Error', _url); + + /// Creates a [Exception] reference. + DartTypeReference get exception => const DartTypeReference('Exception', _url); + + /// Creates a [FormatException] reference. + DartTypeReference get formatException => + const DartTypeReference('FormatException', _url); + + /// Creates a [Function] reference. + DartTypeReference get function => const DartTypeReference('Function', _url); + + /// Creates a [Future] reference. + Reference future([Reference? ref]) => TypeReference( + (t) => + t + ..symbol = 'Future' + ..url = _url + ..types.addAll([if (ref != null) ref]), + ); + + /// Creates a [IndexError] reference. + DartTypeReference get indexError => + const DartTypeReference('IndexError', _url); + + /// Creates an [int] reference. + DartTypeReference get int => const DartTypeReference('int', _url); + + /// Creates a [Iterable] reference. + Reference iterable([Reference? ref]) => TypeReference( + (t) => + t + ..symbol = 'Iterable' + ..url = _url + ..types.addAll([if (ref != null) ref]), + ); + + /// Creates a [List] reference. + Reference list([Reference? ref]) => TypeReference( + (t) => + t + ..symbol = 'List' + ..url = _url + ..types.addAll([if (ref != null) ref]), + ); + + /// Creates a [Map] reference. + Reference map([Reference? key, Reference? value]) => TypeReference( + (t) => + t + ..symbol = 'Map' + ..url = _url + ..types.addAll([ + if (key != null) key, + if (key != null && value != null) value, + ]), + ); + + /// Creates an [MapEntry] reference. + DartTypeReference get mapEntry => const DartTypeReference('MapEntry', _url); + + /// Creates a [OutOfMemoryError] reference. + DartTypeReference get outOfMemoryError => + const DartTypeReference('OutOfMemoryError', _url); + + /// Creates an [Never] reference. + DartTypeReference get never => const DartTypeReference('Never', _url); + + /// Creates a [NoSuchMethodError] reference. + DartTypeReference get noSuchMethodError => + const DartTypeReference('NoSuchMethodError', _url); + + /// Creates a [Null] reference. + DartTypeReference get null$ => const DartTypeReference('Null', _url); + + /// Creates a [num] reference. + DartTypeReference get num => const DartTypeReference('num', _url); + + /// Creates an [Object] reference. + DartTypeReference get object => const DartTypeReference('Object', _url); + + /// Creates a [override] reference. + DartTypeReference get override => const DartTypeReference('override', _url); + + /// Creates a [RangeError] reference. + DartTypeReference get rangeError => + const DartTypeReference('RangeError', _url); + + /// Creates a [RegExp] reference. + DartTypeReference get regExp => DartTypeReference('RegExp', _url, string); + + /// Creates a [Set] reference. + Reference set(Reference ref) => TypeReference( + (t) => + t + ..symbol = 'Set' + ..url = _url + ..types.add(ref), + ); + + /// Creates a [StackOverflowError] reference. + DartTypeReference get stackOverflowError => + const DartTypeReference('StackOverflowError', _url); + + /// Creates a [StackTrace] reference. + DartTypeReference get stackTrace => + DartTypeReference('StackTrace', _url, string); + + /// Create a [StateError] reference. + DartTypeReference get stateError => + const DartTypeReference('StateError', _url); + + /// Creates a [Stream] reference. + Reference stream([Reference? ref]) => TypeReference( + (t) => + t + ..symbol = 'Stream' + ..url = _url + ..types.addAll([if (ref != null) ref]), + ); + + /// Creates a [String] reference. + DartTypeReference get string => const DartTypeReference('String', _url); + + /// Creates a [StringBuffer] reference. + DartTypeReference get stringBuffer => + const DartTypeReference('StringBuffer', _url); + + /// Creates a [Type] reference. + DartTypeReference get type => const DartTypeReference('Type', _url); + + /// Creates a [TypeError] reference. + DartTypeReference get typeError => const DartTypeReference('TypeError', _url); + + /// Create a [UnimplementedError] reference. + DartTypeReference get unimplementedError => + const DartTypeReference('UnimplementedError', _url); + + /// Create a [UnsupportedError] reference. + DartTypeReference get unsupportedError => + const DartTypeReference('UnsupportedError', _url); + + /// Creates a [Uri] reference. + DartTypeReference get uri => DartTypeReference('Uri', _url, string); + + /// Creates a [UriData] reference. + DartTypeReference get uriData => DartTypeReference('UriData', _url, string); + + /// Creates a `void` reference. + DartTypeReference get void$ => const DartTypeReference('void', _url); +} + +/// `dart:async` types +class _Async { + const _Async(); + + static const _url = 'dart:async'; + + /// Creates a [FutureOr] reference. + Reference futureOr(Reference ref) => TypeReference( + (t) => + t + ..symbol = 'FutureOr' + ..url = _url + ..types.add(ref), + ); + + /// Creates a `runZoned` refererence. + DartTypeReference get runZoned => const DartTypeReference('runZoned', _url); +} + +/// `package:built_value` types +class BuiltValueType { + const BuiltValueType._(); + + static const mainUrl = 'package:built_value/built_value.dart'; + static const serializerUrl = 'package:built_value/serializer.dart'; + static const jsonUrl = 'package:built_value/json_object.dart'; + static const collectionUrl = 'package:built_collection/built_collection.dart'; + + /// A [built_value.BuiltValue] reference. + DartTypeReference get builtValue => + const DartTypeReference('BuiltValue', mainUrl); + + /// A [built_value.BuiltValueField] reference. + DartTypeReference get builtValueField => + const DartTypeReference('BuiltValueField', mainUrl); + + /// A [built_value.BuiltValueHook] reference. + DartTypeReference get builtValueHook => + const DartTypeReference('BuiltValueHook', mainUrl); + + /// Creates a [built_value.Built] reference for [ref] and its builder class, + /// [builderRef]. + Reference built(Reference ref, Reference builderRef) => TypeReference( + (t) => + t + ..symbol = 'Built' + ..url = mainUrl + ..types.addAll([ref, builderRef]), + ); + + /// Creates a [built_collection.BuiltList] reference for generic type [ref]. + Reference builtList(Reference ref) => TypeReference( + (t) => + t + ..symbol = 'BuiltList' + ..url = collectionUrl + ..types.add(ref), + ); + + /// Creates a [built_collection.BuiltListMultimap] reference with key [key] + /// and [value] generic types. + /// + /// For example, a key of [String] and value of [String] creates + /// a `BuiltListMultimap` which is the same a + /// `Map>` when built. + Reference builtListMultimap(Reference key, Reference value) => TypeReference( + (t) => + t + ..symbol = 'BuiltListMultimap' + ..url = collectionUrl + ..types.addAll([key, value]), + ); + + /// Creates a [built_collection.BuiltMap] reference with [key] and [value] + /// generic types. + Reference builtMap(Reference key, Reference value) => TypeReference( + (t) => + t + ..symbol = 'BuiltMap' + ..url = collectionUrl + ..types.add(key) + ..types.add(value), + ); + + /// Creates a [built_collection.BuiltSet] reference for generic type [ref]. + Reference builtSet(Reference ref) => TypeReference( + (t) => + t + ..symbol = 'BuiltSet' + ..url = collectionUrl + ..types.add(ref), + ); + + /// Creates a [built_collection.BuiltSetMultimap] reference with key [key] + /// and [value] generic types. + /// + /// For example, a key of [String] and value of [String] creates + /// a `BuiltSetMultimap` which is the same a + /// `Map>` when built. + Reference builtSetMultimap(Reference key, Reference value) => TypeReference( + (t) => + t + ..symbol = 'BuiltSetMultimap' + ..url = collectionUrl + ..types.addAll([key, value]), + ); + + /// Creates a [built_value_serializer.FullType] reference. + DartTypeReference get fullType => + const DartTypeReference('FullType', serializerUrl); + + /// Creates a [built_value_json_object.JsonObject] reference. + DartTypeReference get jsonObject => + const DartTypeReference('JsonObject', jsonUrl); + + /// The builder for [built_collection.ListBuilder]. + Reference listBuilder(Reference ref) => TypeReference( + (t) => + t + ..symbol = 'ListBuilder' + ..url = collectionUrl + ..types.add(ref), + ); + + /// The builder for [built_collection.BuiltListMultimap]. + Reference listMultimapBuilder(Reference key, Reference value) => + TypeReference( + (t) => + t + ..symbol = 'ListMultimapBuilder' + ..url = collectionUrl + ..types.addAll([key, value]), + ); + + /// The builder for [built_collection.MapBuilder]. + Reference mapBuilder(Reference key, Reference value) => TypeReference( + (t) => + t + ..symbol = 'MapBuilder' + ..url = collectionUrl + ..types.addAll([key, value]), + ); + + /// Creates a [built_value.newBuiltValueToStringHelper] reference. + DartTypeReference get newBuiltValueToStringHelper => + const DartTypeReference('newBuiltValueToStringHelper', mainUrl); + + /// Creates a [built_value_serializer.PrimitiveSerializer] reference for + /// generic type [ref]. + Reference primitiveSerializer(Reference ref) => TypeReference( + (t) => + t + ..symbol = 'PrimitiveSerializer' + ..url = serializerUrl + ..types.add(ref), + ); + + /// The builder for [built_collection.SetBuilder]. + Reference setBuilder(Reference ref) => TypeReference( + (t) => + t + ..symbol = 'SetBuilder' + ..url = collectionUrl + ..types.add(ref), + ); + + /// The builder for [built_collection.BuiltSetMultimap]. + Reference setMultimapBuilder(Reference key, Reference value) => TypeReference( + (t) => + t + ..symbol = 'SetMultimapBuilder' + ..url = collectionUrl + ..types.addAll([key, value]), + ); + + /// Creates a [built_value_serializer.Serializers] reference. + DartTypeReference get serializers => + const DartTypeReference('Serializers', serializerUrl); +} + +/// Access to various global values. +class _Globals { + const _Globals(); + + static const _celestGlobalsUrl = 'package:celest_core/src/util/globals.dart'; + + /// Creates a [celest_globals.kIsWeb] reference. + DartTypeReference get kIsWeb => + const DartTypeReference('kIsWeb', _celestGlobalsUrl); +} + +/// `package:celest` types +class _Celest { + const _Celest(); + + static const _url = 'package:celest/celest.dart'; + static const _coreUrl = 'package:celest_core/celest_core.dart'; + static const _runtimeUrl = 'package:celest/src/runtime/serve.dart'; + static const _contextUrl = 'package:celest/src/core/context.dart'; + + /// Creates a [celest_runtime.AuthMiddleware] reference. + DartTypeReference get authMiddleware => + const DartTypeReference('AuthMiddleware', _runtimeUrl); + + /// Creates a [celest.BadRequestException] reference. + DartTypeReference get badRequestException => + const DartTypeReference('BadRequestException', _coreUrl); + + /// Creates a [celest.CloudApi] reference. + DartTypeReference get cloudApi => const DartTypeReference('CloudApi', _url); + + /// Creates a [celest.CloudException] reference. + DartTypeReference get cloudException => + const DartTypeReference('CloudException', _coreUrl); + + /// Creates a [celest.CloudFunction] reference. + Reference get cloudFunction => const DartTypeReference('CloudFunction', _url); + + /// Creates a [celest.CloudWidget] reference. + DartTypeReference get cloudWidget => + const DartTypeReference('CloudWidget', _url); + + /// Creates a [celest.Context] reference. + DartTypeReference get context => + const DartTypeReference('Context', _contextUrl); + + /// Creates a [celest.Environment] reference. + DartTypeReference get environment => + const DartTypeReference('Environment', _url); + + /// Creates a [celest.env] reference. + DartTypeReference get environmentVariable => + const DartTypeReference('env', _url); + + /// Creates a [celest.secret] reference. + DartTypeReference get secret => const DartTypeReference('secret', _url); + + /// Creates a [celest_runtime.FirebaseAuthMiddleware] reference. + DartTypeReference get firebaseAuthMiddleware => + const DartTypeReference('FirebaseAuthMiddleware', _runtimeUrl); + + /// Creates a [celest_core.InternalServerError] reference. + DartTypeReference get internalServerError => + const DartTypeReference('InternalServerError', _coreUrl); + + /// Creates a [celest_core.JsonList] reference. + DartTypeReference get jsonList => + const DartTypeReference('JsonList', _coreUrl); + + /// Creates a [celest_core.JsonMap] reference. + DartTypeReference get jsonMap => const DartTypeReference('JsonMap', _coreUrl); + + /// Creates a [celest_core.JsonValue] reference. + DartTypeReference get jsonValue => + const DartTypeReference('JsonValue', _coreUrl); + + /// Creates a [celest_core.JsonUtf8] reference. + DartTypeReference get jsonUtf8 => + const DartTypeReference('JsonUtf8', _coreUrl); + + /// Creates a [celest_runtime.Middleware] reference. + DartTypeReference get middleware => + const DartTypeReference('Middleware', _runtimeUrl); + + /// Creates a [celest_core.Serializer] reference. + TypeReference serializer([Reference? dartType]) => TypeReference( + (t) => + t + ..symbol = 'Serializer' + ..url = _coreUrl + ..types.addAll([if (dartType != null) dartType]), + ); + + /// Creates a [celest_core.SerializationException] reference. + DartTypeReference get serializationException => + const DartTypeReference('SerializationException', _coreUrl); + + /// Creates a [celest_core.Serializers] reference. + DartTypeReference get serializers => + const DartTypeReference('Serializers', _coreUrl); + + /// Creates a [celest_runtime.SupabaseAuthMiddleware] reference. + DartTypeReference get supabaseAuthMiddleware => + const DartTypeReference('SupabaseAuthMiddleware', _runtimeUrl); + + /// Creates a [celest_core.TypeToken] reference. + DartTypeReference get typeToken => + const DartTypeReference('TypeToken', _coreUrl); + + /// Creates a [celest_runtime.serve] reference. + DartTypeReference get serve => const DartTypeReference('serve', _runtimeUrl); + + /// Creates a [celest_runtime.CloudFunctionTarget] reference. + DartTypeReference get cloudFunctionTarget => + const DartTypeReference('CloudFunctionTarget', _runtimeUrl); + + /// Creates a [celest_runtime.CloudFunctionHttpTarget] reference. + DartTypeReference get cloudFunctionHttpTarget => + const DartTypeReference('CloudFunctionHttpTarget', _runtimeUrl); + + /// Creates a [celest_runtime.CloudEventSourceTarget] reference. + DartTypeReference get cloudEventSourceTarget => + const DartTypeReference('CloudEventSourceTarget', _runtimeUrl); + + /// Creates a `context` reference. + DartTypeReference get globalContext => + const DartTypeReference('context', _contextUrl); + + /// Creates a `ContextKey` reference. + DartTypeReference get contextKey => + const DartTypeReference('ContextKey', _contextUrl); +} + +/// `package:celest_auth` types +class _CelestAuth { + const _CelestAuth(); + + static const _url = 'package:celest_auth/celest_auth.dart'; + + /// Creates a [celest_auth.AuthProviderType] reference. + DartTypeReference get authProviderType => + const DartTypeReference('AuthProviderType', _url); + + /// Creates a [celest_auth.TokenSource] reference. + DartTypeReference get tokenSource => + const DartTypeReference('TokenSource', _url); +} + +class _Collection { + const _Collection(); + + static const _url = 'package:collection/collection.dart'; + + /// Creates a [collection.DelegatingList] reference. + TypeReference delegatingList(TypeReference elementType) => TypeReference( + (t) => + t + ..symbol = 'DelegatingList' + ..url = _url + ..types.add(elementType), + ); + + /// Creates a [collection.DelegatingMap] reference. + TypeReference delegatingMap(Reference keyType, Reference valueType) => + TypeReference( + (t) => + t + ..symbol = 'DelegatingMap' + ..url = _url + ..types.addAll([keyType, valueType]), + ); + + /// Creates a [collection.DelegatingSet] reference. + TypeReference delegatingSet(TypeReference elementType) => TypeReference( + (t) => + t + ..symbol = 'DelegatingSet' + ..url = _url + ..types.add(elementType), + ); +} + +/// `dart:convert` types +class _Convert { + const _Convert(); + + static const _url = 'dart:convert'; + + /// Creates a [convert.base64Decode] reference. + DartTypeReference get base64Decode => + const DartTypeReference('base64Decode', _url); + + /// Creates a [convert.base64Encode] reference. + DartTypeReference get base64Encode => + const DartTypeReference('base64Encode', _url); + + /// Creates a [convert.json] reference. + DartTypeReference get json => const DartTypeReference('json', _url); + + /// Creates a [convert.jsonEncode] reference. + DartTypeReference get jsonEncode => + const DartTypeReference('jsonEncode', _url); + + /// Creates a [convert.JsonUtf8Encoder] reference. + DartTypeReference get jsonUtf8Encoder => + const DartTypeReference('JsonUtf8Encoder', _url); + + /// Creates a [convert.jsonDecode] reference. + DartTypeReference get jsonDecode => + const DartTypeReference('jsonDecode', _url); + + /// Creates a [convert.utf8] reference. + DartTypeReference get utf8 => const DartTypeReference('utf8', _url); +} + +/// `package:drift` types +class _Drift { + const _Drift(); + DartTypeReference get queryExecutor => const DartTypeReference( + 'QueryExecutor', + 'package:drift/src/runtime/executor/executor.dart', + ); + DartTypeReference get generatedDatabase => const DartTypeReference( + 'GeneratedDatabase', + 'package:drift/src/runtime/api/runtime_api.dart', + ); + DartTypeReference get nativeDatabase => + const DartTypeReference('NativeDatabase', 'package:drift/native.dart'); + DartTypeReference get hranaDatabase => const DartTypeReference( + 'HranaDatabase', + 'package:drift_hrana/drift_hrana.dart', + ); +} + +/// `package:libcoder` types +class _Libcoder { + const _Libcoder(); + + static const _url = 'package:libcoder/libcoder.dart'; + + /// Creates a [libcoder.coder] reference. + TypeReference get coder$ => TypeReference( + (t) => + t + ..symbol = 'coder' + ..url = _url, + ); + + /// Creates a [libcoder.Decoder] reference. + TypeReference decoder([Reference? valueType]) => TypeReference( + (t) => + t + ..symbol = 'Decoder' + ..url = _url + ..types.addAll([if (valueType != null) valueType]), + ); + + /// Creates a [libcoder.Encoder] reference. + TypeReference encoder([Reference? valueType]) => TypeReference( + (t) => + t + ..symbol = 'Encoder' + ..url = _url + ..types.addAll([if (valueType != null) valueType]), + ); + + /// Creates a [libcoder.GlobalCoder] reference. + TypeReference get globalCoder => TypeReference( + (t) => + t + ..symbol = 'GlobalCoder' + ..url = _url, + ); + + /// Creates a [libcoder.CoderConfig] reference. + TypeReference coderConfig([Reference? valueType]) => TypeReference( + (t) => + t + ..symbol = 'CoderConfig' + ..url = _url + ..types.addAll([if (valueType != null) valueType]), + ); + + /// Creates a [libcoder.Coder] reference. + TypeReference coderProtocol([Reference? valueType]) => TypeReference( + (t) => + t + ..symbol = 'Coder' + ..url = _url + ..types.addAll([if (valueType != null) valueType]), + ); + + /// Creates a [libcoder.FormFieldsEncoder] reference. + TypeReference get formFieldsEncoder => TypeReference( + (t) => + t + ..symbol = 'FormFieldsEncoder' + ..url = _url, + ); + + /// Creates a [libcoder.Typeref] reference. + TypeReference typeref([Reference? valueType]) => TypeReference( + (t) => + t + ..symbol = 'Typeref' + ..url = _url + ..types.addAll([if (valueType != null) valueType]), + ); +} + +/// `package:flutter` types +class _Flutter { + const _Flutter(); + + static const _servicesUrl = 'package:flutter/services.dart'; + static const _dartUiUrl = 'dart:ui'; + + /// Creates a [flutter.RootIsolateToken] reference. + DartTypeReference get rootIsolateToken => + const DartTypeReference('RootIsolateToken', _dartUiUrl); + + /// Creates a [flutter.ServicesBinding] reference. + DartTypeReference get servicesBiding => + const DartTypeReference('ServicesBinding', _servicesUrl); + + /// Creates a [flutter.BackgroundIsolateBinaryMessenger] reference. + DartTypeReference get backgroundIsolateBinaryMessenger => + const DartTypeReference('BackgroundIsolateBinaryMessenger', _servicesUrl); +} + +/// `package:fixnum` types +class FixNum { + const FixNum(); + + static const url = 'package:fixnum/fixnum.dart'; + + /// Creates an [Int64] reference. + DartTypeReference get int64 => const DartTypeReference('Int64', url); +} + +/// `package:functions_framework` types +class _FunctionsFramework { + const _FunctionsFramework(); + + static const _url = 'package:functions_framework/serve.dart'; + + /// Creates a [functions_framework.serve] reference. + DartTypeReference get serve => const DartTypeReference('serve', _url); +} + +class _Http { + const _Http(); + + static const _url = 'package:http/http.dart'; + + /// Creates a [http.BaseClient] reference. + DartTypeReference get baseClient => + const DartTypeReference('BaseClient', _url); + + /// Creates a [http.Client] reference. + DartTypeReference get client => const DartTypeReference('Client', _url); + + /// Creates a [http.BaseResponse] reference. + DartTypeReference get baseResponse => + const DartTypeReference('BaseResponse', _url); + + /// Creates a [http.MultipartFile] reference. + DartTypeReference get multipartFile => + const DartTypeReference('MultipartFile', _url); + + /// Creates a [http.MultipartRequest] reference. + DartTypeReference get multipartRequest => + const DartTypeReference('MultipartRequest', _url); + + /// Creates a [http.Request] reference. + DartTypeReference get request => const DartTypeReference('Request', _url); + + /// Creates a [http.Response] reference. + DartTypeReference get response => const DartTypeReference('Response', _url); + + /// Creates a [http.StreamedRequest] reference. + DartTypeReference get streamedRequest => + const DartTypeReference('StreamedRequest', _url); + + /// Creates a [http.StreamedResponse] reference. + DartTypeReference get streamedResponse => + const DartTypeReference('StreamedResponse', _url); +} + +class _HttpParser { + const _HttpParser(); + + static const _url = 'package:http_parser/http_parser.dart'; + + /// Creates a [http_parser.MediaType] reference. + DartTypeReference get mediaType => const DartTypeReference('MediaType', _url); +} + +/// `dart:io` types +class _Io { + const _Io(); + + static const _url = 'dart:io'; + + /// Creates a [io.File] reference. + DartTypeReference get file => const DartTypeReference('File', _url); + + /// Creates a [io.Platform] reference. + DartTypeReference get platform => const DartTypeReference('Platform', _url); + + /// Creates a [io.stdout] reference. + DartTypeReference get stdout => const DartTypeReference('stdout', _url); +} + +/// `dart:isolate` types +class _Isolate { + const _Isolate(); + + static const _url = 'dart:isolate'; + + /// Creates an [isolate.Isolate] reference. + Reference get isolate => TypeReference( + (t) => + t + ..symbol = 'Isolate' + ..url = _url, + ); + + /// Creates a [isolate.SendPort] reference. + DartTypeReference get sendPort => const DartTypeReference('SendPort', _url); +} + +/// `package:meta` types. +class _Meta { + const _Meta(); + + static const _url = 'package:meta/meta.dart'; + + /// Creates a [meta.experimental] reference. + DartTypeReference get experimental => + const DartTypeReference('experimental', _url); + + /// Creates a [meta.internal] reference. + DartTypeReference get internal => const DartTypeReference('internal', _url); + + /// Creates a [meta.immutable] reference. + DartTypeReference get immutable => const DartTypeReference('immutable', _url); +} + +/// `package:native_storage` types +class _NativeStorage { + const _NativeStorage(); + + static const _url = 'package:native_storage/native_storage.dart'; + + /// Creates a [native_storage.NativeStorage] reference. + DartTypeReference get nativeStorage => + const DartTypeReference('NativeStorage', _url); +} + +/// `package:path` types +class _Path { + const _Path(); + + static const _url = 'package:path/path.dart'; + + /// Creates a [path.join] reference. + DartTypeReference get join => const DartTypeReference('join', _url); +} + +/// `package:shelf` types +class _Shelf { + const _Shelf(); + + static const _url = 'package:shelf/shelf.dart'; + + /// Creates a [shelf.Handler] reference. + DartTypeReference get handler => const DartTypeReference('Handler', _url); + + /// Creates a [shelf.Middleware] reference. + DartTypeReference get middleware => + const DartTypeReference('Middleware', _url); + + /// Creates a [shelf.Pipeline] reference. + DartTypeReference get pipeline => const DartTypeReference('Pipeline', _url); + + /// Creates a [shelf.Request] reference. + DartTypeReference get request => const DartTypeReference('Request', _url); + + /// Creates a [shelf.Response] reference. + DartTypeReference get response => const DartTypeReference('Response', _url); +} + +/// `package:shelf_router` types +class ShelfRouter { + const ShelfRouter(); + + static const url = 'package:shelf_router/shelf_router.dart'; + + /// Creates a [shelf_router.Route] reference. + DartTypeReference get route => const DartTypeReference('Route', url); + + /// Creates a [shelf_router.Router] reference. + DartTypeReference get router => const DartTypeReference('Router', url); +} + +/// `package:test` types +class _Test { + const _Test(); + + static const _url = 'package:test/test.dart'; + + /// Creates an `test` reference. + DartTypeReference get test => const DartTypeReference('test', _url); +} + +/// `dart:typed_data` types +class _TypedData { + const _TypedData(); + + static const _url = 'dart:typed_data'; + + /// Creates a [Uint8List] reference. + DartTypeReference get uint8List => + DartTypeReference('Uint8List', _url, DartTypes.core.string); +} + +class _XFile { + const _XFile(); + + static const _url = 'package:cross_file/cross_file.dart'; + + /// Creates a [cross_file.XFile] reference. + DartTypeReference get xFile => const DartTypeReference('XFile', _url); +} diff --git a/apps/cli/lib/src/types/type_checker.dart b/apps/cli/lib/src/types/type_checker.dart new file mode 100644 index 000000000..8f7d36ef4 --- /dev/null +++ b/apps/cli/lib/src/types/type_checker.dart @@ -0,0 +1,405 @@ +// Helpers for comparing types. +// +// This is a copy of the code from package:source_gen/source_gen.dart which +// includes only code not dependent on `dart:mirrors`. +library; + +import 'dart:io'; + +import 'package:analyzer/dart/analysis/results.dart'; +import 'package:analyzer/dart/ast/ast.dart'; +import 'package:analyzer/dart/constant/value.dart'; +import 'package:analyzer/dart/element/element.dart'; +import 'package:analyzer/dart/element/type.dart'; +import 'package:path/path.dart' as p; +import 'package:source_span/source_span.dart'; +import 'package:yaml/yaml.dart'; + +/// An abstraction around doing static type checking at compile/build time. +abstract base class TypeChecker { + const TypeChecker(); + + /// Creates a new [TypeChecker] that delegates to other [checkers]. + /// + /// This implementation will return `true` for type checks if _any_ of the + /// provided type checkers return true, which is useful for deprecating an + /// API: + /// ```dart + /// const $Foo = const TypeChecker.fromRuntime(Foo); + /// const $Bar = const TypeChecker.fromRuntime(Bar); + /// + /// // Used until $Foo is deleted. + /// const $FooOrBar = const TypeChecker.forAny(const [$Foo, $Bar]); + /// ``` + const factory TypeChecker.any(Iterable checkers) = _AnyChecker; + + /// Create a new [TypeChecker] backed by a static [type]. + const factory TypeChecker.fromStatic(DartType type) = _LibraryTypeChecker; + + /// Create a new [TypeChecker] backed by a library [url]. + /// + /// Example of referring to a `LinkedHashMap` from `dart:collection`: + /// ```dart + /// const linkedHashMap = const TypeChecker.fromUrl( + /// 'dart:collection#LinkedHashMap', + /// ); + /// ``` + /// + /// **NOTE**: This is considered a more _brittle_ way of determining the type + /// because it relies on knowing the _absolute_ path (i.e. after resolved + /// `export` directives). You should ideally only use `fromUrl` when you know + /// the full path (likely you own/control the package) or it is in a stable + /// package like in the `dart:` SDK. + const factory TypeChecker.fromUrl(dynamic url) = _UriTypeChecker; + + /// Returns the first constant annotating [element] assignable to this type. + /// + /// Otherwise returns `null`. + /// + /// Throws on unresolved annotations unless [throwOnUnresolved] is `false`. + DartObject? firstAnnotationOf( + Element element, { + bool throwOnUnresolved = true, + }) { + if (element.metadata.isEmpty) { + return null; + } + final results = annotationsOf( + element, + throwOnUnresolved: throwOnUnresolved, + ); + return results.isEmpty ? null : results.first; + } + + /// Returns if a constant annotating [element] is assignable to this type. + /// + /// Throws on unresolved annotations unless [throwOnUnresolved] is `false`. + bool hasAnnotationOf(Element element, {bool throwOnUnresolved = true}) => + firstAnnotationOf(element, throwOnUnresolved: throwOnUnresolved) != null; + + /// Returns the first constant annotating [element] that is exactly this type. + /// + /// Throws [UnresolvedAnnotationException] on unresolved annotations unless + /// [throwOnUnresolved] is explicitly set to `false` (default is `true`). + DartObject? firstAnnotationOfExact( + Element element, { + bool throwOnUnresolved = true, + }) { + if (element.metadata.isEmpty) { + return null; + } + final results = annotationsOfExact( + element, + throwOnUnresolved: throwOnUnresolved, + ); + return results.isEmpty ? null : results.first; + } + + /// Returns if a constant annotating [element] is exactly this type. + /// + /// Throws [UnresolvedAnnotationException] on unresolved annotations unless + /// [throwOnUnresolved] is explicitly set to `false` (default is `true`). + bool hasAnnotationOfExact(Element element, {bool throwOnUnresolved = true}) => + firstAnnotationOfExact(element, throwOnUnresolved: throwOnUnresolved) != + null; + + DartObject? _computeConstantValue( + Element element, + int annotationIndex, { + bool throwOnUnresolved = true, + }) { + final annotation = element.metadata[annotationIndex]; + final result = annotation.computeConstantValue(); + if (result == null && throwOnUnresolved) { + throw UnresolvedAnnotationException._from(element, annotationIndex); + } + return result; + } + + /// Returns annotating constants on [element] assignable to this type. + /// + /// Throws [UnresolvedAnnotationException] on unresolved annotations unless + /// [throwOnUnresolved] is explicitly set to `false` (default is `true`). + Iterable annotationsOf( + Element element, { + bool throwOnUnresolved = true, + }) => _annotationsWhere( + element, + isAssignableFromType, + throwOnUnresolved: throwOnUnresolved, + ); + + Iterable _annotationsWhere( + Element element, + bool Function(DartType) predicate, { + bool throwOnUnresolved = true, + }) sync* { + for (var i = 0; i < element.metadata.length; i++) { + final value = _computeConstantValue( + element, + i, + throwOnUnresolved: throwOnUnresolved, + ); + if (value?.type != null && predicate(value!.type!)) { + yield value; + } + } + } + + /// Returns annotating constants on [element] of exactly this type. + /// + /// Throws [UnresolvedAnnotationException] on unresolved annotations unless + /// [throwOnUnresolved] is explicitly set to `false` (default is `true`). + Iterable annotationsOfExact( + Element element, { + bool throwOnUnresolved = true, + }) => _annotationsWhere( + element, + isExactlyType, + throwOnUnresolved: throwOnUnresolved, + ); + + /// Returns `true` if the type of [element] can be assigned to this type. + bool isAssignableFrom(Element element) => + isExactly(element) || + (element is InterfaceElement && element.allSupertypes.any(isExactlyType)); + + /// Returns `true` if [staticType] can be assigned to this type. + bool isAssignableFromType(DartType staticType) => + isAssignableFrom(staticType.element!); + + /// Returns `true` if representing the exact same class as [element]. + bool isExactly(Element element); + + /// Returns `true` if representing the exact same type as [staticType]. + bool isExactlyType(DartType staticType) => switch (staticType.element) { + final element? => isExactly(element), + _ => false, + }; + + /// Returns `true` if representing a super class of [element]. + /// + /// This check only takes into account the *extends* hierarchy. If you wish + /// to check mixins and interfaces, use [isAssignableFrom]. + bool isSuperOf(Element element) { + if (element is InterfaceElement) { + var theSuper = element.supertype; + + do { + if (isExactlyType(theSuper!)) { + return true; + } + + theSuper = theSuper.superclass; + } while (theSuper != null); + } + + return false; + } + + /// Returns `true` if representing a super type of [staticType]. + /// + /// This only takes into account the *extends* hierarchy. If you wish + /// to check mixins and interfaces, use [isAssignableFromType]. + bool isSuperTypeOf(DartType staticType) => isSuperOf(staticType.element!); +} + +// Checks a static type against another static type; +final class _LibraryTypeChecker extends TypeChecker { + const _LibraryTypeChecker(this._type); + + final DartType _type; + + @override + bool isExactly(Element element) => + element is InterfaceElement && element == _type.element; + + @override + String toString() => urlOfElement(_type.element!); +} + +// Checks a runtime type against an Uri and Symbol. +final class _UriTypeChecker extends TypeChecker { + const _UriTypeChecker(dynamic url) : _url = '$url'; + + final String _url; + + // Precomputed cache of String --> Uri. + static final _cache = Expando(); + + @override + bool operator ==(Object o) => o is _UriTypeChecker && o._url == _url; + + @override + int get hashCode => _url.hashCode; + + /// Url as a [Uri] object, lazily constructed. + Uri get uri => _cache[this] ??= normalizeUrl(Uri.parse(_url)); + + /// Returns whether this type represents the same as [url]. + bool hasSameUrl(dynamic url) => + uri.toString() == + (url is String ? url : normalizeUrl(url as Uri).toString()); + + @override + bool isExactly(Element element) => hasSameUrl(urlOfElement(element)); + + @override + String toString() => '$uri'; +} + +final class _AnyChecker extends TypeChecker { + const _AnyChecker(this._checkers); + + final Iterable _checkers; + + @override + bool isExactly(Element element) => _checkers.any((c) => c.isExactly(element)); +} + +/// Returns a URL representing [element]. +String urlOfElement(Element element) => switch (element.kind) { + ElementKind.DYNAMIC => 'dart:core#dynamic', + ElementKind.NEVER => 'dart:core#Never', + // using librarySource.uri – in case the element is in a part + _ => + normalizeUrl( + element.librarySource!.uri, + ).replace(fragment: element.name).toString(), +}; + +Uri normalizeUrl(Uri url) { + switch (url.scheme) { + case 'dart': + return normalizeDartUrl(url); + case 'package': + return _packageToAssetUrl(url); + case 'file': + return _fileToAssetUrl(url); + default: + return url; + } +} + +/// Make `dart:`-type URLs look like a user-knowable path. +/// +/// Some internal dart: URLs are something like `dart:core/map.dart`. +/// +/// This isn't a user-knowable path, so we strip out extra path segments +/// and only expose `dart:core`. +Uri normalizeDartUrl(Uri url) => + url.pathSegments.isNotEmpty + ? url.replace(pathSegments: url.pathSegments.take(1)) + : url; + +Uri _fileToAssetUrl(Uri url) { + if (!p.isWithin(p.url.current, url.path)) return url; + return Uri( + scheme: 'asset', + path: p.join(_rootPackageName, p.relative(url.path)), + ); +} + +/// Returns a `package:` URL converted to a `asset:` URL. +/// +/// This makes internal comparison logic much easier, but still allows users +/// to define assets in terms of `package:`, which is something that makes more +/// sense to most. +/// +/// For example, this transforms `package:source_gen/source_gen.dart` into: +/// `asset:source_gen/lib/source_gen.dart`. +Uri _packageToAssetUrl(Uri url) => + url.scheme == 'package' + ? url.replace( + scheme: 'asset', + pathSegments: [ + url.pathSegments.first, + 'lib', + ...url.pathSegments.skip(1), + ], + ) + : url; + +final String _rootPackageName = () { + final name = + (loadYaml(File('pubspec.yaml').readAsStringSync()) as Map)['name']; + if (name is! String) { + throw StateError( + 'Your pubspec.yaml file is missing a `name` field or it isn\'t ' + 'a String.', + ); + } + return name; +}(); + +/// Exception thrown when [TypeChecker] fails to resolve a metadata annotation. +/// +/// Methods such as [TypeChecker.firstAnnotationOf] may throw this exception +/// when one or more annotations are not resolvable. This is usually a sign that +/// something was misspelled, an import is missing, or a dependency was not +/// defined (for build systems such as Bazel). +class UnresolvedAnnotationException implements Exception { + /// Creates an exception from an annotation ([annotationIndex]) that was not + /// resolvable while traversing [Element.metadata] on [annotatedElement]. + factory UnresolvedAnnotationException._from( + Element annotatedElement, + int annotationIndex, + ) { + final sourceSpan = _findSpan(annotatedElement, annotationIndex); + return UnresolvedAnnotationException._(annotatedElement, sourceSpan); + } + + const UnresolvedAnnotationException._( + this.annotatedElement, + this.annotationSource, + ); + + /// Element that was annotated with something we could not resolve. + final Element annotatedElement; + + /// Source span of the annotation that was not resolved. + /// + /// May be `null` if the import library was not found. + final SourceSpan? annotationSource; + + static SourceSpan? _findSpan(Element annotatedElement, int annotationIndex) { + final parsedLibrary = + annotatedElement.session!.getParsedLibraryByElement( + annotatedElement.library!, + ) + as ParsedLibraryResult; + final declaration = parsedLibrary.getElementDeclaration(annotatedElement); + if (declaration == null) { + return null; + } + final node = declaration.node; + final List metadata; + if (node is AnnotatedNode) { + metadata = node.metadata; + } else if (node is FormalParameter) { + metadata = node.metadata; + } else { + throw StateError( + 'Unhandled Annotated AST node type: ${node.runtimeType}', + ); + } + final annotation = metadata[annotationIndex]; + final start = annotation.offset; + final end = start + annotation.length; + final parsedUnit = declaration.parsedUnit!; + return SourceSpan( + SourceLocation(start, sourceUrl: parsedUnit.uri), + SourceLocation(end, sourceUrl: parsedUnit.uri), + parsedUnit.content.substring(start, end), + ); + } + + @override + String toString() { + final message = 'Could not resolve annotation for `$annotatedElement`.'; + if (annotationSource != null) { + return annotationSource!.message(message); + } + return message; + } +} diff --git a/apps/cli/lib/src/types/type_graph.dart b/apps/cli/lib/src/types/type_graph.dart new file mode 100644 index 000000000..1651e1aec --- /dev/null +++ b/apps/cli/lib/src/types/type_graph.dart @@ -0,0 +1,64 @@ +import 'dart:collection'; + +import 'package:analyzer/dart/element/type.dart'; +import 'package:celest_cli/src/context.dart'; +import 'package:celest_cli/src/utils/analyzer.dart'; +import 'package:graphs/graphs.dart'; + +/// Provides a stable, topological ordering of types relative to each other. +/// +/// Returns a list of types where each type is guaranteed to appear before any +/// of its supertypes. +List topologicallySortTypes(Iterable types) { + final graph = >{ + for (final type in types) + type: HashSet( + equals: _equality.equals, + hashCode: _equality.hash, + ), + }; + for (final type in types) { + for (final other in types) { + switch (type.relationTo(other)) { + case _Relation.equal: + case _Relation.unrelated: + break; + case _Relation.subtype: + graph[type]!.add(other); + case _Relation.supertype: + graph[other]!.add(type); + } + } + } + return topologicalSort( + types, + (type) => graph[type]!, + equals: _equality.equals, + hashCode: _equality.hash, + // Provide a stable iteration order to help with codegen consistency. + secondarySort: (a, b) { + final aName = a.getDisplayString(); + final bName = b.getDisplayString(); + return aName.compareTo(bName); + }, + ); +} + +const _equality = DartTypeEquality(ignoreNullability: true); + +enum _Relation { equal, subtype, supertype, unrelated } + +extension on DartType { + _Relation relationTo(DartType other) { + if (_equality.equals(this, other)) { + return _Relation.equal; + } + if (typeHelper.typeSystem.isSubtypeOf(this, other)) { + return _Relation.subtype; + } + if (typeHelper.typeSystem.isSubtypeOf(other, this)) { + return _Relation.supertype; + } + return _Relation.unrelated; + } +} diff --git a/apps/cli/lib/src/types/type_helper.dart b/apps/cli/lib/src/types/type_helper.dart new file mode 100644 index 000000000..5e89feadb --- /dev/null +++ b/apps/cli/lib/src/types/type_helper.dart @@ -0,0 +1,655 @@ +import 'dart:async'; +import 'dart:collection'; + +import 'package:analyzer/dart/element/element.dart'; +import 'package:analyzer/dart/element/element2.dart'; +import 'package:analyzer/dart/element/nullability_suffix.dart'; +import 'package:analyzer/dart/element/type.dart'; +import 'package:analyzer/dart/element/type_provider.dart'; +import 'package:analyzer/dart/element/type_system.dart'; +import 'package:analyzer/dart/element/type_visitor.dart'; +import 'package:analyzer/src/dart/element/type.dart'; +import 'package:celest_cli/serialization/common.dart'; +import 'package:celest_cli/serialization/is_serializable.dart'; +import 'package:celest_cli/serialization/serialization_verdict.dart'; +import 'package:celest_cli/serialization/serializer_generator.dart'; +import 'package:celest_cli/src/context.dart'; +import 'package:celest_cli/src/types/dart_types.dart'; +import 'package:celest_cli/src/types/type_checker.dart'; +import 'package:celest_cli/src/types/type_impl_alias.dart'; +import 'package:celest_cli/src/utils/analyzer.dart'; +import 'package:celest_cli/src/utils/error.dart'; +import 'package:celest_cli/src/utils/reference.dart'; +import 'package:code_builder/code_builder.dart' as codegen; + +final class CoreTypes implements TypeProvider { + CoreTypes({ + required TypeProvider typeProvider, + required this.coreExceptionType, + required this.coreErrorType, + required this.coreBigIntType, + required this.dateTimeType, + required this.durationType, + required this.coreRegExpType, + required this.coreStackTraceType, + required this.coreUriType, + required this.coreUriDataType, + required this.typedDataUint8ListType, + required this.badRequestExceptionType, + required this.internalServerErrorType, + required this.userType, + required this.cloudExceptionType, + required this.celestEnvType, + required this.celestEnvElement, + required this.celestSecretType, + required this.celestSecretElement, + required this.jsonKeyElement, + }) : _typeProvider = typeProvider; + + final TypeProvider _typeProvider; + + final DartType coreExceptionType; + final DartType coreErrorType; + final DartType coreBigIntType; + final DartType dateTimeType; + final DartType durationType; + final DartType coreRegExpType; + final DartType coreStackTraceType; + final DartType coreUriType; + final DartType coreUriDataType; + final DartType typedDataUint8ListType; + + final DartType badRequestExceptionType; + final DartType internalServerErrorType; + final DartType userType; + final DartType cloudExceptionType; + final InterfaceType celestEnvType; + final ClassElement celestEnvElement; + final InterfaceType celestSecretType; + final ClassElement celestSecretElement; + final ClassElement? jsonKeyElement; + + @override + ClassElement get boolElement => _typeProvider.boolElement; + + @override + InterfaceType get boolType => _typeProvider.boolType; + + @override + DartType get bottomType => _typeProvider.bottomType; + + @override + InterfaceType get deprecatedType => _typeProvider.deprecatedType; + + @override + ClassElement get doubleElement => _typeProvider.doubleElement; + + @override + InterfaceType get doubleType => _typeProvider.doubleType; + + @override + DartType get dynamicType => _typeProvider.dynamicType; + + @override + ClassElement? get enumElement => _typeProvider.enumElement; + + @override + InterfaceType? get enumType => _typeProvider.enumType; + + @override + InterfaceType get functionType => _typeProvider.functionType; + + @override + InterfaceType get futureDynamicType => _typeProvider.futureDynamicType; + + @override + ClassElement get futureElement => _typeProvider.futureElement; + + @override + InterfaceType get futureNullType => _typeProvider.futureNullType; + + @override + ClassElement get futureOrElement => _typeProvider.futureOrElement; + + @override + InterfaceType get futureOrNullType => _typeProvider.futureOrNullType; + + @override + InterfaceType futureOrType(DartType valueType) { + return _typeProvider.futureOrType(valueType); + } + + @override + InterfaceType futureType(DartType valueType) { + return _typeProvider.futureType(valueType); + } + + @override + ClassElement get intElement => _typeProvider.intElement; + + @override + InterfaceType get intType => _typeProvider.intType; + + @override + bool isNonSubtypableClass(InterfaceElement element) { + return _typeProvider.isNonSubtypableClass(element); + } + + @override + bool isNonSubtypableClass2(InterfaceElement2 element) { + return _typeProvider.isNonSubtypableClass2(element); + } + + @override + bool isObjectGetter(String id) { + return _typeProvider.isObjectGetter(id); + } + + @override + bool isObjectMember(String id) { + return _typeProvider.isObjectMember(id); + } + + @override + bool isObjectMethod(String id) { + return _typeProvider.isObjectMethod(id); + } + + @override + InterfaceType get iterableDynamicType => _typeProvider.iterableDynamicType; + + @override + ClassElement get iterableElement => _typeProvider.iterableElement; + + @override + InterfaceType get iterableObjectType => _typeProvider.iterableObjectType; + + @override + InterfaceType iterableType(DartType elementType) { + return _typeProvider.iterableType(elementType); + } + + @override + ClassElement get listElement => _typeProvider.listElement; + + @override + InterfaceType listType(DartType elementType) { + return _typeProvider.listType(elementType); + } + + @override + ClassElement get mapElement => _typeProvider.mapElement; + + @override + InterfaceType get mapObjectObjectType => _typeProvider.mapObjectObjectType; + + @override + InterfaceType mapType(DartType keyType, DartType valueType) { + return _typeProvider.mapType(keyType, valueType); + } + + @override + NeverType get neverType => _typeProvider.neverType; + + @override + ClassElement get nullElement => _typeProvider.nullElement; + + @override + InterfaceType get nullType => _typeProvider.nullType; + + @override + ClassElement get numElement => _typeProvider.numElement; + + @override + InterfaceType get numType => _typeProvider.numType; + + @override + ClassElement get objectElement => _typeProvider.objectElement; + + @override + InterfaceType get objectQuestionType => _typeProvider.objectQuestionType; + + @override + InterfaceType get objectType => _typeProvider.objectType; + + @override + ClassElement get recordElement => _typeProvider.recordElement; + + @override + InterfaceType get recordType => _typeProvider.recordType; + + @override + ClassElement get setElement => _typeProvider.setElement; + + @override + InterfaceType setType(DartType elementType) { + return _typeProvider.setType(elementType); + } + + @override + InterfaceType get stackTraceType => _typeProvider.stackTraceType; + + @override + InterfaceType get streamDynamicType => _typeProvider.streamDynamicType; + + @override + ClassElement get streamElement => _typeProvider.streamElement; + + @override + InterfaceType streamType(DartType elementType) { + return _typeProvider.streamType(elementType); + } + + @override + ClassElement get stringElement => _typeProvider.stringElement; + + @override + InterfaceType get stringType => _typeProvider.stringType; + + @override + ClassElement get symbolElement => _typeProvider.symbolElement; + + @override + InterfaceType get symbolType => _typeProvider.symbolType; + + @override + InterfaceType get typeType => _typeProvider.typeType; + + @override + VoidType get voidType => _typeProvider.voidType; + + @override + ClassElement2 get boolElement2 => _typeProvider.boolElement2; + + @override + ClassElement2 get doubleElement2 => _typeProvider.doubleElement2; + + @override + ClassElement2? get enumElement2 => _typeProvider.enumElement2; + + @override + ClassElement2 get futureElement2 => _typeProvider.futureElement2; + + @override + ClassElement2 get futureOrElement2 => _typeProvider.futureOrElement2; + + @override + ClassElement2 get intElement2 => _typeProvider.intElement2; + + @override + ClassElement2 get iterableElement2 => _typeProvider.iterableElement2; + + @override + ClassElement2 get listElement2 => _typeProvider.listElement2; + + @override + ClassElement2 get mapElement2 => _typeProvider.mapElement2; + + @override + ClassElement2 get nullElement2 => _typeProvider.nullElement2; + + @override + ClassElement2 get numElement2 => _typeProvider.numElement2; + + @override + ClassElement2 get objectElement2 => _typeProvider.objectElement2; + + @override + ClassElement2 get recordElement2 => _typeProvider.recordElement2; + + @override + ClassElement2 get setElement2 => _typeProvider.setElement2; + + @override + ClassElement2 get streamElement2 => _typeProvider.streamElement2; + + @override + ClassElement2 get stringElement2 => _typeProvider.stringElement2; + + @override + ClassElement2 get symbolElement2 => _typeProvider.symbolElement2; +} + +final class TypeHelper { + factory TypeHelper() => _instance; + TypeHelper._(); + + static final _instance = TypeHelper._(); + + TypeSystem? _typeSystem; + TypeSystem get typeSystem { + if (_typeSystem == null) { + throw StateError( + 'TypeHelper.typeSystem was accessed before it was initialized. ' + 'The type system is only available after analysis.', + ); + } + return _typeSystem!; + } + + set typeSystem(TypeSystem typeSystem) { + _typeSystem = typeSystem; + } + + TypeProvider? _typeProvider; + TypeProvider get typeProvider { + if (_typeProvider == null) { + throw StateError( + 'TypeHelper.typeProvider was accessed before it was initialized. ' + 'The type provider is only available after analysis.', + ); + } + return _typeProvider!; + } + + set typeProvider(TypeProvider typeProvider) { + _typeProvider = typeProvider; + } + + CoreTypes? _coreTypes; + CoreTypes get coreTypes { + if (_coreTypes == null) { + throw StateError( + 'TypeHelper.coreTypes was accessed before it was initialized. ' + 'The core types are only available after analysis.', + ); + } + return _coreTypes!; + } + + set coreTypes(CoreTypes coreTypes) { + _coreTypes = coreTypes; + _init(); + } + + // TODO(dnys1): File ticket with Dart team around hashcode/equality of DartType + final _dartTypeToReference = HashMap( + equals: const DartTypeEquality().equals, + hashCode: const DartTypeEquality().hash, + ); + final _referenceToDartType = {}; + final _wireTypeToDartType = {}; + final serializationVerdicts = HashMap( + equals: const DartTypeEquality().equals, + hashCode: const DartTypeEquality().hash, + ); + // final _customSerializers = {}; + + // TODO(dnys1): Test types that are only referred to in nested fields/parameters + /// ^^^^ + codegen.Reference toReference(DartType type) { + if (_dartTypeToReference[type] case final reference?) { + return reference; + } + var reference = type.accept(const _TypeToCodeBuilder()); + // Fix Dart internal types + if (reference.url == 'dart:_http') { + reference = (reference as codegen.TypeReference).rebuild( + (b) => b.url = 'dart:io', + ); + } + _dartTypeToReference[type] ??= reference; + _referenceToDartType[reference] ??= type; + _referenceToDartType[reference.toTypeReference] ??= type; + // Perform for nullable version of [type] so that subsequent + // nullable/non-nullable promotions which require [fromReference] succeed. + if (!reference.isNullableOrFalse) { + _referenceToDartType[reference.withNullability(true)] ??= (type + as TypeImpl) + .withNullability(NullabilitySuffix.question) + .withAlias(type.alias); + _referenceToDartType[reference.withNullability(false)] ??= type; + } + if (toUri(type) case final wireType?) { + _wireTypeToDartType[wireType] ??= type; + } + return reference; + } + + DartType fromReference(codegen.Reference reference) { + final dartType = _referenceToDartType[reference]; + if (dartType == null) { + throw unreachable( + 'Reference $reference was not found in the cache. Did you forget to ' + 'call toReference?', + ); + } + return dartType; + } + + String? toUri(DartType type) => switch (type.element) { + final element? => urlOfElement(element), + _ => null, + }; + + DartType fromWireType(String wireType) { + final type = _wireTypeToDartType[wireType]; + if (type == null) { + throw unreachable( + 'Wire type $wireType was not found in the cache. Did you forget to ' + 'call toReference?', + ); + } + return type; + } + + /// Determines whether a [DartType] can be serialized. + /// + /// Types must: + /// - Be a simple JSON type (bool, double, int, String, null, Object) + /// - Be an enum + /// - Be a supported Dart SDK type + /// - Be a class with a constructor named `fromJson` that takes a single + /// required parameter whose type is `Map`. + /// - Be a class with a method named `toJson` that takes no required parameters. + /// - Be a class which: has fields of the above types, has a constructor with + /// all fields present. For these classes, we generate custom serialization + /// code. + Verdict isSerializable(DartType type) { + final verdict = + serializationVerdicts[type] ??= runZoned( + () => type.asOverriden.accept(const IsSerializable()), + zoneValues: { + _seenKey: + Zone.current[_seenKey] ?? + HashSet( + equals: + const DartTypeEquality(ignoreNullability: true).equals, + hashCode: + const DartTypeEquality(ignoreNullability: true).hash, + ), + }, + ); + assert(() { + bool isValidOverride(Verdict verdict) { + if (verdict is! VerdictYes) { + return true; + } + final isExtensionType = + verdict.primarySpec?.type.isExtensionType ?? false; + if (!isExtensionType) { + return false; + } + for (final additionalSpec in verdict.additionalSpecs) { + if (const DartTypeEquality( + ignoreNullability: true, + ).equals(additionalSpec.type, type)) { + return false; + } + } + return true; + } + + if (type.isOverridden) { + return isValidOverride(verdict); + } + return true; + }(), 'isSerializable($type) returned an invalid verdict'); + + return verdict; + } + + static const _seenKey = #seen; + + /// The set of types seen by the current [isSerializable] check. + Set get seen => Zone.current[_seenKey] as Set; + + Iterable customSerializers(DartType type) { + final verdict = isSerializable(type); + if (verdict case VerdictYes(:final primarySpec?, :final additionalSpecs)) { + return SerializerGenerator( + primarySpec, + additionalSerializationSpecs: additionalSpecs, + ).build(); + } + return const Iterable.empty(); + } + + final Map> subtypes = Map.identity(); + + /// Maps 3p types to their extension type overrides. + final Map overrides = HashMap( + equals: const DartTypeEquality(ignoreNullability: true).equals, + hashCode: const DartTypeEquality(ignoreNullability: true).hash, + ); + + /// Hydrate the caches with built-in types. + void _init() { + for (final builtInType in builtInTypeToReference.keys) { + final reference = toReference(builtInType); + fromReference(reference); + } + } + + /// Reset all caches. + void reset() { + _dartTypeToReference.clear(); + _referenceToDartType.clear(); + _wireTypeToDartType.clear(); + serializationVerdicts.clear(); + subtypes.clear(); + overrides.clear(); + _init(); + } +} + +final class _TypeToCodeBuilder implements TypeVisitor { + const _TypeToCodeBuilder(); + + @override + codegen.Reference visitDynamicType(DynamicType type) => + DartTypes.core.dynamic; + + @override + codegen.Reference visitFunctionType(FunctionType type) { + return codegen.FunctionType( + (b) => + b + ..returnType = typeHelper.toReference(type.returnType) + ..optionalParameters.addAll([ + for (final parameter in type.parameters.where( + (p) => p.isOptionalPositional, + )) + typeHelper.toReference(parameter.type), + ]) + ..requiredParameters.addAll([ + for (final parameter in type.parameters.where( + (p) => p.isRequiredPositional, + )) + typeHelper.toReference(parameter.type), + ]) + ..namedParameters.addAll({ + for (final parameter in type.parameters.where( + (p) => p.isOptionalNamed, + )) + parameter.name: typeHelper.toReference(parameter.type), + }) + ..namedRequiredParameters.addAll({ + for (final parameter in type.parameters.where( + (p) => p.isRequiredNamed, + )) + parameter.name: typeHelper.toReference(parameter.type), + }) + ..types.addAll([ + for (final formal in type.typeFormals) + codegen.TypeReference( + (t) => + t + ..symbol = formal.name + ..bound = switch (formal.bound) { + final bound? => typeHelper.toReference(bound), + _ => null, + }, + ), + ]), + ); + } + + @override + codegen.Reference visitInterfaceType(InterfaceType type) { + final typeArguments = type.typeArguments.map(typeHelper.toReference); + final ref = codegen.TypeReference( + (t) => + t + ..symbol = type.element.name + ..url = type.uri.toString() + ..types.addAll(typeArguments) + ..isNullable = type.nullabilitySuffix != NullabilitySuffix.none, + ); + return builtInTypeToReference[type] ?? ref; + } + + @override + codegen.Reference visitInvalidType(InvalidType type) => + codegen.refer(type.getDisplayString()); + + @override + codegen.Reference visitNeverType(NeverType type) => DartTypes.core.never; + + @override + codegen.Reference visitRecordType(RecordType type) { + if (type.alias case final alias?) { + return codegen.TypeReference( + (b) => + b + ..symbol = alias.element.displayName + ..url = + projectPaths + .normalizeUri(alias.element.sourceLocation!.sourceUrl!) + .toString() + // TODO(dnys1): https://github.com/dart-lang/sdk/issues/54346 + // ..isNullable = alias.element.nullabilitySuffix != NullabilitySuffix.none, + ..isNullable = typeHelper.typeSystem.isNullable(type), + ); + } + return codegen.RecordType( + (r) => + r + ..positionalFieldTypes.addAll([ + for (final parameter in type.positionalFields) + typeHelper.toReference(parameter.type), + ]) + ..namedFieldTypes.addAll({ + for (final parameter in type.namedFields) + parameter.name: typeHelper.toReference(parameter.type), + }) + ..isNullable = type.nullabilitySuffix == NullabilitySuffix.question, + ); + } + + @override + codegen.Reference visitTypeParameterType(TypeParameterType type) { + return codegen.TypeReference( + (t) => + t + ..symbol = type.getDisplayString() + ..bound = + type.bound is DynamicType + ? null + : typeHelper.toReference(type.bound), + ); + } + + @override + codegen.Reference visitVoidType(VoidType type) => DartTypes.core.void$; +} diff --git a/apps/cli/lib/src/types/type_impl_alias.dart b/apps/cli/lib/src/types/type_impl_alias.dart new file mode 100644 index 000000000..1f1fd891a --- /dev/null +++ b/apps/cli/lib/src/types/type_impl_alias.dart @@ -0,0 +1,92 @@ +import 'package:analyzer/dart/element/type.dart'; +import 'package:analyzer/dart/element/type_visitor.dart'; +import 'package:analyzer/src/dart/element/element.dart'; +import 'package:analyzer/src/dart/element/type.dart'; + +extension TypeImplAlias on TypeImpl { + TypeImpl withAlias(InstantiatedTypeAliasElement? alias) { + final visitor = _TypeImplAliasVisitor(); + return acceptWithArgument(visitor, alias); + } +} + +final class _TypeImplAliasVisitor + extends TypeVisitorWithArgument { + @override + TypeImpl visitDynamicType( + DynamicType type, + InstantiatedTypeAliasElement? alias, + ) { + return type as DynamicTypeImpl; + } + + @override + TypeImpl visitFunctionType( + FunctionType type, + InstantiatedTypeAliasElement? alias, + ) { + return FunctionTypeImpl( + typeFormals: type.typeFormals, + parameters: type.parameters, + returnType: type.returnType, + nullabilitySuffix: type.nullabilitySuffix, + alias: alias, + ); + } + + @override + TypeImpl visitInterfaceType( + InterfaceType type, + InstantiatedTypeAliasElement? alias, + ) { + return InterfaceTypeImpl( + element: type.element3 as InterfaceElementImpl2, + typeArguments: type.typeArguments, + nullabilitySuffix: type.nullabilitySuffix, + alias: alias, + ); + } + + @override + TypeImpl visitInvalidType( + InvalidType type, + InstantiatedTypeAliasElement? alias, + ) { + return type as InvalidTypeImpl; + } + + @override + TypeImpl visitNeverType(NeverType type, InstantiatedTypeAliasElement? alias) { + return type as NeverTypeImpl; + } + + @override + TypeImpl visitRecordType( + RecordType type, + InstantiatedTypeAliasElement? alias, + ) { + return RecordTypeImpl( + positionalFields: type.positionalFields.cast(), + namedFields: type.namedFields.cast(), + nullabilitySuffix: type.nullabilitySuffix, + alias: alias, + ); + } + + @override + TypeImpl visitTypeParameterType( + TypeParameterType type, + InstantiatedTypeAliasElement? alias, + ) { + return TypeParameterTypeImpl( + element: type.element, + nullabilitySuffix: type.nullabilitySuffix, + alias: alias, + ); + } + + @override + TypeImpl visitVoidType(VoidType type, InstantiatedTypeAliasElement? alias) { + return type as VoidTypeImpl; + } +} diff --git a/apps/cli/lib/src/url_launcher/launch_url.dart b/apps/cli/lib/src/url_launcher/launch_url.dart new file mode 100644 index 000000000..e7192a0ea --- /dev/null +++ b/apps/cli/lib/src/url_launcher/launch_url.dart @@ -0,0 +1,33 @@ +import 'dart:convert'; +import 'dart:io'; + +import 'package:celest_cli/src/context.dart'; + +/// Launches a URL in the user's default browser. +/// +/// Returns `true` if the URL was successfully launched, `false` otherwise. +Future launchUrl(Uri url) async { + final String command; + if (Platform.isWindows) { + command = 'powershell'; + } else if (Platform.isLinux) { + command = 'xdg-open'; + } else if (Platform.isMacOS) { + command = 'open'; + } else { + throw UnsupportedError('Unsupported OS: ${Platform.operatingSystem}'); + } + + final arguments = + Platform.isWindows ? ['start-process', '"$url"'] : [url.toString()]; + try { + final res = await processManager.run( + [command, ...arguments], + stdoutEncoding: utf8, + stderrEncoding: utf8, + ); + return res.exitCode == 0; + } on Exception { + return false; + } +} diff --git a/apps/cli/lib/src/utils/analyzer.dart b/apps/cli/lib/src/utils/analyzer.dart new file mode 100644 index 000000000..8388497dd --- /dev/null +++ b/apps/cli/lib/src/utils/analyzer.dart @@ -0,0 +1,916 @@ +import 'dart:convert'; +import 'dart:math'; + +import 'package:analyzer/dart/ast/ast.dart'; +import 'package:analyzer/dart/constant/value.dart'; +import 'package:analyzer/dart/element/element.dart'; +import 'package:analyzer/dart/element/nullability_suffix.dart'; +import 'package:analyzer/dart/element/type.dart'; +import 'package:analyzer/source/source.dart'; +import 'package:analyzer/src/dart/analysis/driver.dart'; +import 'package:analyzer/src/dart/analysis/driver_based_analysis_context.dart'; +import 'package:analyzer/src/dart/analysis/search.dart'; +import 'package:analyzer/src/dart/element/element.dart'; +import 'package:analyzer/src/dart/element/type.dart'; +import 'package:celest_ast/celest_ast.dart' as ast; +import 'package:celest_cli/analyzer/const_to_code_builder.dart'; +import 'package:celest_cli/serialization/common.dart'; +import 'package:celest_cli/src/context.dart'; +import 'package:celest_cli/src/types/dart_types.dart'; +import 'package:celest_cli/src/utils/error.dart'; +import 'package:code_builder/code_builder.dart' as codegen; +import 'package:collection/collection.dart'; +import 'package:logging/logging.dart'; +import 'package:source_span/source_span.dart'; + +extension LibraryElementHelper on LibraryElement { + bool get isPackageCelest => switch (source.uri) { + Uri(scheme: 'package', pathSegments: ['celest', ...]) => true, + _ => false, + }; + + bool get isCelestSdk => switch (source.uri) { + Uri(scheme: 'package', pathSegments: [final packageName, ...]) => + packageName.startsWith('celest') && packageName != 'celest_backend', + _ => false, + }; + + bool get isDartSdk => source.uri.scheme == 'dart'; + bool get isFlutterSdk => + source.uri.scheme == 'package' && + source.uri.pathSegments.first == 'flutter'; + + bool get isWithinProject => + p.isWithin(projectPaths.projectRoot, source.fullName); + bool get isWithinProjectLib => + p.isWithin(projectPaths.projectLib, source.fullName); +} + +extension ElementAnnotationHelper on ElementAnnotation { + bool get isCustomOverride => switch (element) { + final PropertyAccessorElement propertyAccessor => + propertyAccessor.name == 'customOverride' && + propertyAccessor.library.isCelestSdk, + _ => false, + }; + + bool get isHttpError => switch (element) { + ConstructorElement( + enclosingElement3: ClassElement(:final name, :final library), + ) => + name == 'httpError' && library.isCelestSdk, + _ => false, + }; +} + +extension DartTypeHelper on DartType { + DartType get flattened { + switch (this) { + case final InterfaceType interface: + final typeSystem = interface.element.library.typeSystem; + final flattened = typeSystem.flatten(this); + return switch ((this, flattened)) { + // TODO(dnys1): https://github.com/dart-lang/sdk/issues/54260 + ( + // e.g. Future/FutureOr + InterfaceType( + typeArguments: [final RecordTypeImpl originalRecordType], + ), + final RecordTypeImpl recordType, + ) => + RecordTypeImpl( + namedFields: recordType.namedFields, + positionalFields: recordType.positionalFields, + nullabilitySuffix: recordType.nullabilitySuffix, + alias: originalRecordType.alias, + ), + _ => flattened, + }; + default: + return this; + } + } + + DartType get nonNullable => + (this as TypeImpl).withNullability(NullabilitySuffix.none); + + bool get isCelestSdk => element?.library?.isCelestSdk ?? false; + + bool get isDartSdk => element?.library?.source.uri.scheme == 'dart'; + + bool get isJsonExtensionType => switch (element) { + ExtensionTypeElement(:final name, :final library) => + name.startsWith('Json') && library.isCelestSdk, + _ => false, + }; + + bool get isCelestVariable => element == typeHelper.coreTypes.celestEnvElement; + + bool get isCelestSecret => + element == typeHelper.coreTypes.celestSecretElement; + + bool get isAuth => switch (element) { + ClassElement(:final name, :final library) => + name == 'Auth' && library.isPackageCelest, + _ => false, + }; + + bool get isAuthProviderEmail => switch (element) { + ClassElement(:final name, :final library) => + name == '_EmailAuthProvider' && library.isPackageCelest, + _ => false, + }; + + bool get isAuthProviderSms => switch (element) { + ClassElement(:final name, :final library) => + name == '_SmsAuthProvider' && library.isPackageCelest, + _ => false, + }; + + bool get isAuthProviderGitHub => switch (element) { + ClassElement(:final name, :final library) => + name == '_GitHubAuthProvider' && library.isPackageCelest, + _ => false, + }; + + bool get isAuthProviderApple => switch (element) { + ClassElement(:final name, :final library) => + name == '_AppleAuthProvider' && library.isPackageCelest, + _ => false, + }; + + bool get isAuthProviderGoogle => switch (element) { + ClassElement(:final name, :final library) => + name == '_GoogleAuthProvider' && library.isPackageCelest, + _ => false, + }; + + bool get isDatabase => switch (element) { + ClassElement(:final name, :final library) => + name == 'Database' && library.isPackageCelest, + _ => false, + }; + + bool get isDriftSchema => switch (element) { + ClassElement(:final name, :final library) => + name == '_DriftSchema' && library.isPackageCelest, + _ => false, + }; + + bool get isDriftGeneratedDatabase => switch (element) { + ClassElement( + name: 'GeneratedDatabase', + library: LibraryElement( + source: Source( + uri: Uri(scheme: 'package', pathSegments: ['drift', ...]), + ), + ), + ) => + true, + _ => false, + }; + + bool get isDriftQueryExecutor => switch (element) { + ClassElement( + name: 'QueryExecutor', + library: LibraryElement( + source: Source( + uri: Uri(scheme: 'package', pathSegments: ['drift', ...]), + ), + ), + ) => + true, + _ => false, + }; + + bool get isExternalAuthProviderFirebase => switch (element) { + ClassElement(:final name, :final library) => + name == '_FirebaseExternalAuthProvider' && library.isPackageCelest, + _ => false, + }; + + bool get isExternalAuthProviderSupabase => switch (element) { + ClassElement(:final name, :final library) => + name == '_SupabaseExternalAuthProvider' && library.isPackageCelest, + _ => false, + }; + + bool get isProject => switch (element) { + ClassElement(:final name, :final library) => + name == 'Project' && library.isPackageCelest, + _ => false, + }; + + bool get isProjectContext => switch (element) { + ClassElement(:final name, :final library) => + name == 'ProjectContext' && library.isPackageCelest, + _ => false, + }; + + bool get isApiAuthenticated => switch (element) { + ClassElement(:final name, :final library) => + name == '_Authenticated' && library.isPackageCelest, + _ => false, + }; + + bool get isApiPublic => switch (element) { + ClassElement(:final name, :final library) => + name == '_Public' && library.isPackageCelest, + _ => false, + }; + + bool get isHttpConfig => switch (element) { + ClassElement(:final name, :final library) => + name == 'http' && library.isCelestSdk, + _ => false, + }; + + bool get isHttpError => switch (element) { + ClassElement(:final name, :final library) => + name == 'httpError' && library.isCelestSdk, + _ => false, + }; + + // bool get isHttpLabel => switch (element) { + // ClassElement(:final name, :final library) => + // name == 'httpLabel' && library.isCelestSdk, + // _ => false, + // }; + + bool get isHttpQuery => switch (element) { + ClassElement(:final name, :final library) => + name == 'httpQuery' && library.isCelestSdk, + _ => false, + }; + + bool get isHttpHeader => switch (element) { + ClassElement(:final name, :final library) => + name == 'httpHeader' && library.isCelestSdk, + _ => false, + }; + + bool get isVariable { + return switch (this) { + InterfaceType(:final allSupertypes) => [ + this, + ...allSupertypes, + ].any((type) => identical(type, typeHelper.coreTypes.celestEnvType)), + _ => false, + }; + } + + bool get isStaticVariable => switch (element) { + ClassElement(:final name, :final library) => + name == '_staticEnv' && library.isPackageCelest, + _ => false, + }; + + bool get isSecret => element == typeHelper.coreTypes.celestSecretElement; + + bool get isUserContext => switch (element) { + ClassElement(:final name, :final library) => + name == '_PrincipalContextKey' && library.isPackageCelest, + _ => false, + }; + + bool get isCloud => switch (element) { + ClassElement(:final name, :final library) => + name == '_Cloud' && library.isPackageCelest, + _ => false, + }; + + bool get isMiddleware { + final el = element; + if (el is! ClassElement) { + return false; + } + final supertypes = el.allSupertypes; + if (supertypes.isEmpty) { + return false; + } + return supertypes.any((supertype) { + final supertypeElement = supertype.element; + if (supertypeElement is! ClassElement) { + return false; + } + return supertypeElement.library.isPackageCelest && + supertypeElement.name == 'Middleware'; + }); + } + + bool get isEnum => element is EnumElement; + bool get isEnumLike => switch (element) { + EnumElement() => true, + ClassElementImpl(isEnumLike: true) && final element => switch (element + .getField('values')) { + FieldElement( + isStatic: true, + isConst: true, + type: InterfaceType( + isDartCoreList: true, + typeArguments: [final typeArg], + ), + ) => + const DartTypeEquality(ignoreNullability: true).equals(typeArg, this), + _ => false, + }, + _ => false, + }; + + /// Used to patch over/ignore the limitations of serializing Flutter + /// types for now. + bool get isFlutterType => switch (element) { + ClassElement(:final library) => switch (library.source.uri) { + // dart:ui + Uri(scheme: 'dart', pathSegments: ['ui', ...]) => true, + // package:flutter + Uri(scheme: 'package', pathSegments: ['flutter', ...]) => true, + _ => false, + }, + _ => false, + }; + + bool get isSimpleJson => + isDartCoreBool || + isDartCoreDouble || + isDartCoreInt || + isDartCoreNum || + isDartCoreString || + isDartCoreObject || + isDartCoreNull || + isEnumLike; + + bool get isThrowable { + return isExceptionType || isErrorType; + } + + bool get isExceptionType { + return typeHelper.typeSystem.isSubtypeOf( + this, + typeHelper.coreTypes.coreExceptionType, + ); + } + + bool get isCloudExceptionType { + return typeHelper.typeSystem.isSubtypeOf( + this, + typeHelper.coreTypes.cloudExceptionType, + ); + } + + bool get isErrorType { + return typeHelper.typeSystem.isSubtypeOf( + this, + typeHelper.coreTypes.coreErrorType, + ); + } + + bool get isExtensionType => element is ExtensionTypeElement; + bool get implementsRepresentationType { + final element = this.element; + if (element is ExtensionTypeElement) { + return element.allSupertypes.contains(extensionTypeErasure); + } + return true; + } + + /// Whether this type is overridden by a custom `@override` extension type. + bool get isOverridden => + typeHelper.overrides.containsKey(extensionTypeErasure); + + DartType get asOverriden => + typeHelper.overrides[extensionTypeErasure] ?? this; + + codegen.Expression? get typeToken { + if (isOverridden) { + return null; + } + if (element case final ExtensionTypeElement extensionType) { + return DartTypes.celest.typeToken.constInstance( + [codegen.literalString(extensionType.name)], + {}, + [typeHelper.toReference(this)], + ); + } + return null; + } + + Uri? get sourceUri { + final sourceUri = switch (this) { + // Don't consider aliases for non-record types. + RecordType(:final alias?) => alias.element.library.source.uri, + _ => element?.library?.source.uri, + }; + if (sourceUri == null) { + return null; + } + return projectPaths.normalizeUri(sourceUri); + } + + Uri get uri { + if (this is DynamicType) { + return Uri.parse('dart:core#dynamic'); + } + return sourceUri!; + } + + Uri get instantiatedUri { + final type = this; + final symbol = switch (type) { + final RecordType type => type.symbol, + _ => element?.name, + }; + assert(symbol != null, 'Symbol is null for $type'); + final symbolizedUri = switch (sourceUri) { + final sourceUri? => sourceUri.replace(fragment: symbol), + _ => Uri(fragment: symbol), + }; + switch (type) { + case InterfaceType( + :final typeArguments, + element: InterfaceElement(:final typeParameters), + ) + when typeParameters.isNotEmpty: + return symbolizedUri.replace( + queryParameters: { + for (final (index, typeParameter) in typeParameters.indexed) + typeParameter.name: + typeArguments[index].instantiatedUri.toString(), + }, + ); + default: + return symbolizedUri; + } + } + + /// Cache for [hasAllowedSubtypes]. + static final _hasAllowedSubtypesCache = {}; + static final _logger = Logger('DartTypeHelper'); + + /// Ensures custom types (e.g. those defined in the current project), have + /// allowed subtypes. + /// + /// Currently, only `sealed` classes are allowed to have subtypes. + Future hasAllowedSubtypes() async { + return _hasAllowedSubtypesCache[this] ??= await _hasAllowedSubtypes(); + } + + Future _hasAllowedSubtypes() async { + final type = this; + if (type is! InterfaceType) { + return _SubtypeResultX._allowed; + } + final element = type.element; + var hasAllowedSubtypes = ( + allowed: true, + disallowedTypes: {}, + ); + // Recurse into type arguments before processing this wrapper, e.g. [type] + // could be List where T is of interest. + for (final typeArgument in type.typeArguments) { + hasAllowedSubtypes &= await typeArgument.hasAllowedSubtypes(); + } + final libraryUri = type.element.librarySource.uri; + final libraryPath = element.library.session.uriConverter.uriToPath( + libraryUri, + ); + if (libraryPath == null) { + _logger.finest('Could not resolve path for URI: $libraryUri'); + return _SubtypeResultX._allowed; + } + if (!p.isWithin(projectPaths.projectRoot, libraryPath)) { + return _SubtypeResultX._allowed; + } + final subtypes = + typeHelper.subtypes[element] ??= switch (element) { + // Don't collect subtypes for final classes. + // TODO(dnys1): How best to handle this? Needed for `OkShapeResult` but + // final classes can still reopen types and introduce new classes with + // new identities. + ClassElement(isFinal: true) => const [], + // TODO(dnys1): This should work but reports errors for sealed types. + // ClassElementImpl() => element.allSubtypes ?? const [], + _ => await element.collectSubtypes(), + }; + for (final subtype in subtypes) { + hasAllowedSubtypes &= await subtype.hasAllowedSubtypes(); + } + final allowed = switch (element) { + ClassElement(isSealed: true) => + // We can't instantiate a sealed class, so we need subtypes + hasAllowedSubtypes.allowed && subtypes.isNotEmpty, + ClassElement(isFinal: true) => hasAllowedSubtypes.allowed, + _ => hasAllowedSubtypes.allowed && subtypes.isEmpty, + }; + return ( + allowed: allowed, + disallowedTypes: { + if (!allowed) type, + ...hasAllowedSubtypes.disallowedTypes, + }, + ); + } + + DartType? get defaultWireType => switch (extensionTypeErasure.element) { + EnumElement() => typeHelper.typeProvider.stringType, + InterfaceElement() => jsonMapType, + _ => null, + }; + + /// A unique, readable name for this type which can be used in generated code + /// and over the wire. + /// + /// We try to follow protobuf versioning guidelines and use the package name, + /// organization name, and the version to give types unique names which are + /// easy to interpret and do not expose implementation details. + String? externalUri(String projectName) { + final symbol = switch (this) { + final RecordType type => type.symbol, + _ => element?.name, + }; + assert(symbol != null, 'Symbol is null for $this'); + final sourceUri = switch (this) { + // Don't consider aliases for non-record types. + RecordType(:final alias) => alias?.element.sourceLocation?.sourceUrl, + _ => element?.sourceLocation?.sourceUrl, + }; + if (sourceUri == null) { + // Anonymous record type. + return null; + } + final externalPackageId = switch (sourceUri) { + Uri(scheme: 'dart', pathSegments: [final library, ...]) => + 'dart.$library', + // TODO(dnys1): Include organization name + // TODO(dnys1): Include version tag + Uri(scheme: 'package', pathSegments: ['celest_backend', ...]) || + Uri(pathSegments: []) => '$projectName.v1', + Uri(scheme: 'package', pathSegments: [final package, ...]) + when isCelestSdk => + '${package.split('_').join('.')}.v1', + // TODO(dnys1): Should this include the package's major version? + Uri(scheme: 'package', :final pathSegments) => pathSegments.first, + _ => unreachable('Unexpected source URI: $sourceUri'), + }; + return '$externalPackageId.$symbol'; + } +} + +typedef SubtypeResult = ({bool allowed, Set disallowedTypes}); + +extension _SubtypeResultX on SubtypeResult { + static const SubtypeResult _allowed = (allowed: true, disallowedTypes: {}); + + SubtypeResult operator &(SubtypeResult other) => ( + allowed: allowed && other.allowed, + disallowedTypes: {...disallowedTypes, ...other.disallowedTypes}, + ); +} + +extension InterfaceElementHelpers on InterfaceElement { + AnalysisDriver get _driver => + (library.session.analysisContext as DriverBasedAnalysisContext).driver; + + static final _searchedFiles = SearchedFiles(); + + /// Collects all subtypes of the given [type]. + Future> collectSubtypes() async { + final subtypes = await _driver.search.subTypes( + thisType.element3, + _searchedFiles, + ); + return subtypes + .where((res) { + return switch (res.kind) { + SearchResultKind.REFERENCE_IN_EXTENDS_CLAUSE || + SearchResultKind.REFERENCE_IN_IMPLEMENTS_CLAUSE || + SearchResultKind.REFERENCE_IN_ON_CLAUSE || + SearchResultKind.REFERENCE_IN_WITH_CLAUSE => true, + _ => false, + }; + }) + .map((res) => res.enclosingElement) + .whereType() + .map((res) => res.thisType) + .toList(); + } + + Stream references() async* { + final elementReferences = await _driver.search.references( + this, + _searchedFiles, + ); + for (final reference in elementReferences) { + yield reference; + } + if (unnamedConstructor case final constructor?) { + final constructorReferences = await _driver.search.references( + constructor, + _searchedFiles, + ); + for (final reference in constructorReferences) { + yield reference; + } + } + } +} + +extension RecordTypeHelper on RecordType { + String get symbol { + switch (alias) { + case final alias?: + return alias.element.displayName; + default: + final reference = typeHelper.toReference(this) as codegen.RecordType; + final uniqueHash = const ListEquality().hash([ + ...reference.positionalFieldTypes, + ...reference.namedFieldTypes.entries.expand( + (entry) => [entry.key, entry.value], + ), + ]); + return 'Record\$${uniqueHash.toRadixString(36)}'; + } + } +} + +extension NodeSourceLocation on AstNode { + FileSpan sourceLocation(Source source) { + return source.toSpan(offset, end); + } +} + +extension ElementSourceLocation on Element { + FileSpan? get sourceLocation { + final source = this.source; + if (source == null || !source.exists()) { + return null; + } + if (nameOffset < 0) { + return null; + } + return source.toSpan(nameOffset, nameOffset + nameLength); + } + + List get docLines => switch (documentationComment) { + final documentationComment? => + LineSplitter.split(documentationComment).toList(), + _ => const [], + }; +} + +extension ElementAnnotationSourceLocation on ElementAnnotation { + FileSpan sourceLocation(Source source) { + final impl = this as ElementAnnotationImpl; + return source.toSpan(impl.annotationAst.offset, impl.annotationAst.end); + } +} + +extension SourceToSpan on Source { + FileSpan toSpan(int start, [int? end]) { + final sourceFile = SourceFile.fromString(contents.data, url: uri); + + // TODO(dnys1): Something to do with caching, but when files are being + // changed, sometimes the range is no longer valid by the time we call this + // with outdated source. + if (start >= sourceFile.length) { + return sourceFile.span(0); + } + if (end != null && end >= sourceFile.length) { + end = null; + } + + return sourceFile.span(start, end); + } +} + +// TODO(dnys1): File ticket with Dart team around hashcode/equality of DartType +// == of RecordType does not take into account alias. +// hashCode only takes into account the length of positionalFields and namedFields. +final class DartTypeEquality implements Equality { + const DartTypeEquality({this.ignoreNullability = false}); + + final bool ignoreNullability; + + @override + bool equals(DartType? e1, DartType? e2) { + if (identical(e1, e2)) { + return true; + } + if (e1 is RecordType && e2 is RecordType) { + return RecordTypeEquality( + ignoreNullability: ignoreNullability, + ).equals(e1, e2); + } + if (ignoreNullability) { + e1 = (e1 as TypeImpl).withNullability(NullabilitySuffix.none); + e2 = (e2 as TypeImpl).withNullability(NullabilitySuffix.none); + } + return e1 == e2; + } + + @override + int hash(DartType? e) { + if (e is RecordType) { + return RecordTypeEquality(ignoreNullability: ignoreNullability).hash(e); + } + if (ignoreNullability) { + e = (e as TypeImpl).withNullability(NullabilitySuffix.none); + } + return e.hashCode; + } + + @override + bool isValidKey(Object? o) => o is DartType?; +} + +// TODO(dnys1): File ticket with Dart team around hashcode/equality of DartType +final class RecordTypeEquality implements Equality { + const RecordTypeEquality({this.ignoreNullability = false}); + + final bool ignoreNullability; + + @override + bool equals(RecordType e1, RecordType e2) { + if (identical(e1, e2)) { + return true; + } + if (!ignoreNullability) { + if (e1.nullabilitySuffix != e2.nullabilitySuffix) { + return false; + } + } + if (e1.alias != e2.alias) { + return false; + } + + final thisPositional = e1.positionalFields; + final otherPositional = e2.positionalFields; + if (thisPositional.length != otherPositional.length) { + return false; + } + for (var i = 0; i < thisPositional.length; i++) { + final thisField = thisPositional[i]; + final otherField = otherPositional[i]; + if (!const DartTypeEquality().equals(thisField.type, otherField.type)) { + return false; + } + } + + final thisNamed = e1.namedFields; + final otherNamed = e2.namedFields; + if (thisNamed.length != otherNamed.length) { + return false; + } + for (var i = 0; i < thisNamed.length; i++) { + final thisField = thisNamed[i]; + final otherField = otherNamed[i]; + if (thisField.name != otherField.name || + !const DartTypeEquality().equals(thisField.type, otherField.type)) { + return false; + } + } + + return true; + } + + @override + int hash(RecordType e) => const DeepCollectionEquality().hash([ + e.nullabilitySuffix, + e.alias, + e.positionalFields.map( + (field) => const DartTypeEquality().hash(field.type), + ), + e.namedFields.map((field) => field.name), + e.namedFields.map((field) => const DartTypeEquality().hash(field.type)), + ]); + + @override + bool isValidKey(Object? o) => o is RecordType; +} + +extension SafeExpand on FileSpan { + /// Allows expanding a span to include another span, but only if they are + /// in the same file, since [ast.FileSpan.expand] will throw if they are not. + // TODO(dnys1): Improve expand functionality to allow multi-file splits and better disjoint expands with (...) instead of showing every line. + FileSpan safeExpand(FileSpan other) { + if (sourceUrl != other.sourceUrl) { + return this; + } + // Limits the maximum number of lines that can be expanded. + // This prevents really long contexts. + const maxLines = 12; + final start = min(this.start.line, other.start.line); + final end = max(this.end.line, other.end.line); + if ((end - start) > maxLines) { + return this; + } + return expand(other); + } +} + +extension AnnotationIsPrivate on ElementAnnotation { + /// Whether the annotation references a private [element]. + bool get isPrivate => switch (element) { + null => false, + final PropertyAccessorElement propertyAccessor => + propertyAccessor.variable2!.isPrivate, + final ConstructorElement constructor => + constructor.enclosingElement3.isPrivate, + _ => unreachable('Unexpected annotation element: ${element.runtimeType}'), + }; + + codegen.Expression? get toCodeBuilder { + if (isPrivate) { + return null; + } + if (element + case VariableElement(:final type) || + PropertyAccessorElement(returnType: final type) || + ConstructorElement(returnType: final DartType type) + when type == typeHelper.coreTypes.celestEnvType || + type == typeHelper.coreTypes.celestSecretType) { + return null; + } + final constant = computeConstantValue(); + if (constant == null) { + return null; + } + final type = constant.type; + if (type == null || type.isCelestSdk || type.isMiddleware) { + return null; + } + if (element case PropertyAccessorElement( + :final name, + :final library, + ) when library.isWithinProjectLib) { + return codegen.refer(name, library.source.uri.toString()); + } + return constant.toCodeBuilder; + } + + ast.DartValue? get toDartValue { + if (isPrivate) { + return null; + } + if (element + case VariableElement(:final type) || + PropertyAccessorElement(returnType: final type) || + ConstructorElement(returnType: final DartType type) + when type == typeHelper.coreTypes.celestEnvType || + type == typeHelper.coreTypes.celestSecretType) { + return null; + } + final constant = computeConstantValue(); + if (constant == null) { + return null; + } + return constant.toDartValue; + } +} + +extension ParameterDefaultTo on ParameterElement { + /// The parameter's default value as a [codegen.Expression]. + codegen.Expression? get defaultToExpression => switch (this) { + // TODO(dnys1): File ticket with Dart team + // Required, named, non-nullable parameters have a default value + // of `null` for some reason. + _ when isRequired && isNamed => null, + final ConstVariableElement constVar => + constVar.computeConstantValue()?.toCodeBuilder, + _ => null, + }; + + /// The parameter's default value as a [ast.DartValue]. + ast.DartValue? get defaultToValue => switch (this) { + // TODO(dnys1): File ticket with Dart team + // Required, named, non-nullable parameters have a default value + // of `null` for some reason. + _ when isRequired && isNamed => null, + final ConstVariableElement constVar => + constVar.computeConstantValue()?.toDartValue, + _ => null, + }; +} + +extension NonPrivate on String { + String get nonPrivate { + if (startsWith('_')) { + return substring(1); + } + return this; + } +} + +extension DartObjectHelpers on DartObject { + String get configValueName { + if (getField('name')?.toStringValue() case final name?) { + return name; + } + final name = getField('(super)')?.getField('name')?.toStringValue(); + if (name != null) { + return name; + } + // Should never happen since `name` is non-nullable. + unreachable('Missing name for config value: $this'); + } +} diff --git a/apps/cli/lib/src/utils/cli.dart b/apps/cli/lib/src/utils/cli.dart new file mode 100644 index 000000000..67493c2fe --- /dev/null +++ b/apps/cli/lib/src/utils/cli.dart @@ -0,0 +1,43 @@ +import 'dart:convert'; +import 'dart:io' as io; + +import 'package:async/async.dart'; + +typedef ProcessSink = void Function(String); + +/// Allows storing forwarding streams so we can listen to process outputs +/// multiple times. +final _stdoutStreams = Expando>>(); +final _stderrStreams = Expando>>(); + +/// Helpers on [Process]. +extension ProcessUtil on io.Process { + static void _printToStdout(String message) => io.stdout.writeln(message); + static void _printToStderr(String message) => io.stderr.writeln(message); + + /// Returns a [Stream] of the `stdout` of this process, which can be listened + /// to multiple times. + Stream> get stdout => + (_stdoutStreams[this] ??= StreamSplitter(this.stdout)).split(); + + /// Returns a [Stream] of the `stderr` of this process, which can be listened + /// to multiple times. + Stream> get stderr => + (_stderrStreams[this] ??= StreamSplitter(this.stderr)).split(); + + /// Captures `stdout` to the provided sink, the global [stdout] by default. + void captureStdout({ProcessSink sink = _printToStdout, String prefix = ''}) { + stdout + .transform(const Utf8Decoder()) + .transform(const LineSplitter()) + .listen((line) => sink('$prefix$line')); + } + + /// Captures `stderr` to the provided sink, the global [stderr] by default. + void captureStderr({ProcessSink sink = _printToStderr, String prefix = ''}) { + stderr + .transform(const Utf8Decoder()) + .transform(const LineSplitter()) + .listen((line) => sink('$prefix$line')); + } +} diff --git a/apps/cli/lib/src/utils/error.dart b/apps/cli/lib/src/utils/error.dart new file mode 100644 index 000000000..676e0e42c --- /dev/null +++ b/apps/cli/lib/src/utils/error.dart @@ -0,0 +1,14 @@ +class _UnreachableError extends Error { + _UnreachableError(this.message); + + final String message; + + @override + String toString() => message; +} + +Never unreachable([String message = 'Unreachable code reached']) => + throw _UnreachableError(message); + +// ignore: non_constant_identifier_names +Never TODO([String? message]) => throw UnimplementedError(message); diff --git a/apps/cli/lib/src/utils/json.dart b/apps/cli/lib/src/utils/json.dart new file mode 100644 index 000000000..4892c9cc0 --- /dev/null +++ b/apps/cli/lib/src/utils/json.dart @@ -0,0 +1,5 @@ +import 'dart:convert'; + +String prettyPrintJson(Object? object) { + return const JsonEncoder.withIndent(' ').convert(object); +} diff --git a/apps/cli/lib/src/utils/list.dart b/apps/cli/lib/src/utils/list.dart new file mode 100644 index 000000000..f24e0036b --- /dev/null +++ b/apps/cli/lib/src/utils/list.dart @@ -0,0 +1,17 @@ +import 'dart:async'; + +extension ListHelpers on Iterable { + Future> asyncMap(Future Function(T) mapper) async { + // Iterates sequentially to mimic the behavior of `Iterable.map` since + // `Future.wait` executes all tasks at once which may cause race conditions. + // TODO(dnys1): Find fix which allows parallelization. + final results = []; + for (final it in this) { + results.add(await mapper(it)); + } + return results; + } + + Future> asyncExpand(Future> Function(T) mapper) => + asyncMap(mapper).then((it) => it.expand((it) => it).toList()); +} diff --git a/apps/cli/lib/src/utils/path.dart b/apps/cli/lib/src/utils/path.dart new file mode 100644 index 000000000..91a19f162 --- /dev/null +++ b/apps/cli/lib/src/utils/path.dart @@ -0,0 +1,12 @@ +import 'package:celest_cli/src/context.dart'; +import 'package:path/path.dart' as path; + +extension PathConvert on path.Context { + String convert(String path, {required path.Context to}) { + return to.joinAll(split(path)); + } +} + +extension ConvertPath on String { + String to(path.Context to) => to.joinAll(p.split(this)); +} diff --git a/apps/cli/lib/src/utils/recase.dart b/apps/cli/lib/src/utils/recase.dart new file mode 100644 index 000000000..a093af3df --- /dev/null +++ b/apps/cli/lib/src/utils/recase.dart @@ -0,0 +1,126 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + +import 'package:collection/collection.dart'; + +/// Re-casing helpers for strings. +extension StringRecase on String { + /// The capitalized version of `this`, with the first letter upper-cased and + /// all others lower-cased. + String get capitalized { + if (length < 2) return toUpperCase(); + return this[0].toUpperCase() + substring(1).toLowerCase(); + } + + /// The `camelCase` version of `this`. + String get camelCase => groupIntoWords().camelCase; + + /// The `param-case` version of `this`. + String get paramCase => groupIntoWords().paramCase; + + /// The `PascalCase` version of `this`. + String get pascalCase => groupIntoWords().pascalCase; + + /// The `snake_case` version of `this`. + String get snakeCase => groupIntoWords().snakeCase; + + // "acm-success"-> "acm success" + static final _nonAlphaNumericChars = RegExp(r'[^A-Za-z0-9+]'); + + // TESTv4 -> "TEST v4" + static final _standaloneVLower = RegExp(r'([^a-z]{2,})v([0-9]+)'); + + // TestV4 -> "Test V4" + static final _standaloneVUpper = RegExp(r'([^A-Z]{2,})V([0-9]+)'); + + // "AcmSuccess" -> "Acm Success" + // Workaround for lack of support for lookbehinds in Safari: + // https://caniuse.com/js-regexp-lookbehind + static final _camelCasedWords = RegExp(r'(?=[a-z][A-Z]([a-zA-Z0-9]|$))'); + + // "ACMSuccess" -> "ACM Success" + static final _acronyms = RegExp(r'([A-Z]+)([A-Z][a-z])'); + + // "s3ec2" -> "s3 ec2" + static final _numInMiddleOrEnd = RegExp(r'([0-9])([a-zA-Z])'); + + /// Splits `this` into words along word boundaries. + WordGroup groupIntoWords() { + var result = this; + + // all non-alphanumeric characters: "acm-success"-> "acm success" + result = result.replaceAll(_nonAlphaNumericChars, ' '); + + // if a number has a standalone v in front of it, separate it out + result = result + // TESTv4 -> "TEST v4" + .replaceAllMapped( + _standaloneVLower, + (m) => '${m.group(1)} v${m.group(2)}', + ) + + // TestV4 -> "Test V4" + .replaceAllMapped( + _standaloneVUpper, + (m) => '${m.group(1)} V${m.group(2)}', + ); + + // add a space between camelCased words: "AcmSuccess" -> "Acm Success" + // Workaround for lack of support for lookbehinds in Safari: + // https://caniuse.com/js-regexp-lookbehind + var start = 0; + result = () sync* { + yield* _camelCasedWords.allMatches(result).map((match) { + final end = match.start + 1; + final substr = result.substring(start, end); + start = end; + return substr; + }); + yield result.substring(start); + }() + .join(' '); + + // add a space after acronyms: "ACMSuccess" -> "ACM Success" + result = result.replaceAllMapped( + _acronyms, + (m) => '${m.group(1)} ${m.group(2)}', + ); + + // add space after a number in the middle of a word: "s3ec2" -> "s3 ec2" + result = result.replaceAllMapped( + _numInMiddleOrEnd, + (m) => '${m.group(1)} ${m.group(2)}', + ); + + // remove extra spaces - multiple consecutive ones or those and the + // beginning/end of words + result = result.replaceAll(RegExp(r'\s+'), ' ').trim(); + + return WordGroup(result.split(' ')); + } +} + +extension type WordGroup(List _group) implements List { + /// Acronyms for which we should maintain casing. + static const List _maintainCase = []; + + /// The `camelCase` version of `this`. + String get camelCase => mapIndexed((index, word) { + if (index == 0) return word.toLowerCase(); + return word.capitalized; + }).join(); + + /// The `param-case` version of `this`. + String get paramCase => map((word) => word.toLowerCase()).join('-'); + + /// The `PascalCase` version of `this`. + String get pascalCase => map((word) { + if (_maintainCase.contains(word)) { + return word; + } + return word.capitalized; + }).join(); + + /// The `snake_case` version of `this`. + String get snakeCase => map((word) => word.toLowerCase()).join('_'); +} diff --git a/apps/cli/lib/src/utils/reference.dart b/apps/cli/lib/src/utils/reference.dart new file mode 100644 index 000000000..6ae07e6e8 --- /dev/null +++ b/apps/cli/lib/src/utils/reference.dart @@ -0,0 +1,313 @@ +import 'package:analyzer/dart/element/type.dart' as ast; +import 'package:celest_cli/src/context.dart'; +import 'package:celest_cli/src/types/dart_types.dart'; +import 'package:celest_cli/src/utils/analyzer.dart'; +import 'package:celest_cli/src/utils/error.dart'; +import 'package:code_builder/code_builder.dart'; + +extension ReferenceHelper on Reference { + bool get isPackageCelest => switch (url) { + final url? => + url.startsWith('package:celest') && + !url.startsWith('package:celest_backend'), + _ => false, + }; + bool get isFunctionContext => + symbol == 'FunctionContext' && + (url?.startsWith('package:celest') ?? false); + + bool get isDynamic => symbol == 'dynamic' && url == 'dart:core'; + bool get isDartCoreObject => symbol == 'Object' && url == 'dart:core'; + + TypeReference get toTypeReference => switch (this) { + final TypeReference type => type, + final RecordType recordType => TypeReference((t) { + final dartType = typeHelper.fromReference(recordType) as ast.RecordType; + t + ..symbol = dartType.symbol + ..url = dartType.sourceUri?.toString() + ..isNullable = recordType.isNullable; + }), + final FunctionType functionType => TypeReference((t) { + final dartType = + typeHelper.fromReference(functionType) as ast.FunctionType; + t + ..symbol = dartType.getDisplayString() + ..url = dartType.sourceUri?.toString() + ..isNullable = functionType.isNullable; + }), + _ => TypeReference((t) { + assert(symbol != null); + t + ..symbol = symbol + ..url = url; + }), + }; + + /// Returns a nullable version of `this`. + TypeReference get nullable { + return toTypeReference.rebuild((t) => t.isNullable = true); + } + + /// Returns a non-nullable version of `this`. + TypeReference get nonNullable { + return toTypeReference.rebuild((t) => t.isNullable = false); + } + + Reference get noBound { + return switch (this) { + final TypeReference type => type.rebuild( + (t) => + t + ..bound = null + ..types.map((t) => t.toTypeReference.noBound), + ), + _ => this, + }; + } + + Reference withNullability(bool isNullable) => switch (this) { + final RecordType recordType => recordType.rebuild( + (t) => t..isNullable = isNullable, + ), + final FunctionType functionType => functionType.rebuild( + (t) => t..isNullable = isNullable, + ), + final TypeReference type => type.rebuild((t) { + if (symbol != 'dynamic') t.isNullable = isNullable; + }), + _ => toTypeReference.rebuild((t) => t..isNullable = isNullable), + }; + + bool get isNullableOrFalse => switch (this) { + TypeReference(:final isNullable) => isNullable ?? false, + RecordType(:final isNullable) => isNullable ?? false, + _ => false, + }; + + /// Constructs a `built_value` FullType reference for this. + Expression fullType([Iterable? parameters]) { + final typeRef = toTypeReference; + final ctor = + typeRef.isNullable ?? false + ? (Iterable args) => DartTypes.builtValue.fullType + .constInstanceNamed('nullable', args) + : DartTypes.builtValue.fullType.constInstance; + if (typeRef.types.isEmpty && (parameters == null || parameters.isEmpty)) { + return ctor([typeRef.nonNullable]); + } + return ctor([ + typeRef.rebuild((t) => t.types.clear()).nonNullable, + literalList( + parameters?.map((param) => param.fullType()) ?? + typeRef.types.map((t) => t.fullType()), + ), + ]); + } + + /// A unique, readable name for this type which can be used in generated code + /// and over the wire. + /// + /// We try to follow protobuf versioning guidelines and use the package name, + /// organization name, and the version to give types unique names which are + /// easy to interpret and do not expose implementation details. + String? externalUri(String projectName) { + assert(symbol != null, 'Symbol is null for $this'); + if (url == null) { + // Would only be an anonymous record type. + return null; + } + final sourceUri = Uri.parse(url!); + final externalPackageId = switch (sourceUri) { + Uri(scheme: 'dart') => 'dart.${sourceUri.pathSegments.single}', + // TODO(dnys1): Include organization name + // TODO(dnys1): Include version tag + Uri(scheme: 'package', pathSegments: ['celest_backend', ...]) || + Uri(pathSegments: []) => '$projectName.v1', + Uri(scheme: 'package', pathSegments: [final package, ...]) + when isPackageCelest => + '${package.split('_').join('.')}.v1', + // TODO(dnys1): Should this include the package's major version? + Uri(scheme: 'package', :final pathSegments) => pathSegments.first, + _ => unreachable('Unexpected source URI: $sourceUri'), + }; + return '$externalPackageId.$symbol'; + } +} + +Expression mapIf(Expression condition, Expression key) => + _MapIfExpression(condition: condition, key: key); + +final class _MapIfExpression extends Expression { + _MapIfExpression({required this.condition, required this.key}); + + final Expression condition; + final Expression key; + + @override + R accept(covariant ExpressionVisitor visitor, [R? context]) { + return visitor.visitCodeExpression( + CodeExpression( + Block.of([ + const Code('if ('), + condition.code, + const Code(') '), + key.code, + ]), + ), + context, + ); + } +} + +Expression collectionIf(Expression condition, Expression ifTrue) => + _ListIfExpression(condition: condition, ifTrue: ifTrue); + +final class _ListIfExpression extends Expression { + _ListIfExpression({required this.condition, required this.ifTrue}); + + final Expression condition; + final Expression ifTrue; + + @override + R accept(covariant ExpressionVisitor visitor, [R? context]) { + return visitor.visitCodeExpression( + CodeExpression( + Block.of([ + const Code('if ('), + condition.code, + const Code(') '), + ifTrue.code, + ]), + ), + context, + ); + } +} + +Expression nullCheckBind( + String variableName, + Expression expression, { + bool isNullable = true, +}) => NullCheckCaseExpression( + variableName: variableName, + caseClause: expression, + isNullable: isNullable, +); + +// Creates a `value case final variable?` expression. +final class NullCheckCaseExpression extends Expression { + NullCheckCaseExpression({ + required this.caseClause, + required this.variableName, + this.isNullable = true, + }); + + final Expression caseClause; + final String variableName; + final bool isNullable; + + @override + R accept(covariant ExpressionVisitor visitor, [R? context]) { + return visitor.visitCodeExpression( + CodeExpression( + Block.of([ + caseClause.code, + const Code(' case final '), + Code(variableName), + if (isNullable) const Code('?'), + ]), + ), + context, + ); + } +} + +extension ExpressionUtil on Expression { + /// The property getter, given [isNullable]. + Expression nullableProperty(String name, bool isNullable) { + if (isNullable) { + return nullSafeProperty(name); + } else { + return property(name); + } + } + + Expression nullSafeIndex(Expression index, {bool isNullable = true}) => + _BinaryExpression( + // ignore: invalid_use_of_visible_for_overriding_member + expression, + CodeExpression( + Block.of([const Code('['), index.code, const Code(']')]), + ), + isNullable ? '?' : '', + ); + + Expression wrapWithInlineNullCheck( + Expression check, [ + bool isNullable = true, + ]) { + if (!isNullable) return this; + return check.equalTo(literalNull).conditional(literalNull, nullChecked); + } + + Code wrapWithBlockNullCheck(Expression check, bool isNullable) { + return isNullable + ? nullChecked.wrapWithBlockIf(check, isNullable) + : wrapWithBlockIf(check, isNullable); + } + + Code wrapWithBlockIf(Expression check, [bool performCheck = true]) { + return Block.of([ + if (performCheck) ...[const Code('if ('), check.code, const Code(') {')], + statement, + if (performCheck) const Code('}'), + ]); + } + + /// Strips the `const` keyword from this expression. + /// + // TODO(dnys1): File a ticket with `code_builder` since this is only used to + /// workaround limitation with const constructors in annotations. + Expression get stripConst { + if (this case final InvokeExpression invoke) { + return InvokeExpression.newOf( + invoke.target, + invoke.positionalArguments, + invoke.namedArguments, + invoke.typeArguments, + invoke.name, + ); + } + return this; + } +} + +extension CodeHelpers on Code { + Code wrapWithBlockIf(Expression check, [bool performCheck = true]) { + return Block.of([ + if (performCheck) ...[const Code('if ('), check.code, const Code(') {')], + this, + if (performCheck) const Code('}'), + ]); + } +} + +final class _BinaryExpression extends Expression implements BinaryExpression { + const _BinaryExpression(this.left, this.right, this.operator); + + @override + final Expression left; + @override + final Expression right; + @override + final String operator; + @override + bool get addSpace => true; + @override + bool get isConst => false; + + @override + R accept(ExpressionVisitor visitor, [R? context]) => + visitor.visitBinaryExpression(this, context); +} diff --git a/apps/cli/lib/src/utils/run.dart b/apps/cli/lib/src/utils/run.dart new file mode 100644 index 000000000..6b18a60a3 --- /dev/null +++ b/apps/cli/lib/src/utils/run.dart @@ -0,0 +1,7 @@ +@pragma('vm:prefer-inline') +R run(R Function() fn) => fn(); + +extension Let on T { + @pragma('vm:prefer-inline') + R let(R Function(T) fn) => fn(this); +} diff --git a/apps/cli/lib/src/utils/typeid.dart b/apps/cli/lib/src/utils/typeid.dart new file mode 100644 index 000000000..3ccce1d46 --- /dev/null +++ b/apps/cli/lib/src/utils/typeid.dart @@ -0,0 +1,147 @@ +import 'dart:typed_data'; + +import 'package:celest_core/_internal.dart'; + +TypeId typeId([String type = '']) => + TypeId._create(type); + +typedef TypeIdData = ({String type, Uuid uuid}); + +extension type TypeId._(String _encoded) implements String { + factory TypeId._create(String type) { + final id = Uuid.v7(); + return TypeId._('${type}_${_encode(id)}'); + } + + String get type => split('_').first; + + TypeIdData get decoded { + final [type, id] = split('_'); + return (type: type, uuid: _decode(id)); + } +} + +final _alphabet = '0123456789abcdefghjkmnpqrstvwxyz'.codeUnits; + +/// Encodes a [value] as a base32 string. +String _encode(Uuid uuid) { + final value = uuid.value; + if (value.length != 16) { + throw FormatException( + 'Invalid UUID. Expected 16 bytes, got ${value.length}.', + ); + } + + final result = Uint8List(26); + + // 10 byte timestamp + result[0] = _alphabet[(value[0] & 224) >> 5]; + result[1] = _alphabet[value[0] & 31]; + result[2] = _alphabet[(value[1] & 248) >> 3]; + result[3] = _alphabet[((value[1] & 7) << 2) | ((value[2] & 192) >> 6)]; + result[4] = _alphabet[(value[2] & 62) >> 1]; + result[5] = _alphabet[((value[2] & 1) << 4) | ((value[3] & 240) >> 4)]; + result[6] = _alphabet[((value[3] & 15) << 1) | ((value[4] & 128) >> 7)]; + result[7] = _alphabet[(value[4] & 124) >> 2]; + result[8] = _alphabet[((value[4] & 3) << 3) | ((value[5] & 224) >> 5)]; + result[9] = _alphabet[value[5] & 31]; + + // 16 bytes of entropy + result[10] = _alphabet[(value[6] & 248) >> 3]; + result[11] = _alphabet[((value[6] & 7) << 2) | ((value[7] & 192) >> 6)]; + result[12] = _alphabet[(value[7] & 62) >> 1]; + result[13] = _alphabet[((value[7] & 1) << 4) | ((value[8] & 240) >> 4)]; + result[14] = _alphabet[((value[8] & 15) << 1) | ((value[9] & 128) >> 7)]; + result[15] = _alphabet[(value[9] & 124) >> 2]; + result[16] = _alphabet[((value[9] & 3) << 3) | ((value[10] & 224) >> 5)]; + result[17] = _alphabet[value[10] & 31]; + result[18] = _alphabet[(value[11] & 248) >> 3]; + result[19] = _alphabet[((value[11] & 7) << 2) | ((value[12] & 192) >> 6)]; + result[20] = _alphabet[(value[12] & 62) >> 1]; + result[21] = _alphabet[((value[12] & 1) << 4) | ((value[13] & 240) >> 4)]; + result[22] = _alphabet[((value[13] & 15) << 1) | ((value[14] & 128) >> 7)]; + result[23] = _alphabet[(value[14] & 124) >> 2]; + result[24] = _alphabet[((value[14] & 3) << 3) | ((value[15] & 224) >> 5)]; + result[25] = _alphabet[value[15] & 31]; + + return String.fromCharCodes(result); +} + +const _dec = [ + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x01, // + 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0xFF, 0xFF, // + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x0A, 0x0B, 0x0C, // + 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0xFF, 0x12, 0x13, 0xFF, 0x14, // + 0x15, 0xFF, 0x16, 0x17, 0x18, 0x19, 0x1A, 0xFF, 0x1B, 0x1C, // + 0x1D, 0x1E, 0x1F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, +]; + +Uuid _decode(String encoded) { + final bytes = encoded.codeUnits; + if (bytes.length != 26) { + throw FormatException('Invalid base32 length: ${encoded.length}', encoded); + } + + // Check if all the characters are part of the expected base32 character set + for (var offset = 0; offset < 26; offset++) { + final byte = bytes[offset]; + if (_dec[byte] == 0xff) { + throw FormatException( + 'Invalid base32 character: $byte (offset=$offset)', + encoded, + ); + } + } + + final id = Uint8List(16); + + // 6 bytes timestamp (48 bits) + id[0] = (_dec[bytes[0]] << 5) | _dec[bytes[1]]; + id[1] = (_dec[bytes[2]] << 3) | (_dec[bytes[3]] >> 2); + id[2] = (_dec[bytes[3]] << 6) | (_dec[bytes[4]] << 1) | (_dec[bytes[5]] >> 4); + id[3] = (_dec[bytes[5]] << 4) | (_dec[bytes[6]] >> 1); + id[4] = (_dec[bytes[6]] << 7) | (_dec[bytes[7]] << 2) | (_dec[bytes[8]] >> 3); + id[5] = (_dec[bytes[8]] << 5) | _dec[bytes[9]]; + + // 10 bytes of entropy (80 bits) + id[6] = + (_dec[bytes[10]] << 3) | + (_dec[bytes[11]] >> 2); // First 4 bits are the version + id[7] = + (_dec[bytes[11]] << 6) | (_dec[bytes[12]] << 1) | (_dec[bytes[13]] >> 4); + id[8] = + (_dec[bytes[13]] << 4) | + (_dec[bytes[14]] >> 1); // First 2 bits are the variant + id[9] = + (_dec[bytes[14]] << 7) | (_dec[bytes[15]] << 2) | (_dec[bytes[16]] >> 3); + id[10] = (_dec[bytes[16]] << 5) | _dec[bytes[17]]; + id[11] = (_dec[bytes[18]] << 3) | _dec[bytes[19]] >> 2; + id[12] = + (_dec[bytes[19]] << 6) | (_dec[bytes[20]] << 1) | (_dec[bytes[21]] >> 4); + id[13] = (_dec[bytes[21]] << 4) | (_dec[bytes[22]] >> 1); + id[14] = + (_dec[bytes[22]] << 7) | (_dec[bytes[23]] << 2) | (_dec[bytes[24]] >> 3); + id[15] = (_dec[bytes[24]] << 5) | _dec[bytes[25]]; + + return Uuid(id); +} diff --git a/apps/cli/lib/src/version.dart b/apps/cli/lib/src/version.dart new file mode 100644 index 000000000..748c730fb --- /dev/null +++ b/apps/cli/lib/src/version.dart @@ -0,0 +1,13 @@ +import 'package:celest_cli/src/utils/run.dart'; +import 'package:pub_semver/pub_semver.dart'; + +const String _version = '1.0.6+2'; + +final String packageVersion = run(() { + const override = String.fromEnvironment('celest.version'); + if (override.isEmpty) { + return _version; + } + Version.parse(override); // Trigger a format exception if invalid. + return override; +}); diff --git a/apps/cli/pubspec.lock b/apps/cli/pubspec.lock new file mode 100644 index 000000000..62ce3a726 --- /dev/null +++ b/apps/cli/pubspec.lock @@ -0,0 +1,1567 @@ +# Generated by pub +# See https://dart.dev/tools/pub/glossary#lockfile +packages: + _discoveryapis_commons: + dependency: transitive + description: + name: _discoveryapis_commons + sha256: "113c4100b90a5b70a983541782431b82168b3cae166ab130649c36eb3559d498" + url: "https://pub.dev" + source: hosted + version: "1.0.7" + _fe_analyzer_shared: + dependency: transitive + description: + name: _fe_analyzer_shared + sha256: dc27559385e905ad30838356c5f5d574014ba39872d732111cd07ac0beff4c57 + url: "https://pub.dev" + source: hosted + version: "80.0.0" + adaptive_number: + dependency: transitive + description: + name: adaptive_number + sha256: "3a567544e9b5c9c803006f51140ad544aedc79604fd4f3f2c1380003f97c1d77" + url: "https://pub.dev" + source: hosted + version: "1.0.0" + analyzer: + dependency: "direct main" + description: + name: analyzer + sha256: "192d1c5b944e7e53b24b5586db760db934b177d4147c42fbca8c8c5f1eb8d11e" + url: "https://pub.dev" + source: hosted + version: "7.3.0" + analyzer_plugin: + dependency: "direct main" + description: + name: analyzer_plugin + sha256: b3075265c5ab222f8b3188342dcb50b476286394a40323e85d1fa725035d40a4 + url: "https://pub.dev" + source: hosted + version: "0.13.0" + archive: + dependency: "direct main" + description: + name: archive + sha256: "0c64e928dcbefddecd234205422bcfc2b5e6d31be0b86fef0d0dd48d7b4c9742" + url: "https://pub.dev" + source: hosted + version: "4.0.4" + args: + dependency: "direct main" + description: + name: args + sha256: bf9f5caeea8d8fe6721a9c358dd8a5c1947b27f1cfaa18b39c301273594919e6 + url: "https://pub.dev" + source: hosted + version: "2.6.0" + asn1lib: + dependency: transitive + description: + name: asn1lib + sha256: "068190d6c99c436287936ba5855af2e1fa78d8083ae65b4db6a281780da727ae" + url: "https://pub.dev" + source: hosted + version: "1.6.0" + async: + dependency: "direct main" + description: + name: async + sha256: "758e6d74e971c3e5aceb4110bfd6698efc7f501675bcfe0c775459a8140750eb" + url: "https://pub.dev" + source: hosted + version: "2.13.0" + benchmark_harness: + dependency: "direct dev" + description: + name: benchmark_harness + sha256: "83f65107165883ba8623eb822daacb23dcf9f795c66841de758c9dd7c5a0cf28" + url: "https://pub.dev" + source: hosted + version: "2.3.1" + boolean_selector: + dependency: transitive + description: + name: boolean_selector + sha256: "8aab1771e1243a5063b8b0ff68042d67334e3feab9e95b9490f9a6ebf73b42ea" + url: "https://pub.dev" + source: hosted + version: "2.1.2" + build: + dependency: "direct dev" + description: + name: build + sha256: cef23f1eda9b57566c81e2133d196f8e3df48f244b317368d65c5943d91148f0 + url: "https://pub.dev" + source: hosted + version: "2.4.2" + build_config: + dependency: transitive + description: + name: build_config + sha256: "4ae2de3e1e67ea270081eaee972e1bd8f027d459f249e0f1186730784c2e7e33" + url: "https://pub.dev" + source: hosted + version: "1.1.2" + build_daemon: + dependency: transitive + description: + name: build_daemon + sha256: "8e928697a82be082206edb0b9c99c5a4ad6bc31c9e9b8b2f291ae65cd4a25daa" + url: "https://pub.dev" + source: hosted + version: "4.0.4" + build_resolvers: + dependency: transitive + description: + name: build_resolvers + sha256: b9e4fda21d846e192628e7a4f6deda6888c36b5b69ba02ff291a01fd529140f0 + url: "https://pub.dev" + source: hosted + version: "2.4.4" + build_runner: + dependency: "direct dev" + description: + name: build_runner + sha256: "058fe9dce1de7d69c4b84fada934df3e0153dd000758c4d65964d0166779aa99" + url: "https://pub.dev" + source: hosted + version: "2.4.15" + build_runner_core: + dependency: transitive + description: + name: build_runner_core + sha256: "22e3aa1c80e0ada3722fe5b63fd43d9c8990759d0a2cf489c8c5d7b2bdebc021" + url: "https://pub.dev" + source: hosted + version: "8.0.0" + build_test: + dependency: "direct dev" + description: + name: build_test + sha256: a580c76c28440d0006b75c6746bbbb3c1648959ba9e1afae2c2b0f2c26acdf3d + url: "https://pub.dev" + source: hosted + version: "2.2.3" + built_collection: + dependency: "direct main" + description: + name: built_collection + sha256: "376e3dd27b51ea877c28d525560790aee2e6fbb5f20e2f85d5081027d94e2100" + url: "https://pub.dev" + source: hosted + version: "5.1.1" + built_value: + dependency: "direct main" + description: + name: built_value + sha256: "8b158ab94ec6913e480dc3f752418348b5ae099eb75868b5f4775f0572999c61" + url: "https://pub.dev" + source: hosted + version: "8.9.4" + built_value_generator: + dependency: "direct dev" + description: + name: built_value_generator + sha256: be1985fc0befbd467b47f60c7bebe77135cd946584c11cd13debbbb274e99bd0 + url: "https://pub.dev" + source: hosted + version: "8.9.4" + cedar: + dependency: "direct main" + description: + name: cedar + sha256: "1ce1a9c06f10436739e1757e364ba016e4c13418761b83af76fa4ba784a028be" + url: "https://pub.dev" + source: hosted + version: "0.2.3" + celest: + dependency: "direct main" + description: + path: "../../packages/celest" + relative: true + source: path + version: "1.0.1+2" + celest_ast: + dependency: "direct main" + description: + path: "../../packages/celest_ast" + relative: true + source: path + version: "0.1.4" + celest_auth: + dependency: "direct main" + description: + path: "../../packages/celest_auth" + relative: true + source: path + version: "1.0.0" + celest_cloud: + dependency: "direct main" + description: + path: "../../packages/celest_cloud" + relative: true + source: path + version: "0.1.4" + celest_core: + dependency: "direct main" + description: + path: "../../packages/celest_core" + relative: true + source: path + version: "1.0.0" + celest_lints: + dependency: "direct dev" + description: + path: "../../packages/celest_lints" + relative: true + source: path + version: "1.0.0" + characters: + dependency: transitive + description: + name: characters + sha256: f71061c654a3380576a52b451dd5532377954cf9dbd272a78fc8479606670803 + url: "https://pub.dev" + source: hosted + version: "1.4.0" + charcode: + dependency: transitive + description: + name: charcode + sha256: fb0f1107cac15a5ea6ef0a6ef71a807b9e4267c713bb93e00e92d737cc8dbd8a + url: "https://pub.dev" + source: hosted + version: "1.4.0" + checked_yaml: + dependency: transitive + description: + name: checked_yaml + sha256: feb6bed21949061731a7a75fc5d2aa727cf160b91af9a3e464c5e3a32e28b5ff + url: "https://pub.dev" + source: hosted + version: "2.0.3" + checks: + dependency: "direct dev" + description: + name: checks + sha256: aad431b45a8ae2fa26db8c22e385b9cdec73f72986a1d9d9f2017f4c39ecf5c9 + url: "https://pub.dev" + source: hosted + version: "0.3.0" + chunked_stream: + dependency: "direct main" + description: + name: chunked_stream + sha256: b2fde5f81d780f0c1699b8347cae2e413412ae947fc6e64727cc48c6bb54c95c + url: "https://pub.dev" + source: hosted + version: "1.4.2" + circular_buffer: + dependency: transitive + description: + name: circular_buffer + sha256: b3a315fef3fee7fe58879643fc8ce21c7c2449d01c1a8a396dc9e24687f335c4 + url: "https://pub.dev" + source: hosted + version: "0.12.0" + cli_config: + dependency: transitive + description: + name: cli_config + sha256: ac20a183a07002b700f0c25e61b7ee46b23c309d76ab7b7640a028f18e4d99ec + url: "https://pub.dev" + source: hosted + version: "0.2.0" + cli_script: + dependency: "direct main" + description: + name: cli_script + sha256: "4d4d47dcac7f2e6fb68a6b3e806787b031eeb042bc330ba6dd333ad1e7f83252" + url: "https://pub.dev" + source: hosted + version: "1.0.0" + cli_util: + dependency: "direct main" + description: + name: cli_util + sha256: ff6785f7e9e3c38ac98b2fb035701789de90154024a75b6cb926445e83197d1c + url: "https://pub.dev" + source: hosted + version: "0.4.2" + clock: + dependency: transitive + description: + name: clock + sha256: fddb70d9b5277016c77a80201021d40a2247104d9f4aa7bab7157b7e3f05b84b + url: "https://pub.dev" + source: hosted + version: "1.1.2" + cloud_http: + dependency: transitive + description: + name: cloud_http + sha256: c20f72646647545dee042854b6da07773728f20d4217123f946108066a7cb0f4 + url: "https://pub.dev" + source: hosted + version: "0.1.0" + code_builder: + dependency: "direct main" + description: + name: code_builder + sha256: "0ec10bf4a89e4c613960bf1e8b42c64127021740fb21640c29c909826a5eea3e" + url: "https://pub.dev" + source: hosted + version: "4.10.1" + collection: + dependency: "direct main" + description: + name: collection + sha256: "2f5709ae4d3d59dd8f7cd309b4e023046b57d8a6c82130785d2b0e5868084e76" + url: "https://pub.dev" + source: hosted + version: "1.19.1" + convert: + dependency: "direct main" + description: + name: convert + sha256: b30acd5944035672bc15c6b7a8b47d773e41e2f17de064350988c5d02adb1c68 + url: "https://pub.dev" + source: hosted + version: "3.1.2" + corks_cedar: + dependency: "direct main" + description: + name: corks_cedar + sha256: "7e32abda7dbf548e5edbad526c5394473ac462b8a9b335911f541372563e6514" + url: "https://pub.dev" + source: hosted + version: "0.2.2" + coverage: + dependency: transitive + description: + name: coverage + sha256: e3493833ea012784c740e341952298f1cc77f1f01b1bbc3eb4eecf6984fb7f43 + url: "https://pub.dev" + source: hosted + version: "1.11.1" + crypto: + dependency: "direct main" + description: + name: crypto + sha256: "1e445881f28f22d6140f181e07737b22f1e099a5e1ff94b0af2f9e4a463f4855" + url: "https://pub.dev" + source: hosted + version: "3.0.6" + crypto_keys: + dependency: transitive + description: + name: crypto_keys + sha256: acc19abf34623d990a0e8aec69463d74a824c31f137128f42e2810befc509ad0 + url: "https://pub.dev" + source: hosted + version: "0.3.0+1" + csslib: + dependency: transitive + description: + name: csslib + sha256: "09bad715f418841f976c77db72d5398dc1253c21fb9c0c7f0b0b985860b2d58e" + url: "https://pub.dev" + source: hosted + version: "1.0.2" + csv: + dependency: transitive + description: + name: csv + sha256: c6aa2679b2a18cb57652920f674488d89712efaf4d3fdf2e537215b35fc19d6c + url: "https://pub.dev" + source: hosted + version: "6.0.0" + dart_console: + dependency: transitive + description: + name: dart_console + sha256: "30776f697c440fdf5615a5b4fa318fd03c0788a2aeb30625a5972e83592b40c5" + url: "https://pub.dev" + source: hosted + version: "4.1.1" + dart_jsonwebtoken: + dependency: "direct dev" + description: + name: dart_jsonwebtoken + sha256: b268ff9bb87a16360a397f1accb50e7c781384e1119010b34f6d7c25820c44d8 + url: "https://pub.dev" + source: hosted + version: "3.1.1" + dart_style: + dependency: "direct main" + description: + name: dart_style + sha256: "27eb0ae77836989a3bc541ce55595e8ceee0992807f14511552a898ddd0d88ac" + url: "https://pub.dev" + source: hosted + version: "3.0.1" + dcli: + dependency: "direct main" + description: + name: dcli + sha256: "9b53041e4cce8558fc56e67c2f64b80da53bc54786c3685b349b4edc813f3883" + url: "https://pub.dev" + source: hosted + version: "7.0.1" + dcli_common: + dependency: transitive + description: + name: dcli_common + sha256: "4333d6e1d979311f36a32a1a031176fcb1d87af46ed295fd8e11bf5f71331ba7" + url: "https://pub.dev" + source: hosted + version: "7.0.1" + dcli_core: + dependency: transitive + description: + name: dcli_core + sha256: "24e15093c4e2643cc3ba31269df4a0eebe5848ef20194dbb7e189b7a9730d26b" + url: "https://pub.dev" + source: hosted + version: "7.0.1" + dcli_terminal: + dependency: "direct main" + description: + name: dcli_terminal + sha256: a08525f5c7d990396cf4b9eb0400dc665c4316e20025c5bbeb0c8727ecd53950 + url: "https://pub.dev" + source: hosted + version: "7.0.1" + decimal: + dependency: transitive + description: + name: decimal + sha256: "4140a688f9e443e2f4de3a1162387bf25e1ac6d51e24c9da263f245210f41440" + url: "https://pub.dev" + source: hosted + version: "3.0.2" + drift: + dependency: "direct main" + description: + name: drift + sha256: "97d5832657d49f26e7a8e07de397ddc63790b039372878d5117af816d0fdb5cb" + url: "https://pub.dev" + source: hosted + version: "2.25.1" + drift_dev: + dependency: "direct dev" + description: + name: drift_dev + sha256: f1db88482dbb016b9bbddddf746d5d0a6938b156ff20e07320052981f97388cc + url: "https://pub.dev" + source: hosted + version: "2.25.2" + drift_hrana: + dependency: transitive + description: + name: drift_hrana + sha256: "7645fac48c0c455787034416344e3d62b4ed06e93b3a212527fb83e98a0720e8" + url: "https://pub.dev" + source: hosted + version: "1.0.4" + ed25519_edwards: + dependency: transitive + description: + name: ed25519_edwards + sha256: "6ce0112d131327ec6d42beede1e5dfd526069b18ad45dcf654f15074ad9276cd" + url: "https://pub.dev" + source: hosted + version: "0.3.1" + email_validator: + dependency: "direct main" + description: + name: email_validator + sha256: b19aa5d92fdd76fbc65112060c94d45ba855105a28bb6e462de7ff03b12fa1fb + url: "https://pub.dev" + source: hosted + version: "3.0.0" + equatable: + dependency: transitive + description: + name: equatable + sha256: "567c64b3cb4cf82397aac55f4f0cbd3ca20d77c6c03bedbc4ceaddc08904aef7" + url: "https://pub.dev" + source: hosted + version: "2.0.7" + ffi: + dependency: "direct main" + description: + name: ffi + sha256: "289279317b4b16eb2bb7e271abccd4bf84ec9bdcbe999e278a94b804f5630418" + url: "https://pub.dev" + source: hosted + version: "2.1.4" + file: + dependency: "direct main" + description: + name: file + sha256: a3b4f84adafef897088c160faf7dfffb7696046cb13ae90b508c2cbc95d3b8d4 + url: "https://pub.dev" + source: hosted + version: "7.0.1" + fixnum: + dependency: "direct main" + description: + name: fixnum + sha256: b6dc7065e46c974bc7c5f143080a6764ec7a4be6da1285ececdc37be96de53be + url: "https://pub.dev" + source: hosted + version: "1.1.1" + flutter_lints: + dependency: transitive + description: + name: flutter_lints + sha256: "3f41d009ba7172d5ff9be5f6e6e6abb4300e263aab8866d2a0842ed2a70f8f0c" + url: "https://pub.dev" + source: hosted + version: "4.0.0" + frontend_server_client: + dependency: transitive + description: + name: frontend_server_client + sha256: f64a0333a82f30b0cca061bc3d143813a486dc086b574bfb233b7c1372427694 + url: "https://pub.dev" + source: hosted + version: "4.0.0" + functional_data: + dependency: transitive + description: + name: functional_data + sha256: "76d17dc707c40e552014f5a49c0afcc3f1e3f05e800cd6b7872940bfe41a5039" + url: "https://pub.dev" + source: hosted + version: "1.2.0" + functions_framework: + dependency: "direct main" + description: + name: functions_framework + sha256: e40725fd249690d97319a2e96a0ef82f0510dffc6c99e22a0ebde4a26bddd7a9 + url: "https://pub.dev" + source: hosted + version: "0.4.3+1" + gcloud: + dependency: "direct dev" + description: + name: gcloud + sha256: c63576bbd60b7dccd1548d51286e1c5b82e26b62440372a09c2aad0785d2e9f4 + url: "https://pub.dev" + source: hosted + version: "0.8.18" + git: + dependency: "direct main" + description: + name: git + sha256: de678c6f0d5e2761c2c3643d31b1010883cc4d3e352949ef7c15f98f27d676ea + url: "https://pub.dev" + source: hosted + version: "2.3.1" + glob: + dependency: transitive + description: + name: glob + sha256: c3f1ee72c96f8f78935e18aa8cecced9ab132419e8625dc187e1c2408efc20de + url: "https://pub.dev" + source: hosted + version: "2.1.3" + globbing: + dependency: transitive + description: + name: globbing + sha256: "4f89cfaf6fa74c9c1740a96259da06bd45411ede56744e28017cc534a12b6e2d" + url: "https://pub.dev" + source: hosted + version: "1.0.0" + google_cloud: + dependency: transitive + description: + name: google_cloud + sha256: "2fa5d1adf3939ac6e7130ae84de40727efea9d0e08db2e3d7fea3b8b432d741c" + url: "https://pub.dev" + source: hosted + version: "0.2.0" + google_identity_services_web: + dependency: transitive + description: + name: google_identity_services_web + sha256: "55580f436822d64c8ff9a77e37d61f5fb1e6c7ec9d632a43ee324e2a05c3c6c9" + url: "https://pub.dev" + source: hosted + version: "0.3.3" + googleapis: + dependency: "direct dev" + description: + name: googleapis + sha256: "864f222aed3f2ff00b816c675edf00a39e2aaf373d728d8abec30b37bee1a81c" + url: "https://pub.dev" + source: hosted + version: "13.2.0" + googleapis_auth: + dependency: "direct dev" + description: + name: googleapis_auth + sha256: befd71383a955535060acde8792e7efc11d2fccd03dd1d3ec434e85b68775938 + url: "https://pub.dev" + source: hosted + version: "1.6.0" + graphs: + dependency: "direct main" + description: + name: graphs + sha256: "741bbf84165310a68ff28fe9e727332eef1407342fca52759cb21ad8177bb8d0" + url: "https://pub.dev" + source: hosted + version: "2.3.2" + grpc: + dependency: transitive + description: + name: grpc + sha256: "5b99b7a420937d4361ece68b798c9af8e04b5bc128a7859f2a4be87427694813" + url: "https://pub.dev" + source: hosted + version: "4.0.1" + hrana: + dependency: transitive + description: + name: hrana + sha256: "201f5e56600d5ee81b2770fa34ab6526fe05528fd23610e9e4f22cbdafc29487" + url: "https://pub.dev" + source: hosted + version: "0.4.0" + html: + dependency: transitive + description: + name: html + sha256: "1fc58edeaec4307368c60d59b7e15b9d658b57d7f3125098b6294153c75337ec" + url: "https://pub.dev" + source: hosted + version: "0.15.5" + html2md: + dependency: "direct main" + description: + name: html2md + sha256: "465cf8ffa1b510fe0e97941579bf5b22e2d575f2cecb500a9c0254efe33a8036" + url: "https://pub.dev" + source: hosted + version: "1.3.2" + http: + dependency: "direct main" + description: + name: http + sha256: fe7ab022b76f3034adc518fb6ea04a82387620e19977665ea18d30a1cf43442f + url: "https://pub.dev" + source: hosted + version: "1.3.0" + http2: + dependency: transitive + description: + name: http2 + sha256: "382d3aefc5bd6dc68c6b892d7664f29b5beb3251611ae946a98d35158a82bbfa" + url: "https://pub.dev" + source: hosted + version: "2.3.1" + http_methods: + dependency: transitive + description: + name: http_methods + sha256: "6bccce8f1ec7b5d701e7921dca35e202d425b57e317ba1a37f2638590e29e566" + url: "https://pub.dev" + source: hosted + version: "1.1.1" + http_multi_server: + dependency: transitive + description: + name: http_multi_server + sha256: aa6199f908078bb1c5efb8d8638d4ae191aac11b311132c3ef48ce352fb52ef8 + url: "https://pub.dev" + source: hosted + version: "3.2.2" + http_parser: + dependency: "direct main" + description: + name: http_parser + sha256: "178d74305e7866013777bab2c3d8726205dc5a4dd935297175b19a23a2e66571" + url: "https://pub.dev" + source: hosted + version: "4.1.2" + http_sfv: + dependency: transitive + description: + name: http_sfv + sha256: "469922520f97ceb1ddfea6c10f9fe0d45814f6e83f41fd7d32fcb995b3030d00" + url: "https://pub.dev" + source: hosted + version: "0.1.0" + ini: + dependency: transitive + description: + name: ini + sha256: "12a76c53591ffdf86d1265be3f986888a6dfeb34a85957774bc65912d989a173" + url: "https://pub.dev" + source: hosted + version: "2.1.0" + intl: + dependency: "direct main" + description: + name: intl + sha256: d6f56758b7d3014a48af9701c085700aac781a92a87a62b1333b46d8879661cf + url: "https://pub.dev" + source: hosted + version: "0.19.0" + io: + dependency: "direct main" + description: + name: io + sha256: dfd5a80599cf0165756e3181807ed3e77daf6dd4137caaad72d0b7931597650b + url: "https://pub.dev" + source: hosted + version: "1.0.5" + jni: + dependency: transitive + description: + name: jni + sha256: caefbbf9ed3b54b87bd3d479438e3837e7f8512015d04046a60b13c0b90d126f + url: "https://pub.dev" + source: hosted + version: "0.11.0" + jose: + dependency: "direct dev" + description: + name: jose + sha256: "7955ec5d131960104e81fbf151abacb9d835c16c9e793ed394b2809f28b2198d" + url: "https://pub.dev" + source: hosted + version: "0.3.4" + js: + dependency: transitive + description: + name: js + sha256: "53385261521cc4a0c4658fd0ad07a7d14591cf8fc33abbceae306ddb974888dc" + url: "https://pub.dev" + source: hosted + version: "0.7.2" + json2yaml: + dependency: transitive + description: + name: json2yaml + sha256: da94630fbc56079426fdd167ae58373286f603371075b69bf46d848d63ba3e51 + url: "https://pub.dev" + source: hosted + version: "3.0.1" + json_annotation: + dependency: "direct main" + description: + name: json_annotation + sha256: "1ce844379ca14835a50d2f019a3099f419082cfdd231cd86a142af94dd5c6bb1" + url: "https://pub.dev" + source: hosted + version: "4.9.0" + json_serializable: + dependency: "direct dev" + description: + name: json_serializable + sha256: "81f04dee10969f89f604e1249382d46b97a1ccad53872875369622b5bfc9e58a" + url: "https://pub.dev" + source: hosted + version: "6.9.4" + libcoder: + dependency: "direct main" + description: + name: libcoder + sha256: "879c1698e4b498f8cd2b02fdfcb03a6ee73716db731c6bde9d54373e4c19a687" + url: "https://pub.dev" + source: hosted + version: "0.0.3" + lints: + dependency: transitive + description: + name: lints + sha256: "976c774dd944a42e83e2467f4cc670daef7eed6295b10b36ae8c85bcbf828235" + url: "https://pub.dev" + source: hosted + version: "4.0.0" + logging: + dependency: "direct main" + description: + name: logging + sha256: c8245ada5f1717ed44271ed1c26b8ce85ca3228fd2ffdb75468ab01979309d61 + url: "https://pub.dev" + source: hosted + version: "1.3.0" + mason_logger: + dependency: "direct main" + description: + name: mason_logger + sha256: "6d5a989ff41157915cb5162ed6e41196d5e31b070d2f86e1c2edf216996a158c" + url: "https://pub.dev" + source: hosted + version: "0.3.3" + matcher: + dependency: transitive + description: + name: matcher + sha256: dc58c723c3c24bf8d3e2d3ad3f2f9d7bd9cf43ec6feaa64181775e60190153f2 + url: "https://pub.dev" + source: hosted + version: "0.12.17" + meta: + dependency: "direct main" + description: + name: meta + sha256: e3641ec5d63ebf0d9b41bd43201a66e3fc79a65db5f61fc181f04cd27aab950c + url: "https://pub.dev" + source: hosted + version: "1.16.0" + mime: + dependency: transitive + description: + name: mime + sha256: "41a20518f0cb1256669420fdba0cd90d21561e560ac240f26ef8322e45bb7ed6" + url: "https://pub.dev" + source: hosted + version: "2.0.0" + mocktail: + dependency: "direct dev" + description: + name: mocktail + sha256: "890df3f9688106f25755f26b1c60589a92b3ab91a22b8b224947ad041bf172d8" + url: "https://pub.dev" + source: hosted + version: "1.0.4" + mustache_template: + dependency: "direct dev" + description: + name: mustache_template + sha256: a46e26f91445bfb0b60519be280555b06792460b27b19e2b19ad5b9740df5d1c + url: "https://pub.dev" + source: hosted + version: "2.0.0" + native_assets_builder: + dependency: "direct main" + description: + name: native_assets_builder + sha256: "3368f3eda23d59e98c8eadeafe609feb3bf6c342e5885796d6eceadc3d4581f8" + url: "https://pub.dev" + source: hosted + version: "0.8.2" + native_assets_cli: + dependency: "direct main" + description: + name: native_assets_cli + sha256: "1ff032c0ca050391c4c5107485f1a26e0e95cee18d1fdb2b7bdbb990efd3c188" + url: "https://pub.dev" + source: hosted + version: "0.7.3" + native_authentication: + dependency: transitive + description: + name: native_authentication + sha256: "2e9105516e792af6186861c3f59b5255a6c1435422f58a76e6a30929d85bc8e4" + url: "https://pub.dev" + source: hosted + version: "0.1.0+2" + native_storage: + dependency: "direct main" + description: + name: native_storage + sha256: "28ba067a74c6e1b610737e06f86d397e7271b2a0e045dfb71ee25eebdec05832" + url: "https://pub.dev" + source: hosted + version: "0.2.2" + native_synchronization_temp: + dependency: transitive + description: + name: native_synchronization_temp + sha256: f9ad36a5054c606db10e3dc0c9c352e6d0d56d08621af5c470abf9fa41da40fa + url: "https://pub.dev" + source: hosted + version: "0.7.1" + native_toolchain_c: + dependency: transitive + description: + name: native_toolchain_c + sha256: e227eb4873aaa6983191a6656557489b5a3c7d8f6221dccecb45506bb567359c + url: "https://pub.dev" + source: hosted + version: "0.5.3" + node_preamble: + dependency: transitive + description: + name: node_preamble + sha256: "6e7eac89047ab8a8d26cf16127b5ed26de65209847630400f9aefd7cd5c730db" + url: "https://pub.dev" + source: hosted + version: "2.0.2" + objective_c: + dependency: transitive + description: + name: objective_c + sha256: "7ad3b1e4478812f8d642af1fe4698f86310ebec1248ba87e2a8fe74d2412731e" + url: "https://pub.dev" + source: hosted + version: "2.0.0" + os_detect: + dependency: "direct main" + description: + name: os_detect + sha256: "7d87c0dd98c6faf110d5aa498e9a6df02ffce4bb78cc9cfc8ad02929be9bb71f" + url: "https://pub.dev" + source: hosted + version: "2.0.3" + package_config: + dependency: "direct main" + description: + name: package_config + sha256: "92d4488434b520a62570293fbd33bb556c7d49230791c1b4bbd973baf6d2dc67" + url: "https://pub.dev" + source: hosted + version: "2.1.1" + path: + dependency: "direct main" + description: + name: path + sha256: "75cca69d1490965be98c73ceaea117e8a04dd21217b37b292c9ddbec0d955bc5" + url: "https://pub.dev" + source: hosted + version: "1.9.1" + petitparser: + dependency: transitive + description: + name: petitparser + sha256: "07c8f0b1913bcde1ff0d26e57ace2f3012ccbf2b204e070290dad3bb22797646" + url: "https://pub.dev" + source: hosted + version: "6.1.0" + platform: + dependency: "direct main" + description: + name: platform + sha256: "5d6b1b0036a5f331ebc77c850ebc8506cbc1e9416c27e59b439f917a902a4984" + url: "https://pub.dev" + source: hosted + version: "3.1.6" + plugin_platform_interface: + dependency: transitive + description: + name: plugin_platform_interface + sha256: "4820fbfdb9478b1ebae27888254d445073732dae3d6ea81f0b7e06d5dedc3f02" + url: "https://pub.dev" + source: hosted + version: "2.1.8" + pointycastle: + dependency: transitive + description: + name: pointycastle + sha256: "4be0097fcf3fd3e8449e53730c631200ebc7b88016acecab2b0da2f0149222fe" + url: "https://pub.dev" + source: hosted + version: "3.9.1" + pool: + dependency: "direct main" + description: + name: pool + sha256: "20fe868b6314b322ea036ba325e6fc0711a22948856475e2c2b6306e8ab39c2a" + url: "https://pub.dev" + source: hosted + version: "1.5.1" + posix: + dependency: transitive + description: + name: posix + sha256: a0117dc2167805aa9125b82eee515cc891819bac2f538c83646d355b16f58b9a + url: "https://pub.dev" + source: hosted + version: "6.0.1" + process: + dependency: "direct main" + description: + name: process + sha256: "107d8be718f120bbba9dcd1e95e3bd325b1b4a4f07db64154635ba03f2567a0d" + url: "https://pub.dev" + source: hosted + version: "5.0.3" + protobuf: + dependency: "direct main" + description: + name: protobuf + sha256: "68645b24e0716782e58948f8467fd42a880f255096a821f9e7d0ec625b00c84d" + url: "https://pub.dev" + source: hosted + version: "3.1.0" + pub_semver: + dependency: "direct main" + description: + name: pub_semver + sha256: "7b3cfbf654f3edd0c6298ecd5be782ce997ddf0e00531b9464b55245185bbbbd" + url: "https://pub.dev" + source: hosted + version: "2.1.5" + pubspec_lock: + dependency: transitive + description: + name: pubspec_lock + sha256: ed5fc1ecd0cdc0e14475a091afcb2c4cbb00e74cebff17635e9abbec18d76cc4 + url: "https://pub.dev" + source: hosted + version: "3.0.2" + pubspec_manager: + dependency: transitive + description: + name: pubspec_manager + sha256: "7d3e74f0f673fdc441002d45a66dcb37d26dcea99ae730c4fd6671c42423149c" + url: "https://pub.dev" + source: hosted + version: "1.0.1" + pubspec_parse: + dependency: "direct main" + description: + name: pubspec_parse + sha256: "0560ba233314abbed0a48a2956f7f022cce7c3e1e73df540277da7544cad4082" + url: "https://pub.dev" + source: hosted + version: "1.5.0" + quiver: + dependency: transitive + description: + name: quiver + sha256: ea0b925899e64ecdfbf9c7becb60d5b50e706ade44a85b2363be2a22d88117d2 + url: "https://pub.dev" + source: hosted + version: "3.2.2" + rational: + dependency: transitive + description: + name: rational + sha256: cb808fb6f1a839e6fc5f7d8cb3b0a10e1db48b3be102de73938c627f0b636336 + url: "https://pub.dev" + source: hosted + version: "2.2.3" + recase: + dependency: transitive + description: + name: recase + sha256: e4eb4ec2dcdee52dcf99cb4ceabaffc631d7424ee55e56f280bc039737f89213 + url: "https://pub.dev" + source: hosted + version: "4.1.0" + retry: + dependency: transitive + description: + name: retry + sha256: "822e118d5b3aafed083109c72d5f484c6dc66707885e07c0fbcb8b986bba7efc" + url: "https://pub.dev" + source: hosted + version: "3.1.2" + scope: + dependency: transitive + description: + name: scope + sha256: "0b056e5b64ca16a2db9e1eb35cf7fd05a9e99a6b15140f82bfa651d081e4819b" + url: "https://pub.dev" + source: hosted + version: "5.1.0" + sentry: + dependency: "direct main" + description: + name: sentry + sha256: "90c2f956c146bcc9c4843406dd4a65d08b25575828dc2ad51de0ca5cd713209f" + url: "https://pub.dev" + source: hosted + version: "8.13.2" + sentry_logging: + dependency: "direct main" + description: + name: sentry_logging + sha256: "6890cf8ad67ebf96b6fe062dbccf98ec0a858aba38632a72197c882cdc14ee3f" + url: "https://pub.dev" + source: hosted + version: "8.13.2" + settings_yaml: + dependency: transitive + description: + name: settings_yaml + sha256: ed2714686a1a22d45c1454ca3da1b0ce889b639b929aa09f6afa2bba8c0a423e + url: "https://pub.dev" + source: hosted + version: "8.2.0" + shelf: + dependency: "direct main" + description: + name: shelf + sha256: e7dd780a7ffb623c57850b33f43309312fc863fb6aa3d276a754bb299839ef12 + url: "https://pub.dev" + source: hosted + version: "1.4.2" + shelf_packages_handler: + dependency: transitive + description: + name: shelf_packages_handler + sha256: "89f967eca29607c933ba9571d838be31d67f53f6e4ee15147d5dc2934fee1b1e" + url: "https://pub.dev" + source: hosted + version: "3.0.2" + shelf_router: + dependency: transitive + description: + name: shelf_router + sha256: f5e5d492440a7fb165fe1e2e1a623f31f734d3370900070b2b1e0d0428d59864 + url: "https://pub.dev" + source: hosted + version: "1.1.4" + shelf_static: + dependency: "direct main" + description: + name: shelf_static + sha256: c87c3875f91262785dade62d135760c2c69cb217ac759485334c5857ad89f6e3 + url: "https://pub.dev" + source: hosted + version: "1.1.3" + shelf_web_socket: + dependency: "direct main" + description: + name: shelf_web_socket + sha256: cc36c297b52866d203dbf9332263c94becc2fe0ceaa9681d07b6ef9807023b67 + url: "https://pub.dev" + source: hosted + version: "2.0.1" + simple_sparse_list: + dependency: transitive + description: + name: simple_sparse_list + sha256: aa648fd240fa39b49dcd11c19c266990006006de6699a412de485695910fbc1f + url: "https://pub.dev" + source: hosted + version: "0.1.4" + source_gen: + dependency: "direct overridden" + description: + name: source_gen + sha256: "35c8150ece9e8c8d263337a265153c3329667640850b9304861faea59fc98f6b" + url: "https://pub.dev" + source: hosted + version: "2.0.0" + source_helper: + dependency: transitive + description: + name: source_helper + sha256: "86d247119aedce8e63f4751bd9626fc9613255935558447569ad42f9f5b48b3c" + url: "https://pub.dev" + source: hosted + version: "1.3.5" + source_map_stack_trace: + dependency: transitive + description: + name: source_map_stack_trace + sha256: c0713a43e323c3302c2abe2a1cc89aa057a387101ebd280371d6a6c9fa68516b + url: "https://pub.dev" + source: hosted + version: "2.1.2" + source_maps: + dependency: transitive + description: + name: source_maps + sha256: "190222579a448b03896e0ca6eca5998fa810fda630c1d65e2f78b3f638f54812" + url: "https://pub.dev" + source: hosted + version: "0.10.13" + source_span: + dependency: "direct main" + description: + name: source_span + sha256: "254ee5351d6cb365c859e20ee823c3bb479bf4a293c22d17a9f1bf144ce86f7c" + url: "https://pub.dev" + source: hosted + version: "1.10.1" + sprintf: + dependency: transitive + description: + name: sprintf + sha256: "1fc9ffe69d4df602376b52949af107d8f5703b77cda567c4d7d86a0693120f23" + url: "https://pub.dev" + source: hosted + version: "7.0.0" + sqlite3: + dependency: "direct main" + description: + name: sqlite3 + sha256: "32b632dda27d664f85520093ed6f735ae5c49b5b75345afb8b19411bc59bb53d" + url: "https://pub.dev" + source: hosted + version: "2.7.4" + sqlparser: + dependency: transitive + description: + name: sqlparser + sha256: "27dd0a9f0c02e22ac0eb42a23df9ea079ce69b52bb4a3b478d64e0ef34a263ee" + url: "https://pub.dev" + source: hosted + version: "0.41.0" + stack_trace: + dependency: "direct main" + description: + name: stack_trace + sha256: "8b27215b45d22309b5cddda1aa2b19bdfec9df0e765f2de506401c071d38d1b1" + url: "https://pub.dev" + source: hosted + version: "1.12.1" + stream_channel: + dependency: "direct main" + description: + name: stream_channel + sha256: "969e04c80b8bcdf826f8f16579c7b14d780458bd97f56d107d3950fdbeef059d" + url: "https://pub.dev" + source: hosted + version: "2.1.4" + stream_transform: + dependency: "direct main" + description: + name: stream_transform + sha256: ad47125e588cfd37a9a7f86c7d6356dde8dfe89d071d293f80ca9e9273a33871 + url: "https://pub.dev" + source: hosted + version: "2.1.1" + string_scanner: + dependency: transitive + description: + name: string_scanner + sha256: "921cd31725b72fe181906c6a94d987c78e3b98c2e205b397ea399d4054872b43" + url: "https://pub.dev" + source: hosted + version: "1.4.1" + strings: + dependency: transitive + description: + name: strings + sha256: "482f1511d2cd8ab9f2c4cc148e6837be8a00c03b9a8eaedbc981a84d9c6305d8" + url: "https://pub.dev" + source: hosted + version: "3.2.0" + sum_types: + dependency: transitive + description: + name: sum_types + sha256: c0a0fad9a518d011987e1d9f27fc336194294e55dafdc3699363e52aa5776e09 + url: "https://pub.dev" + source: hosted + version: "0.3.5" + system_info2: + dependency: transitive + description: + name: system_info2 + sha256: "65206bbef475217008b5827374767550a5420ce70a04d2d7e94d1d2253f3efc9" + url: "https://pub.dev" + source: hosted + version: "4.0.0" + term_glyph: + dependency: transitive + description: + name: term_glyph + sha256: "7f554798625ea768a7518313e58f83891c7f5024f88e46e7182a4558850a4b8e" + url: "https://pub.dev" + source: hosted + version: "1.2.2" + test: + dependency: "direct dev" + description: + name: test + sha256: "301b213cd241ca982e9ba50266bd3f5bd1ea33f1455554c5abb85d1be0e2d87e" + url: "https://pub.dev" + source: hosted + version: "1.25.15" + test_api: + dependency: transitive + description: + name: test_api + sha256: fb31f383e2ee25fbbfe06b40fe21e1e458d14080e3c67e7ba0acfde4df4e0bbd + url: "https://pub.dev" + source: hosted + version: "0.7.4" + test_core: + dependency: transitive + description: + name: test_core + sha256: "84d17c3486c8dfdbe5e12a50c8ae176d15e2a771b96909a9442b40173649ccaa" + url: "https://pub.dev" + source: hosted + version: "0.6.8" + test_descriptor: + dependency: "direct dev" + description: + name: test_descriptor + sha256: "9ce468c97ae396e8440d26bb43763f84e2a2a5331813ee5a397cb4da481aaf9a" + url: "https://pub.dev" + source: hosted + version: "2.0.2" + timing: + dependency: transitive + description: + name: timing + sha256: "62ee18aca144e4a9f29d212f5a4c6a053be252b895ab14b5821996cff4ed90fe" + url: "https://pub.dev" + source: hosted + version: "1.0.2" + toml: + dependency: "direct main" + description: + name: toml + sha256: d968d149c8bd06dc14e09ea3a140f90a3f2ba71949e7a91df4a46f3107400e71 + url: "https://pub.dev" + source: hosted + version: "0.16.0" + tuple: + dependency: transitive + description: + name: tuple + sha256: a97ce2013f240b2f3807bcbaf218765b6f301c3eff91092bcfa23a039e7dd151 + url: "https://pub.dev" + source: hosted + version: "2.0.2" + typed_data: + dependency: transitive + description: + name: typed_data + sha256: f9049c039ebfeb4cf7a7104a675823cd72dba8297f264b6637062516699fa006 + url: "https://pub.dev" + source: hosted + version: "1.4.0" + unicode: + dependency: transitive + description: + name: unicode + sha256: "0d99edbd2e74726bed2e4989713c8bec02e5581628e334d8c88c0271593fb402" + url: "https://pub.dev" + source: hosted + version: "1.1.8" + uuid: + dependency: transitive + description: + name: uuid + sha256: a5be9ef6618a7ac1e964353ef476418026db906c4facdedaa299b7a2e71690ff + url: "https://pub.dev" + source: hosted + version: "4.5.1" + validators2: + dependency: transitive + description: + name: validators2 + sha256: "5c63054b2f47b6a3f39e0d0e3f5d38829db4545250144a34c9e1585466de4814" + url: "https://pub.dev" + source: hosted + version: "5.0.0" + vm_service: + dependency: "direct main" + description: + name: vm_service + sha256: ddfa8d30d89985b96407efce8acbdd124701f96741f2d981ca860662f1c0dc02 + url: "https://pub.dev" + source: hosted + version: "15.0.0" + watcher: + dependency: "direct main" + description: + name: watcher + sha256: "69da27e49efa56a15f8afe8f4438c4ec02eff0a117df1b22ea4aad194fe1c104" + url: "https://pub.dev" + source: hosted + version: "1.1.1" + web: + dependency: transitive + description: + name: web + sha256: "868d88a33d8a87b18ffc05f9f030ba328ffefba92d6c127917a2ba740f9cfe4a" + url: "https://pub.dev" + source: hosted + version: "1.1.1" + web_socket: + dependency: transitive + description: + name: web_socket + sha256: "3c12d96c0c9a4eec095246debcea7b86c0324f22df69893d538fcc6f1b8cce83" + url: "https://pub.dev" + source: hosted + version: "0.1.6" + web_socket_channel: + dependency: transitive + description: + name: web_socket_channel + sha256: "0b8e2457400d8a859b7b2030786835a28a8e80836ef64402abef392ff4f1d0e5" + url: "https://pub.dev" + source: hosted + version: "3.0.2" + webkit_inspection_protocol: + dependency: transitive + description: + name: webkit_inspection_protocol + sha256: "87d3f2333bb240704cd3f1c6b5b7acd8a10e7f0bc28c28dcf14e782014f4a572" + url: "https://pub.dev" + source: hosted + version: "1.2.1" + win32: + dependency: "direct main" + description: + name: win32 + sha256: b89e6e24d1454e149ab20fbb225af58660f0c0bf4475544650700d8e2da54aef + url: "https://pub.dev" + source: hosted + version: "5.11.0" + win32_registry: + dependency: transitive + description: + name: win32_registry + sha256: "21ec76dfc731550fd3e2ce7a33a9ea90b828fdf19a5c3bcf556fa992cfa99852" + url: "https://pub.dev" + source: hosted + version: "1.1.5" + windows_applicationmodel: + dependency: transitive + description: + name: windows_applicationmodel + sha256: fce866308c8395efca0ea646cc8ee3ff5a59470f82458e420cf170129876cc85 + url: "https://pub.dev" + source: hosted + version: "0.2.0" + windows_data: + dependency: transitive + description: + name: windows_data + sha256: "7da30e632a9bb8db10c7c4bae11e8cae66cf9b89efb5f1a7ff19b8906f3fdf08" + url: "https://pub.dev" + source: hosted + version: "0.2.0" + windows_devices: + dependency: transitive + description: + name: windows_devices + sha256: "503d78b9f721d42b35c1d280c3ec839d1006d29b7b5cabd38ed100458d9f0358" + url: "https://pub.dev" + source: hosted + version: "0.2.0" + windows_foundation: + dependency: transitive + description: + name: windows_foundation + sha256: "3ed6e5346e9d54eff9781b1b371a47ca323d0978f4b26e8916e8bc494cae187f" + url: "https://pub.dev" + source: hosted + version: "0.2.0" + windows_globalization: + dependency: transitive + description: + name: windows_globalization + sha256: "162e7f05a866f2d99ae797afa9c68dff570ba8562d13c5c0a7cc14089b3c8d18" + url: "https://pub.dev" + source: hosted + version: "0.1.0+1" + windows_graphics: + dependency: transitive + description: + name: windows_graphics + sha256: a6646c32ff79105264dcc9cf47ead211ba176386f857b63394e6d29f0c5ff9eb + url: "https://pub.dev" + source: hosted + version: "0.2.0" + windows_media: + dependency: transitive + description: + name: windows_media + sha256: "6b55c1a7ed48f1e38eb1dc4829eca7ee9fdbe6d2a4744d887d99ba13bde78c7d" + url: "https://pub.dev" + source: hosted + version: "0.2.0" + windows_networking: + dependency: transitive + description: + name: windows_networking + sha256: "04f9e1f004f85af3d400c24bd226efb0c4513f7f843ba07998528f0bdee62e7a" + url: "https://pub.dev" + source: hosted + version: "0.2.0" + windows_perception: + dependency: transitive + description: + name: windows_perception + sha256: aa9fb6c8c97be855aece8f28943284c2680afa65a012144e012173081e568728 + url: "https://pub.dev" + source: hosted + version: "0.1.0" + windows_security: + dependency: transitive + description: + name: windows_security + sha256: c1f2bbe4c2b2fdf07cb50afff652413bb8f908d27328c547db03e7591c1331e2 + url: "https://pub.dev" + source: hosted + version: "0.1.0+1" + windows_services: + dependency: transitive + description: + name: windows_services + sha256: dad37ce3c795867e650b66a347b412e066e625a734ac2444ff163f4e5b8a040b + url: "https://pub.dev" + source: hosted + version: "0.1.0" + windows_storage: + dependency: transitive + description: + name: windows_storage + sha256: ba370214ad4dca9ffda684f40231a5da68f296d8d8dde1b7c0b8011dd150b64e + url: "https://pub.dev" + source: hosted + version: "0.2.0" + windows_system: + dependency: transitive + description: + name: windows_system + sha256: "8d5c2524bef8c71923b16cd9610fe194c77540687fae661e4fbbb7c78340fabe" + url: "https://pub.dev" + source: hosted + version: "0.1.0+1" + windows_ui: + dependency: transitive + description: + name: windows_ui + sha256: "8fdff2a7bc05070ea3021b320d64fa27559095708bc8912cd3ee9eb509ed9b95" + url: "https://pub.dev" + source: hosted + version: "0.2.0" + x509: + dependency: transitive + description: + name: x509 + sha256: cbd1a63846884afd273cda247b0365284c8d85a365ca98e110413f93d105b935 + url: "https://pub.dev" + source: hosted + version: "0.2.4+3" + xdg_directories: + dependency: transitive + description: + name: xdg_directories + sha256: "7a3f37b05d989967cdddcbb571f1ea834867ae2faa29725fd085180e0883aa15" + url: "https://pub.dev" + source: hosted + version: "1.1.0" + yaml: + dependency: "direct main" + description: + name: yaml + sha256: b9da305ac7c39faa3f030eccd175340f968459dae4af175130b3fc47e40d76ce + url: "https://pub.dev" + source: hosted + version: "3.1.3" + yaml_edit: + dependency: "direct main" + description: + name: yaml_edit + sha256: e9c1a3543d2da0db3e90270dbb1e4eebc985ee5e3ffe468d83224472b2194a5f + url: "https://pub.dev" + source: hosted + version: "2.2.1" +sdks: + dart: ">=3.7.0 <4.0.0" diff --git a/apps/cli/pubspec.yaml b/apps/cli/pubspec.yaml new file mode 100644 index 000000000..d654b175c --- /dev/null +++ b/apps/cli/pubspec.yaml @@ -0,0 +1,125 @@ +name: celest_cli +description: The command-line interface for Celest. +version: 1.0.6+2 +publish_to: none + +environment: + sdk: ^3.7.0 + +dependencies: + analyzer: ^7.3.0 + analyzer_plugin: ^0.13.0 + archive: ^4.0.4 + args: ^2.4.2 + async: ^2.11.0 + built_collection: ^5.1.1 + built_value: ^8.6.3 + cedar: ^0.2.1 + celest: + path: ../../packages/celest + celest_ast: + path: ../../packages/celest_ast + celest_auth: + path: ../../packages/celest_auth + celest_cloud: + path: ../../packages/celest_cloud + celest_core: + path: ../../packages/celest_core + chunked_stream: ^1.4.2 + cli_script: ^1.0.0 + cli_util: ^0.4.2 + code_builder: ^4.8.0 + collection: ^1.18.0 + convert: ^3.1.1 + corks_cedar: ^0.2.1 + crypto: ^3.0.3 + dart_style: ^3.0.0 + dcli: ^7.0.1 + dcli_terminal: ^7.0.1 + drift: '>=2.25.0 <2.26.0' + email_validator: ^3.0.0 + ffi: ^2.1.4 + file: ^7.0.0 + fixnum: ^1.1.0 + functions_framework: ^0.4.3+1 + git: ^2.3.0 + graphs: ^2.3.2 + html2md: ^1.3.1 + http: ^1.1.2 + http_parser: ^4.0.2 + intl: ^0.19.0 + io: ^1.0.4 + json_annotation: ^4.9.0 + libcoder: ^0.0.1 + logging: ^1.2.0 + mason_logger: ^0.3.0 + meta: ^1.10.0 + native_assets_builder: ^0.8.1 + native_assets_cli: ^0.7.2 + native_storage: ^0.2.2 + os_detect: ^2.0.1 + package_config: ^2.1.0 + path: ^1.8.3 + platform: ^3.1.3 + pool: ^1.5.1 + process: ^5.0.1 + protobuf: ^3.1.0 + pub_semver: ^2.1.4 + pubspec_parse: ^1.2.3 + sentry: ^8.5.0 + sentry_logging: ^8.13.2 + shelf: ^1.4.1 + shelf_static: ^1.1.2 + shelf_web_socket: ^2.0.0 + source_span: ^1.10.0 + sqlite3: ^2.4.6 + stack_trace: ^1.11.1 + stream_channel: ^2.1.2 + stream_transform: ^2.1.0 + toml: ^0.16.0 + vm_service: ^15.0.0 + watcher: ^1.1.0 + win32: ^5.11.0 + yaml: ^3.1.2 + # TODO: 2.2.2 breaks sorting of edits + yaml_edit: 2.2.1 + +dependency_overrides: + # TODO: Remove when built_value supports latest analyzer + analyzer: ^7.3.0 + celest: + path: ../../packages/celest + celest_ast: + path: ../../packages/celest_ast + celest_auth: + path: ../../packages/celest_auth + celest_cloud: + path: ../../packages/celest_cloud + celest_core: + path: ../../packages/celest_core + # TODO: Remove when built_value supports latest analyzer + source_gen: ^2.0.0 + +dev_dependencies: + benchmark_harness: ^2.2.2 + build: ^2.4.1 + build_runner: ^2.4.7 + build_test: ^2.2.1 + built_value_generator: ^8.9.4 + celest_lints: + path: ../../packages/celest_lints + checks: ^0.3.0 + dart_jsonwebtoken: ^3.1.1 + drift_dev: '>=2.25.0 <2.26.0' + gcloud: ^0.8.13 + googleapis: ^13.2.0 + googleapis_auth: ^1.4.1 + jose: ^0.3.4 + json_serializable: ^6.8.0 + mocktail: ^1.0.2 + mustache_template: ^2.0.0 + test: ^1.24.9 + test_descriptor: ^2.0.1 + +executables: + celest: diff --git a/apps/cli/test/analyzer/analysis_options_test.dart b/apps/cli/test/analyzer/analysis_options_test.dart new file mode 100644 index 000000000..1a09a4876 --- /dev/null +++ b/apps/cli/test/analyzer/analysis_options_test.dart @@ -0,0 +1,37 @@ +import 'package:celest_cli/analyzer/analysis_options.dart'; +import 'package:celest_cli/src/context.dart'; +import 'package:test/test.dart'; +import 'package:test_descriptor/test_descriptor.dart' as d; + +import '../common.dart'; + +String get path => p.join(d.sandbox, 'analysis_options.yaml'); + +void main() { + group('AnalysisOptions', () { + setUpAll(initTests); + + group('load', () { + test('enabled experiments', () async { + await d.file('analysis_options.yaml', ''' +analyzer: + enable-experiment: + - inline-class +''').create(); + + final analysisOptions = await AnalysisOptions.load(path); + expect(analysisOptions.enabledExperiments, ['inline-class']); + }); + + test('gracefully handles invalid analysis options', () async { + await d.file('analysis_options.yaml', ''' +analyzer: + enable-experiment: inline-class +''').create(); + + final analysisOptions = await AnalysisOptions.load(path); + expect(analysisOptions.enabledExperiments, const []); + }); + }); + }); +} diff --git a/apps/cli/test/analyzer/celest_analyzer_test.dart b/apps/cli/test/analyzer/celest_analyzer_test.dart new file mode 100644 index 000000000..d276d20b5 --- /dev/null +++ b/apps/cli/test/analyzer/celest_analyzer_test.dart @@ -0,0 +1,2418 @@ +import 'dart:io'; + +import 'package:celest/http.dart'; +import 'package:celest_ast/celest_ast.dart'; +import 'package:celest_cli/analyzer/analysis_result.dart'; +import 'package:celest_cli/analyzer/celest_analyzer.dart'; +import 'package:celest_cli/project/celest_project.dart'; +import 'package:celest_cli/pub/pub_cache.dart'; +import 'package:celest_cli/pub/pub_environment.dart'; +import 'package:celest_cli/src/context.dart'; +import 'package:celest_cli/src/utils/error.dart'; +import 'package:checks/checks.dart'; +import 'package:package_config/package_config.dart'; +import 'package:path/path.dart' as p; +import 'package:test/test.dart'; +import 'package:test_descriptor/test_descriptor.dart' as d; + +import '../common.dart'; + +String _simpleProjectDart(String name) => ''' +import 'package:celest/celest.dart'; + +const project = Project(name: '$name'); +'''; + +Future newProject({ + required String name, + String? pubspecYaml, + String? analysisOptions, + String? projectDart, + String? authDart, + String? resourcesDart, + String? models, + String? exceptions, + Map apis = const {}, + Map config = const {}, + Map*/> lib = const {}, + String? parentDirectory, +}) async { + projectDart ??= _simpleProjectDart(name); + if (authDart != null) { + projectDart += authDart; + } + final celestDir = p.fromUri( + Directory.current.uri.resolve('../../packages/celest/'), + ); + final celestCoreDir = p.fromUri( + Directory.current.uri.resolve('../../packages/celest_core/'), + ); + final packageConfig = PackageConfig([ + Package( + 'celest', + p.toUri(celestDir), + packageUriRoot: Uri.parse('lib/'), + relativeRoot: false, + ), + Package( + 'celest_core', + p.toUri(celestCoreDir), + packageUriRoot: Uri.parse('lib/'), + relativeRoot: false, + ), + Package( + 'json_annotation', + p.toUri(pubCache.latestVersionPath('json_annotation')!), + packageUriRoot: Uri.parse('lib/'), + relativeRoot: false, + ), + Package( + name, + p.toUri(d.path('$name/')), + packageUriRoot: Uri.parse('lib/'), + relativeRoot: false, + ), + ]); + final packageConfigJson = StringBuffer(); + PackageConfig.writeString( + packageConfig, + packageConfigJson, + p.toUri(p.join(d.sandbox, name)), + ); + print(packageConfigJson.toString()); + final project = d.dir(name, [ + d.dir('.dart_tool', [ + d.file('package_config.json', packageConfigJson.toString()), + ]), + if (analysisOptions != null) + d.file('analysis_options.yaml', analysisOptions), + d.file( + 'pubspec.yaml', + pubspecYaml ?? + ''' +name: $name + +environment: + sdk: ${PubEnvironment.dartSdkConstraint} + +dependencies: + celest: any + celest_core: any + json_annotation: any +''', + ), + if (config.isNotEmpty) + for (final MapEntry(key: fileName, value: contents) in config.entries) + d.file(fileName, contents), + d.dir('lib', [ + d.file('models.dart', models ?? ''), + d.file('exceptions.dart', exceptions ?? ''), + ..._nestedDescriptor( + _mergeMaps(lib, { + 'src': { + 'project.dart': projectDart, + if (apis.isNotEmpty) + 'functions': { + for (final MapEntry(key: fileName, value: contents) + in apis.entries) + fileName: + contents.startsWith('@') + ? contents + : ''' +import 'package:celest/celest.dart'; +import 'package:$name/exceptions.dart'; +import 'package:$name/models.dart'; + +$contents +''', + }, + }, + }), + ), + ]), + ]); + await project.create(parentDirectory); + final projectRoot = p.join(parentDirectory ?? d.sandbox, name); + await init(projectRoot: projectRoot); + return celestProject; +} + +Map _mergeMaps(Map a, Map b) { + final result = {}; + for (final entry in a.entries) { + result[entry.key] = entry.value; + } + for (final entry in b.entries) { + final key = entry.key; + final value = entry.value; + if (result.containsKey(key)) { + final existing = result[key]; + if (existing is Map && value is Map) { + result[key] = _mergeMaps(existing, value) as V; + } else { + result[key] = value; + } + } else { + result[key] = value; + } + } + return result; +} + +Iterable _nestedDescriptor( + Map descriptors, +) sync* { + for (final MapEntry(key: name, value: contents) in descriptors.entries) { + yield switch (contents) { + String() => d.file(name, contents), + Map() => d.dir(name, _nestedDescriptor(contents.cast())), + final badContents => unreachable( + 'Bad contents: ${badContents.runtimeType}', + ), + }; + } +} + +void testNoErrors({ + required String name, + String? analysisOptions, + String? skip, + String? projectDart, + String? authDart, + String? resourcesDart, + String? models, + String? exceptions, + Map apis = const {}, + Map config = const {}, + Map lib = const {}, + void Function(Project)? expectProject, + List warnings = const [], +}) { + testErrors( + name: name, + analysisOptions: analysisOptions, + skip: skip, + errors: [], + warnings: warnings, + projectDart: projectDart, + authDart: authDart, + resourcesDart: resourcesDart, + models: models, + exceptions: exceptions, + apis: apis, + config: config, + lib: lib, + expectProject: expectProject, + ); +} + +void testErrors({ + required String name, + String? analysisOptions, + String? skip, + String? projectDart, + String? authDart, + String? resourcesDart, + String? models, + String? exceptions, + Map apis = const {}, + Map config = const {}, + Map lib = const {}, + required List errors, + List warnings = const [], + void Function(Project)? expectProject, +}) { + test(name, skip: skip, () async { + celestProject = await newProject( + name: name, + analysisOptions: analysisOptions, + projectDart: projectDart, + authDart: authDart, + resourcesDart: resourcesDart, + models: models, + exceptions: exceptions, + apis: apis, + config: config, + lib: lib, + ); + final analyzer = CelestAnalyzer(); + final CelestAnalysisResult( + :project, + errors: actualErrors, + warnings: actualWarnings, + ) = await analyzer.analyzeProject(); + for (final error in actualErrors) { + print(error); + } + expect( + actualErrors.map((e) => e.toString()), + unorderedEquals( + errors.map((error) { + return switch (error) { + Matcher _ => error, + String _ => contains(error), + _ => unreachable(), + }; + }), + ), + ); + expect( + actualWarnings.map((e) => e.toString()), + unorderedEquals( + warnings.map((warning) { + return switch (warning) { + Matcher _ => warning, + String _ => contains(warning), + _ => unreachable(), + }; + }), + ), + ); + if (actualErrors.isEmpty) { + expectProject?.call(project!); + } + }); +} + +void main() { + group('CelestAnalyzer', () { + setUpAll(initTests); + + tearDown(() async { + CelestAnalyzer().reset(); + await celestProject.close(); + }); + + group('part files', () { + testNoErrors( + name: 'can_resolve_part_files', + lib: { + 'models': { + 'test.dart': ''' +part 'test.g.dart'; +''', + 'test.g.dart': ''' +part of 'test.dart'; + +class Test {} +''', + }, + }, + apis: { + 'test.dart': ''' +import 'package:can_resolve_part_files/models/test.dart'; + +@cloud +Test test() => Test(); +''', + }, + ); + + testNoErrors( + name: 'can_define_to_json_in_part_files', + lib: { + 'models': { + 'test.dart': ''' +part 'test.g.dart'; + +class NotSerializable with _NotSerializable { + NotSerializable({ + Future? value, + }): value = value ?? Future.value(42); + + factory NotSerializable.fromJson(Map json) { + return NotSerializable( + value: Future.value(json['value'] as int), + ); + } + + final Future value; +} +''', + 'test.g.dart': ''' +part of 'test.dart'; + +mixin _NotSerializable on NotSerializable { + Map toJson() => {'value': 42}; +} +''', + }, + }, + apis: { + 'test.dart': ''' +import 'package:can_define_to_json_in_part_files/models/test.dart'; + +@cloud +NotSerializable test() => NotSerializable(); +''', + }, + ); + }); + + group('project.dart', () { + testNoErrors( + name: 'simple_project', + projectDart: _simpleProjectDart('simple_project'), + ); + + testErrors( + name: 'no_project', + projectDart: '', + errors: ['No `Project` type found'], + ); + + testErrors( + name: 'empty_project_name', + projectDart: ''' + import 'package:celest/celest.dart'; + + const project = Project(name: ''); + ''', + errors: ['The project name cannot be empty.'], + ); + }); + + group('apis', () { + testNoErrors( + name: 'simple_api', + apis: { + 'greeting.dart': ''' + import 'package:celest/celest.dart'; + + @cloud + String sayHello() => 'Hello, World!'; + ''', + }, + ); + + testErrors( + name: 'bad_file_name', + apis: { + 'greeting.dev.dart': ''' + import 'package:celest/celest.dart'; + + @cloud + String sayHello() => 'Hello, World!'; + ''', + }, + errors: ['API files must be named as follows: .dart'], + ); + + testErrors( + name: 'bad_file_name_underscore', + apis: { + '_greeting.dart': ''' + import 'package:celest/celest.dart'; + + @cloud + String sayHello() => 'Hello, World!'; + ''', + }, + errors: ['API names may not start with an underscore'], + ); + + testErrors( + name: 'bad_parameter_types_core', + apis: { + 'greeting.dart': ''' + import 'package:celest/celest.dart'; + + @cloud + void sayHello({ + required Enum myEnum, + required List listOfEnum, + required Iterable iterableOfEnum, + required void Function() function, + required List listOfFunction, + required Iterable iterableOfFunction, + required Never never, + required List listOfNever, + required Iterable iterableOfNever, + required void void_, + required List listOfVoid, + required Iterable iterableOfVoid, + required Set set, + required Symbol symbol, + required List listOfSymbol, + required Iterable iterableOfSymbol, + required Type type, + required List listOfType, + required Iterable iterableOfType, + required Stream streamOfStrings, + required Stream streamOfDynamics, + }) {} + ''', + }, + errors: [ + 'Untyped enums are not supported', // Enum + 'Untyped enums are not supported', // List + 'Untyped enums are not supported', // Iterable + 'Function types are not supported', // void Function() + 'Function types are not supported', // List + 'Function types are not supported', // Iterable + 'Never types are not supported', // Never + 'Never types are not supported', // List + 'Never types are not supported', // Iterable + 'Void types are not supported', // void + 'Void types are not supported', // List + 'Void types are not supported', // Iterable + 'Set types are not supported', // Set + 'Symbol types are not supported', // Symbol + 'Symbol types are not supported', // List + 'Symbol types are not supported', // Iterable + 'Type literals are not supported', // Type + 'Type literals are not supported', // List + 'Type literals are not supported', // Iterable + 'Stream types are not supported', // Stream + 'Stream types are not supported', // Stream + ], + ); + + testErrors( + name: 'bad_parameter_extension_types_core', + apis: { + 'greeting.dart': ''' +import 'package:celest/celest.dart'; + +@cloud +void sayHello({ + required EnumX myEnum, + required ListOfEnumX listOfEnum, + required IterableOfEnumX iterableOfEnum, + required FunctionX function, + required ListOfFunctionX listOfFunction, + required IterableOfFunctionX iterableOfFunction, + required VoidX void_, + required ListOfVoidX listOfVoid, + required IterableOfVoidX iterableOfVoid, + required SetX set, + required SymbolX symbol, + required ListOfSymbolX listOfSymbol, + required IterableOfSymbolX iterableOfSymbol, + required TypeX type, + required ListOfTypeX listOfType, + required IterableOfTypeX iterableOfType, + required StreamOfStringsX streamOfStrings, + required StreamX streamOfDynamics, +}) {} +''', + }, + models: ''' +extension type EnumX(Enum _) {} +extension type ListOfEnumX(List _) {} +extension type IterableOfEnumX(Iterable _) {} +extension type FunctionX(void Function() _) {} +extension type ListOfFunctionX(List _) {} +extension type IterableOfFunctionX(Iterable _) {} +extension type VoidX(void _) {} +extension type ListOfVoidX(List _) {} +extension type IterableOfVoidX(Iterable _) {} +extension type SetX(Set _) {} +extension type SymbolX(Symbol _) {} +extension type ListOfSymbolX(List _) {} +extension type IterableOfSymbolX(Iterable _) {} +extension type TypeX(Type _) {} +extension type ListOfTypeX(List _) {} +extension type IterableOfTypeX(Iterable _) {} +extension type StreamOfStringsX(Stream _) {} +extension type StreamX(Stream _) {} +''', + errors: [ + 'The representation type of EnumX is not serializable', + 'Untyped enums are not supported', // Enum + 'The representation type of ListOfEnumX is not serializable', + 'Untyped enums are not supported', // List + 'The representation type of IterableOfEnumX is not serializable', + 'Untyped enums are not supported', // Iterable + 'The representation type of FunctionX is not serializable', + 'Function types are not supported', // void Function() + 'The representation type of ListOfFunctionX is not serializable', + 'Function types are not supported', // List + 'The representation type of IterableOfFunctionX is not serializable', + 'Function types are not supported', // Iterable + 'The representation type of VoidX is not serializable', + 'Void types are not supported', // void + 'The representation type of ListOfVoidX is not serializable', + 'Void types are not supported', // List + 'The representation type of IterableOfVoidX is not serializable', + 'Void types are not supported', // Iterable + 'The representation type of SetX is not serializable', + 'Set types are not supported', // Set + 'The representation type of SymbolX is not serializable', + 'Symbol types are not supported', // Symbol + 'The representation type of ListOfSymbolX is not serializable', + 'Symbol types are not supported', // List + 'The representation type of IterableOfSymbolX is not serializable', + 'Symbol types are not supported', // Iterable + 'The representation type of TypeX is not serializable', + 'Type literals are not supported', // Type + 'The representation type of ListOfTypeX is not serializable', + 'Type literals are not supported', // List + 'The representation type of IterableOfTypeX is not serializable', + 'Type literals are not supported', // Iterable + 'The representation type of StreamOfStringsX is not serializable', + 'Stream types are not supported', // Stream + 'The representation type of StreamX is not serializable', + 'Stream types are not supported', // Stream + ], + ); + + testErrors( + name: 'bad_return_types_core', + apis: { + 'greeting.dart': ''' +import 'package:celest/celest.dart'; + +@cloud +ReturnTypes sayHello() => throw UnimplementedError(null); +''', + }, + models: ''' +typedef ReturnTypes = ({ + Enum enum, + List listOfEnum, + Iterable iterableOfEnum, + void Function() function, + List listOfFunction, + Iterable iterableOfFunction, + InvalidType invalidType, + List listOfInvalidType, + Iterable iterableOfInvalidType, + Never never, + List listOfNever, + Iterable iterableOfNever, + void void_, + List listOfVoid, + Iterable iterableOfVoid, + Set set, + Symbol symbol, + List listOfSymbol, + Iterable iterableOfSymbol, + Type type, + List listOfType, + Iterable iterableOfType, + Stream streamOfStrings, + Stream streamOfDynamics, +}); +''', + errors: [ + 'Untyped enums are not supported', // Enum + 'Untyped enums are not supported', // List + 'Untyped enums are not supported', // Iterable + 'Function types are not supported', // void Function() + 'Function types are not supported', // List + 'Function types are not supported', // Iterable + 'Invalid type', // InvalidType + 'Invalid type', // List + 'Invalid type', // Iterable + 'Never types are not supported', // Never + 'Never types are not supported', // List + 'Never types are not supported', // Iterable + 'Void types are not supported', // void + 'Void types are not supported', // List + 'Void types are not supported', // Iterable + 'Set types are not supported', // Set + 'Symbol types are not supported', // Symbol + 'Symbol types are not supported', // List + 'Symbol types are not supported', // Iterable + 'Type literals are not supported', // Type + 'Type literals are not supported', // List + 'Type literals are not supported', // Iterable + 'Stream types are not supported', // Stream + 'Stream types are not supported', // Stream + ], + ); + + testErrors( + name: 'bad_return_extension_types_core', + apis: { + 'greeting.dart': ''' +import 'package:celest/celest.dart'; + +@cloud +ReturnTypes sayHello() => throw UnimplementedError(null); +''', + }, + models: ''' +extension type EnumX(Enum _) {} +extension type ListOfEnumX(List _) {} +extension type IterableOfEnumX(Iterable _) {} +extension type FunctionX(void Function() _) {} +extension type ListOfFunctionX(List _) {} +extension type IterableOfFunctionX(Iterable _) {} +extension type VoidX(void _) {} +extension type ListOfVoidX(List _) {} +extension type IterableOfVoidX(Iterable _) {} +extension type SetX(Set _) {} +extension type SymbolX(Symbol _) {} +extension type ListOfSymbolX(List _) {} +extension type IterableOfSymbolX(Iterable _) {} +extension type TypeX(Type _) {} +extension type ListOfTypeX(List _) {} +extension type IterableOfTypeX(Iterable _) {} +extension type StreamOfStringsX(Stream _) {} +extension type StreamX(Stream _) {} + +typedef ReturnTypes = ({ + EnumX enum, + ListOfEnumX listOfEnum, + IterableOfEnumX iterableOfEnum, + FunctionX function, + ListOfFunctionX listOfFunction, + IterableOfFunctionX iterableOfFunction, + VoidX void_, + ListOfVoidX listOfVoid, + IterableOfVoidX iterableOfVoid, + SetX set, + SymbolX symbol, + ListOfSymbolX listOfSymbol, + IterableOfSymbolX iterableOfSymbol, + TypeX type, + ListOfTypeX listOfType, + IterableOfTypeX iterableOfType, + StreamOfStringsX streamOfStrings, + StreamX streamOfDynamics, +}); +''', + errors: [ + 'The representation type of EnumX is not serializable', + 'Untyped enums are not supported', // Enum + 'The representation type of ListOfEnumX is not serializable', + 'Untyped enums are not supported', // List + 'The representation type of IterableOfEnumX is not serializable', + 'Untyped enums are not supported', // Iterable + 'The representation type of FunctionX is not serializable', + 'Function types are not supported', // void Function() + 'The representation type of ListOfFunctionX is not serializable', + 'Function types are not supported', // List + 'The representation type of IterableOfFunctionX is not serializable', + 'Function types are not supported', // Iterable + 'The representation type of VoidX is not serializable', + 'Void types are not supported', // void + 'The representation type of ListOfVoidX is not serializable', + 'Void types are not supported', // List + 'The representation type of IterableOfVoidX is not serializable', + 'Void types are not supported', // Iterable + 'The representation type of SetX is not serializable', + 'Set types are not supported', // Set + 'The representation type of SymbolX is not serializable', + 'Symbol types are not supported', // Symbol + 'The representation type of ListOfSymbolX is not serializable', + 'Symbol types are not supported', // List + 'The representation type of IterableOfSymbolX is not serializable', + 'Symbol types are not supported', // Iterable + 'The representation type of TypeX is not serializable', + 'Type literals are not supported', // Type + 'The representation type of ListOfTypeX is not serializable', + 'Type literals are not supported', // List + 'The representation type of IterableOfTypeX is not serializable', + 'Type literals are not supported', // Iterable + 'The representation type of StreamOfStringsX is not serializable', + 'Stream types are not supported', // Stream + 'The representation type of StreamX is not serializable', + 'Stream types are not supported', // Stream + ], + ); + + testNoErrors( + name: 'extension_type_primitives', + apis: { + 'greeting.dart': ''' +import 'package:celest/celest.dart'; + +@cloud +StringX string(StringX s) => s; + +@cloud +StringXString stringString(StringXString s) => s; +''', + }, + models: ''' +extension type StringX(String s) {} +extension type StringXString(String s) implements String {} +''', + ); + + testNoErrors( + name: 'extension_type_complex', + apis: { + 'greeting.dart': ''' +import 'package:celest/celest.dart'; + +@cloud +Value value(Value v) => v; +@cloud +ValueX valueX(ValueX v) => v; +@cloud +ValueXImpl valueXImpl(ValueXImpl v) => v; +''', + }, + models: ''' +class Value { + const Value(this.value); + + factory Value.fromJson(String value) => Value(value); + + final String value; + + String toJson() => value; +} + +extension type const ValueX(Value v) {} +extension type const ValueXImpl(Value v) implements Value {} +''', + ); + + testNoErrors( + name: 'extension_type_complex_to_from_json', + apis: { + 'greeting.dart': ''' +import 'package:celest/celest.dart'; + +@cloud +ValueXToFromJson valueXToFromJson(ValueXToFromJson v) => v; +@cloud +ValueXToJson valueXToJson(ValueXToJson v) => v; +@cloud +ValueXToJsonImpl valueXToJsonImpl(ValueXToJsonImpl v) => v; +@cloud +ValueXFromJson valueXFromJson(ValueXFromJson v) => v; +@cloud +ValueXFromJsonImpl valueXFromJsonImpl(ValueXFromJsonImpl v) => v; +@cloud +ValueXFromJsonStatic valueXFromJsonStatic(ValueXFromJsonStatic v) => v; +''', + }, + models: r''' +class Value { + const Value(this.value); + + factory Value.fromJson(String value) => Value(value); + + final String value; + + String toJson() => value; +} + +extension type const ValueXToFromJson(Value v) { + ValueXToFromJson.fromJson(String value) : v = Value('${value}FromJson'); + + String toJson() => '${v.value}ToJson'; +} +extension type const ValueXToJson(Value v) { + Map toJson() => {'value': '${v.value}ToJson'}; +} +extension type const ValueXToJsonImpl(Value v) implements Value { + String toJson() => '${v.value}ToJson'; +} +extension type const ValueXFromJson(Value v) { + ValueXFromJson.fromJson(Map json) + : v = Value('${json['value']}FromJson'); +} +extension type const ValueXFromJsonImpl(Value v) implements Value { + ValueXFromJsonImpl.fromJson(String value) : v = Value('${value}FromJson'); + + String toJson() => v.toJson(); +} +extension type const ValueXFromJsonStatic(Value v) { + static ValueXFromJsonStatic fromJson(Map json) => + ValueXFromJsonStatic(Value('${json['value']}FromJson')); +} +''', + ); + + testNoErrors( + name: 'allows_map_string_dynamic_object', + apis: { + 'greeting.dart': ''' +import 'package:celest/celest.dart'; + +@cloud +Map mapStringDynamic(Map map) => map; + +@cloud +Map mapStringObject(Map map) => map; + +@cloud +Map mapStringObjectNullable(Map map) => map; +''', + }, + ); + + testErrors( + name: 'bad_json_parameter', + apis: { + 'greeting.dart': ''' +import 'package:celest/celest.dart'; + +@cloud +String sayHello(NotJsonable _) => 'Hello, World!'; +''', + }, + models: ''' +abstract class NotJsonable {} +''', + errors: [ + 'The type of a parameter must be serializable as JSON. ' + 'Class NotJsonable is abstract and must have an unnamed factory or ' + 'fromJson factory constructor to be used.', + ], + ); + + testErrors( + name: 'positional_record_fields', + apis: { + 'greeting.dart': ''' +import 'package:celest/celest.dart'; + +@cloud +(String positionalField,) sayHello((String positionalField,) _) => ('Hello, World!',); +''', + }, + errors: [ + 'Positional fields are not supported in record types', + 'Positional fields are not supported in record types', + ], + ); + + testErrors( + name: 'positional_record_fields_aliased', + apis: { + 'greeting.dart': ''' +import 'package:celest/celest.dart'; + +@cloud +PositionalFields sayHello(PositionalFields _) => ('Hello, World!',); +''', + }, + models: ''' +typedef PositionalFields = (String positionalField); +''', + errors: [ + 'Positional fields are not supported in record types', + 'Positional fields are not supported in record types', + ], + ); + + testErrors( + name: 'parameter_with_subtypes', + apis: { + 'greeting.dart': ''' +import 'package:celest/celest.dart'; + +@cloud +String sayHello(Base _) => 'Hello, World!'; +''', + }, + models: ''' +class Base {} +final class Actual extends Base {} +''', + errors: [ + 'Classes with subtypes (which are not sealed classes) are not currently supported as parameters', + ], + ); + + testErrors( + name: 'return_type_with_subtypes', + apis: { + 'greeting.dart': ''' +import 'package:celest/celest.dart'; + +@cloud +Base sayHello() => Base(); +''', + }, + models: ''' +class Base {} +final class Actual extends Base {} +''', + errors: [ + 'Classes with subtypes (which are not sealed classes) are not currently supported as return types', + ], + ); + + testNoErrors( + name: 'valid_jsonable', + apis: { + 'greeting.dart': ''' +import 'package:celest/celest.dart'; + +@cloud +ValidJsonable sayHello(ValidJsonable param) => param; +''', + }, + models: ''' +class ValidJsonable {} +''', + ); + + testNoErrors( + name: 'valid_custom_json', + apis: { + 'greeting.dart': ''' +import 'package:celest/celest.dart'; + +@cloud +ValidCustomJson sayHello(ValidCustomJson param) => param; +''', + }, + models: ''' +class ValidCustomJson { + factory ValidCustomJson.fromJson(Map _) => throw UnimplementedError(null); + Map toJson() => throw UnimplementedError(null); +} +''', + ); + + testNoErrors( + name: 'custom_json_in_mixin', + lib: { + 'models': { + 'test.dart': ''' +class NotSerializable with _NotSerializable { + NotSerializable({ + Future? value, + }): value = value ?? Future.value(42); + + factory NotSerializable.fromJson(Map json) { + return NotSerializable( + value: Future.value(json['value'] as int), + ); + } + + final Future value; +} + +mixin _NotSerializable on NotSerializable { + Map toJson() => {'value': 42}; +} +''', + }, + }, + apis: { + 'test.dart': ''' +import 'package:custom_json_in_mixin/models/test.dart'; + +@cloud +NotSerializable test() => NotSerializable(); +''', + }, + ); + + testNoErrors( + name: 'valid_static_fromJson', + apis: { + 'greeting.dart': ''' +import 'package:celest/celest.dart'; + +@cloud +ValidFromJsonStatic sayHello(ValidFromJsonStatic param) => param; +''', + }, + models: ''' +class ValidFromJsonStatic { + static ValidFromJsonStatic fromJson(Map _) => throw UnimplementedError(null); + Map toJson() => throw UnimplementedError(null); +} +''', + ); + + testErrors( + name: 'invalid_static_fromJson', + apis: { + 'greeting.dart': ''' +import 'package:celest/celest.dart'; + +@cloud +void sayHello(ValidFromJsonStatic param) {} +''', + }, + models: ''' +class ValidFromJsonStatic { + static ValidFromJsonStatic? fromJson(Map _) => throw UnimplementedError(null); + Map toJson() => throw UnimplementedError(null); +} +''', + errors: [ + 'The return type of ValidFromJsonStatic\'s fromJson constructor must ' + 'be ValidFromJsonStatic', + ], + ); + + testErrors( + name: 'direct_cycle', + apis: { + 'greeting.dart': ''' +import 'package:celest/celest.dart'; + +@cloud +void sayHello(ValidJsonable param) => param; +''', + }, + models: ''' +class ValidJsonable { + const ValidJsonable(this.value); + + final ValidJsonable value; +} +''', + errors: ['Classes are not allowed to have fields of their own type'], + ); + + testNoErrors( + name: 'indirect_cycle', + apis: { + 'greeting.dart': ''' +import 'package:celest/celest.dart'; + +@cloud +void sayHello(ValidJsonable param) => param; +''', + }, + models: ''' +class ValidJsonable { + const ValidJsonable(this.value, this.values, this.wrapper); + + final ValidJsonable? value; + final List values; + final ValidJsonableWrapper wrapper; +} + +class ValidJsonableWrapper { + const ValidJsonableWrapper(this.value); + + final ValidJsonable value; +} +''', + ); + + testErrors( + name: 'bad_json_return', + apis: { + 'greeting.dart': ''' +import 'package:celest/celest.dart'; + +@cloud +NotJsonable sayHello() => throw UnimplementedError(null); +''', + }, + models: ''' +class NotJsonable { + NotJson(this.value); + + final Enum value; +} +''', + errors: ['Untyped enums are not supported'], + ); + + testErrors( + name: 'non_map_from_json', + apis: { + 'greeting.dart': ''' +import 'package:celest/celest.dart'; + +@cloud +NonMapFromJson nonMayFromJson(NonMapFromJson value) => value; +''', + }, + models: ''' +class NonMapFromJson { + NonMapFromJson.fromJson(this.field); + + final String field; +} +''', + errors: [ + 'The type of a parameter must be serializable as JSON. The parameter ' + 'type of NonMapFromJson\'s fromJson constructor must be ' + 'assignable to Map.', + 'The return type of a function must be serializable as JSON. The ' + 'parameter type of NonMapFromJson\'s fromJson constructor must ' + 'be assignable to Map.', + ], + ); + + testErrors( + name: 'from_json_optional_parameter', + apis: { + 'greeting.dart': ''' +import 'package:celest/celest.dart'; + +@cloud +FromJson fromJson(FromJson value) => value; +''', + }, + models: ''' +class FromJson { + FromJson.fromJson([Map? json]): + field = json?['field'] as String? ?? 'default'; + + final String field; +} +''', + errors: [ + 'The type of a parameter must be serializable as JSON. The fromJson ' + 'constructor of type FromJson must have one required, ' + 'positional parameter.', + 'The return type of a function must be serializable as JSON. The ' + 'fromJson constructor of type FromJson must have one ' + 'required, positional parameter.', + ], + ); + + testErrors( + name: 'bad_parameter_names', + apis: { + 'greeting.dart': r''' +import 'package:celest/celest.dart'; + +@cloud +String sayHello(String $param) => 'Hello, World!'; +''', + }, + errors: ['Parameter names may not start with a dollar sign'], + ); + + testErrors( + name: 'private_parameter_type', + apis: { + 'greeting.dart': r''' +import 'package:celest/celest.dart'; + +@cloud +String sayHello(Private privateAliased) => 'Hello, World!'; +''', + }, + models: ''' +class _Private { + const _Private(); +} + +typedef Private = _Private; +''', + errors: ['Private types are not supported'], + ); + + testErrors( + name: 'sealed_via_mixins', + apis: { + 'greeting.dart': r''' +import 'package:celest/celest.dart'; + +@cloud +void sealedViaMixins(Base base) {} +''', + }, + models: ''' +sealed class Base {} + +mixin class BaseMixin implements Base {} + +final class Leaf with BaseMixin {} +''', + errors: [ + // Base and BaseMixin are not allowed as parameter/return types + // because they have unsealed classes in their hierarchy or are + // unsealed themselves. + allOf([ + contains( + 'Classes with subtypes (which are not sealed classes) are not ' + 'currently supported', + ), + contains('BaseMixin'), + contains('Base'), + isNot(contains('Leaf')), + ]), + ], + ); + + testErrors( + name: 'sealed_with_conflicting_wire_types', + apis: { + 'greeting.dart': r''' +import 'package:celest/celest.dart'; + +@cloud +List takesLeaves(LeafA a, LeafB b) => [a, b]; +''', + }, + models: ''' +sealed class Base {} + +final class LeafA extends Base {} + +final class LeafB extends Base { + LeafB.fromJson(String json); + + String toJson() => ''; +} +''', + errors: [ + 'All classes in a sealed class hierarchy must use Map', + ], + ); + + testNoErrors( + name: 'legacy_def_locations', + apis: { + 'greeting.dart': ''' +import 'package:celest/celest.dart'; + +@cloud +ValidJsonable sayHello(ValidJsonable param) => throw ValidException(); +''', + }, + models: ''' +class ValidJsonable {} +''', + exceptions: ''' +class ValidException implements Exception {} +''', + ); + + // In V1, it is valid to define models in the same file as the API which + // uses them. + testNoErrors( + name: 'valid_def_locations', + apis: { + 'greeting.dart': ''' +import 'package:celest/celest.dart'; + +class ValidJsonable {} +class ValidException implements Exception {} + +@cloud +ValidJsonable sayHello(ValidJsonable param) => throw ValidException(); +''', + }, + ); + + testErrors( + name: 'function_with_same_name', + apis: { + 'greeting.dart': ''' +import 'package:celest/celest.dart'; + +@cloud +void sayHello() {} + +@cloud +void sayHello() {} +''', + }, + authDart: ''' +const auth = Auth( + providers: [AuthProvider.email()], +); +''', + errors: ["The name 'sayHello' is already defined"], + ); + + // Valid types but invalid to target with `@httpHeader` + testErrors( + name: 'http_header_invalid', + apis: { + 'greeting.dart': ''' +import 'package:celest/celest.dart'; +import 'package:celest/http.dart'; + +@cloud +String sayHello({ + @httpHeader('x-custom-regexp') required RegExp customRegex, + @httpHeader('x-custom-bigint') required BigInt customBigInt, + @httpHeader('x-custom-uri') required Uri customUri, + @httpHeader('x-custom-list-regexp') required List customListRegex, + @httpHeader('x-custom-list-bigint') required List customListBigInt, + @httpHeader('x-custom-list-uri') required List customListUri, + @httpHeader('x-custom-list-string') required List customListString, + @httpHeader('x-custom-list-bool') required List customListBool, + @httpHeader('x-custom-list-int') required List customListInt, + @httpHeader('x-custom-list-num') required List customListNum, + @httpHeader('x-custom-list-double') required List customListDouble, + @httpHeader('x-custom-list-datetime') required List customListDateTime, + @httpHeader('x-custom-nullable-list-string') List? customNullableListString, + @httpHeader('x-custom-nullable-list-bool') List? customNullableListBool, + @httpHeader('x-custom-nullable-list-int') List? customNullableListInt, + @httpHeader('x-custom-nullable-list-num') List? customNullableListNum, + @httpHeader('x-custom-nullable-list-double') List? customNullableListDouble, + @httpHeader('x-custom-nullable-list-datetime') List? customNullableListDateTime, + @httpHeader('x-custom-nullable-list-nullable-string') List? customNullableListNullableString, + @httpHeader('x-custom-nullable-list-nullable-bool') List? customNullableListNullableBool, + @httpHeader('x-custom-nullable-list-nullable-int') List? customNullableListNullableInt, + @httpHeader('x-custom-nullable-list-nullable-num') List? customNullableListNullableNum, + @httpHeader('x-custom-nullable-list-nullable-double') List? customNullableListNullableDouble, + @httpHeader('x-custom-nullable-list-nullable-datetime') List? customNullableListNullableDateTime, +}) => 'Hello, World!'; +''', + }, + errors: [ + 'Invalid HTTP header type', // RegExp + 'Invalid HTTP header type', // BigInt + 'Invalid HTTP header type', // Uri + 'Invalid HTTP header type', // List + 'Invalid HTTP header type', // List + 'Invalid HTTP header type', // List + 'Invalid HTTP header type', // List + 'Invalid HTTP header type', // List + 'Invalid HTTP header type', // List + 'Invalid HTTP header type', // List + 'Invalid HTTP header type', // List + 'Invalid HTTP header type', // List + 'Invalid HTTP header type', // List + 'Invalid HTTP header type', // List + 'Invalid HTTP header type', // List + 'Invalid HTTP header type', // List + 'Invalid HTTP header type', // List + 'Invalid HTTP header type', // List + 'Invalid HTTP header type', // List? + 'Invalid HTTP header type', // List? + 'Invalid HTTP header type', // List? + 'Invalid HTTP header type', // List? + 'Invalid HTTP header type', // List? + 'Invalid HTTP header type', // List? + ], + ); + + // Valid types but invalid to target with `@httpHeader` + testErrors( + name: 'http_query_invalid', + apis: { + 'greeting.dart': ''' +import 'package:celest/celest.dart'; +import 'package:celest/http.dart'; + +@cloud +String sayHello({ + @httpQuery('x-custom-regexp') required RegExp customRegex, + @httpQuery('x-custom-bigint') required BigInt customBigInt, + @httpQuery('x-custom-uri') required Uri customUri, + @httpQuery('x-custom-list-regexp') required List customListRegex, + @httpQuery('x-custom-list-bigint') required List customListBigInt, + @httpQuery('x-custom-list-uri') required List customListUri, +}) => 'Hello, World!'; +''', + }, + errors: [ + 'Invalid HTTP query type', // RegExp + 'Invalid HTTP query type', // BigInt + 'Invalid HTTP query type', // Uri + 'Invalid HTTP query type', // List + 'Invalid HTTP query type', // List + 'Invalid HTTP query type', // List + ], + ); + }); + + group('auth', () { + testNoErrors( + name: 'api_authenticated', + apis: { + 'greeting.dart': ''' +@authenticated +library; + +import 'package:celest/celest.dart'; + +@cloud +String sayHello() => 'Hello, World!'; +''', + }, + authDart: ''' +const auth = Auth( + providers: [AuthProvider.email()], +); +''', + ); + + testNoErrors( + name: 'api_public', + apis: { + 'greeting.dart': ''' +@public +library; + +import 'package:celest/celest.dart'; + +@cloud +String sayHello() => 'Hello, World!'; +''', + }, + authDart: ''' +const auth = Auth( + providers: [AuthProvider.email()], +); +''', + ); + + testErrors( + name: 'multiple_api_auth', + apis: { + 'greeting.dart': ''' +@public +@authenticated +library; + +import 'package:celest/celest.dart'; + +@cloud +String sayHello() => 'Hello, World!'; +''', + }, + authDart: ''' +const auth = Auth( + providers: [AuthProvider.email()], +); +''', + errors: [ + 'Only one `@authenticated` or `@public` annotation may be ' + 'specified on the same function or API library', + ], + ); + + testErrors( + name: 'multiple_api_auth_same_type', + apis: { + 'greeting.dart': ''' +@authenticated +@authenticated +library; + +import 'package:celest/celest.dart'; + +@cloud +String sayHello() => 'Hello, World!'; +''', + }, + authDart: ''' +const auth = Auth( + providers: [AuthProvider.email()], +); +''', + errors: [ + 'Only one `@authenticated` or `@public` annotation may be ' + 'specified on the same function or API library', + ], + ); + + testNoErrors( + name: 'function_authenticated', + apis: { + 'greeting.dart': ''' +import 'package:celest/celest.dart'; + +@cloud +@authenticated +String sayHello() => 'Hello, World!'; +''', + }, + authDart: ''' +const auth = Auth( + providers: [AuthProvider.email()], +); +''', + ); + + testNoErrors( + name: 'function_public', + apis: { + 'greeting.dart': ''' +import 'package:celest/celest.dart'; + +@cloud +@public +String sayHello() => 'Hello, World!'; +''', + }, + authDart: ''' +const auth = Auth( + providers: [AuthProvider.email()], +); +''', + ); + + testNoErrors( + name: 'function_public_no_auth', + apis: { + 'greeting.dart': ''' +import 'package:celest/celest.dart'; + +@cloud +@public +String sayHello() => 'Hello, World!'; +''', + }, + ); + + testErrors( + name: 'function_authenticated_no_auth', + apis: { + 'greeting.dart': ''' +import 'package:celest/celest.dart'; + +@cloud +@authenticated +String sayHello() => 'Hello, World!'; +''', + }, + errors: [ + 'The `@authenticated` annotation may only be used in ' + 'projects with authentication enabled.', + ], + ); + + testErrors( + name: 'multiple_function_auth', + apis: { + 'greeting.dart': ''' +import 'package:celest/celest.dart'; + +@cloud +@public +@authenticated +String sayHello() => 'Hello, World!'; +''', + }, + authDart: ''' +const auth = Auth( + providers: [AuthProvider.email()], +); +''', + errors: [ + 'Only one `@authenticated` or `@public` annotation may be ' + 'specified on the same function or API library', + ], + ); + + testErrors( + name: 'multiple_function_auth_same_type', + apis: { + 'greeting.dart': ''' +import 'package:celest/celest.dart'; + +@cloud +@authenticated +@authenticated +String sayHello() => 'Hello, World!'; +''', + }, + authDart: ''' +const auth = Auth( + providers: [AuthProvider.email()], +); +''', + errors: [ + 'Only one `@authenticated` or `@public` annotation may be ' + 'specified on the same function or API library', + ], + ); + + testNoErrors( + name: 'api_public_no_auth', + apis: { + 'greeting.dart': ''' +@public +library; + +import 'package:celest/celest.dart'; + +@cloud +String sayHello() => 'Hello, World!'; +''', + }, + ); + + testErrors( + name: 'api_authenticated_no_auth', + apis: { + 'greeting.dart': ''' +@authenticated +library; + +import 'package:celest/celest.dart'; + +@cloud +String sayHello() => 'Hello, World!'; +''', + }, + errors: [ + 'The `@authenticated` annotation may only be used in ' + 'projects with authentication enabled.', + ], + ); + + testNoErrors( + name: 'conflicting_auth', + apis: { + 'greeting.dart': ''' +@authenticated +library; + +import 'package:celest/celest.dart'; + +@cloud +@public +String sayHello() => 'Hello, World!'; +''', + }, + authDart: ''' +const auth = Auth( + providers: [AuthProvider.email()], +); +''', + warnings: [ + '`@public` has no effect when `@authenticated` is applied at the ' + 'API level. It is recommended to move the `@public` method to ' + 'another API.', + ], + ); + }); + + group('http', () { + testNoErrors( + name: 'http_method', + apis: { + 'greeting.dart': ''' +import 'package:celest/celest.dart'; +import 'package:celest/http.dart'; + +@cloud +@http(method: HttpMethod.get) +String sayHello() => 'Hello, World!'; +''', + }, + expectProject: (project) { + final function = project.apis.values.single.functions.values.single; + check(function.metadata.single) + .isA() + .has((it) => it.method, 'method') + .equals(HttpMethod.get); + }, + ); + + testNoErrors( + name: 'http_status_valid', + apis: { + 'greeting.dart': ''' +import 'package:celest/celest.dart'; +import 'package:celest/http.dart'; + +@cloud +@http(statusCode: HttpStatus.created) +String sayHello() => 'Hello, World!'; +''', + }, + expectProject: (project) { + final function = project.apis.values.single.functions.values.single; + check(function.metadata.single) + .isA() + .has((it) => it.statusCode, 'statusCode') + .equals(HttpStatus.created); + }, + ); + + testErrors( + name: 'http_status_invalid', + apis: { + 'greeting.dart': ''' +import 'package:celest/celest.dart'; +import 'package:celest/http.dart'; + +@cloud +@http(statusCode: HttpStatus(600)) +String sayHello() => 'Hello, World!'; +''', + }, + errors: ['Invalid HTTP status code'], + ); + + testNoErrors( + name: 'http_errors_valid', + apis: { + 'greeting.dart': ''' +import 'package:celest/celest.dart'; +import 'package:celest/http.dart'; +import 'package:http_errors_valid/exceptions.dart'; + +@cloud +@httpError(HttpStatus.unauthorized, UnauthorizedException, ForbiddenException) +@httpError(HttpStatus.notFound, ItemNotFoundException) +String sayHello() => 'Hello, World!'; +''', + }, + exceptions: ''' +class ForbiddenException implements Exception {} +class ItemNotFoundException implements Exception {} +''', + expectProject: (project) { + final function = project.apis.values.single.functions.values.single; + + hasErrorType(String type, int statusCode) => + (Subject it) => + it.isA() + ..has((it) => it.type.symbol, 'symbol').equals(type) + ..has( + (it) => it.statusCode, + 'statusCode', + ).equals(statusCode); + + check(function.metadata).containsInOrder([ + hasErrorType('UnauthorizedException', HttpStatus.unauthorized), + hasErrorType('ForbiddenException', HttpStatus.unauthorized), + hasErrorType('ItemNotFoundException', HttpStatus.notFound), + ]); + }, + ); + + testNoErrors( + name: 'http_header_valid', + apis: { + 'greeting.dart': ''' +import 'package:celest/celest.dart'; +import 'package:celest/http.dart'; + +@cloud +String sayHello({ + @httpHeader() required String header, + @httpHeader('x-custom-string') required String customString, + @httpHeader('x-custom-bool') required bool customBool, + @httpHeader('x-custom-int') required int customInt, + @httpHeader('x-custom-num') required num customNum, + @httpHeader('x-custom-double') required double customDouble, + @httpHeader('x-custom-datetime') required DateTime customDateTime, + @httpHeader('x-custom-nullable-string') String? customNullableString, + @httpHeader('x-custom-nullable-bool') bool? customNullableBool, + @httpHeader('x-custom-nullable-int') int? customNullableInt, + @httpHeader('x-custom-nullable-num') num? customNullableNum, + @httpHeader('x-custom-nullable-double') double? customNullableDouble, + @httpHeader('x-custom-nullable-datetime') DateTime? customNullableDateTime, +}) => 'Hello, World!'; +''', + }, + expectProject: (project) { + final parameters = + project.apis.values.single.functions.values.single.parameters; + hasHeader(String name) => + (Subject it) => + it + .has((it) => it.references, 'references') + .isA() + ..has((it) => it.type, 'type').equals(NodeType.httpHeader) + ..has((it) => it.name, 'name').equals(name); + check(parameters).containsInOrder([ + hasHeader('header'), + hasHeader('x-custom-string'), + hasHeader('x-custom-bool'), + hasHeader('x-custom-int'), + hasHeader('x-custom-num'), + hasHeader('x-custom-double'), + hasHeader('x-custom-datetime'), + hasHeader('x-custom-nullable-string'), + hasHeader('x-custom-nullable-bool'), + hasHeader('x-custom-nullable-int'), + hasHeader('x-custom-nullable-num'), + hasHeader('x-custom-nullable-double'), + hasHeader('x-custom-nullable-datetime'), + ]); + }, + ); + + testNoErrors( + name: 'http_query_valid', + apis: { + 'greeting.dart': ''' +import 'package:celest/celest.dart'; +import 'package:celest/http.dart'; + +@cloud +String sayHello({ + @httpQuery() required String query, + @httpQuery('x-custom-string') required String customString, + @httpQuery('x-custom-bool') required bool customBool, + @httpQuery('x-custom-int') required int customInt, + @httpQuery('x-custom-num') required num customNum, + @httpQuery('x-custom-double') required double customDouble, + @httpQuery('x-custom-datetime') required DateTime customDateTime, + @httpQuery('x-custom-nullable-string') String? customNullableString, + @httpQuery('x-custom-nullable-bool') bool? customNullableBool, + @httpQuery('x-custom-nullable-int') int? customNullableInt, + @httpQuery('x-custom-nullable-num') num? customNullableNum, + @httpQuery('x-custom-nullable-double') double? customNullableDouble, + @httpQuery('x-custom-nullable-datetime') DateTime? customNullableDateTime, + @httpQuery('x-custom-list-string') required List customListString, + @httpQuery('x-custom-list-bool') required List customListBool, + @httpQuery('x-custom-list-int') required List customListInt, + @httpQuery('x-custom-list-num') required List customListNum, + @httpQuery('x-custom-list-double') required List customListDouble, + @httpQuery('x-custom-list-datetime') required List customListDateTime, + @httpQuery('x-custom-nullable-list-string') List? customNullableListString, + @httpQuery('x-custom-nullable-list-bool') List? customNullableListBool, + @httpQuery('x-custom-nullable-list-int') List? customNullableListInt, + @httpQuery('x-custom-nullable-list-num') List? customNullableListNum, + @httpQuery('x-custom-nullable-list-double') List? customNullableListDouble, + @httpQuery('x-custom-nullable-list-datetime') List? customNullableListDateTime, + @httpQuery('x-custom-nullable-list-nullable-string') List? customNullableListNullableString, + @httpQuery('x-custom-nullable-list-nullable-bool') List? customNullableListNullableBool, + @httpQuery('x-custom-nullable-list-nullable-int') List? customNullableListNullableInt, + @httpQuery('x-custom-nullable-list-nullable-num') List? customNullableListNullableNum, + @httpQuery('x-custom-nullable-list-nullable-double') List? customNullableListNullableDouble, + @httpQuery('x-custom-nullable-list-nullable-datetime') List? customNullableListNullableDateTime, +}) => 'Hello, World!'; +''', + }, + expectProject: (project) { + final parameters = + project.apis.values.single.functions.values.single.parameters; + hasQuery(String name) => + (Subject it) => + it + .has((it) => it.references, 'references') + .isA() + ..has((it) => it.type, 'type').equals(NodeType.httpQuery) + ..has((it) => it.name, 'name').equals(name); + check(parameters).containsInOrder([ + hasQuery('query'), + hasQuery('x-custom-string'), + hasQuery('x-custom-bool'), + hasQuery('x-custom-int'), + hasQuery('x-custom-num'), + hasQuery('x-custom-double'), + hasQuery('x-custom-datetime'), + hasQuery('x-custom-nullable-string'), + hasQuery('x-custom-nullable-bool'), + hasQuery('x-custom-nullable-int'), + hasQuery('x-custom-nullable-num'), + hasQuery('x-custom-nullable-double'), + hasQuery('x-custom-nullable-datetime'), + hasQuery('x-custom-list-string'), + hasQuery('x-custom-list-bool'), + hasQuery('x-custom-list-int'), + hasQuery('x-custom-list-num'), + hasQuery('x-custom-list-double'), + hasQuery('x-custom-list-datetime'), + hasQuery('x-custom-nullable-list-string'), + hasQuery('x-custom-nullable-list-bool'), + hasQuery('x-custom-nullable-list-int'), + hasQuery('x-custom-nullable-list-num'), + hasQuery('x-custom-nullable-list-double'), + hasQuery('x-custom-nullable-list-datetime'), + hasQuery('x-custom-nullable-list-nullable-string'), + hasQuery('x-custom-nullable-list-nullable-bool'), + hasQuery('x-custom-nullable-list-nullable-int'), + hasQuery('x-custom-nullable-list-nullable-num'), + hasQuery('x-custom-nullable-list-nullable-double'), + hasQuery('x-custom-nullable-list-nullable-datetime'), + ]); + }, + ); + }); + + group('streaming', () { + testNoErrors( + name: 'streaming_return_type', + apis: { + 'greeting.dart': r''' +import 'package:celest/celest.dart'; + +@cloud +Stream greetings(List names) async* { + for (final name in names) { + yield 'Hello, $name!'; + } +} +''', + }, + ); + + testNoErrors( + name: 'streaming_complex_type', + apis: { + 'greeting.dart': r''' +import 'package:celest/celest.dart'; + +@cloud +Stream greetings() async* { + throw UnimplementedError(null); +} +''', + }, + models: ''' +class SimpleClass { + const SimpleClass(this.value); + + final String value; +} + +class ComplexClass { + const ComplexClass(this.simple, this.list); + + final SimpleClass simple; + final List list; +} +''', + ); + + testErrors( + name: 'future_of_streaming_return_type', + apis: { + 'greeting.dart': r''' +import 'package:celest/celest.dart'; + +@cloud +Future> greetings(List names) async { + return Stream.fromIterable([ + for (final name in names) 'Hello, $name!' + ]); +} +''', + }, + errors: ['Stream types are not supported'], + ); + + testErrors( + name: 'http_config_streaming_return_type', + apis: { + 'greeting.dart': r''' +import 'package:celest/celest.dart'; +import 'package:celest/http.dart'; + +@cloud +@http(method: HttpMethod.post) +Stream greetings(List names) async* { + for (final name in names) { + yield 'Hello, $name!'; + } +} +''', + }, + errors: [ + 'Functions that return a stream may not customize their HTTP ' + 'configuration', + ], + ); + + testErrors( + name: 'http_error_config_streaming_return_type', + apis: { + 'greeting.dart': r''' +import 'package:celest/celest.dart'; +import 'package:celest/http.dart'; + +@cloud +@httpError(HttpStatus.unauthorized, Exception) +Stream greetings(List names) async* { + for (final name in names) { + yield 'Hello, $name!'; + } +} +''', + }, + errors: [ + 'Functions that return a stream may not customize their HTTP ' + 'configuration', + ], + ); + + testErrors( + name: 'http_header', + apis: { + 'greeting.dart': r''' +import 'package:celest/celest.dart'; +import 'package:celest/http.dart'; + +@cloud +Stream greetings({ + @httpHeader('x-custom-string') required String customString, +}) async* { + throw UnimplementedError(null); +} +''', + }, + errors: [ + 'HTTP headers may not be used in functions that return a stream', + ], + ); + + testNoErrors( + name: 'http_query', + apis: { + 'greeting.dart': r''' +import 'package:celest/celest.dart'; +import 'package:celest/http.dart'; + +@cloud +Stream greetings({ + @httpQuery('x-custom-string') required String customString, +}) async* { + throw UnimplementedError(null); +} +''', + }, + ); + + testErrors( + name: 'streaming_parameter_type', + apis: { + 'greeting.dart': r''' +import 'package:celest/celest.dart'; + +@cloud +Future> greetings(Stream names) async { + final greetings = []; + await for (final name in names) { + greetings.add('Hello, $name!'); + } + return greetings; +} +''', + }, + errors: ['Stream types are not supported'], + ); + }); + + group('context', () { + testNoErrors( + name: 'function_authenticated_context', + apis: { + 'greeting.dart': ''' +import 'package:celest/celest.dart'; + +@cloud +@authenticated +String sayHello({ + @principal required User user, +}) => 'Hello, World!'; +''', + }, + authDart: ''' +const auth = Auth( + providers: [AuthProvider.email()], +); +''', + expectProject: (project) { + check(project.apis['greeting']) + .isNotNull() + .has((it) => it.functions['sayHello'], 'function') + .isNotNull() + .has((it) => it.parameters.firstOrNull, 'parameter') + .isNotNull() + .has((it) => it.references, 'nodeReference') + .isNotNull() + .has((it) => it.type, 'type') + .equals(NodeType.userContext); + }, + ); + + testNoErrors( + name: 'function_public_context', + apis: { + 'greeting.dart': ''' +import 'package:celest/celest.dart'; + +@cloud +@public +String sayHello({ + @principal User? user, +}) => 'Hello, World!'; +''', + }, + authDart: ''' +const auth = Auth( + providers: [AuthProvider.email()], +); +''', + expectProject: (project) { + check(project.apis['greeting']) + .isNotNull() + .has((it) => it.functions['sayHello'], 'function') + .isNotNull() + .has((it) => it.parameters.firstOrNull, 'parameter') + .isNotNull() + .has((it) => it.references, 'nodeReference') + .isNotNull() + .has((it) => it.type, 'type') + .equals(NodeType.userContext); + }, + ); + + testNoErrors( + name: 'api_authenticated_context', + apis: { + 'greeting.dart': ''' +@authenticated +library; + +import 'package:celest/celest.dart'; + +@cloud +String sayHello({ + @principal required User user, +}) => 'Hello, World!'; +''', + }, + authDart: ''' +const auth = Auth( + providers: [AuthProvider.email()], +); +''', + expectProject: (project) { + check(project.apis['greeting']) + .isNotNull() + .has((it) => it.functions['sayHello'], 'function') + .isNotNull() + .has((it) => it.parameters.firstOrNull, 'parameter') + .isNotNull() + .has((it) => it.references, 'nodeReference') + .isNotNull() + .has((it) => it.type, 'type') + .equals(NodeType.userContext); + }, + ); + + testNoErrors( + name: 'api_public_context', + apis: { + 'greeting.dart': ''' +@public +library; + +import 'package:celest/celest.dart'; + +@cloud +String sayHello({ + @principal User? user, +}) => 'Hello, World!'; +''', + }, + authDart: ''' +const auth = Auth( + providers: [AuthProvider.email()], +); +''', + expectProject: (project) { + check(project.apis['greeting']) + .isNotNull() + .has((it) => it.functions['sayHello'], 'function') + .isNotNull() + .has((it) => it.parameters.firstOrNull, 'parameter') + .isNotNull() + .has((it) => it.references, 'nodeReference') + .isNotNull() + .has((it) => it.type, 'type') + .equals(NodeType.userContext); + }, + ); + }); + + group('env_vars', () { + testNoErrors( + name: 'good_envs', + config: { + '.env.local': ''' + MY_NAME=Celest + MY_AGE=28 + ''', + }, + apis: { + 'greeting.dart': r''' + import 'package:celest/celest.dart'; + + const myName = env('MY_NAME'); + const myAge = env('MY_AGE'); + + @cloud + void sayHelloPositional( + @myName String name, + @myAge int age, + ) => 'Hello, $name. I am $age years old.'; + + @cloud + void sayHelloNamed({ + @myName required String name, + @myAge required int age, + }) => 'Hello, $name. I am $age years old.'; + ''', + }, + expectProject: (project) { + expect( + project.variables.map((env) => env.name), + unorderedEquals(['MY_NAME', 'MY_AGE']), + ); + expect( + project + .apis['greeting']! + .functions['sayHelloPositional']! + .parameters + .map((param) => param.references), + unorderedEquals([ + NodeReference(name: 'MY_NAME', type: NodeType.variable), + NodeReference(name: 'MY_AGE', type: NodeType.variable), + ]), + ); + expect( + project.apis['greeting']!.functions['sayHelloNamed']!.parameters + .map((param) => param.references), + unorderedEquals([ + NodeReference(name: 'MY_NAME', type: NodeType.variable), + NodeReference(name: 'MY_AGE', type: NodeType.variable), + ]), + ); + }, + ); + + testErrors( + name: 'bad_parameter_type', + config: { + '.env.local': ''' + MY_NAME=Celest + ''', + }, + apis: { + 'greeting.dart': r''' + import 'package:celest/celest.dart'; + + @cloud + void sayHello(@env('MY_NAME') List name) => 'Hello, $name'; + ''', + }, + errors: [ + 'The type of an environment variable parameter must be one of', + ], + ); + + testErrors( + name: 'reserved_name', + config: { + '.env.local': ''' +PORT=8080 +''', + }, + apis: { + 'greeting.dart': r''' +import 'package:celest/celest.dart'; + +@cloud +void sayHello(@env('PORT') int port) => 'Hello, $port'; +''', + }, + errors: ['The environment variable name `PORT` is reserved by Celest'], + ); + + testErrors( + name: 'multiple_env_applications', + config: { + '.env.local': ''' +TEST=Hello +''', + }, + apis: { + 'greeting.dart': r''' +import 'package:celest/celest.dart'; + +@cloud +void sayHello( + @env('TEST') + @env('TEST') + int port, +) => 'Hello, $port'; +''', + }, + errors: ['Only one annotation may be specified on a parameter'], + ); + }); + + group('auth', () { + testNoErrors( + name: 'valid_inline_providers', + authDart: ''' +const auth = Auth( + providers: [ + AuthProvider.email(), + // AuthProvider.sms(), + ], +); +''', + expectProject: (project) { + check(project.auth) + .isNotNull() + .has((it) => it.providers.map((it) => it.type), 'providers') + .unorderedEquals([ + EmailAuthProvider.$type, + // SmsAuthProvider.$type, + ]); + }, + ); + + testNoErrors( + name: 'valid_referenced_provider', + authDart: ''' +const email = AuthProvider.email(); +const auth = Auth( + providers: [email], +); +''', + expectProject: (project) { + check(project.auth) + .isNotNull() + .has((it) => it.providers, 'providers') + .single + .has((it) => it.type, 'type') + .equals(EmailAuthProvider.$type); + }, + ); + + testErrors( + name: 'no_providers', + authDart: ''' +const auth = Auth( + providers: [], +); +''', + errors: ['At least one Auth provider must be specified'], + ); + + testErrors( + name: 'duplicate_provider', + authDart: ''' +const email = AuthProvider.email(); +// const sms = AuthProvider.sms(); +const auth = Auth( + providers: [ + email, email, + // sms, sms, + ], +); +''', + errors: [ + 'Duplicate emailOtp auth provider', + // 'Duplicate smsOtp auth provider', + ], + ); + + testNoErrors( + name: 'valid_external_provider', + authDart: ''' +const auth = Auth( + providers: [ + ExternalAuthProvider.firebase(), + ], +); +''', + expectProject: (project) { + check(project.auth).isNotNull() + ..has((it) => it.providers, 'providers').isEmpty() + ..has( + (it) => it.externalProviders.map((it) => it.type), + 'providers', + ).single.equals(FirebaseExternalAuthProvider.$type); + + // The default env variable is created. + check( + project.variables, + ).single.has((it) => it.name, 'name').equals('FIREBASE_PROJECT_ID'); + }, + ); + }); + }); +} diff --git a/apps/cli/test/codegen/allocator_test.dart b/apps/cli/test/codegen/allocator_test.dart new file mode 100644 index 000000000..9070c5784 --- /dev/null +++ b/apps/cli/test/codegen/allocator_test.dart @@ -0,0 +1,69 @@ +import 'package:celest_cli/codegen/allocator.dart'; +import 'package:code_builder/code_builder.dart'; +import 'package:test/test.dart'; + +void main() { + group('CelestAllocator', () { + group('Windows', testOn: 'windows', () { + // When the temp dir (generated outputs) is on a separate drive from the source project, + // ensure that paths are absolute and not relative since there is no way to express a + // relative path between drives. + test('separate drives', () { + final reference = refer( + 'sayHello', + r'D:\workspace\celest_example\celest\functions\greeting.dart', + ); + const generatingForPath = + r'C:\Users\celest\AppData\Local\Temp\af0ceaa9\functions\greeting\sayHello.dart'; + final allocator = CelestAllocator( + forFile: generatingForPath, + pathStrategy: PathStrategy.robust, + prefixingStrategy: PrefixingStrategy.pretty, + ); + final symbol = allocator.allocate(reference); + expect(symbol, r'_$greeting.sayHello'); + expect( + allocator.imports.single, + isA().having( + (d) => d.url, + 'url', + 'file:///D:/workspace/celest_example/celest/functions/greeting.dart', + ), + ); + }); + }); + + test('de-dups import prefixes', () async { + // Only applies in pretty mode. + const prefixingStrategy = PrefixingStrategy.pretty; + + // These should all get unique import prefixes. + final uris = [ + Uri.parse('package:package_1/a.dart'), + Uri.parse('package:package_2/a.dart'), + Uri.parse('package:package_3/a.dart'), + ]; + + final allocator = CelestAllocator( + forFile: '/test.dart', + pathStrategy: PathStrategy.pretty, + prefixingStrategy: prefixingStrategy, + packageName: 'celest_backend', + clientPackageName: 'test_client', + ); + for (final uri in uris) { + allocator.allocate(refer('A', uri.toString())); + } + + expect(allocator.imports, hasLength(3)); + expect( + allocator.importMap, + equals({ + 'package:package_1/a.dart': r'_$package_1_a', + 'package:package_2/a.dart': r'_$package_2_a', + 'package:package_3/a.dart': r'_$package_3_a', + }), + ); + }); + }); +} diff --git a/apps/cli/test/commands/uninstall_test.dart b/apps/cli/test/commands/uninstall_test.dart new file mode 100644 index 000000000..99b49857a --- /dev/null +++ b/apps/cli/test/commands/uninstall_test.dart @@ -0,0 +1,282 @@ +import 'dart:io'; + +import 'package:celest_cli/commands/uninstall/celest_uninstaller.dart'; +import 'package:celest_cli/src/context.dart' as ctx; +import 'package:celest_cli/src/context.dart'; +import 'package:file/memory.dart'; +import 'package:mocktail/mocktail.dart'; +import 'package:platform/platform.dart'; +import 'package:process/process.dart'; +import 'package:test/test.dart'; + +import '../common.dart'; + +final class MockProcessManager extends Mock implements ProcessManager {} + +final class MockProcess extends Mock implements Process {} + +final class MockPlatform extends Mock implements Platform {} + +void main() { + group('CelestUninstaller', () { + setUpAll(() { + registerFallbackValue(ProcessStartMode.normal); + }); + + setUp(() { + return initTests(processManager: MockProcessManager()); + }); + + test('removes local storage', () async { + ctx.fileSystem = MemoryFileSystem.test(); + await init(projectRoot: ctx.fileSystem.systemTempDirectory.path); + + await celestProject.config.settings.setOrganizationId('org-id'); + + expect(await celestProject.config.settings.getOrganizationId(), 'org-id'); + + await const CelestUninstaller().uninstall(); + + expect(await celestProject.config.settings.getOrganizationId(), isNull); + }); + + group('uninstall AOT', () { + test('windows', () async { + ctx.fileSystem = MemoryFileSystem.test(style: FileSystemStyle.windows); + + const appData = r'C:\Users\test\AppData\Local\Microsoft\WindowsApps'; + final installFolder = p.windows.join( + appData, + 'Celest.CLI_6580ymbmddxye', + ); + ctx.platform = FakePlatform( + operatingSystem: 'windows', + executable: p.windows.join(appData, 'celest.exe'), + script: Uri.file( + p.windows.join(appData, 'celest.exe'), + windows: true, + ), + resolvedExecutable: p.windows.join(installFolder, 'celest.exe'), + environment: {'APPDATA': ctx.fileSystem.systemTempDirectory.path}, + ); + + final configDir = ctx.fileSystem.systemTempDirectory.childDirectory( + 'Celest', + ); + configDir.createSync(recursive: true); + + ctx.fileSystem + .directory(r'C:\') + .childDirectory('Users') + .childDirectory('test') + .childDirectory('AppData') + .childDirectory('Local') + .childDirectory('Microsoft') + .childDirectory('WindowsApps') + .createSync(recursive: true); + + await init(projectRoot: ctx.fileSystem.systemTempDirectory.path); + + expect( + p.windows.equals(configDir.path, celestProject.config.configDir.path), + isTrue, + reason: 'Setting APPDATA should point the config dir here', + ); + + when( + () => ctx.processManager.run( + [ + 'powershell', + '-Command', + r'Get-AppxPackage -Name "Celest.CLI" | Remove-AppxPackage -Confirm:$false', + ], + stdoutEncoding: any(named: 'stdoutEncoding'), + stderrEncoding: any(named: 'stderrEncoding'), + ), + ).thenAnswer((_) async => ProcessResult(0, 0, '', '')); + + expect(configDir.existsSync(), isTrue); + + await const CelestUninstaller().uninstall(); + + expect(configDir.existsSync(), isFalse); + + verify( + () => ctx.processManager.run( + [ + 'powershell', + '-Command', + r'Get-AppxPackage -Name "Celest.CLI" | Remove-AppxPackage -Confirm:$false', + ], + stdoutEncoding: any(named: 'stdoutEncoding'), + stderrEncoding: any(named: 'stderrEncoding'), + ), + ).called(1); + }); + + test('macos', () async { + ctx.fileSystem = MemoryFileSystem.test(style: FileSystemStyle.posix); + final configDir = ctx.fileSystem.systemTempDirectory + .childDirectory('Library') + .childDirectory('Application Support') + .childDirectory('Celest'); + configDir.createSync(recursive: true); + ctx.fileSystem + .file('/opt/celest/celest.app/Contents/MacOS/celest') + .createSync(recursive: true); + ctx.fileSystem.file(CelestUninstaller.macosEntrypoint) + ..createSync(recursive: true) + ..writeAsStringSync(r''' +#!/bin/bash + +/opt/celest/celest.app/Contents/MacOS/celest $@ +'''); + ctx.platform = FakePlatform( + operatingSystem: 'macos', + executable: 'celest', + script: Uri.file( + '/opt/celest/celest.app/Contents/MacOS/celest', + windows: false, + ), + resolvedExecutable: '/opt/celest/celest.app/Contents/MacOS/celest', + environment: {'HOME': ctx.fileSystem.systemTempDirectory.path}, + ); + + await init(projectRoot: ctx.fileSystem.systemTempDirectory.path); + + const uninstallScript = + "[[ -d '/opt/celest' ]] && rm -r '/opt/celest'; " + "[[ -h '/usr/local/bin/celest' || -f '/usr/local/bin/celest' ]] && rm '/usr/local/bin/celest'"; + when( + () => ctx.processManager.run( + [ + 'osascript', + '-e', + 'do shell script "$uninstallScript" ' + 'with prompt "Celest needs your permission to uninstall" ' + 'with administrator privileges', + ], + stdoutEncoding: any(named: 'stdoutEncoding'), + stderrEncoding: any(named: 'stderrEncoding'), + ), + ).thenAnswer((_) async => ProcessResult(0, 0, '', '')); + + expect(configDir.existsSync(), isTrue); + + await const CelestUninstaller().uninstall(); + + expect(configDir.existsSync(), isFalse); + + verify( + () => ctx.processManager.run( + [ + 'osascript', + '-e', + 'do shell script "$uninstallScript" ' + 'with prompt "Celest needs your permission to uninstall" ' + 'with administrator privileges', + ], + stdoutEncoding: any(named: 'stdoutEncoding'), + stderrEncoding: any(named: 'stderrEncoding'), + ), + ).called(1); + }); + + group('linux', () { + test('deb installation', () async { + ctx.fileSystem = MemoryFileSystem.test(style: FileSystemStyle.posix); + final configDir = ctx.fileSystem.systemTempDirectory + .childDirectory('.config') + .childDirectory('Celest'); + configDir.createSync(recursive: true); + ctx.platform = FakePlatform( + operatingSystem: 'linux', + executable: 'celest', + script: Uri.file('/opt/celest/celest', windows: false), + resolvedExecutable: '/opt/celest/celest', + environment: {'HOME': ctx.fileSystem.systemTempDirectory.path}, + ); + + await init(projectRoot: ctx.fileSystem.systemTempDirectory.path); + + when( + () => ctx.processManager.run( + ['dpkg', '-S', '/opt/celest/celest'], + stdoutEncoding: any(named: 'stdoutEncoding'), + stderrEncoding: any(named: 'stderrEncoding'), + ), + ).thenAnswer( + (_) async => ProcessResult(0, 0, 'celest: /opt/celest/celest', ''), + ); + + final purgeProcess = MockProcess(); + when( + () => ctx.processManager.start([ + 'sudo', + 'dpkg', + '--purge', + 'celest', + ], mode: any(named: 'mode')), + ).thenAnswer((_) async => purgeProcess); + when(() => purgeProcess.exitCode).thenAnswer((_) async => 0); + + expect(configDir.existsSync(), isTrue); + + await const CelestUninstaller().uninstall(); + + expect(configDir.existsSync(), isFalse); + + verify( + () => ctx.processManager.start([ + 'sudo', + 'dpkg', + '--purge', + 'celest', + ], mode: any(named: 'mode')), + ).called(1); + verify(() => purgeProcess.exitCode).called(1); + }); + + test('zip installation', () async { + ctx.fileSystem = MemoryFileSystem.test(style: FileSystemStyle.posix); + final configDir = ctx.fileSystem.systemTempDirectory + .childDirectory('.config') + .childDirectory('Celest'); + configDir.createSync(recursive: true); + ctx.platform = FakePlatform( + operatingSystem: 'linux', + executable: 'celest', + script: Uri.file('/opt/celest/celest', windows: false), + resolvedExecutable: '/opt/celest/celest', + environment: {'HOME': ctx.fileSystem.systemTempDirectory.path}, + ); + + await init(projectRoot: ctx.fileSystem.systemTempDirectory.path); + + when( + () => ctx.processManager.run( + ['dpkg', '-S', '/opt/celest/celest'], + stdoutEncoding: any(named: 'stdoutEncoding'), + stderrEncoding: any(named: 'stderrEncoding'), + ), + ).thenAnswer((_) async => ProcessResult(0, 1, '', '')); + + expect(configDir.existsSync(), isTrue); + + await const CelestUninstaller().uninstall(); + + expect(configDir.existsSync(), isFalse); + + verifyNever( + () => ctx.processManager.start([ + 'sudo', + 'dpkg', + '--purge', + 'celest', + ], mode: any(named: 'mode')), + ); + }); + }); + }); + }); +} diff --git a/apps/cli/test/common.dart b/apps/cli/test/common.dart new file mode 100644 index 000000000..5e270d4a6 --- /dev/null +++ b/apps/cli/test/common.dart @@ -0,0 +1,44 @@ +import 'dart:io' as io; + +import 'package:celest_cli/src/cli.dart'; +import 'package:celest_cli/src/context.dart'; +import 'package:celest_cli/src/storage/storage.dart'; +import 'package:drift/drift.dart'; +import 'package:file/file.dart'; +import 'package:http/http.dart' as http; +import 'package:logging/logging.dart'; +import 'package:platform/platform.dart'; +import 'package:process/process.dart'; + +Future initTests({ + FileSystem? fileSystem, + http.Client? httpClient, + Platform? platform, + ProcessManager? processManager, +}) async { + if (kCelestTest) { + return; + } + driftRuntimeOptions.dontWarnAboutMultipleDatabases = true; + kCelestTest = true; + celestLocalPath = + io.Directory.current.uri.resolve('../../celest').toFilePath(); + Logger.root.level = Level.ALL; + Logger.root.onRecord.listen((record) { + print('[${record.loggerName}] ${record.level.name}: ${record.message}'); + if (record.error != null) { + print(record.error); + } + if (record.stackTrace != null) { + print(record.stackTrace); + } + }); + await Cli.configure( + verbose: true, + fileSystem: fileSystem, + platform: platform, + httpClient: httpClient, + processManager: processManager, + storage: Storage.memory(), + ); +} diff --git a/apps/cli/test/config/celest_config_test.dart b/apps/cli/test/config/celest_config_test.dart new file mode 100644 index 000000000..117c0b9c9 --- /dev/null +++ b/apps/cli/test/config/celest_config_test.dart @@ -0,0 +1,29 @@ +import 'package:celest_cli/src/context.dart' as ctx; +import 'package:celest_cli/src/context.dart'; +import 'package:file/memory.dart'; +import 'package:test/test.dart'; + +import '../common.dart'; + +void main() { + group('CelestConfig', () { + setUp(initTests); + + test('migrates to local storage', () async { + ctx.fileSystem = MemoryFileSystem.test(); + final configHome = ctx.fileSystem.systemTempDirectory.childDirectory( + 'config', + )..createSync(recursive: true); + + final configJson = configHome.childFile('config.json'); + configJson.writeAsStringSync('{"organization_id": "org-id"}'); + await init( + projectRoot: ctx.fileSystem.systemTempDirectory.path, + configHome: configHome.path, + ); + + expect(await celestProject.config.settings.getOrganizationId(), 'org-id'); + expect(await configJson.exists(), isFalse); + }); + }); +} diff --git a/apps/cli/test/e2e/common/command.dart b/apps/cli/test/e2e/common/command.dart new file mode 100644 index 000000000..ceb6a662f --- /dev/null +++ b/apps/cli/test/e2e/common/command.dart @@ -0,0 +1,307 @@ +import 'dart:async'; +import 'dart:convert'; +import 'dart:io'; + +import 'package:async/async.dart'; +import 'package:celest_cli/src/context.dart'; +import 'package:celest_cli/src/logging/log_message.dart'; +import 'package:checks/checks.dart'; +import 'package:logging/logging.dart'; +import 'package:mason_logger/mason_logger.dart' show red; +import 'package:stack_trace/stack_trace.dart'; +import 'package:test/test.dart'; + +import 'common.dart'; + +final class Command { + Command(this.command); + + final List command; + + String? _workingDirectory; + final Map _environment = Map.of(defaultCliEnvironment); + Matcher? _expectedExitCode; + Matcher? _expectedError; + bool _usePublishedRuntime = false; + + Future run() async { + final result = await Process.run( + command.first, + command.skip(1).toList(), + workingDirectory: _workingDirectory, + environment: {...platform.environment, ..._environment}, + runInShell: platform.isWindows, + stdoutEncoding: utf8, + stderrEncoding: utf8, + ); + if (_expectedExitCode != null) { + expect(result.exitCode, _expectedExitCode); + } + if (_expectedError != null) { + expect(result.stderr, _expectedError); + } + } + + InteractiveCommand start() { + final environment = {...platform.environment, ..._environment}; + if (_usePublishedRuntime) { + environment.remove('CELEST_LOCAL_PATH'); + } + final process = Process.start( + command.first, + command.skip(1).toList(), + workingDirectory: _workingDirectory, + environment: environment, + includeParentEnvironment: false, + ); + return InteractiveCommand._(process); + } + + Command workingDirectory(String path) { + _workingDirectory = path; + return this; + } + + Command environment(Map env) { + _environment.addAll(env); + return this; + } + + Command withPublishedRuntime() { + _usePublishedRuntime = true; + return this; + } + + Future expectSuccess() { + if (_expectedExitCode != null) { + throw Exception('Cannot expect both success and failure'); + } + _expectedExitCode = equals(0); + return run(); + } + + Future expectFailure([String? error]) { + if (_expectedExitCode != null) { + throw Exception('Cannot expect both success and failure'); + } + _expectedExitCode = greaterThanOrEqualTo(1); + if (error != null) { + _expectedError = contains(error); + } + return run(); + } +} + +extension FlatMap on Stream { + Stream flatMap(S? Function(T) mapper) => transform( + StreamTransformer.fromHandlers( + handleData: (value, sink) { + if (mapper(value) case final value?) { + sink.add(value); + } + }, + ), + ); +} + +final _logger = Logger('InteractiveCommand'); +Never _fail(String method, Object e, StackTrace st) => fail('$e\n$st'); +void _error(String message) { + final output = ansiColorsEnabled ? red.wrap(message) ?? message : message; + stderr.writeln(output); +} + +extension on Future { + Future trace(String methodName, [Duration? timeout]) { + final fut = Chain.capture(() => this, errorZone: false) + .then((_) => _logger.fine('$methodName completed')) + .onError( + (e, st) => + _fail(methodName, e, Chain([Trace.from(st), Trace.current()])), + ); + if (timeout != null) { + return fut.timeout( + timeout, + onTimeout: + () => _fail( + '$methodName Timed out', + TimeoutException(null, timeout), + Chain.current(), + ), + ); + } + return fut; + } +} + +extension on Subject> { + Future contains(String text) => this.completes( + (it) => it.has((log) => log.message, 'message').contains(text), + ); +} + +final class InteractiveCommand { + InteractiveCommand._(Future process) { + process = process + .then((process) { + _process = process; + process.stderr + .transform(utf8.decoder) + .transform(const LineSplitter()) + .forEach(_error); + process.exitCode.then((exitCode) { + if (_pendingTasks != null) { + _fail( + 'start', + 'Command exited with code $exitCode while tasks were pending', + StackTrace.current, + ); + } + }); + return process; + }) + .onError((e, st) => _fail('start', e, st)); + _logs = StreamQueue( + Stream.fromFuture(process).asyncExpand( + (process) => process.stdout + .transform(utf8.decoder) + .transform(const LineSplitter()) + .where((line) => line.isNotEmpty) + .map((line) { + print(line); + try { + return jsonDecode(line) as Map; + } on FormatException { + _error('Failed to parse log message: $line'); + rethrow; + } + }) + .map(LogMessage.fromJson) + .where( + (log) => switch (log) { + LogMessageProgress(:final progress) => + // Ignore cancel messages since they will double count + // expectLater/expectNext + progress != ProgressAction.cancel, + _ => true, + }, + ), + ), + ); + } + + late final Process _process; + late final StreamQueue _logs; + + Future? _pendingTasks; + Future get _currentTasks => _pendingTasks ?? Future.value(); + Future flush() { + final pendingTasks = _currentTasks; + _pendingTasks = null; + return pendingTasks; + } + + InteractiveCommand _addTask( + String methodName, + FutureOr Function() task, { + Duration? timeout, + }) { + _pendingTasks = _currentTasks.then((_) { + _logger.fine('$methodName started'); + return Future.value(task()).trace(methodName, timeout); + }); + return this; + } + + static const _defaultTimeout = Duration(minutes: 3); + + InteractiveCommand writeLine(String line) { + return _addTask('writeLine($line)', () => _process.stdin.writeln(line)); + } + + InteractiveCommand expectNext( + String text, { + Duration timeout = _defaultTimeout, + }) { + return _addTask( + 'expectNext($text)', + timeout: timeout, + () => check(_logs.next).contains(text), + ); + } + + InteractiveCommand expectLater( + String text, { + Duration timeout = _defaultTimeout, + }) { + skipWhere('not contains($text)', (line) { + _logger.fine('Testing "$line" does not contain "$text"'); + return !line.contains(text); + }, timeout: timeout); + return expectNext(text, timeout: timeout); + } + + InteractiveCommand skip({int lines = 1, Duration timeout = _defaultTimeout}) { + return _addTask('skip', timeout: timeout, () => _logs.take(lines)); + } + + InteractiveCommand skipWhere( + String description, + bool Function(String) test, { + Duration timeout = _defaultTimeout, + }) { + final label = 'skipWhere $description'; + return _addTask(label, timeout: timeout, () async { + await _logs.withTransaction((logs) async { + while (await logs.hasNext) { + _logger.fine('$label: Waiting for next line'); + final log = await logs.peek; + final message = log.message; + _logger.fine('$label: Got message: $message'); + if (test(message)) { + _logger.fine('$label: Skipping line: "$log"'); + await logs.next; + continue; + } + _logger.fine('$label: Found matching line: "$log"'); + return true; + } + fail('$label: Process closed without matching'); + }); + }); + } + + InteractiveCommand hotReload() { + // SIGUSR1 is not supported on Windows. + if (platform.isWindows) { + return this; + } + return _addTask( + 'hotReload', + () => check(_process.kill(ProcessSignal.sigusr1)).isTrue(), + ); + } + + Future run() async { + _logger.fine('Running to completion'); + await flush().trace('run').whenComplete(() { + _logger.fine('Killing process and draining logs'); + _process.kill(); + return _logs.rest.drain(); + }); + await _process.exitCode; + _logger.fine('Flushing test logs'); + await [stdout.flush(), stderr.flush()].wait; + } + + Future expectSuccess() async { + try { + await flush().trace('expectSuccess'); + await check(_process.exitCode).completes((it) => it.equals(0)); + } finally { + _process.kill(); + await _logs.cancel(); + await [stdout.flush(), stderr.flush()].wait; + } + } +} diff --git a/apps/cli/test/e2e/common/common.dart b/apps/cli/test/e2e/common/common.dart new file mode 100644 index 000000000..285dca911 --- /dev/null +++ b/apps/cli/test/e2e/common/common.dart @@ -0,0 +1,136 @@ +import 'dart:io' show Process, Platform, ProcessException; +import 'dart:math'; + +import 'package:celest_cli/src/context.dart'; +import 'package:celest_cli/src/utils/cli.dart'; +import 'package:celest_cli/src/utils/recase.dart'; +import 'package:file/file.dart'; +import 'package:meta/meta.dart'; +import 'package:process/src/interface/common.dart'; + +import 'command.dart'; + +export 'command.dart'; + +/// The default environment to use when running CLI processes. +final defaultCliEnvironment = {...platform.environment, 'NO_COLOR': 'true'}; + +abstract base class TestTarget with TestHelpers { + @override + TestTarget get target => this; + + List get tags => const []; + + @override + File? get logFile => null; + + String get name; + List get executable; + Map get environment => const {}; + Future setUpAll() async {} + Future tearDownAll() async {} +} + +abstract base class E2ETest with TestHelpers { + E2ETest(this.target); + + @override + final TestTarget target; + + @override + File get logFile => tempDir.childFile('${name.snakeCase}.log')..createSync(); + + @override + void log(Object? object) { + final terminator = Platform.lineTerminator; + print(object); + logFile.writeAsStringSync( + '$terminator$object$terminator', + mode: FileMode.append, + ); + } + + List get tags => const []; + + static final Random _random = Random(); + final projectName = 'test_project_${_random.nextInt(1 << 20)}'; + + @mustCallSuper + Future setUp() async {} + + @mustCallSuper + Future tearDown() async {} + + String get name; + Future run(); +} + +mixin TestHelpers { + final tempDir = fileSystem.systemTempDirectory.createTempSync('celest_cli_'); + + TestTarget get target; + bool get skip => false; + File? get logFile; + + void log(Object? object) => print(object); + + bool get hasFlutter { + return getExecutablePath('flutter', null) != null; + } + + Future runCommand( + List command, { + String? workingDirectory, + Map? environment, + bool? runInShell, + }) async { + log( + 'Running command: "${command.join(' ')}" in ' + '"${workingDirectory ?? fileSystem.currentDirectory.path}"', + ); + final process = await Process.start( + command.first, + command.skip(1).toList(), + workingDirectory: workingDirectory, + environment: { + ...platform.environment, + ...defaultCliEnvironment, + ...?environment, + }, + runInShell: runInShell ?? platform.isWindows, + ); + process.captureStdout(sink: log); + process.captureStderr(sink: log); + if (await process.exitCode case final exitCode && != 0) { + throw ProcessException( + command.first, + command.skip(1).toList(), + 'Command failed', + exitCode, + ); + } + } + + Future celest( + String command, { + List args = const [], + String? workingDirectory, + Map? environment, + }) => runCommand( + [...target.executable, command, '--json', ...args], + workingDirectory: workingDirectory, + environment: { + if (logFile case final logFile?) 'CELEST_LOG_FILE': logFile.path, + ...defaultCliEnvironment, + ...target.environment, + ...?environment, + }, + ); + + Command celestCommand(String command, [List args = const []]) => + Command([...target.executable, command, '--json', ...args]).environment({ + if (logFile case final logFile?) 'CELEST_LOG_FILE': logFile.path, + ...defaultCliEnvironment, + ...target.environment, + }); +} diff --git a/apps/cli/test/e2e/common/test_projects.dart b/apps/cli/test/e2e/common/test_projects.dart new file mode 100644 index 000000000..f0e2cfe33 --- /dev/null +++ b/apps/cli/test/e2e/common/test_projects.dart @@ -0,0 +1,47 @@ +import 'package:celest_cli/src/context.dart'; +import 'package:file/file.dart'; +import 'package:meta/meta.dart'; + +import 'common.dart'; + +base mixin TestFlutterProject on E2ETest { + late final Directory projectDir; + Directory get celestDir => projectDir.childDirectory('celest'); + + @override + bool get skip => !hasFlutter; + + @override + @mustCallSuper + Future setUp() async { + await super.setUp(); + projectDir = fileSystem.directory(p.join(tempDir.path, projectName)); + await projectDir.create(recursive: true); + await runCommand([ + 'flutter', + 'create', + '.', + ], workingDirectory: projectDir.path); + print('Running test in ${projectDir.path}'); + } +} + +base mixin TestDartProject on E2ETest { + late final Directory projectDir; + Directory get celestDir => projectDir.childDirectory('celest'); + + @override + @mustCallSuper + Future setUp() async { + await super.setUp(); + projectDir = fileSystem.directory(p.join(tempDir.path, projectName)); + await projectDir.create(recursive: true); + await runCommand([ + 'dart', + 'create', + '--force', + '.', + ], workingDirectory: projectDir.path); + print('Running test in ${projectDir.path}'); + } +} diff --git a/apps/cli/test/e2e/e2e_test.dart b/apps/cli/test/e2e/e2e_test.dart new file mode 100644 index 000000000..a5866f878 --- /dev/null +++ b/apps/cli/test/e2e/e2e_test.dart @@ -0,0 +1,69 @@ +// ignore_for_file: unused_import, flutter_style_todos + +import 'package:celest_cli/src/context.dart'; +import 'package:test/test.dart'; + +import '../common.dart'; +import 'common/common.dart'; +import 'features/bugs/add_remove_fields.dart'; +import 'features/create/create_project_in_dart_app.dart'; +import 'features/create/create_project_in_dart_app_no_deps.dart'; +import 'features/create/create_project_in_flutter_app.dart'; +import 'features/create/create_project_isolated.dart'; +import 'features/hello_project.dart'; +import 'features/hot_reload/hot_reload_add_auth.dart'; +import 'features/hot_reload/hot_reload_add_model_after_error.dart'; +import 'features/package_support/supports_supabase.dart'; +import 'targets/installed_target.dart'; +import 'targets/local_target.dart'; + +void main() { + final targets = [LocalTarget(), InstalledTarget()]; + + final tests = [ + // Example projects + HelloProjectTest.new, + + // Project creation + CreateProjectInFlutterAppTest.new, + CreateProjectInDartAppTest.new, + CreateProjectInDartAppNoDepsTest.new, + CreateProjectIsolatedTest.new, + + // Hot reload + AddRemoveFieldsTest.new, + HotReloadAddAuthTest.new, + HotReloadNonExistentModel.new, + + // Package support + SupportsSupabase.new, + ]; + + for (final target in targets) { + group(target.name, tags: ['e2e', ...target.tags], () { + setUpAll(() async { + await initTests(); + await target.setUpAll(); + addTearDown(target.tearDownAll); + }); + + for (final t in tests.map((create) => create(target))) { + test(t.name, tags: t.tags, skip: t.skip, () async { + try { + await t.setUp(); + await t.run(); + } on Object { + print('LOGS'); + print('--------------------------------'); + print(t.logFile.readAsStringSync()); + print('--------------------------------'); + print('Full logs written to: ${t.logFile.path}'); + rethrow; + } finally { + await t.tearDown(); + } + }); + } + }); + } +} diff --git a/apps/cli/test/e2e/features/bugs/add_remove_fields.dart b/apps/cli/test/e2e/features/bugs/add_remove_fields.dart new file mode 100644 index 000000000..9853c4fbc --- /dev/null +++ b/apps/cli/test/e2e/features/bugs/add_remove_fields.dart @@ -0,0 +1,134 @@ +import 'package:celest_cli/src/context.dart'; + +import '../../common/common.dart'; +import '../../common/test_projects.dart'; + +// Repro: https://github.com/celest-dev/celest/issues/25 +final class AddRemoveFieldsTest extends E2ETest with TestDartProject { + AddRemoveFieldsTest(super.target); + + @override + String get name => 'add/remove fields in model'; + + @override + List get tags => ['add_remove_fields']; + + // TODO(dnys1): Get watcher working on Windows so that SIGUSR1 is not + // needed. + @override + bool get skip => platform.isWindows; + + @override + Future run() async { + final celest = celestCommand('start') + .workingDirectory(projectDir.path) + .start() + .expectNext('Enter a name for your project') + .writeLine(projectName); + log('Waiting for initial start'); + await celest + .expectLater('Starting Celest') + .expectNext('Celest is running') + .flush(); + final functionFile = + await celestDir + .childDirectory('functions') + .childFile('location.dart') + .create(); + final modelsDir = projectDir + .childDirectory('celest') + .childDirectory('lib') + .childDirectory('models'); + + final locationFile = await modelsDir + .childFile('location.dart') + .create(recursive: true); + + // Create location function + log('Creating location function'); + await functionFile.writeAsString(''' +import 'package:celest_backend/models/location.dart'; + +Future getLocation(String name) async { + return Location(name: name); +} +'''); + await celest + .hotReload() + .expectLater('Reloading Celest') + .expectNext('Project has errors') + .flush(); + + log('Creating location model'); + await locationFile.writeAsString(''' +class Location { + Location({required this.name}); + final String name; +} +'''); + await celest + .hotReload() + .expectLater('Reloading Celest') + .expectNext('Celest is running') + .flush(); + + // Add GPS field to location + log('Adding GPS field to location'); + await locationFile.writeAsString(''' +typedef GPS = ({double latitude, double longitude}); + +class Location { + Location({required this.name, required this.gps}); + final String name; + GPS gps; +} +'''); + await celest + .hotReload() + .expectLater('Reloading Celest') + .expectNext('Project has errors') + .flush(); + + log('Fixing location function'); + await functionFile.writeAsString(''' +import 'package:celest_backend/models/location.dart'; + +Future getLocation(String name) async { + return Location(name: name, gps: (latitude: 0.0, longitude: 0.0)); +} +'''); + await celest + .hotReload() + .expectLater('Reloading Celest') + .expectNext('Celest is running') + .flush(); + + // Remove GPS field + log('Removing GPS field'); + await locationFile.writeAsString(''' +class Location { + Location({required this.name}); + final String name; +} +'''); + await celest + .hotReload() + .expectLater('Reloading Celest') + .expectNext('Project has errors') + .flush(); + + log('Fixing location function'); + await functionFile.writeAsString(''' +import 'package:celest_backend/models/location.dart'; + +Future getLocation(String name) async { + return Location(name: name); +} +'''); + await celest + .hotReload() + .expectLater('Reloading Celest') + .expectNext('Celest is running') + .run(); + } +} diff --git a/apps/cli/test/e2e/features/create/create_project_in_dart_app.dart b/apps/cli/test/e2e/features/create/create_project_in_dart_app.dart new file mode 100644 index 000000000..07752a33d --- /dev/null +++ b/apps/cli/test/e2e/features/create/create_project_in_dart_app.dart @@ -0,0 +1,22 @@ +import '../../common/common.dart'; +import '../../common/test_projects.dart'; + +final class CreateProjectInDartAppTest extends E2ETest with TestDartProject { + CreateProjectInDartAppTest(super.target); + + @override + String get name => 'start (w/ Dart parent)'; + @override + Future run() async { + await celestCommand('start') + .workingDirectory(projectDir.path) + .start() + .expectNext('Enter a name for your project') + .writeLine(projectName) + .expectLater('Generating project') + .expectLater('Project generated successfully') + .expectLater('Starting Celest') + .expectNext('Celest is running') + .run(); + } +} diff --git a/apps/cli/test/e2e/features/create/create_project_in_dart_app_no_deps.dart b/apps/cli/test/e2e/features/create/create_project_in_dart_app_no_deps.dart new file mode 100644 index 000000000..255363c3f --- /dev/null +++ b/apps/cli/test/e2e/features/create/create_project_in_dart_app_no_deps.dart @@ -0,0 +1,46 @@ +import 'dart:io'; + +import 'package:celest_cli/pub/pub_environment.dart'; +import 'package:celest_cli/src/context.dart'; +import 'package:checks/checks.dart'; +import 'package:test_descriptor/test_descriptor.dart' as d; + +import '../../common/common.dart'; + +final class CreateProjectInDartAppNoDepsTest extends E2ETest { + CreateProjectInDartAppNoDepsTest(super.target); + + @override + String get name => 'start (w/ Dart parent)'; + @override + Future run() async { + final dartProject = d.dir(projectName, [ + d.file('pubspec.yaml', ''' +name: hello_project + +environment: + sdk: ${PubEnvironment.dartSdkConstraint} +'''), + ]); + await dartProject.create(tempDir.path); + final projectDir = fileSystem.directory(p.join(tempDir.path, projectName)); + await check( + Process.run( + 'dart', + ['pub', 'get'], + runInShell: platform.isWindows, + workingDirectory: projectDir.path, + ), + ).completes((it) => it.has((it) => it.exitCode, 'exitCode').equals(0)); + await celestCommand('start') + .workingDirectory(projectDir.path) + .start() + .expectNext('Enter a name for your project') + .writeLine(projectName) + .expectLater('Generating project') + .expectLater('Project generated successfully') + .expectLater('Starting Celest') + .expectNext('Celest is running') + .run(); + } +} diff --git a/apps/cli/test/e2e/features/create/create_project_in_flutter_app.dart b/apps/cli/test/e2e/features/create/create_project_in_flutter_app.dart new file mode 100644 index 000000000..af6f75451 --- /dev/null +++ b/apps/cli/test/e2e/features/create/create_project_in_flutter_app.dart @@ -0,0 +1,24 @@ +import '../../common/common.dart'; +import '../../common/test_projects.dart'; + +final class CreateProjectInFlutterAppTest extends E2ETest + with TestFlutterProject { + CreateProjectInFlutterAppTest(super.target); + + @override + String get name => 'start (w/ Flutter parent)'; + + @override + Future run() async { + await celestCommand('start') + .workingDirectory(projectDir.path) + .start() + .expectNext('Enter a name for your project') + .writeLine(projectName) + .expectLater('Generating project') + .expectLater('Project generated successfully') + .expectLater('Starting Celest') + .expectNext('Celest is running') + .run(); + } +} diff --git a/apps/cli/test/e2e/features/create/create_project_isolated.dart b/apps/cli/test/e2e/features/create/create_project_isolated.dart new file mode 100644 index 000000000..cb4db2644 --- /dev/null +++ b/apps/cli/test/e2e/features/create/create_project_isolated.dart @@ -0,0 +1,53 @@ +import 'package:checks/checks.dart'; + +import '../../common/common.dart'; + +final class CreateProjectIsolatedTest extends E2ETest { + CreateProjectIsolatedTest(super.target); + + @override + String get name => 'start (w/ no parent)'; + + @override + Future run() async { + { + final celest = celestCommand('start') + .workingDirectory(tempDir.path) + .start() + .expectNext('Would you like to create one?') + .writeLine('y') + .expectNext('Enter a name for your project') + .writeLine(projectName) + .expectLater('Generating project') + .expectLater('Project generated successfully') + .expectLater('Starting Celest') + .expectNext('Celest is running'); + await celest.run(); + + check( + tempDir + .childDirectory(projectName) + .childFile('pubspec.yaml') + .existsSync(), + ).isTrue(); + } + + { + final emptyDir = await tempDir.createTemp('empty'); + final celest = celestCommand('start') + .workingDirectory(emptyDir.path) + .start() + .expectNext('Would you like to create one?') + .writeLine('y') + .expectNext('Enter a name for your project') + .writeLine(projectName) + .expectLater('Generating project') + .expectLater('Project generated successfully') + .expectLater('Starting Celest') + .expectNext('Celest is running'); + await celest.run(); + + check(emptyDir.childFile('pubspec.yaml').existsSync()).isTrue(); + } + } +} diff --git a/apps/cli/test/e2e/features/hello_project.dart b/apps/cli/test/e2e/features/hello_project.dart new file mode 100644 index 000000000..74612d6cd --- /dev/null +++ b/apps/cli/test/e2e/features/hello_project.dart @@ -0,0 +1,34 @@ +import 'dart:io'; + +import '../common/common.dart'; + +final class HelloProjectTest extends E2ETest { + HelloProjectTest(super.target); + + @override + String get name => 'start (hello project)'; + + @override + bool get skip => !hasFlutter; + + @override + Future run() async { + final helloExample = + Directory.current.uri + .resolve('../../celest/packages/celest/example') + .toFilePath(); + await celestCommand('start') + .workingDirectory(helloExample) + .start() + .expectLater('Starting Celest') + .expectNext('Celest is running') + .run(); + print('Resetting git repo'); + await runCommand([ + 'git', + 'reset', + '--hard', + 'HEAD', + ], workingDirectory: helloExample); + } +} diff --git a/apps/cli/test/e2e/features/hot_reload/hot_reload_add_auth.dart b/apps/cli/test/e2e/features/hot_reload/hot_reload_add_auth.dart new file mode 100644 index 000000000..4080285ea --- /dev/null +++ b/apps/cli/test/e2e/features/hot_reload/hot_reload_add_auth.dart @@ -0,0 +1,44 @@ +import 'package:celest_cli/src/context.dart'; + +import '../../common/common.dart'; +import '../../common/test_projects.dart'; + +final class HotReloadAddAuthTest extends E2ETest with TestDartProject { + HotReloadAddAuthTest(super.target); + + @override + String get name => 'hot reload (add auth)'; + + // TODO(dnys1): Get watcher working on Windows so that SIGUSR1 is not + // needed. + @override + bool get skip => platform.isWindows; + + @override + Future run() async { + final celest = celestCommand('start') + .workingDirectory(projectDir.path) + .start() + .expectNext('Enter a name for your project') + .writeLine(projectName) + .expectLater('Celest is running'); + await celest.flush(); + + log('Adding auth'); + await celestDir.childFile('auth.dart').writeAsString(''' +import 'package:celest/celest.dart'; + +const auth = Auth( + providers: [ + AuthProvider.email(), + ], +); +'''); + + await celest + .hotReload() + .expectLater('Reloading Celest') + .expectLater('Celest is running') + .run(); + } +} diff --git a/apps/cli/test/e2e/features/hot_reload/hot_reload_add_model_after_error.dart b/apps/cli/test/e2e/features/hot_reload/hot_reload_add_model_after_error.dart new file mode 100644 index 000000000..df58a8136 --- /dev/null +++ b/apps/cli/test/e2e/features/hot_reload/hot_reload_add_model_after_error.dart @@ -0,0 +1,69 @@ +import 'package:celest_cli/src/context.dart'; + +import '../../common/common.dart'; +import '../../common/test_projects.dart'; + +// Tests that saving a file with an error and then fixing the error correctly +// reloads the project. +final class HotReloadNonExistentModel extends E2ETest with TestDartProject { + HotReloadNonExistentModel(super.target); + + @override + String get name => 'hot reload (add auth)'; + + // TODO(dnys1): Get watcher working on Windows so that SIGUSR1 is not + // needed. + @override + bool get skip => platform.isWindows; + + @override + Future run() async { + final celest = celestCommand('start') + .workingDirectory(projectDir.path) + .start() + .expectNext('Enter a name for your project') + .writeLine(projectName) + .expectLater('Celest is running'); + await celest.flush(); + + log('Creating API with non-existent model'); + final api = celestDir.childDirectory('functions').childFile('test.dart'); + await api.writeAsString(''' +import 'package:celest/celest.dart'; + +@cloud +Future createModel() async { + return Model(); +} +'''); + + await celest.hotReload().expectLater('Project has errors').flush(); + + log('Adding model'); + final model = celestDir + .childDirectory('lib') + .childDirectory('models') + .childFile('model.dart'); + await model.create(recursive: true); + await model.writeAsString(''' +import 'package:celest/celest.dart'; + +class Model {} +'''); + await api.writeAsString(''' +import 'package:celest/celest.dart'; +import 'package:celest_backend/models/model.dart'; + +@cloud +Future createModel() async { + return Model(); +} +'''); + + await celest + .hotReload() + .expectLater('Reloading Celest') + .expectLater('Celest is running') + .run(); + } +} diff --git a/apps/cli/test/e2e/features/package_support/supports_supabase.dart b/apps/cli/test/e2e/features/package_support/supports_supabase.dart new file mode 100644 index 000000000..2cd4f5a99 --- /dev/null +++ b/apps/cli/test/e2e/features/package_support/supports_supabase.dart @@ -0,0 +1,38 @@ +import '../../common/common.dart'; +import '../../common/test_projects.dart'; + +// Regression: https://github.com/celest-dev/celest/issues/151 +final class SupportsSupabase extends E2ETest with TestDartProject { + SupportsSupabase(super.target); + + @override + String get name => 'supports supabase'; + + @override + Future run() async { + // Create project + await celestCommand('start') + .withPublishedRuntime() + .workingDirectory(projectDir.path) + .start() + .expectNext('Enter a name for your project') + .writeLine(projectName) + .expectLater('Celest is running') + .run(); + + // Add dependency on supabase + await runCommand( + ['dart', 'pub', 'add', 'supabase'], + runInShell: true, + workingDirectory: celestDir.path, + ); + + // Ensure supabase compiles + await celestCommand('start') + .withPublishedRuntime() + .workingDirectory(projectDir.path) + .start() + .expectLater('Celest is running') + .run(); + } +} diff --git a/apps/cli/test/e2e/targets/installed_target.dart b/apps/cli/test/e2e/targets/installed_target.dart new file mode 100644 index 000000000..2e01a825c --- /dev/null +++ b/apps/cli/test/e2e/targets/installed_target.dart @@ -0,0 +1,25 @@ +import 'package:celest_cli/src/context.dart'; +import 'package:process/src/interface/common.dart'; + +import '../common/common.dart'; + +final class InstalledTarget extends TestTarget { + @override + String get name => 'Installed'; + + @override + List get tags => const ['e2e-installed']; + + @override + List get executable => [ + if (platform.isWindows) + p.join( + platform.environment['LOCALAPPDATA']!, + 'Microsoft', + 'WindowsApps', + 'celest.exe', + ) + else + getExecutablePath('celest', null, throwOnFailure: true)!, + ]; +} diff --git a/apps/cli/test/e2e/targets/local_target.dart b/apps/cli/test/e2e/targets/local_target.dart new file mode 100644 index 000000000..2f7a26f40 --- /dev/null +++ b/apps/cli/test/e2e/targets/local_target.dart @@ -0,0 +1,47 @@ +import 'dart:io'; + +import 'package:celest_cli/src/context.dart'; +import 'package:celest_cli/src/sdk/dart_sdk.dart'; + +import '../common/common.dart'; + +final class LocalTarget extends TestTarget { + @override + String get name => 'Local'; + + @override + Future setUpAll() async { + // Speed up tests by precompiling the CLI to kernel. + final entrypoint = + Directory.current.uri.resolve('bin/celest.dart').toFilePath(); + final output = tempDir.childFile('celest.dill').path; + await runCommand([ + Sdk.current.dartAotRuntime, + Sdk.current.genKernelAotSnapshot, + // TODO(dnys1): Create AOT snapshot when --enable-asserts is available + // https://github.com/dart-lang/sdk/issues/53343 + // '--aot', + '--enable-asserts', + '--platform=${Sdk.current.vmPlatformProductDill}', + '--output=$output', + entrypoint, + ]); + executable = [Sdk.current.dart, output]; + } + + @override + List get tags => const ['e2e-local']; + + @override + late final List executable; + + @override + Map get environment => { + // /apps/cli/ -> /celest/ + 'CELEST_LOCAL_PATH': + fileSystem.currentDirectory.parent.parent.absolute.uri + .resolve('celest/') + .toFilePath(), + 'CELEST_TEST': 'true', + }; +} diff --git a/apps/cli/test/env/env_manager_test.dart b/apps/cli/test/env/env_manager_test.dart new file mode 100644 index 000000000..f0cdf708d --- /dev/null +++ b/apps/cli/test/env/env_manager_test.dart @@ -0,0 +1,79 @@ +import 'package:celest_cli/env/env_manager.dart'; +import 'package:celest_cli/project/project_paths.dart'; +import 'package:celest_cli/src/context.dart'; +import 'package:checks/checks.dart'; +import 'package:test/test.dart'; + +import '../common.dart'; + +void main() { + initTests(); + + group('EnvManager', () { + test('overlay', () async { + final projectDir = fileSystem.systemTempDirectory.createTempSync( + 'project', + ); + projectDir.childFile('.env').writeAsStringSync(''' +PROJECT_ID=test +PROJECT_NAME="Test Project" +'''); + projectDir.childFile('.env.local').writeAsStringSync(''' +PROJECT_ID=local +'''); + projectPaths = ProjectPaths(projectDir.path); + final localManager = await EnvManager().environment('local'); + final prodManager = await EnvManager().environment('production'); + + await check( + localManager.valueFor('PROJECT_ID'), + ).completes((it) => it.equals('local')); + await check( + localManager.valueFor('PROJECT_NAME'), + ).completes((it) => it.equals('Test Project')); + + await check( + prodManager.valueFor('PROJECT_ID'), + ).completes((it) => it.equals('test')); + await check( + prodManager.valueFor('PROJECT_NAME'), + ).completes((it) => it.equals('Test Project')); + }); + + test('updates', () async { + final projectDir = fileSystem.systemTempDirectory.createTempSync( + 'project', + ); + final envFile = projectDir.childFile('.env'); + envFile.writeAsStringSync(''' +PROJECT_ID=test +PROJECT_NAME="Test Project" +'''); + final lastModified = envFile.lastModifiedSync(); + projectPaths = ProjectPaths(projectDir.path); + final localManager = await EnvManager().environment('local'); + + await check( + localManager.valueFor('PROJECT_ID'), + ).completes((it) => it.equals('test')); + await check( + localManager.valueFor('PROJECT_NAME'), + ).completes((it) => it.equals('Test Project')); + + // TODO(dnys1): Use `package:clock` or fake_async instead. + await Future.delayed(const Duration(seconds: 1)); + envFile.writeAsStringSync(''' +PROJECT_ID=local +PROJECT_NAME="Local Project" +'''); + check(envFile.lastModifiedSync()).isGreaterThan(lastModified); + + await check( + localManager.valueFor('PROJECT_ID'), + ).completes((it) => it.equals('local')); + await check( + localManager.valueFor('PROJECT_NAME'), + ).completes((it) => it.equals('Local Project')); + }); + }); +} diff --git a/apps/cli/test/env/firebase_config_value_solver_test.dart b/apps/cli/test/env/firebase_config_value_solver_test.dart new file mode 100644 index 000000000..1ce7b954e --- /dev/null +++ b/apps/cli/test/env/firebase_config_value_solver_test.dart @@ -0,0 +1,208 @@ +import 'dart:convert'; + +import 'package:celest_ast/celest_ast.dart'; +import 'package:celest_cli/database/cache/cache_database.dart'; +import 'package:celest_cli/database/project/project_database.dart'; +import 'package:celest_cli/env/firebase_config_value_solver.dart'; +import 'package:celest_cli/project/celest_project.dart'; +import 'package:celest_cli/src/context.dart'; +import 'package:checks/checks.dart'; +import 'package:file/memory.dart'; +import 'package:native_storage/native_storage.dart'; +import 'package:pubspec_parse/pubspec_parse.dart'; +import 'package:test/test.dart'; + +import '../common.dart'; + +Future> _resolveProjectTest({ + String environmentId = 'production', + Map? projectAliases, // alias -> project ID + String? globalProjectPointer, + Map? firebaseJson, +}) async { + fileSystem = MemoryFileSystem.test(); + final appDir = fileSystem.systemTempDirectory.createTempSync('app_'); + if (firebaseJson != null) { + appDir + .childFile('firebase.json') + .writeAsStringSync(jsonEncode(firebaseJson)); + } + if (projectAliases != null) { + appDir + .childFile('.firebaserc') + .writeAsStringSync(jsonEncode({'projects': projectAliases})); + } + if (globalProjectPointer != null) { + final configPath = fileSystem.path.join( + platform.environment['HOME']!, + '.config', + 'configstore', + 'firebase-tools.json', + ); + fileSystem.file(configPath) + ..parent.createSync(recursive: true) + ..writeAsStringSync( + jsonEncode({ + 'activeProjects': {appDir.path: globalProjectPointer}, + }), + ); + } + + final celestDir = appDir.childDirectory('celest')..createSync(); + celestDir.childFile('pubspec.yaml').writeAsStringSync(''' +name: celest_backend +'''); + + final projectDb = ProjectDatabase.memory(); + final cacheDb = await CacheDatabase.memory(); + await init( + projectRoot: celestDir.path, + parentProject: ParentProject( + name: 'app', + path: appDir.path, + pubspec: Pubspec('app'), + pubspecYaml: '', + type: SdkType.flutter, + ), + projectDb: projectDb, + cacheDb: cacheDb, + ); + final resolver = FirebaseConfigValueSolver( + projectName: 'test', + environmentId: environmentId, + projectDb: projectDb, + ); + + return await resolver.searchLocalEnvironment() ?? const []; +} + +void main() { + initTests(); + + group('FirebaseConfigValueSolver', () { + setUp(() { + secureStorage = NativeMemoryStorage(); + }); + + test('no configuration', () async { + final projects = await _resolveProjectTest(); + check(projects).isEmpty(); + }); + + group('resolves flutterfire config', () { + test('single project', () async { + const projectId = 'firebase-test'; + final projects = await _resolveProjectTest( + firebaseJson: { + 'flutter': { + 'platforms': { + 'android': { + 'default': {'projectId': projectId}, + }, + 'dart': { + 'lib/firebase_options.dart': {'projectId': projectId}, + }, + }, + }, + }, + ); + check(projects).single.hasProjectId(projectId); + }); + + test('multiple projects', () async { + const devProjectId = 'firebase-test-dev'; + const prodProjectId = 'firebase-test-prod'; + final projects = await _resolveProjectTest( + firebaseJson: { + 'flutter': { + 'platforms': { + 'android': { + 'default': {'projectId': devProjectId}, + }, + 'dart': { + 'lib/firebase_options_dev.dart': {'projectId': devProjectId}, + 'lib/firebase_options_prod.dart': { + 'projectId': prodProjectId, + }, + }, + }, + }, + }, + ); + check(projects).unorderedMatches([ + (it) => + it.equals((active: false, projectId: devProjectId, alias: null)), + (it) => + it.equals((active: false, projectId: prodProjectId, alias: null)), + ]); + }); + }); + + group('global config', () { + test('single project', () async { + const projectId = 'firebase-test'; + final projects = await _resolveProjectTest( + globalProjectPointer: projectId, + ); + check(projects).single.hasProjectId(projectId); + }); + + test('multiple projects (projectId pointer)', () async { + const devProjectId = 'firebase-test-dev'; + const prodProjectId = 'firebase-test-prod'; + final projects = await _resolveProjectTest( + globalProjectPointer: devProjectId, + projectAliases: {'dev': devProjectId, 'prod': prodProjectId}, + ); + check(projects).unorderedMatches([ + (it) => + it.equals((active: true, projectId: devProjectId, alias: 'dev')), + (it) => it.equals(( + active: false, + projectId: prodProjectId, + alias: 'prod', + )), + ]); + }); + + test('multiple projects (alias pointer)', () async { + const devProjectId = 'firebase-test-dev'; + const prodProjectId = 'firebase-test-prod'; + final projects = await _resolveProjectTest( + globalProjectPointer: 'prod', + projectAliases: {'dev': devProjectId, 'prod': prodProjectId}, + ); + check(projects).unorderedMatches([ + (it) => + it.equals((active: false, projectId: devProjectId, alias: 'dev')), + (it) => it.equals(( + active: true, + projectId: prodProjectId, + alias: 'prod', + )), + ]); + }); + }); + + test('multiple projects (alias matches environment ID)', () async { + const devProjectId = 'firebase-test-dev'; + const prodProjectId = 'firebase-test-prod'; + final projects = await _resolveProjectTest( + environmentId: 'prod', + globalProjectPointer: 'prod', + projectAliases: {'dev': devProjectId, 'prod': prodProjectId}, + ); + + // When there is an alias matching the environment ID, we always use that. + check(projects).unorderedMatches([ + (it) => + it.equals((active: true, projectId: prodProjectId, alias: 'prod')), + ]); + }); + }); +} + +extension on Subject { + void hasProjectId(String projectId) => + has((it) => it.projectId, 'projectId').equals(projectId); +} diff --git a/apps/cli/test/init/project_item_test.dart b/apps/cli/test/init/project_item_test.dart new file mode 100644 index 000000000..ee9c2a889 --- /dev/null +++ b/apps/cli/test/init/project_item_test.dart @@ -0,0 +1,416 @@ +import 'package:celest_ast/celest_ast.dart'; +import 'package:celest_cli/init/migrations/pubspec_updater.dart'; +import 'package:celest_cli/init/project_migration.dart'; +import 'package:celest_cli/project/celest_project.dart'; +import 'package:celest_cli/pub/project_dependency.dart'; +import 'package:celest_cli/pub/pub_environment.dart'; +import 'package:celest_cli/src/context.dart'; +import 'package:file/file.dart'; +import 'package:pub_semver/pub_semver.dart'; +import 'package:pubspec_parse/pubspec_parse.dart'; +import 'package:test/test.dart'; + +import '../analyzer/celest_analyzer_test.dart'; + +const _projectName = 'celest_backend'; + +String _pubspecYaml({ + String name = _projectName, + VersionConstraint? sdk, + VersionConstraint? celest, + VersionConstraint? celestCore, +}) { + final sdkConstraint = sdk ?? PubEnvironment.dartSdkConstraint; + final celestConstraint = + celest ?? ProjectDependency.celest.pubDependency.version; + + return ''' +name: $name + +environment: + sdk: $sdkConstraint + +dependencies: + celest: $celestConstraint +'''; +} + +void main() { + group('ProjectDependencyUpdater', skip: true, () { + late Directory tempDir; + + setUpAll(() async { + tempDir = await fileSystem.systemTempDirectory.createTemp('celest_test_'); + }); + + tearDownAll(() async { + try { + await tempDir.delete(recursive: true); + } on Object { + // OK, may fail on Windows in CI. + } + }); + + test('up-to-date constraints', () async { + final pubspecYaml = _pubspecYaml(); + await newProject( + name: _projectName, + pubspecYaml: pubspecYaml, + parentDirectory: tempDir.path, + ); + + final updater = PubspecUpdater( + projectPaths.projectRoot, + null, + _projectName, + ); + await updater.create(); + + final updatedPubspec = + await fileSystem.file(projectPaths.pubspecYaml).readAsString(); + expect(updatedPubspec, equalsIgnoringWhitespace(pubspecYaml)); + }); + + test('out-of-date sdk', () async { + final pubspecYaml = _pubspecYaml(sdk: VersionConstraint.parse('^3.2.0')); + await newProject( + name: _projectName, + pubspecYaml: pubspecYaml, + parentDirectory: tempDir.path, + ); + + final updater = PubspecUpdater( + projectPaths.projectRoot, + null, + _projectName, + ); + await updater.create(); + + final updatedPubspec = + await fileSystem.file(projectPaths.pubspecYaml).readAsString(); + expect(updatedPubspec, equalsIgnoringWhitespace(_pubspecYaml())); + }); + + test('out-of-date celest+celest_core', () async { + final pubspecYaml = _pubspecYaml( + celest: VersionConstraint.parse('^0.1.0'), + celestCore: VersionConstraint.parse('^0.1.0'), + ); + await newProject( + name: _projectName, + pubspecYaml: pubspecYaml, + parentDirectory: tempDir.path, + ); + + final updater = PubspecUpdater( + projectPaths.projectRoot, + null, + _projectName, + ); + await updater.create(); + + final updatedPubspec = + await fileSystem.file(projectPaths.pubspecYaml).readAsString(); + expect( + updatedPubspec, + equalsIgnoringWhitespace(_pubspecYaml()), + reason: 'Updates celest constraint + removes celest_core', + ); + }); + + test('out-of-date celest', () async { + final pubspecYaml = _pubspecYaml( + celest: VersionConstraint.parse('^0.1.0'), + ); + await newProject( + name: _projectName, + pubspecYaml: pubspecYaml, + parentDirectory: tempDir.path, + ); + + final updater = PubspecUpdater( + projectPaths.projectRoot, + null, + _projectName, + ); + await updater.create(); + + final updatedPubspec = + await fileSystem.file(projectPaths.pubspecYaml).readAsString(); + expect( + updatedPubspec, + equalsIgnoringWhitespace(_pubspecYaml()), + reason: 'Updates celest constraint', + ); + }); + + test('out-of-date celest_core', () async { + final pubspecYaml = _pubspecYaml( + celestCore: VersionConstraint.parse('^0.1.0'), + ); + await newProject( + name: _projectName, + pubspecYaml: pubspecYaml, + parentDirectory: tempDir.path, + ); + + final updater = PubspecUpdater( + projectPaths.projectRoot, + null, + _projectName, + ); + await updater.create(); + + final updatedPubspec = + await fileSystem.file(projectPaths.pubspecYaml).readAsString(); + expect( + updatedPubspec, + equalsIgnoringWhitespace(_pubspecYaml()), + reason: 'Adds celest constraint + removes celest_core', + ); + }); + }); + + group('PubspecFile', () { + late Directory tempDir; + + setUpAll(() async { + tempDir = await fileSystem.systemTempDirectory.createTemp('celest_test_'); + }); + + tearDownAll(() async { + try { + await tempDir.delete(recursive: true); + } on Object { + // OK, may fail on Windows in CI. + } + }); + + test('barebones dart project', () async { + const pubspecYaml = ''' +name: barebones +description: A sample command-line application. +version: 1.0.0 +# repository: https://github.com/my_org/my_repo + +environment: + sdk: ^3.4.1 +'''; + + await tempDir.childFile('pubspec.yaml').writeAsString(pubspecYaml); + await PubspecFile( + p.join(tempDir.path, 'celest'), + 'barebones', + ParentProject( + name: 'barebones', + path: tempDir.path, + pubspec: Pubspec.parse(pubspecYaml), + pubspecYaml: pubspecYaml, + type: SdkType.dart, + ), + ).create(); + + final updatedPubspecYaml = + await tempDir.childFile('pubspec.yaml').readAsString(); + expect( + updatedPubspecYaml, + equalsIgnoringWhitespace(''' +name: barebones +description: A sample command-line application. +version: 1.0.0 +# repository: https://github.com/my_org/my_repo + +environment: + sdk: ^3.4.1 + +dependencies: + barebones_client: + path: celest/client/ +'''), + ); + + final updatedPubspec = Pubspec.parse(updatedPubspecYaml); + expect(updatedPubspec.dependencies, contains('barebones_client')); + }); + + test('empty dart project', () async { + const pubspecYaml = ''' +name: empty +description: A sample command-line application. +version: 1.0.0 +# repository: https://github.com/my_org/my_repo + +environment: + sdk: ^3.4.1 + +# Add regular dependencies here. +dependencies: + # path: ^1.8.0 + +dev_dependencies: + lints: ^3.0.0 + test: ^1.24.0 +'''; + + await tempDir.childFile('pubspec.yaml').writeAsString(pubspecYaml); + await PubspecFile( + p.join(tempDir.path, 'celest'), + 'empty', + ParentProject( + name: 'empty', + path: tempDir.path, + pubspec: Pubspec.parse(pubspecYaml), + pubspecYaml: pubspecYaml, + type: SdkType.dart, + ), + ).create(); + + final updatedPubspecYaml = + await tempDir.childFile('pubspec.yaml').readAsString(); + expect( + updatedPubspecYaml, + equalsIgnoringWhitespace(''' +name: empty +description: A sample command-line application. +version: 1.0.0 +# repository: https://github.com/my_org/my_repo + +environment: + sdk: ^3.4.1 + +# Add regular dependencies here. +dependencies: + empty_client: + path: celest/client/ + +dev_dependencies: + lints: ^3.0.0 + test: ^1.24.0 +'''), + ); + + final updatedPubspec = Pubspec.parse(updatedPubspecYaml); + expect(updatedPubspec.dependencies, contains('empty_client')); + }); + + test('existing dart project', () async { + const pubspecYaml = ''' +name: existing +description: A sample command-line application. +version: 1.0.0 +# repository: https://github.com/my_org/my_repo + +environment: + sdk: ^3.4.1 + +dependencies: + path: ^1.8.0 + +dev_dependencies: + lints: ^3.0.0 + test: ^1.24.0 +'''; + + await tempDir.childFile('pubspec.yaml').writeAsString(pubspecYaml); + await PubspecFile( + p.join(tempDir.path, 'celest'), + 'existing', + ParentProject( + name: 'existing', + path: tempDir.path, + pubspec: Pubspec.parse(pubspecYaml), + pubspecYaml: pubspecYaml, + type: SdkType.dart, + ), + ).create(); + + final updatedPubspecYaml = + await tempDir.childFile('pubspec.yaml').readAsString(); + expect( + updatedPubspecYaml, + equalsIgnoringWhitespace(''' +name: existing +description: A sample command-line application. +version: 1.0.0 +# repository: https://github.com/my_org/my_repo + +environment: + sdk: ^3.4.1 + +dependencies: + existing_client: + path: celest/client/ + path: ^1.8.0 + +dev_dependencies: + lints: ^3.0.0 + test: ^1.24.0 +'''), + ); + + final updatedPubspec = Pubspec.parse(updatedPubspecYaml); + expect(updatedPubspec.dependencies, contains('existing_client')); + }); + + test('existing celest project', () async { + const pubspecYaml = ''' +name: existing +description: A sample command-line application. +version: 1.0.0 +# repository: https://github.com/my_org/my_repo + +environment: + sdk: ^3.4.1 + +dependencies: + existing_client: + path: celest/client/ + path: ^1.8.0 + +dev_dependencies: + lints: ^3.0.0 + test: ^1.24.0 +'''; + + await tempDir.childFile('pubspec.yaml').writeAsString(pubspecYaml); + await PubspecFile( + p.join(tempDir.path, 'celest'), + 'existing', + ParentProject( + name: 'existing', + path: tempDir.path, + pubspec: Pubspec.parse(pubspecYaml), + pubspecYaml: pubspecYaml, + type: SdkType.dart, + ), + ).create(); + + final updatedPubspecYaml = + await tempDir.childFile('pubspec.yaml').readAsString(); + expect( + updatedPubspecYaml, + equalsIgnoringWhitespace(''' +name: existing +description: A sample command-line application. +version: 1.0.0 +# repository: https://github.com/my_org/my_repo + +environment: + sdk: ^3.4.1 + +dependencies: + existing_client: + path: celest/client/ + path: ^1.8.0 + +dev_dependencies: + lints: ^3.0.0 + test: ^1.24.0 +'''), + ); + + final updatedPubspec = Pubspec.parse(updatedPubspecYaml); + expect(updatedPubspec.dependencies, contains('existing_client')); + }); + }); +} diff --git a/apps/cli/test/init/pubspec_test.dart b/apps/cli/test/init/pubspec_test.dart new file mode 100644 index 000000000..124c539ca --- /dev/null +++ b/apps/cli/test/init/pubspec_test.dart @@ -0,0 +1,45 @@ +import 'package:celest_cli/pub/pubspec.dart'; +import 'package:pub_semver/pub_semver.dart'; +import 'package:pubspec_parse/pubspec_parse.dart'; +import 'package:test/test.dart'; + +import '../common.dart'; + +void main() { + group('PubspecToYaml', () { + setUpAll(initTests); + + test('formats correctly', () { + final pubspec = Pubspec( + 'hello', + description: 'Test description', + publishTo: 'none', + environment: {'sdk': VersionConstraint.parse('^3.2.0')}, + dependencies: { + 'celest': HostedDependency(version: VersionConstraint.parse('0.1.0')), + }, + devDependencies: { + 'test': HostedDependency(version: VersionConstraint.parse('0.1.0')), + }, + ); + + expect( + pubspec.toYaml(), + equalsIgnoringWhitespace(''' +name: hello +description: Test description +publish_to: none + +environment: + sdk: ^3.2.0 + +dependencies: + celest: 0.1.0 + +dev_dependencies: + test: 0.1.0 +'''), + ); + }); + }); +} diff --git a/apps/cli/test/path_test.dart b/apps/cli/test/path_test.dart new file mode 100644 index 000000000..56bc4ce05 --- /dev/null +++ b/apps/cli/test/path_test.dart @@ -0,0 +1,49 @@ +@Skip('Needs work') +library; + +import 'package:celest_cli/src/context.dart'; +import 'package:celest_cli/src/utils/path.dart'; +import 'package:path/path.dart' as path; +import 'package:test/test.dart'; +import 'package:test_descriptor/test_descriptor.dart' as d; + +import 'common.dart'; + +enum _Style { + posix, + windows; + + path.Context get context => switch (this) { + _Style.posix => p.posix, + _Style.windows => p.windows, + }; +} + +void main() { + group('paths', () { + setUpAll(() async { + await initTests(); + await init(projectRoot: d.sandbox); + }); + + for (final style in _Style.values) { + group(style.name, () { + final p = style.context; + + test('resolves project-relative paths', () { + final projectRoot = projectPaths.projectRoot.to(p); + final analysisOptions = projectPaths.analysisOptionsYaml.to(p); + + expect( + p.relative(analysisOptions, from: projectRoot), + equals('analysis_options.yaml'), + ); + expect( + p.project.relative(analysisOptions), + equals('analysis_options.yaml'), + ); + }); + }); + } + }); +} diff --git a/apps/cli/test/pub/pub_action_test.dart b/apps/cli/test/pub/pub_action_test.dart new file mode 100644 index 000000000..fb5463500 --- /dev/null +++ b/apps/cli/test/pub/pub_action_test.dart @@ -0,0 +1,129 @@ +@OnPlatform({ + // Windows needs extra time in CI to run `pub get` and `pub upgrade`. + 'windows': Timeout.factor(4), +}) +library; + +import 'dart:io' show Platform; + +import 'package:celest_cli/pub/pub_action.dart'; +import 'package:celest_cli/src/context.dart'; +import 'package:celest_cli/src/exceptions.dart'; +import 'package:celest_cli/src/sdk/versions.dart'; +import 'package:file/file.dart'; +import 'package:test/test.dart'; + +import '../common.dart'; + +void main() { + group('runPub', () { + setUpAll(initTests); + + final matrix = [ + (PubAction.get, 'flutter'), + (PubAction.get, Platform.resolvedExecutable), + (PubAction.upgrade, 'flutter'), + (PubAction.upgrade, Platform.resolvedExecutable), + ]; + for (final (action, exe) in matrix) { + group('${exe.split('/').last} pub ${action.name}', () { + late Directory tempDir; + File packageConfig() => tempDir + .childDirectory('.dart_tool') + .childFile('package_config.json'); + + setUp(() { + tempDir = fileSystem.systemTempDirectory.createTempSync( + 'celest_cli_test', + ); + }); + + tearDown(() { + try { + tempDir.deleteSync(recursive: true); + } catch (_) {} + }); + + test('resolves successfully', () async { + tempDir.childFile('pubspec.yaml').writeAsStringSync(''' +name: test_1234 + +environment: + sdk: ^$minSupportedDartSdk + +dependencies: + path: any +'''); + await expectLater( + runPub(exe: exe, action: action, workingDirectory: tempDir.path), + completes, + ); + expect(packageConfig().existsSync(), true); + }); + + test('proxies failures gracefully', () async { + tempDir.childFile('pubspec.yaml').writeAsStringSync(''' +name: test_1234 + +environment: + sdk: ^$minSupportedDartSdk + +dependencies: + # A non-existent version of Celest + celest: 0.0.1 +'''); + await expectLater( + runPub(exe: exe, action: action, workingDirectory: tempDir.path), + throwsA( + isA().having( + (e) => e.toString(), + 'message', + contains( + 'Because test_1234 depends on celest 0.0.1 which doesn\'t match ' + 'any versions, version solving failed.', + ), + ), + ), + ); + }); + + // TODO(dnys1): Should we allow direct dependencies on Flutter? + test('works when depending on flutter', () async { + tempDir.childFile('pubspec.yaml').writeAsStringSync(''' +name: test_1234 + +environment: + sdk: ^$minSupportedDartSdk + +dependencies: + flutter: + sdk: flutter +'''); + await expectLater( + runPub(exe: exe, action: action, workingDirectory: tempDir.path), + completes, + ); + expect(packageConfig().existsSync(), true); + }); + + test('works with flutter environment constraint', () async { + tempDir.childFile('pubspec.yaml').writeAsStringSync(''' +name: test_1234 + +environment: + sdk: ^$minSupportedDartSdk + flutter: ">=3.19.0" + +dependencies: + path: any +'''); + await expectLater( + runPub(exe: exe, action: action, workingDirectory: tempDir.path), + completes, + ); + expect(packageConfig().existsSync(), true); + }); + }); + } + }); +} diff --git a/apps/cli/test/pub/pub_cache_test.dart b/apps/cli/test/pub/pub_cache_test.dart new file mode 100644 index 000000000..b77d32d7d --- /dev/null +++ b/apps/cli/test/pub/pub_cache_test.dart @@ -0,0 +1,34 @@ +import 'package:celest_cli/pub/pub_cache.dart'; +import 'package:test/test.dart'; + +import '../common.dart'; + +void main() { + initTests(); + + group('PubCache', () { + test('finds pub cache', () { + expect(pubCache.findCachePath(), isNotNull); + }); + + test('hydrates packages', () async { + final packages = + PubCache.packagesToFix.entries + .map((e) => '${e.key}:${e.value}') + .toList(); + final results = await pubCache.hydrate(); + for (final (index, (exitCode, output)) in results.indexed) { + if (exitCode != 0) { + fail('Failed to hydrate ${packages[index]}:\n$output'); + } + } + }); + + test('fixes cache', timeout: Timeout.none, () async { + final result = await pubCache.repair(); + expect(result.exitCode, 0, reason: '${result.stdout}\n${result.stderr}'); + final numFixed = await pubCache.fix(throwOnError: true); + expect(numFixed, greaterThan(PubCache.packagesToFix.length)); + }); + }); +} diff --git a/apps/cli/test/src/process/port_finder_test.dart b/apps/cli/test/src/process/port_finder_test.dart new file mode 100644 index 000000000..37d620428 --- /dev/null +++ b/apps/cli/test/src/process/port_finder_test.dart @@ -0,0 +1,38 @@ +import 'dart:io'; + +import 'package:celest_cli/src/process/port_finder.dart'; +import 'package:checks/checks.dart'; +import 'package:test/test.dart'; + +void main() { + group('PortFinder', () { + group('checkPort', () { + test('valid ports', () async { + await check(PortFinder.checkPort(0)).completes((it) => it.isTrue()); + await check( + PortFinder.checkPort(PortFinder.maxPort + 1), + ).throws((it) => it.isA()); + }); + + final ips = [InternetAddress.anyIPv4, InternetAddress.loopbackIPv4]; + for (final ip in ips) { + test('used port ($ip)', () async { + final socket = await ServerSocket.bind(ip, 0); + addTearDown(socket.close); + await check( + PortFinder.checkPort(socket.port), + ).completes((it) => it.isFalse()); + }); + } + }); + }); + + group('RandomPortFinder', () { + test('checks all interfaces', () async { + final randomPort = await const RandomPortFinder().findOpenPort(); + await check( + PortFinder.checkPort(randomPort), + ).completes((it) => it.isTrue()); + }); + }); +} diff --git a/apps/cli/test/src/sdk/dart_sdk_test.dart b/apps/cli/test/src/sdk/dart_sdk_test.dart new file mode 100644 index 000000000..002748f78 --- /dev/null +++ b/apps/cli/test/src/sdk/dart_sdk_test.dart @@ -0,0 +1,229 @@ +// ignore_for_file: avoid_print + +import 'dart:io'; + +import 'package:celest_cli/src/context.dart' as ctx; +import 'package:celest_cli/src/context.dart'; +import 'package:celest_cli/src/sdk/dart_sdk.dart'; +import 'package:file/chroot.dart'; +import 'package:file/local.dart'; +import 'package:logging/logging.dart'; +import 'package:platform/platform.dart'; +import 'package:test/test.dart'; +import 'package:test_descriptor/test_descriptor.dart' as d; + +void main() { + Logger.root.level = Level.ALL; + Logger.root.onRecord.listen((record) { + print('${record.level.name}: ${record.message}'); + }); + + group('Sdk', () { + group('Flutter', () { + test('homebrew', testOn: '!windows', () async { + // Mimics the directory structure of a Homebrew-installed Flutter SDK. + final root = d.dir('opt', [ + d.dir('homebrew', [ + d.dir('bin', [ + link( + 'flutter', + '/opt/homebrew/Caskroom/flutter/3.22.2/flutter/bin/flutter', + ), + ]), + d.dir('Caskroom', [ + d.dir('flutter', [ + d.dir('3.22.2', [ + d.dir('flutter', [ + d.dir('bin', [ + d.file('flutter'), + d.dir('cache', [ + d.dir('dart-sdk', [ + d.dir('bin', [d.file('dart'), d.dir('snapshots')]), + ]), + ]), + ]), + ]), + ]), + ]), + ]), + ]), + ]); + await root.create(); + await root.validate(); + print(root.describe()); + + const localPlatform = LocalPlatform(); + ctx.fileSystem = ChrootFileSystem(const LocalFileSystem(), d.sandbox); + ctx.platform = FakePlatform( + operatingSystem: localPlatform.operatingSystem, + version: localPlatform.version, + environment: {'PATH': '/opt/homebrew/bin'}, + // Fake the resolved exe since this is checked first and would + // otherwise point to the Dart SDK running this test. + resolvedExecutable: '/fake-dart', + ); + + // Make `flutter` executable + for (final target in [ + '/opt/homebrew/bin/flutter', + '/opt/homebrew/Caskroom/flutter/3.22.2/flutter/bin/flutter', + ]) { + await Process.run('chmod', ['+x', '${d.sandbox}$target']); + } + + expect( + Sdk.load().sdkPath, + '/opt/homebrew/Caskroom/flutter/3.22.2/flutter/bin/cache/dart-sdk', + ); + }); + }); + + group('Dart', () { + test('homebrew', testOn: '!windows', () async { + // Mimics the directory structure of a Homebrew-installed Dart SDK. + final root = d.dir('opt', [ + d.dir('homebrew', [ + d.dir('bin', [ + link('dart', '/opt/homebrew/Cellar/dart/3.2.0/bin/dart'), + ]), + d.dir('Cellar', [ + d.dir('dart', [ + d.dir('3.2.0', [ + d.dir('bin', [ + link( + 'dart', + '/opt/homebrew/Cellar/dart/3.2.0/libexec/bin/dart', + ), + ]), + d.dir('libexec', [ + d.dir('bin', [d.file('dart'), d.dir('snapshots')]), + ]), + ]), + ]), + ]), + ]), + ]); + await root.create(); + await root.validate(); + print(root.describe()); + + const localPlatform = LocalPlatform(); + ctx.fileSystem = ChrootFileSystem(const LocalFileSystem(), d.sandbox); + ctx.platform = FakePlatform( + operatingSystem: localPlatform.operatingSystem, + version: localPlatform.version, + environment: {'PATH': '/opt/homebrew/bin'}, + // Fake the resolved exe since this is checked first and would + // otherwise point to the Dart SDK running this test. + resolvedExecutable: '/fake-dart', + ); + + // Make `dart` executable + for (final target in [ + '/opt/homebrew/bin/dart', + '/opt/homebrew/Cellar/dart/3.2.0/bin/dart', + '/opt/homebrew/Cellar/dart/3.2.0/libexec/bin/dart', + ]) { + await Process.run('chmod', ['+x', '${d.sandbox}$target']); + } + + expect(Sdk.load().sdkPath, '/opt/homebrew/Cellar/dart/3.2.0/libexec'); + }); + + test('snap', testOn: '!windows', () async { + // Mimics the directory structure of a Snap-installed Dart SDK. + final usr = d.dir('usr', [ + d.dir('bin', [d.file('snap')]), + ]); + await usr.create(); + await usr.validate(); + + final snap = d.dir('snap', [ + d.dir('bin', [ + link('flutter.dart', '/usr/bin/snap'), + link('dart', '/snap/bin/flutter.dart'), + ]), + ]); + await snap.create(); + await snap.validate(); + + final home = d.dir('home', [ + d.dir('user', [ + d.dir('snap', [ + d.dir('flutter', [ + d.dir('common', [ + d.dir('flutter', [ + d.dir('bin', [ + d.file('dart'), + d.dir('cache', [ + d.dir('dart-sdk', [ + d.dir('bin', [d.file('dart'), d.dir('snapshots')]), + ]), + ]), + ]), + ]), + ]), + ]), + ]), + ]), + ]); + await home.create(); + await home.validate(); + + const localPlatform = LocalPlatform(); + ctx.fileSystem = ChrootFileSystem(const LocalFileSystem(), d.sandbox); + ctx.platform = FakePlatform( + operatingSystem: localPlatform.operatingSystem, + version: localPlatform.version, + environment: {'PATH': '/usr/bin:/snap/bin', 'HOME': '/home/user'}, + // Fake the resolved exe since this is checked first and would + // otherwise point to the Dart SDK running this test. + resolvedExecutable: '/fake-dart', + ); + + // Make `dart` executable + for (final target in [ + '/usr/bin/snap', + '/home/user/snap/flutter/common/flutter/bin/dart', + '/home/user/snap/flutter/common/flutter/bin/cache/dart-sdk/bin/dart', + ]) { + await Process.run('chmod', ['+x', '${d.sandbox}$target']); + } + + expect( + Sdk.load().sdkPath, + '/home/user/snap/flutter/common/flutter/bin/cache/dart-sdk', + ); + }); + }); + }); +} + +d.Descriptor link(String name, String target) => _LinkDescriptor(name, target); + +final class _LinkDescriptor extends d.Descriptor { + _LinkDescriptor(super.name, this.target); + + /// The sandbox-relative path to the target of the link. + final String target; + + @override + Future create([String? parent]) async { + final linkPath = p.join(parent ?? d.sandbox, name); + await Link(linkPath).create(target); + } + + @override + String describe() => '$name -> $target'; + + @override + Future validate([String? parent]) async { + final linkPath = p.join(parent ?? d.sandbox, name); + if (!await Link(linkPath).exists()) { + fail('Link not found: "$linkPath".'); + } + if (await Link(linkPath).target() != target) { + fail('Link "$linkPath" does not point to "$target".'); + } + } +} diff --git a/apps/cli/test/src/types/type_checker_test.dart b/apps/cli/test/src/types/type_checker_test.dart new file mode 100644 index 000000000..28de0c0c0 --- /dev/null +++ b/apps/cli/test/src/types/type_checker_test.dart @@ -0,0 +1,530 @@ +// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'package:analyzer/dart/element/element.dart'; +import 'package:analyzer/dart/element/nullability_suffix.dart'; +import 'package:analyzer/dart/element/type.dart'; +import 'package:build/build.dart'; +import 'package:build_test/build_test.dart'; +import 'package:celest_cli/src/types/type_checker.dart'; +import 'package:test/test.dart'; + +void main() { + // Resolved top-level types from dart:core and dart:collection. + late InterfaceType staticUri; + late InterfaceType staticMap; + late InterfaceType staticHashMap; + late InterfaceType staticUnmodifiableListView; + late InterfaceType staticEnum; + late TypeChecker staticIterableChecker; + late TypeChecker staticEnumMixinChecker; + late TypeChecker staticMapChecker; + late TypeChecker staticMapMixinChecker; + late TypeChecker staticHashMapChecker; + late TypeChecker staticEnumChecker; + + // Resolved top-level types from this file + late InterfaceType staticEnumMixin; + late InterfaceType staticMapMixin; + late InterfaceType staticMyEnum; + late InterfaceType staticMyEnumWithMixin; + + setUpAll(() async { + late LibraryElement core; + late LibraryElement collection; + late LibraryElement testSource; + await resolveSource( + r''' + export 'package:celest_cli/celest_cli.dart'; + export 'type_checker_test.dart' show NonPublic; + ''', + (resolver) async { + core = (await resolver.findLibraryByName('dart.core'))!; + collection = (await resolver.findLibraryByName('dart.collection'))!; + testSource = await resolver.libraryFor( + AssetId('celest_cli', 'test/src/types/type_checker_test.dart'), + ); + }, + inputId: AssetId('celest_cli', 'test/example.dart'), + ); + + final staticIterable = core + .getClass('Iterable')! + .instantiate( + typeArguments: [core.typeProvider.dynamicType], + nullabilitySuffix: NullabilitySuffix.none, + ); + staticIterableChecker = TypeChecker.fromStatic(staticIterable); + staticUri = core + .getClass('Uri')! + .instantiate( + typeArguments: [], + nullabilitySuffix: NullabilitySuffix.none, + ); + staticMap = core + .getClass('Map')! + .instantiate( + typeArguments: [ + core.typeProvider.dynamicType, + core.typeProvider.dynamicType, + ], + nullabilitySuffix: NullabilitySuffix.none, + ); + staticMapChecker = TypeChecker.fromStatic(staticMap); + staticEnum = core + .getClass('Enum')! + .instantiate( + typeArguments: [], + nullabilitySuffix: NullabilitySuffix.none, + ); + staticEnumChecker = TypeChecker.fromStatic(staticEnum); + staticEnumMixin = (testSource.exportNamespace.get('MyEnumMixin')! + as InterfaceElement) + .instantiate( + typeArguments: [], + nullabilitySuffix: NullabilitySuffix.none, + ); + staticEnumMixinChecker = TypeChecker.fromStatic(staticEnumMixin); + staticMapMixin = (testSource.exportNamespace.get('MyMapMixin')! + as InterfaceElement) + .instantiate( + typeArguments: [], + nullabilitySuffix: NullabilitySuffix.none, + ); + staticMapMixinChecker = TypeChecker.fromStatic(staticMapMixin); + staticMyEnum = (testSource.exportNamespace.get('MyEnum')! + as InterfaceElement) + .instantiate( + typeArguments: [], + nullabilitySuffix: NullabilitySuffix.none, + ); + staticMyEnumWithMixin = (testSource.exportNamespace.get('MyEnumWithMixin')! + as InterfaceElement) + .instantiate( + typeArguments: [], + nullabilitySuffix: NullabilitySuffix.none, + ); + + staticHashMap = collection + .getClass('HashMap')! + .instantiate( + typeArguments: [ + core.typeProvider.dynamicType, + core.typeProvider.dynamicType, + ], + nullabilitySuffix: NullabilitySuffix.none, + ); + staticHashMapChecker = TypeChecker.fromStatic(staticHashMap); + staticUnmodifiableListView = collection + .getClass('UnmodifiableListView')! + .instantiate( + typeArguments: [core.typeProvider.dynamicType], + nullabilitySuffix: NullabilitySuffix.none, + ); + }); + + // Run a common set of type comparison checks with various implementations. + void commonTests({ + required TypeChecker Function() checkIterable, + required TypeChecker Function() checkEnum, + required TypeChecker Function() checkMap, + required TypeChecker Function() checkMapMixin, + required TypeChecker Function() checkEnumMixin, + required TypeChecker Function() checkHashMap, + }) { + group('(Iterable)', () { + test( + 'should be assignable from dart:collection#UnmodifiableListView', + () { + expect( + checkIterable().isAssignableFromType(staticUnmodifiableListView), + true, + ); + }, + ); + }); + + group('(Enum)', () { + test('should be supertype of enum classes', () { + expect(checkEnum().isSuperTypeOf(staticMyEnum), isTrue); + }); + + test( + 'with mixins should be assignable to mixin class', + () { + expect( + checkEnumMixin().isAssignableFromType(staticMyEnumWithMixin), + isTrue, + ); + }, + onPlatform: const { + 'windows': Skip('https://github.com/dart-lang/source_gen/issues/573'), + }, + ); + }); + + group( + '(MapMixin', + () { + test('should equal MapMixin class', () { + expect(checkMapMixin().isExactlyType(staticMapMixin), isTrue); + expect(checkMapMixin().isExactly(staticMapMixin.element), isTrue); + }); + }, + onPlatform: const { + 'windows': Skip('https://github.com/dart-lang/source_gen/issues/573'), + }, + ); + + group('(Map)', () { + test('should equal dart:core#Map', () { + expect( + checkMap().isExactlyType(staticMap), + isTrue, + reason: '${checkMap()} != ${staticMap.element.name}', + ); + }); + + test('should not be a super type of dart:core#Map', () { + expect(checkMap().isSuperTypeOf(staticMap), isFalse); + }); + + test('should not equal dart:core#HashMap', () { + expect( + checkMap().isExactlyType(staticHashMap), + isFalse, + reason: '${checkMap()} == $staticHashMapChecker', + ); + }); + + test('should be a super type of dart:collection#HashMap', () { + expect(checkMap().isSuperTypeOf(staticHashMap), isFalse); + }); + + test('should be assignable from dart:collection#HashMap', () { + expect(checkMap().isAssignableFromType(staticHashMap), isTrue); + }); + + test('should be assignable from dart:collection#MapMixin', () { + expect(checkMap().isAssignableFromType(staticMapMixin), isTrue); + }); + + // Ensure we're consistent WRT generic types + test('should be assignable from Map', () { + // Using Uri.queryParameters to get a Map + final stringStringMapType = + staticUri.getGetter('queryParameters')!.returnType; + + expect(checkMap().isAssignableFromType(stringStringMapType), isTrue); + expect(checkMap().isExactlyType(stringStringMapType), isTrue); + }); + }); + + group('(HashMap)', () { + test('should equal dart:collection#HashMap', () { + expect( + checkHashMap().isExactlyType(staticHashMap), + isTrue, + reason: '${checkHashMap()} != $staticHashMapChecker', + ); + }); + + test('should not be a super type of dart:core#Map', () { + expect(checkHashMap().isSuperTypeOf(staticMap), isFalse); + }); + + test('should not assignable from type dart:core#Map', () { + expect(checkHashMap().isAssignableFromType(staticMap), isFalse); + }); + }); + } + + group('TypeChecker.forStatic', () { + commonTests( + checkIterable: () => staticIterableChecker, + checkEnum: () => staticEnumChecker, + checkEnumMixin: () => staticEnumMixinChecker, + checkMap: () => staticMapChecker, + checkMapMixin: () => staticMapMixinChecker, + checkHashMap: () => staticHashMapChecker, + ); + }); + + group('TypeChecker.fromUrl', () { + commonTests( + checkIterable: () => const TypeChecker.fromUrl('dart:core#Iterable'), + checkEnum: () => const TypeChecker.fromUrl('dart:core#Enum'), + checkEnumMixin: + () => const TypeChecker.fromUrl( + 'asset:celest_cli/test/src/types/type_checker_test.dart#MyEnumMixin', + ), + checkMap: () => const TypeChecker.fromUrl('dart:core#Map'), + checkMapMixin: + () => const TypeChecker.fromUrl( + 'asset:celest_cli/test/src/types/type_checker_test.dart#MyMapMixin', + ), + checkHashMap: () => const TypeChecker.fromUrl('dart:collection#HashMap'), + ); + }); + + test('should fail gracefully when something is not resolvable', () async { + final library = await resolveSource(r''' + library _test; + + @depracated // Intentionally mispelled. + class X {} + ''', (resolver) async => (await resolver.findLibraryByName('_test'))!); + final classX = library.getClass('X')!; + const $deprecated = TypeChecker.fromUrl('dart:core#deprecated'); + + expect( + () => $deprecated.annotationsOf(classX), + throwsA( + const TypeMatcher().having( + (e) => e.toString(), + 'toString', + allOf( + contains('Could not resolve annotation for `class X`.'), + contains('@depracated'), + ), + ), + ), + ); + }); + + test('should check multiple checkers', () { + final listOrMap = TypeChecker.any([staticEnumChecker, staticMapChecker]); + expect(listOrMap.isExactlyType(staticMap), isTrue); + }); + + group('should find annotations', () { + late TypeChecker $A; + late TypeChecker $B; + late TypeChecker $C; + + late ClassElement $ExampleOfA; + late ClassElement $ExampleOfMultiA; + late ClassElement $ExampleOfAPlusB; + late ClassElement $ExampleOfBPlusC; + + setUpAll(() async { + final library = await resolveSource(r''' + library _test; + + @A() + class ExampleOfA {} + + @A() + @A() + class ExampleOfMultiA {} + + @A() + @B() + class ExampleOfAPlusB {} + + @B() + @C() + class ExampleOfBPlusC {} + + class A { + const A(); + } + + class B { + const B(); + } + + class C extends B { + const C(); + } + ''', (resolver) async => (await resolver.findLibraryByName('_test'))!); + + $A = TypeChecker.fromStatic( + library + .getClass('A')! + .instantiate( + typeArguments: [], + nullabilitySuffix: NullabilitySuffix.none, + ), + ); + $B = TypeChecker.fromStatic( + library + .getClass('B')! + .instantiate( + typeArguments: [], + nullabilitySuffix: NullabilitySuffix.none, + ), + ); + $C = TypeChecker.fromStatic( + library + .getClass('C')! + .instantiate( + typeArguments: [], + nullabilitySuffix: NullabilitySuffix.none, + ), + ); + $ExampleOfA = library.getClass('ExampleOfA')!; + $ExampleOfMultiA = library.getClass('ExampleOfMultiA')!; + $ExampleOfAPlusB = library.getClass('ExampleOfAPlusB')!; + $ExampleOfBPlusC = library.getClass('ExampleOfBPlusC')!; + }); + + test('of a single @A', () { + expect($A.hasAnnotationOf($ExampleOfA), isTrue); + final aAnnotation = $A.firstAnnotationOf($ExampleOfA)!; + expect(aAnnotation.type!.element!.name, 'A'); + expect($B.annotationsOf($ExampleOfA), isEmpty); + expect($C.annotationsOf($ExampleOfA), isEmpty); + }); + + test('of a multiple @A', () { + final aAnnotations = $A.annotationsOf($ExampleOfMultiA); + expect(aAnnotations.map((a) => a.type!.element!.name), ['A', 'A']); + expect($B.annotationsOf($ExampleOfA), isEmpty); + expect($C.annotationsOf($ExampleOfA), isEmpty); + }); + + test('of a single @A + single @B', () { + final aAnnotations = $A.annotationsOf($ExampleOfAPlusB); + expect(aAnnotations.map((a) => a.type!.element!.name), ['A']); + final bAnnotations = $B.annotationsOf($ExampleOfAPlusB); + expect(bAnnotations.map((a) => a.type!.element!.name), ['B']); + expect($C.annotationsOf($ExampleOfAPlusB), isEmpty); + }); + + test('of a single @B + single @C', () { + final cAnnotations = $C.annotationsOf($ExampleOfBPlusC); + expect(cAnnotations.map((a) => a.type!.element!.name), ['C']); + final bAnnotations = $B.annotationsOf($ExampleOfBPlusC); + expect(bAnnotations.map((a) => a.type!.element!.name), ['B', 'C']); + expect($B.hasAnnotationOfExact($ExampleOfBPlusC), isTrue); + final bExact = $B.annotationsOfExact($ExampleOfBPlusC); + expect(bExact.map((a) => a.type!.element!.name), ['B']); + }); + }); + + group('unresolved annotations', () { + late TypeChecker $A; + late ClassElement $ExampleOfA; + late ParameterElement $annotatedParameter; + + setUpAll(() async { + final library = await resolveSource(r''' + library _test; + + // Put the missing annotation first so it throws. + @B() + @A() + class ExampleOfA {} + + void annotatedParameter(@B() @A() String parameter) {} + + class A { + const A(); + } + ''', (resolver) async => (await resolver.findLibraryByName('_test'))!); + $A = TypeChecker.fromStatic( + library + .getClass('A')! + .instantiate( + typeArguments: [], + nullabilitySuffix: NullabilitySuffix.none, + ), + ); + $ExampleOfA = library.getClass('ExampleOfA')!; + $annotatedParameter = + library.topLevelElements + .whereType() + .firstWhere((f) => f.name == 'annotatedParameter') + .parameters + .single; + }); + + test('should throw by default', () { + expect( + () => $A.firstAnnotationOf($ExampleOfA), + throwsUnresolvedAnnotationException, + ); + expect( + () => $A.annotationsOf($ExampleOfA), + throwsUnresolvedAnnotationException, + ); + expect( + () => $A.firstAnnotationOfExact($ExampleOfA), + throwsUnresolvedAnnotationException, + ); + expect( + () => $A.annotationsOfExact($ExampleOfA), + throwsUnresolvedAnnotationException, + ); + expect( + () => $A.firstAnnotationOf($annotatedParameter), + throwsUnresolvedAnnotationException, + ); + expect( + () => $A.annotationsOf($annotatedParameter), + throwsUnresolvedAnnotationException, + ); + expect( + () => $A.firstAnnotationOfExact($annotatedParameter), + throwsUnresolvedAnnotationException, + ); + expect( + () => $A.annotationsOfExact($annotatedParameter), + throwsUnresolvedAnnotationException, + ); + }); + + test('should not throw if `throwOnUnresolved` == false', () { + expect( + $A + .firstAnnotationOf($ExampleOfA, throwOnUnresolved: false)! + .type! + .element! + .name, + 'A', + ); + expect( + $A + .annotationsOf($ExampleOfA, throwOnUnresolved: false) + .map((a) => a.type!.element!.name), + ['A'], + ); + expect( + $A + .firstAnnotationOfExact($ExampleOfA, throwOnUnresolved: false)! + .type! + .element! + .name, + 'A', + ); + expect( + $A + .annotationsOfExact($ExampleOfA, throwOnUnresolved: false) + .map((a) => a.type!.element!.name), + ['A'], + ); + }); + }); +} + +final throwsUnresolvedAnnotationException = throwsA( + const TypeMatcher().having( + (e) => e.annotationSource, + 'annotationSource', + isNotNull, + ), +); + +// Not using `dart.collection#MapMixin` because we want to test elements +// actually declared as a `mixin`. +mixin MyMapMixin on Map {} + +enum MyEnum { foo, bar } + +mixin MyEnumMixin on Enum { + int get value => 1; +} + +enum MyEnumWithMixin with MyEnumMixin { foo, bar } diff --git a/apps/cli/test/src/utils/recase_test.dart b/apps/cli/test/src/utils/recase_test.dart new file mode 100644 index 000000000..becef5f4b --- /dev/null +++ b/apps/cli/test/src/utils/recase_test.dart @@ -0,0 +1,16 @@ +import 'package:celest_cli/src/utils/recase.dart'; +import 'package:test/test.dart'; + +void main() { + group('recase', () { + test('camel -> param', () { + const camelCase = 'camelCase'; + const paramCase = 'camel-case'; + expect(camelCase.paramCase, paramCase); + + const camelCase2 = 'camelC'; + const paramCase2 = 'camel-c'; + expect(camelCase2.paramCase, paramCase2); + }); + }); +} diff --git a/apps/cli/test/src/utils/typeid_test.dart b/apps/cli/test/src/utils/typeid_test.dart new file mode 100644 index 000000000..4f041e948 --- /dev/null +++ b/apps/cli/test/src/utils/typeid_test.dart @@ -0,0 +1,10 @@ +import 'package:celest_cli/src/utils/typeid.dart'; +import 'package:celest_core/celest_core.dart'; +import 'package:test/test.dart'; + +void main() { + test('TypeId', () { + final id = typeId('user'); + print(id); + }); +} diff --git a/apps/cli/tool/linux/deb/DEBIAN/control b/apps/cli/tool/linux/deb/DEBIAN/control new file mode 100644 index 000000000..af9307d7b --- /dev/null +++ b/apps/cli/tool/linux/deb/DEBIAN/control @@ -0,0 +1,6 @@ +Package: Celest +Depends: libsecret-1-dev, gnome-keyring, libsqlite3-dev +Version: {{ version }} +Maintainer: Teo, Inc. +Architecture: {{ arch }} +Description: The CLI for Celest, the Flutter cloud platform diff --git a/apps/cli/tool/linux/deb/DEBIAN/postinst b/apps/cli/tool/linux/deb/DEBIAN/postinst new file mode 100755 index 000000000..8d496f60e --- /dev/null +++ b/apps/cli/tool/linux/deb/DEBIAN/postinst @@ -0,0 +1,5 @@ +#!/bin/sh + +chmod +x /opt/celest/launcher.sh +chmod +x /opt/celest/celest +ln -sf /opt/celest/launcher.sh /usr/local/bin/celest diff --git a/apps/cli/tool/linux/deb/DEBIAN/postrm b/apps/cli/tool/linux/deb/DEBIAN/postrm new file mode 100755 index 000000000..195608a82 --- /dev/null +++ b/apps/cli/tool/linux/deb/DEBIAN/postrm @@ -0,0 +1,3 @@ +#!/bin/sh + +rm -f /usr/local/bin/celest diff --git a/apps/cli/tool/linux/launcher.sh b/apps/cli/tool/linux/launcher.sh new file mode 100755 index 000000000..2677b062d --- /dev/null +++ b/apps/cli/tool/linux/launcher.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +export LD_LIBRARY_PATH="$PWD:$LD_LIBRARY_PATH" +exec /opt/celest/celest $@ diff --git a/apps/cli/tool/macos/Info.plist b/apps/cli/tool/macos/Info.plist new file mode 100644 index 000000000..45c33c481 --- /dev/null +++ b/apps/cli/tool/macos/Info.plist @@ -0,0 +1,16 @@ + + + + + CFBundleExecutable + celest + CFBundleName + Celest + CFBundleInfoDictionaryVersion + 6.0 + CFBundleIdentifier + dev.celest.cli + CFBundleVersion + {{ version }} + + diff --git a/apps/cli/tool/macos/distribution.xml b/apps/cli/tool/macos/distribution.xml new file mode 100644 index 000000000..b15ff946a --- /dev/null +++ b/apps/cli/tool/macos/distribution.xml @@ -0,0 +1,25 @@ + + + Celest + + + + + + + + + + + + + + + + + + + + + {{ filename }} + \ No newline at end of file diff --git a/apps/cli/tool/macos/embedded.provisionprofile b/apps/cli/tool/macos/embedded.provisionprofile new file mode 100644 index 000000000..016b381c3 Binary files /dev/null and b/apps/cli/tool/macos/embedded.provisionprofile differ diff --git a/apps/cli/tool/macos/entitlements.xml b/apps/cli/tool/macos/entitlements.xml new file mode 100644 index 000000000..98b448367 --- /dev/null +++ b/apps/cli/tool/macos/entitlements.xml @@ -0,0 +1,20 @@ + + + + + + com.apple.security.cs.allow-unsigned-executable-memory + + com.apple.security.cs.disable-library-validation + + + com.apple.application-identifier + {{ teamId }}.dev.celest.cli + com.apple.developer.team-identifier + {{ teamId }} + keychain-access-groups + + {{ teamId }}.dev.celest + + + \ No newline at end of file diff --git a/apps/cli/tool/macos/resources/conclusion.html b/apps/cli/tool/macos/resources/conclusion.html new file mode 100644 index 000000000..2e796b6f7 --- /dev/null +++ b/apps/cli/tool/macos/resources/conclusion.html @@ -0,0 +1,23 @@ + + + + + + +

Welcome to Celest!

+

+ To start using Celest, run the celest start command from your + console inside your Flutter project. +

+

+ For resources on getting started, check out the Celest + docs. And for any questions you may + have, join us on Discord! +

+ + diff --git a/apps/cli/tool/macos/resources/logo.png b/apps/cli/tool/macos/resources/logo.png new file mode 100644 index 000000000..19252c1e8 Binary files /dev/null and b/apps/cli/tool/macos/resources/logo.png differ diff --git a/apps/cli/tool/macos/resources/welcome.html b/apps/cli/tool/macos/resources/welcome.html new file mode 100644 index 000000000..3488e7e49 --- /dev/null +++ b/apps/cli/tool/macos/resources/welcome.html @@ -0,0 +1,17 @@ + + + + + + +

+ This installer will set up the Celest CLI, enabling you to build your + backend in Dart. +

+ + diff --git a/apps/cli/tool/macos/scripts/postinstall b/apps/cli/tool/macos/scripts/postinstall new file mode 100755 index 000000000..3223193a6 --- /dev/null +++ b/apps/cli/tool/macos/scripts/postinstall @@ -0,0 +1,12 @@ +#!/bin/sh + +# Create symlinks +CELEST_PATH=/opt/celest/celest.app/Contents/MacOS +sudo cat < /usr/local/bin/celest +#!/bin/sh + +# Works around native-assets issues on macOS +export LD_LIBRARY_PATH=$CELEST_PATH +exec $CELEST_PATH/celest "\$@" +EOF +sudo chmod +x /usr/local/bin/celest diff --git a/apps/cli/tool/macos/scripts/preinstall b/apps/cli/tool/macos/scripts/preinstall new file mode 100755 index 000000000..19a45b656 --- /dev/null +++ b/apps/cli/tool/macos/scripts/preinstall @@ -0,0 +1,5 @@ +#!/bin/sh + +# Remove previous installation +sudo rm -rf /opt/celest +sudo rm -rf /usr/local/bin/celest diff --git a/apps/cli/tool/release.dart b/apps/cli/tool/release.dart new file mode 100644 index 000000000..5d323878d --- /dev/null +++ b/apps/cli/tool/release.dart @@ -0,0 +1,1007 @@ +import 'dart:convert'; +import 'dart:ffi'; +import 'dart:io' show ProcessException, stderr, stdout; + +import 'package:archive/archive_io.dart'; +import 'package:args/args.dart'; +import 'package:celest_cli/src/context.dart'; +import 'package:celest_cli/src/releases/celest_release_info.dart'; +import 'package:celest_cli/src/utils/error.dart'; +import 'package:celest_cli/src/utils/json.dart'; +import 'package:celest_cli/src/version.dart'; +import 'package:chunked_stream/chunked_stream.dart'; +import 'package:file/file.dart'; +import 'package:gcloud/storage.dart'; +import 'package:googleapis/cloudkms/v1.dart'; +import 'package:googleapis/storage/v1.dart' show DetailedApiRequestError; +import 'package:googleapis_auth/auth_io.dart'; +import 'package:http/http.dart' as http; +import 'package:mustache_template/mustache.dart'; +import 'package:path/path.dart' as p; +import 'package:pub_semver/pub_semver.dart'; + +/// The directory containing this script and build assets. +final Directory toolDir = fileSystem.file(platform.script).parent; + +/// The directory with the built CLI. +final String buildPath = platform.environment['BUILD_DIR'] ?? 'build'; +final Directory buildDir = fileSystem.directory( + platform.script.resolve('../$buildPath'), +); + +/// The directory to use for temporary (non-bundled) files. +final Directory tempDir = fileSystem.systemTempDirectory.createTempSync( + 'celest_build_', +); + +/// The HTTP client to use for downloading files. +final http.Client httpClient = http.Client(); + +/// The current ABI which identifies the OS and architecture. +final Abi osArch = Abi.current(); + +/// The current version of the CLI. +final String version = packageVersion; + +/// The bundler to use for the current platform. +final Bundler bundler = Bundler(); + +/// The path to the output file, dependent on the OS/arch. +final String outputFilepath = p.canonicalize( + p.join( + platform.script.toFilePath(), + '..', + 'celest-$version-$osArch.${bundler.extension}', + ), +); + +/// Access token for GCP. +final String? accessToken = platform.environment['GCP_ACCESS_TOKEN']; + +/// The current SHA of the branch being built. +final String? currentSha = + platform.environment.containsKey('CI') + ? (processManager.runSync( + // ['git', 'log', '-1', '--format=format:%H'], ? + ['git', 'rev-parse', 'HEAD'], + stdoutEncoding: utf8, + ).stdout + as String) + .trim() + : null; + +/// Whether we're running in CI. +final isCI = platform.environment['CI'] == 'true'; + +/// Builds and bundles the CLI for the current platform. +/// +/// This script is used by the GitHub workflow `apps_cli_release.yaml` to create +/// a zip of the CLI and its dependencies for the current platform. +Future main(List args) async { + final argParser = + ArgParser() + ..addFlag('build', negatable: false) + ..addFlag('release', negatable: false); + final argResult = argParser.parse(args); + + var needsBuild = argResult['build'] as bool?; + var needsRelease = argResult['release'] as bool?; + if (isCI) { + if (needsBuild == null && needsRelease == null) { + throw StateError('Either --build or --release must be specified'); + } + needsBuild ??= false; + needsRelease ??= false; + } else { + needsBuild ??= true; + needsRelease ??= false; + } + + if (needsBuild) { + await _build(); + if (platform.environment['GITHUB_OUTPUT'] case final ciOutput?) { + fileSystem + .file(ciOutput) + .writeAsStringSync( + 'installer=$outputFilepath', + mode: FileMode.append, + ); + } + } + if (needsRelease) { + await _release(); + } +} + +Future _build() async { + print('Bundling CLI version $version for $osArch...'); + + await buildDir.create(recursive: true); + await _runProcess('dart', [ + if (currentSha case final currentSha?) '--define=gitSha=$currentSha', + '--define=version=$version', + 'compile', + 'exe', + '--output=$buildPath/celest.exe', + 'bin/celest.dart', + ], workingDirectory: platform.script.resolve('..').toFilePath()); + if (!buildDir.existsSync()) { + throw StateError('Build directory does not exist'); + } + + if (!platform.isWindows) { + final exeUri = platform.script.resolve('../$buildPath/celest.exe'); + final exe = fileSystem.file(exeUri); + final destExe = p.withoutExtension(p.absolute(exeUri.path)); + if (!exe.existsSync() && !fileSystem.file(destExe).existsSync()) { + throw StateError('Executable does not exist: $exe'); + } + exe.renameSync(destExe); + } + + await bundler.bundle(); + + print('Successfully wrote $outputFilepath'); +} + +Future _release() async { + if (!isCI) { + return; + } + + final project = platform.environment['GCP_BUILD_PROJECT']; + final bucketName = platform.environment['GCP_BUILD_ARTIFACTS']; + if (project == null || bucketName == null || accessToken == null) { + throw StateError( + 'GCP_BUILD_PROJECT or GCP_BUILD_ARTIFACTS or GCP_ACCESS_TOKEN ' + 'is not set', + ); + } + final client = authenticatedClient( + httpClient, + AccessCredentials( + AccessToken( + 'Bearer', + accessToken!, + DateTime.timestamp().add(const Duration(hours: 1)), + ), + null, + [], + ), + ); + final storage = Storage(client, project); + final bucket = storage.bucket(bucketName); + // Don't cache artifacts when returned from the bucket since they're + // cached at the CDN layer. + final objectMetadata = ObjectMetadata( + cacheControl: 'no-cache, no-store, max-age=0', + ); + + final currentReleasesInfoKey = '$osArch/releases.json'; + CelestReleasesInfo? currentReleasesInfo; + try { + await bucket.info(currentReleasesInfoKey); + final currentReleasesInfoBytes = await readByteStream( + bucket.read(currentReleasesInfoKey), + ); + currentReleasesInfo = CelestReleasesInfo.fromJson( + jsonDecode(utf8.decode(currentReleasesInfoBytes)) as Map, + ); + } on DetailedApiRequestError catch (e) { + if (e.status != 404) { + rethrow; + } + } + + // Upload the build artifacts to GCS. + final withoutExt = p.withoutExtension(p.basename(outputFilepath)); + final debFilepath = '${p.withoutExtension(outputFilepath)}.deb'; + assert(!p.equals(outputFilepath, debFilepath)); + final setLatest = !Version.parse(version).isPreRelease; + final storagePaths = [ + ( + localPath: outputFilepath, + storagePath: '$osArch/$version/${p.basename(outputFilepath)}', + ), + if (setLatest) + ( + localPath: outputFilepath, + storagePath: + '$osArch/latest/${p.basename(outputFilepath).replaceFirst(version, 'latest')}', + ), + if (platform.isLinux) ...[ + (localPath: debFilepath, storagePath: '$osArch/$version/$withoutExt.deb'), + if (setLatest) + ( + localPath: debFilepath, + storagePath: + '$osArch/latest/${withoutExt.replaceFirst(version, 'latest')}.deb', + ), + ], + if (platform.isWindows) ...[ + for (final dll in fileSystem + .directory(buildPath) + .listSync() + .whereType() + .where((f) => p.extension(f.path) == '.dll')) + ( + localPath: dll.path, + storagePath: '$osArch/$version/${p.basename(dll.path)}', + ), + ], + ]; + print('Uploading storage paths: $storagePaths'); + for (final (:localPath, :storagePath) in storagePaths) { + final bucketSink = bucket.write( + storagePath, + metadata: objectMetadata, + contentType: switch (platform.operatingSystem) { + 'windows' => switch (p.extension(storagePath)) { + '.appx' => 'application/appx', + '.dll' => 'application/octet-stream', + _ => unreachable(), + }, + 'macos' => 'application/octet-stream', + 'linux' => switch (p.extension(storagePath)) { + '.deb' => 'application/vnd.debian.binary-package', + '.zip' => 'application/zip', + _ => unreachable(), + }, + _ => unreachable(), + }, + ); + await fileSystem.file(localPath).openRead().pipe(bucketSink); + } + + final latestRelease = CelestReleaseInfo( + version: Version.parse(version), + installer: switch (platform.operatingSystem) { + 'windows' || 'macos' => storagePaths.first.storagePath, + 'linux' => storagePaths[setLatest ? 2 : 1].storagePath, + _ => unreachable(), + }, + zip: switch (platform.operatingSystem) { + 'windows' || 'macos' => null, + 'linux' => storagePaths.first.storagePath, + _ => unreachable(), + }, + ); + CelestReleaseInfo? latestDev; + if (setLatest) { + if (currentReleasesInfo!.latestDev case final currentLatestDev?) { + if (Version.parse(version) < currentLatestDev.version) { + latestDev = currentLatestDev; + } + } + } else { + latestDev = latestRelease; + } + final updatedReleasesInfo = CelestReleasesInfo( + latest: setLatest ? latestRelease : currentReleasesInfo!.latest, + latestDev: latestDev, + releases: {...?currentReleasesInfo?.releases, version: latestRelease}, + ); + final updatedReleasesInfoJson = updatedReleasesInfo.toJson(); + print('Updated releases info: ${prettyPrintJson(updatedReleasesInfoJson)}'); + + await bucket.writeBytes( + currentReleasesInfoKey, + JsonUtf8Encoder().convert(updatedReleasesInfoJson), + metadata: objectMetadata, + contentType: 'application/json', + ); + + print('Successfully updated build artifacts'); +} + +abstract class Bundler { + factory Bundler() { + return switch (osArch) { + Abi.macosArm64 || Abi.macosX64 => MacOSBundler(), + Abi.windowsArm64 || Abi.windowsX64 => WindowsBundler(), + Abi.linuxArm64 || Abi.linuxX64 => LinuxBundler(), + final unsupported => + throw UnsupportedError('Unsupported ABI: $unsupported'), + }; + } + + String get extension; + + /// Bundles the CLI and its dependencies into a single file, performing + /// code signing and notarization as needed. + Future bundle(); +} + +final class MacOSBundler implements Bundler { + static final String? keychainName = () { + final isCI = platform.environment['CI'] == 'true'; + if (isCI) { + final keychainName = platform.environment['KEYCHAIN_NAME']; + if (keychainName.isNullOrEmpty) { + throw StateError('KEYCHAIN_NAME environment variable is not set'); + } + return keychainName; + } + return null; + }(); + + /// The Apple ID to use for notarization. + static final String appleId = platform.environment['APPLE_ID']!; + + /// The app-specific password for the Apple ID to use for notarization. + static final String appleIdPass = platform.environment['APPLE_ID_PASS']!; + + /// The Apple Team ID to use for notarization. + static final String appleTeamId = platform.environment['APPLE_TEAM_ID']!; + + /// Codesigning identities for macOS. + static final String developerApplicationIdentity = + 'Developer ID Application: Teo, Inc. ($appleTeamId)'; + static final String developerInstallerIdentity = + 'Developer ID Installer: Teo, Inc. ($appleTeamId)'; + + /// The directory containing the built CLI, bundled as a dummy .app so that + /// we can embedded the provisioning profile which is needed for Keychain + /// entitlements. + /// + /// See: + /// - https://developer.apple.com/documentation/Xcode/signing-a-daemon-with-a-restricted-entitlement + /// - https://developer.apple.com/documentation/technotes/tn3125-inside-code-signing-provisioning-profiles#Entitlements-on-macOS + final appDir = fileSystem.directory(tempDir.path).childDirectory('celest.app') + ..createSync(); + + @override + String get extension => 'pkg'; + + @override + Future bundle() async { + await _codesign(); + await _createPkg(); + } + + /// Uses `codesign` to codesign the CLI binaries. + /// + /// References: + /// - https://stackoverflow.com/questions/64652704/how-to-notarize-an-macos-command-line-tool-created-outside-of-xcode + /// - https://scriptingosx.com/2021/07/notarize-a-command-line-tool-with-notarytool/ + /// - https://developer.apple.com/documentation/security/notarizing_macos_software_before_distribution/customizing_the_notarization_workflow + Future _codesign() async { + final exeDir = appDir.childDirectory('Contents').childDirectory('MacOS') + ..createSync(recursive: true); + appDir + .childDirectory('Contents') + .childDirectory('Frameworks') + .childDirectory('celest') + .createSync(recursive: true); + final exe = p.join(appDir.path, 'Contents', 'MacOS', 'celest'); + final toSign = []; + + buildDir.childFile('celest').copySync(exe); + + // Updates the LC_RPATH of `celest` to match .app directory structure. + // https://developer.apple.com/documentation/xcode/embedding-nonstandard-code-structures-in-a-bundle#Adopt-rpath-relative-references + await _runProcess('install_name_tool', [ + '-add_rpath', + '@executable_path/../Frameworks', + exe, + ]); + + for (final dylib in buildDir.listSync().whereType().where( + (f) => p.extension(f.path) == '.dylib', + )) { + final dylibFilename = p.basename(dylib.path); + // Even though rpath is Frameworks/ in the binary, the runtime searches + // at Frameworks/celest/. + final appDylibPath = p.join( + appDir.path, + 'Contents', + 'Frameworks', + 'celest', + dylibFilename, + ); + dylib.copySync(appDylibPath); + await _runProcess('install_name_tool', [ + '-id', + '@rpath/celest/$dylibFilename', + appDylibPath, + ]); + // Symlink next to exe since native assets are hard-coded this way. + fileSystem + .link(exeDir.childFile(dylibFilename).path) + .createSync('../Frameworks/celest/$dylibFilename'); + toSign.add(appDylibPath); + } + + toSign.add(appDir.path); + + // Print directory structure + _printFs(appDir); + + // Matches the entitlements needed by `dartaotruntime`: + // https://github.com/dart-lang/sdk/blob/7e5ce1f688e036dbe4b417f7fd92bbced67b5ec5/runtime/tools/entitlements/dart_precompiled_runtime_product.plist + final entitlementsPlistPath = p.join(tempDir.path, 'entitlements.xml'); + final entitlementsPlist = Template( + toolDir + .childDirectory('macos') + .childFile('entitlements.xml') + .readAsStringSync(), + ).renderString({'teamId': appleTeamId}); + print('Rendered entitlements.xml:\n\n$entitlementsPlist\n'); + fileSystem.file(entitlementsPlistPath) + ..createSync() + ..writeAsStringSync(entitlementsPlist); + + final infoPlist = Template( + toolDir + .childDirectory('macos') + .childFile('Info.plist') + .readAsStringSync(), + ).renderString({'version': version, 'teamId': appleTeamId}); + print('Rendered Info.plist:\n\n$infoPlist\n'); + appDir.childDirectory('Contents').childFile('Info.plist') + ..createSync() + ..writeAsStringSync(infoPlist); + + toolDir + .childDirectory('macos') + .childFile('embedded.provisionprofile') + .copySync(p.join(appDir.path, 'Contents', 'embedded.provisionprofile')); + + // Sign executable last (working upwards). This was historically done + // with `--deep` but Apple has since deprecated this option. + toSign.add(exe); + + // Codesign all files in the build directory. + // TODO(dnys1): Currently we must sign everything in the app directory + /// individually because Dart's native-assets support requires the wrong + /// structure, e.g. searching `Frameworks/celest/` instead of + /// `Frameworks/` as expected. + /// + /// We must also sign the app directory itself because the provisioning + /// profile is embedded in the app directory. + for (final pathToSign in toSign) { + print('Codesigning $pathToSign...'); + await _runProcess('codesign', [ + '--sign', + developerApplicationIdentity, + if (keychainName case final keychain?) ...['--keychain', keychain], + if (p.extension(pathToSign) != '.dylib') ...[ + '--generate-entitlement-der', + '--entitlements', + entitlementsPlistPath, + '--identifier', + 'dev.celest.cli', + '--options=runtime', + ], + '--force', + '--timestamp', + '--file-list', + '-', + '--verbose', + pathToSign, + ]); + + Future dumpCodesignResults() async { + await _runProcess('codesign', ['--display', '--verbose=4', pathToSign]); + print('Entitlement results:'); + await _runProcess('codesign', [ + '--display', + '--entitlements=-', + pathToSign, + ]); + } + + print('Verifying code signature for $pathToSign...'); + await _runProcess( + 'codesign', + ['--verify', '--verbose', pathToSign], + onError: (_) async { + print('Could not verify code signature. Code-signing results:'); + await dumpCodesignResults(); + }, + ); + await dumpCodesignResults(); + } + + print('Codesigning complete.'); + } + + /// Uses `pkgbuild`, `productbuild` and `notarytool` to package and notarize + /// the CLI as a macOS installer package. + Future _createPkg() async { + final scriptsPath = p.join(toolDir.path, 'macos', 'scripts'); + + // Create a temp, unsigned PKG installer using pkgbuild + final tmpPkgPath = p.join(tempDir.path, p.basename(outputFilepath)); + print('Creating component package...'); + await _runProcess('pkgbuild', [ + '--root', + appDir.path, + '--identifier', + 'dev.celest.cli', + '--version', + version, + // https://www.pathname.com/fhs/pub/fhs-2.3.html#OPTADDONAPPLICATIONSOFTWAREPACKAGES + // TODO(dnys1): /usr/local/lib + /usr/local/bin? + '--install-location', + '/opt/celest/celest.app', + '--scripts', + scriptsPath, + // Dart minimum OS version is 12.0 + // https://dart.dev/get-dart#macos + '--min-os-version', + '12.0', + tmpPkgPath, + ]); + + // Create distribution XML file + // See: https://developer.apple.com/library/archive/documentation/DeveloperTools/Reference/DistributionDefinitionRef/Chapters/Distribution_XML_Ref.html + // TODO(dnys1): enable_currentUserHome="true"? https://developer.apple.com/library/archive/documentation/DeveloperTools/Reference/DistributionDefinitionRef/Chapters/Distribution_XML_Ref.html#//apple_ref/doc/uid/TP40005370-CH100-SW35 + final distributionTmpl = + toolDir + .childDirectory('macos') + .childFile('distribution.xml') + .readAsStringSync(); + final distributionFile = tempDir.childFile('distribution.xml'); + final distributionXml = Template(distributionTmpl).renderString({ + 'filename': p.basename(tmpPkgPath), + 'hostArchitectures': osArch == Abi.macosArm64 ? 'arm64' : 'x86_64', + }); + print('Writing distribution.xml contents:\n\n$distributionXml\n'); + await distributionFile.writeAsString(distributionXml, flush: true); + + // Create a product archive using productbuild + print('Creating signed product archive...'); + await _runProcess('productbuild', [ + '--distribution', + distributionFile.path, + '--package-path', + tempDir.path, + '--resources', + p.join(toolDir.path, 'macos', 'resources'), + '--sign', + developerInstallerIdentity, + if (keychainName case final keychain?) ...['--keychain', keychain], + '--timestamp', + outputFilepath, + ]); + + // Notarize the installer package + print('Notarizing package...'); + Future onNotarizationFailed(String logs) async { + print('Notarization failed. Detailed logs:'); + final uuid = RegExp( + r'Submission with ID ([\w\d-]+)', + ).firstMatch(logs)?.group(1); + if (uuid == null) { + print('ERR: Could not find UUID in logs'); + return; + } + await _runProcess('xcrun', [ + 'notarytool', + 'log', + '--apple-id', + appleId, + '--password', + appleIdPass, + '--team-id', + appleTeamId, + uuid, + ]); + } + + final notaryLogs = await _runProcess('xcrun', [ + 'notarytool', + 'submit', + '--apple-id', + appleId, + '--password', + appleIdPass, + '--team-id', + appleTeamId, + '--wait', + '--verbose', + outputFilepath, + ], onError: onNotarizationFailed); + final status = LineSplitter.split( + notaryLogs, + ).map(RegExp(r'status: (\w+)').firstMatch).nonNulls.toList().last.group(1); + if (status != 'Accepted') { + await onNotarizationFailed(notaryLogs); + throw StateError('Notarization failed: $status'); + } + + // Staple the notarization ticket to the installer package + print('Stapling notarization ticket...'); + await _runProcess('xcrun', ['stapler', 'staple', outputFilepath]); + + // Verify the notarization ticket + print('Verifying notarization ticket...'); + await _runProcess('xcrun', [ + 'spctl', + '--assess', + '--type', + 'install', + '-vv', + outputFilepath, + ]); + + print('Packaging and notarization complete.'); + } +} + +final class WindowsBundler implements Bundler { + static final String _windowsSdkBinDir = () { + const binDir = r'C:\Program Files (x86)\Windows Kits\10\bin'; + final allSdks = + fileSystem + .directory(binDir) + .listSync() + .whereType() + .map((e) => p.basename(e.path)) + .where((path) => path.startsWith('10.')) + .toList(); + allSdks.sort(); + final latestSdk = allSdks.last; + return switch (Abi.current()) { + Abi.windowsArm64 => p.join(binDir, latestSdk, 'arm64'), + Abi.windowsX64 => p.join(binDir, latestSdk, 'x64'), + final unsupported => + throw UnsupportedError('Unsupported ABI: $unsupported'), + }; + }(); + + @override + String get extension => 'appx'; + + @override + Future bundle() async { + final appxPackage = await _createAppx(); + if (isCI) { + await _evCodesign(appxPackage); + } else { + await fileSystem.file(appxPackage).copy(outputFilepath); + } + } + + /// Creates an APPX installer package for the CLI. + Future _createAppx() async { + // Mostly copied from winget: https://github.com/microsoft/winget-cli/blob/master/src/AppInstallerCLIPackage/Package.appxmanifest + // Schema: https://learn.microsoft.com/en-us/uwp/schemas/appxpackage/uapmanifestschema/element-application + // Fix for firewall rules: https://learn.microsoft.com/en-us/windows/apps/desktop/modernize/desktop-to-uwp-extensions#create-firewall-exception-for-your-app + final appxManifestPath = p.join(buildDir.path, 'AppxManifest.xml'); + final appxManifest = Template( + toolDir + .childDirectory('windows') + .childFile('AppxManifest.xml') + .readAsStringSync(), + ).renderString({ + 'arch': osArch == Abi.windowsArm64 ? 'arm64' : 'x64', + // Expects format major.minor.build.revision + 'version': switch (Version.parse(version)) { + Version( + isPreRelease: true, + :final major, + :final minor, + :final patch, + :final preRelease, + ) => + // Use the first number in the pre-release as the build number + // e.g. `1.2.0-dev.1` -> `1.2.0.1` + '${Version(major, minor, patch)}.${preRelease.whereType().firstOrNull ?? 0}', + Version(:final major, :final minor, :final patch, :final build) + when build.isNotEmpty => + // Use the first number in the build tag as the build number + // e.g. `1.2.0+1` -> `1.2.0.1` + '${Version(major, minor, patch)}.${build.first}', + _ => '$version.0', + }, + }); + print('Rendered AppxManifest.xml:\n\n$appxManifest\n'); + fileSystem.file(appxManifestPath) + ..createSync() + ..writeAsStringSync(appxManifest, flush: true); + + // Copy logo files to buildDir. + // + // These are generated using VS Studio 2022's built-in Asset Generator. + final sourceDir = p.join( + p.dirname(p.fromUri(platform.script)), + 'windows', + 'Assets', + ); + final assetsDir = buildDir.childDirectory('Assets') + ..createSync(recursive: true); + for (final logoFile + in fileSystem.directory(sourceDir).listSync().whereType()) { + logoFile.copySync(p.join(assetsDir.path, p.basename(logoFile.path))); + } + + // Create Package Resource Index (PRI) using unplated files. This resolves + // the transparency issues when using PNGs. + // + // See: + // - https://learn.microsoft.com/en-us/windows/msix/desktop/desktop-to-uwp-manual-conversion#optional-add-target-based-unplated-assets + // - https://learn.microsoft.com/en-us/windows/apps/design/style/iconography/app-icon-construction + // - https://learn.microsoft.com/en-us/windows/uwp/app-resources/tailor-resources-lang-scale-contrast#shell-light-theme-and-unplated-resources + + print('Creating PRI...'); + await _runProcess(p.join(_windowsSdkBinDir, 'makepri.exe'), [ + 'createconfig', + '/cf', + 'priconfig.xml', + '/dq', + 'en-US', + ], workingDirectory: buildDir.path); + await _runProcess(p.join(_windowsSdkBinDir, 'makepri.exe'), [ + 'new', + '/pr', + '.', + '/cf', + 'priconfig.xml', + '/v', + ], workingDirectory: buildDir.path); + + // Output to temporary APPX since jsign gets confused when the filename + // contains the version (periods). + final tempOutputFilepath = p.join(tempDir.path, 'celest.appx'); + + await _runProcess(p.join(_windowsSdkBinDir, 'makeappx.exe'), [ + 'pack', + '/d', + buildDir.path, + '/p', + tempOutputFilepath, + '/v', + ]); + + return tempOutputFilepath; + } + + Future _evCodesign(String appxPackage) async { + final evKeyRing = platform.environment['EV_KEY_RING']; + final evKeyName = platform.environment['EV_KEY_NAME']; + final certData = platform.environment['WINDOWS_CERTS_DATA']; + + if (evKeyRing.isNullOrEmpty || + evKeyName.isNullOrEmpty || + certData.isNullOrEmpty) { + throw StateError( + 'EV_KEY_RING or EV_KEY_NAME or WINDOWS_CERTS_DATA is empty', + ); + } + if (!evKeyRing!.startsWith('projects/')) { + throw StateError( + r'EV_KEY_RING must be of the form "projects/$projectId/locations/$location/keyRings/$keyRingName"', + ); + } + + final windowsCertsFile = tempDir.childFile('windows-certs.p7b'); + await windowsCertsFile.create(); + await windowsCertsFile.writeAsBytes(base64Decode(certData!), flush: true); + + print('Downloading jsign tool...'); + // TODO(dnys1): Replace with GH release once 5.1 is released. + const jsignUrl = 'https://releases.celest.dev/_build/jsign.jar'; + final jsignJarReq = await httpClient.get(Uri.parse(jsignUrl)); + if (jsignJarReq.statusCode != 200) { + throw StateError( + 'Could not download jsign (${jsignJarReq.statusCode}): ' + '${jsignJarReq.body}', + ); + } + final jsignJar = tempDir.childFile('jsign.jar'); + await jsignJar.create(); + await jsignJar.writeAsBytes(jsignJarReq.bodyBytes, flush: true); + + if (accessToken == null) { + throw StateError('GCP_ACCESS_TOKEN is not set'); + } + + final jsignArgs = [ + '-jar', + jsignJar.path, + '--storetype', + 'GOOGLECLOUD', + '--storepass', + accessToken!, + '--keystore', + evKeyRing, + '--alias', + evKeyName!, + '--certfile', + windowsCertsFile.path, + '--tsmode', + 'RFC3161', + '--tsaurl', + 'http://timestamp.globalsign.com/tsa/r6advanced1', + appxPackage, + ]; + + print('Running jsign tool...'); + final jsignRes = await processManager.run( + ['java', ...jsignArgs], + stdoutEncoding: utf8, + stderrEncoding: utf8, + ); + if (jsignRes.exitCode != 0) { + throw ProcessException( + 'java', + jsignArgs, + jsignRes.stderr as String, + jsignRes.exitCode, + ); + } + + print('Verifying EV code signature...'); + await _runProcess(p.join(_windowsSdkBinDir, 'signtool.exe'), [ + 'verify', + '/pa', + '/v', + appxPackage, + ]); + + // Copy the temp appx package to its final output path. + await fileSystem.file(appxPackage).copy(outputFilepath); + + print('Successfully codesigned $appxPackage'); + } +} + +final class LinuxBundler implements Bundler { + @override + String get extension => 'deb'; + + @override + Future bundle() async { + // Copy launcher to buildDir + toolDir + .childDirectory('linux') + .childFile('launcher.sh') + .copySync(p.join(buildDir.path, 'launcher.sh')); + + // Create the ZIP file. + await _createZip( + fromDir: buildDir, + outputPath: p.setExtension(outputFilepath, '.zip'), + ); + + // Create the DEB installer. + await _createDeb(); + } + + /// Creates the DEB file structure. + /// + /// DEBIAN/ + /// control + /// postinst + /// postrm + /// opt/ + /// celest/ + /// celest + /// launcher.sh + Future _createDeb() async { + print('Creating Debian archive...'); + + final debDir = tempDir.childDirectory('deb')..createSync(); + final debControlDir = debDir.childDirectory('DEBIAN')..createSync(); + final debInstallDir = debDir.childDirectory('opt').childDirectory('celest') + ..createSync(recursive: true); + + final toolDebianDir = toolDir.childDirectory('linux').childDirectory('deb'); + + for (final controlFile + in toolDebianDir.childDirectory('DEBIAN').listSync().cast()) { + if (p.basename(controlFile.path) == 'control') { + final outputControlFile = debControlDir.childFile('control'); + final outputControl = Template( + controlFile.readAsStringSync(), + ).renderString({ + 'arch': switch (osArch) { + Abi.linuxArm64 => 'arm64', + Abi.linuxX64 => 'amd64', + _ => unreachable(), + }, + 'version': version, + }); + print('Writing control contents:\n\n$outputControl\n'); + await outputControlFile.writeAsString(outputControl); + } else { + controlFile.copySync( + p.join(debControlDir.path, p.basename(controlFile.path)), + ); + } + } + + for (final installFile in buildDir.listSync().cast()) { + installFile.copySync( + p.join(debInstallDir.path, p.basename(installFile.path)), + ); + } + + // Print directory structure + _printFs(debDir); + + await _runProcess('dpkg-deb', [ + '--build', + debDir.path, + p.setExtension(outputFilepath, '.deb'), + ], workingDirectory: tempDir.path); + } +} + +Future _runProcess( + String executable, + List args, { + String? workingDirectory, + Future Function(String logs)? onError, +}) async { + print('Running process "$executable ${args.join(' ')}"...'); + final proc = await processManager.start([ + executable, + ...args, + ], workingDirectory: workingDirectory); + + // For logging + executable = executable == 'xcrun' ? args.first : executable; + args = executable == 'xcrun' ? args.skip(1).toList() : args; + + final logsBuf = StringBuffer(); + proc.stdout.transform(utf8.decoder).transform(const LineSplitter()).listen(( + event, + ) { + logsBuf.writeln(event); + stdout.writeln('$executable: $event'); + }); + proc.stderr.transform(utf8.decoder).transform(const LineSplitter()).listen(( + event, + ) { + stderr.writeln('$executable: $event'); + }); + final exitCode = await proc.exitCode; + final logs = logsBuf.toString(); + if (exitCode != 0) { + await onError?.call(logs); + throw ProcessException(executable, args, 'Process failed', exitCode); + } + return logs; +} + +Future _createZip({ + required Directory fromDir, + required String outputPath, +}) async { + final zipStream = OutputFileStream(outputPath); + final archive = + ZipEncoder()..startEncode(zipStream, level: DeflateLevel.bestCompression); + for (final file in fromDir.listSync(recursive: false).whereType()) { + final relativePath = p.relative(file.path, from: fromDir.parent.path); + final archiveFile = ArchiveFile.stream( + relativePath, + InputFileStream(file.path), + ); + archive.add(archiveFile); + } + archive.endEncode(); + await zipStream.close(); +} + +extension on String? { + bool get isNullOrEmpty => this == null || this!.isEmpty; +} + +void _printFs(Directory dir) { + print('${dir.path} file structure:'); + print('---------------------'); + for (final entity in dir.listSync(recursive: true)) { + final type = switch (fileSystem.typeSync(entity.path)) { + FileSystemEntityType.directory => 'D', + FileSystemEntityType.file => 'F', + FileSystemEntityType.link => 'L', + _ => '?', + }; + final relativePath = p.relative(entity.path, from: dir.path); + print('$type $relativePath'); + } + print('---------------------'); +} diff --git a/apps/cli/tool/test_deploy_env.sh b/apps/cli/tool/test_deploy_env.sh new file mode 100755 index 000000000..7433e021e --- /dev/null +++ b/apps/cli/tool/test_deploy_env.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash + +set -eu + +ID=$(LC_ALL=C tr -dc a-z0-9 + + + + + Celest + Celest + The CLI for Celest, the Flutter cloud platform. + Assets\StoreLogo.png + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/apps/cli/tool/windows/Assets/Square150x150Logo.png b/apps/cli/tool/windows/Assets/Square150x150Logo.png new file mode 100644 index 000000000..c155b6ceb Binary files /dev/null and b/apps/cli/tool/windows/Assets/Square150x150Logo.png differ diff --git a/apps/cli/tool/windows/Assets/Square44x44Logo.altform-lightunplated_targetsize-16.png b/apps/cli/tool/windows/Assets/Square44x44Logo.altform-lightunplated_targetsize-16.png new file mode 100644 index 000000000..bca8d959c Binary files /dev/null and b/apps/cli/tool/windows/Assets/Square44x44Logo.altform-lightunplated_targetsize-16.png differ diff --git a/apps/cli/tool/windows/Assets/Square44x44Logo.altform-lightunplated_targetsize-24.png b/apps/cli/tool/windows/Assets/Square44x44Logo.altform-lightunplated_targetsize-24.png new file mode 100644 index 000000000..2d4f331e9 Binary files /dev/null and b/apps/cli/tool/windows/Assets/Square44x44Logo.altform-lightunplated_targetsize-24.png differ diff --git a/apps/cli/tool/windows/Assets/Square44x44Logo.altform-lightunplated_targetsize-256.png b/apps/cli/tool/windows/Assets/Square44x44Logo.altform-lightunplated_targetsize-256.png new file mode 100644 index 000000000..02fecdde7 Binary files /dev/null and b/apps/cli/tool/windows/Assets/Square44x44Logo.altform-lightunplated_targetsize-256.png differ diff --git a/apps/cli/tool/windows/Assets/Square44x44Logo.altform-lightunplated_targetsize-32.png b/apps/cli/tool/windows/Assets/Square44x44Logo.altform-lightunplated_targetsize-32.png new file mode 100644 index 000000000..2ea542932 Binary files /dev/null and b/apps/cli/tool/windows/Assets/Square44x44Logo.altform-lightunplated_targetsize-32.png differ diff --git a/apps/cli/tool/windows/Assets/Square44x44Logo.altform-lightunplated_targetsize-48.png b/apps/cli/tool/windows/Assets/Square44x44Logo.altform-lightunplated_targetsize-48.png new file mode 100644 index 000000000..1871852a1 Binary files /dev/null and b/apps/cli/tool/windows/Assets/Square44x44Logo.altform-lightunplated_targetsize-48.png differ diff --git a/apps/cli/tool/windows/Assets/Square44x44Logo.altform-unplated_targetsize-16.png b/apps/cli/tool/windows/Assets/Square44x44Logo.altform-unplated_targetsize-16.png new file mode 100644 index 000000000..bca8d959c Binary files /dev/null and b/apps/cli/tool/windows/Assets/Square44x44Logo.altform-unplated_targetsize-16.png differ diff --git a/apps/cli/tool/windows/Assets/Square44x44Logo.altform-unplated_targetsize-24.png b/apps/cli/tool/windows/Assets/Square44x44Logo.altform-unplated_targetsize-24.png new file mode 100644 index 000000000..2d4f331e9 Binary files /dev/null and b/apps/cli/tool/windows/Assets/Square44x44Logo.altform-unplated_targetsize-24.png differ diff --git a/apps/cli/tool/windows/Assets/Square44x44Logo.altform-unplated_targetsize-256.png b/apps/cli/tool/windows/Assets/Square44x44Logo.altform-unplated_targetsize-256.png new file mode 100644 index 000000000..02fecdde7 Binary files /dev/null and b/apps/cli/tool/windows/Assets/Square44x44Logo.altform-unplated_targetsize-256.png differ diff --git a/apps/cli/tool/windows/Assets/Square44x44Logo.altform-unplated_targetsize-32.png b/apps/cli/tool/windows/Assets/Square44x44Logo.altform-unplated_targetsize-32.png new file mode 100644 index 000000000..2ea542932 Binary files /dev/null and b/apps/cli/tool/windows/Assets/Square44x44Logo.altform-unplated_targetsize-32.png differ diff --git a/apps/cli/tool/windows/Assets/Square44x44Logo.altform-unplated_targetsize-48.png b/apps/cli/tool/windows/Assets/Square44x44Logo.altform-unplated_targetsize-48.png new file mode 100644 index 000000000..1871852a1 Binary files /dev/null and b/apps/cli/tool/windows/Assets/Square44x44Logo.altform-unplated_targetsize-48.png differ diff --git a/apps/cli/tool/windows/Assets/Square44x44Logo.png b/apps/cli/tool/windows/Assets/Square44x44Logo.png new file mode 100644 index 000000000..12b95c45c Binary files /dev/null and b/apps/cli/tool/windows/Assets/Square44x44Logo.png differ diff --git a/apps/cli/tool/windows/Assets/Square44x44Logo.targetsize-16.png b/apps/cli/tool/windows/Assets/Square44x44Logo.targetsize-16.png new file mode 100644 index 000000000..7896a7564 Binary files /dev/null and b/apps/cli/tool/windows/Assets/Square44x44Logo.targetsize-16.png differ diff --git a/apps/cli/tool/windows/Assets/Square44x44Logo.targetsize-24.png b/apps/cli/tool/windows/Assets/Square44x44Logo.targetsize-24.png new file mode 100644 index 000000000..3dbe7a8ab Binary files /dev/null and b/apps/cli/tool/windows/Assets/Square44x44Logo.targetsize-24.png differ diff --git a/apps/cli/tool/windows/Assets/Square44x44Logo.targetsize-256.png b/apps/cli/tool/windows/Assets/Square44x44Logo.targetsize-256.png new file mode 100644 index 000000000..a0e3f78c9 Binary files /dev/null and b/apps/cli/tool/windows/Assets/Square44x44Logo.targetsize-256.png differ diff --git a/apps/cli/tool/windows/Assets/Square44x44Logo.targetsize-32.png b/apps/cli/tool/windows/Assets/Square44x44Logo.targetsize-32.png new file mode 100644 index 000000000..041a4d630 Binary files /dev/null and b/apps/cli/tool/windows/Assets/Square44x44Logo.targetsize-32.png differ diff --git a/apps/cli/tool/windows/Assets/Square44x44Logo.targetsize-48.png b/apps/cli/tool/windows/Assets/Square44x44Logo.targetsize-48.png new file mode 100644 index 000000000..00cf75754 Binary files /dev/null and b/apps/cli/tool/windows/Assets/Square44x44Logo.targetsize-48.png differ diff --git a/apps/cli/tool/windows/Assets/StoreLogo.png b/apps/cli/tool/windows/Assets/StoreLogo.png new file mode 100644 index 000000000..47847446f Binary files /dev/null and b/apps/cli/tool/windows/Assets/StoreLogo.png differ diff --git a/apps/cli/tool/windows/debug.ps1 b/apps/cli/tool/windows/debug.ps1 new file mode 100644 index 000000000..102cb12a8 --- /dev/null +++ b/apps/cli/tool/windows/debug.ps1 @@ -0,0 +1,9 @@ +$CelestPackageName = "Celest.CLI" + +function Remove-Celest { + Get-AppxPackage -Name $CelestPackageName | Remove-AppxPackage +} + +function Install-Local { + Add-AppxPackage -Register .\celest\AppxManifest.xml +} \ No newline at end of file diff --git a/apps/cli/tool/windows/logo.png b/apps/cli/tool/windows/logo.png new file mode 100644 index 000000000..f03563d8b Binary files /dev/null and b/apps/cli/tool/windows/logo.png differ diff --git a/pubspec.yaml b/pubspec.yaml index 6860a608e..5ad98759c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,9 +1,16 @@ name: celest_dev publish_to: none +# The version locks for GitHub actions. +# +# Because many golden tests encode the precise Dart/Flutter SDKs used to generate +# them, these values must be consistently used when running tests locally and in CI. +# +# However, setting these locks in the actual packages is too restrictive when +# switching between versions, so they are instead centrally managed here. environment: - sdk: ^3.4.0 - flutter: ">=3.22.0" + sdk: 3.7.0 + flutter: 3.29.0 dev_dependencies: melos: ^5.3.0 diff --git a/tool/setup-ci.sh b/tool/setup-ci.sh new file mode 100755 index 000000000..df0b68cc2 --- /dev/null +++ b/tool/setup-ci.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +set -e + +if [[ "$OSTYPE" == "linux-gnu"* ]]; then + + sudo apt-get update && sudo apt-get install -y libsecret-1-dev gnome-keyring jq + + # If running in headless mode, re-run script in dbus session. + if [ -z $DBUS_SESSION_BUS_ADDRESS && -n $1 ]; then + exec dbus-run-session -- $@ + fi + + # Set up keyring in CI env + if [ -n $CI ]; then + echo 'password' | gnome-keyring-daemon --start --replace --daemonize --unlock + fi +fi